:root {
  --bg: #05070d;
  --fg: #e6edf3;
  --line: #202638;
  --accent: #ffb347;

}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
}

body { height: auto; min-height: 100%; }

body > * {
  position: relative;
  z-index: 1;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

/* Starry background canvas */
#desert-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* Header */
#site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 20px 16px;
  backdrop-filter: blur(10px);
  background: radial-gradient(circle at top left, rgba(16,28,64,.92), rgba(5,7,13,.95));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.75);
}

#site-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .3px;
}

#site-header h2 {
  margin: 4px 0 6px 0;
  font-size: 13px;
  font-weight: 500;
  opacity: .9;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.header-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .22em;
  opacity: .7;
}

.header-nav {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  position: relative;
  overflow: hidden;
  appearance: none;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background:
    radial-gradient(circle at 0 0, rgba(255,255,255,.14), transparent 55%) #050814;
  color: var(--fg);
  padding: 9px 18px 9px 16px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .16em;
  box-shadow:
    0 0 0 rgba(0,0,0,0),
    0 0 0 1px rgba(0,0,0,.4);
  transition:
    background .18s ease,
    box-shadow .18s ease,
    transform .06s ease,
    color .18s ease;
  isolation: isolate;
}

.btn::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: conic-gradient(
    from 210deg,
    rgba(255,206,107,.5),
    rgba(255,123,64,.85),
    rgba(107,220,255,.9),
    rgba(255,206,107,.6)
  );
  opacity: 0;
  transform: scale(0.9);
  filter: blur(12px);
  z-index: -1;
  transition:
    opacity .22s ease,
    transform .22s ease;
}

.btn span {
  opacity: .9;
  white-space: nowrap;
}

.btn-icon {
  font-size: 13px;
  line-height: 1;
  opacity: .9;
}

.btn:hover {
  background: radial-gradient(circle at 10% -10%, rgba(255,210,140,.2), #0b1022);
  color: #fffaf0;
  box-shadow:
    0 0 22px rgba(255,155,81,.45),
    0 0 0 1px rgba(0,0,0,.9);
  transform: translateY(-1px);
}

.btn:hover::before {
  opacity: 1;
  transform: scale(1.05);
}

.btn:active {
  transform: translateY(0);
  box-shadow:
    0 0 14px rgba(255,155,81,.35),
    0 0 0 1px rgba(0,0,0,1);
}

.btn-primary {
  border-color: rgba(255,191,112,.9);
  background:
    radial-gradient(circle at 0 0, rgba(255,255,255,.16), transparent 60%)
    linear-gradient(125deg, #25140b, #44240c);
  box-shadow:
    0 0 20px rgba(255,167,86,.4),
    0 0 0 1px rgba(0,0,0,.9);
}

.btn-primary .btn-icon {
  opacity: 1;
}

main {
  padding-bottom: 48px;
}

/* Generic section layout */
section.block {
  padding: 40px 5vw;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.section-inner {
  max-width: 1120px;
  margin: 0 auto;
}

.section-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .4px;
}

.section-kicker {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .14em;
  opacity: .7;
  margin-bottom: 4px;
}

.section-lead {
  margin: 0 0 18px;
  max-width: 60ch;
  font-size: 14px;
  opacity: .9;
}

/* ===== STORY SECTION ===== */

#story {
  padding-top: 56px;
  padding-bottom: 72px;
  
}

.story-block {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  background: radial-gradient(circle at top left, #151a35 0, #05070d 55%);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.75),
    0 0 0 1px rgba(255,255,255,0.04);
}

.story-parallax {
  position: absolute;
  inset: -4vh -4vw;
  pointer-events: none;
  perspective: 800px;
  opacity: .96;
}

.story-parallax .layer {
  position: absolute;
  inset: 0;
  transform: none;
  will-change: auto;
}

.layer-stars,
.layer-stars-2 {
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.9), rgba(255,255,255,0)),
    radial-gradient(1.5px 1.5px at 70% 60%, rgba(255,255,255,.8), rgba(255,255,255,0)),
    radial-gradient(1.2px 1.2px at 40% 80%, rgba(255,255,255,.6), rgba(255,255,255,0)),
    radial-gradient(1px 1px at 85% 20%, rgba(255,255,255,.7), rgba(255,255,255,0));
  background-size: 600px 600px, 800px 800px, 700px 700px, 900px 900px;
  background-repeat: repeat;
  filter: drop-shadow(0 0 2px rgba(255,255,255,.35));
  animation: twinkle 10s linear infinite paused;
}

.layer-stars-2 {
  opacity: .7;
  animation-duration: 16s;
  filter: drop-shadow(0 0 3px rgba(255,255,255,.3));
}

.layer-nebula {
  background:
    radial-gradient(60% 60% at 18% 22%, rgba(122,80,255,.28), transparent 60%),
    radial-gradient(40% 40% at 78% 58%, rgba(255,80,180,.2), transparent 60%),
    radial-gradient(48% 48% at 45% 82%, rgba(80,200,255,.18), transparent 60%);
  filter: blur(14px) saturate(120%);
  mix-blend-mode: screen;
}

.layer-milky {
  background:
    linear-gradient(98deg,
      transparent 0 30%,
      rgba(255,255,255,.09) 40%,
      rgba(255,255,255,.17) 50%,
      rgba(255,255,255,.09) 60%,
      transparent 70%
    ),
    radial-gradient(100% 60% at 50% 50%, rgba(255,255,255,.06), transparent 60%);
  transform: rotate(8deg) translateZ(-120px) scale(1.15);
  filter: blur(1.6px);
  opacity: .7;
}

@keyframes twinkle {
  0%, 100% { opacity: .65; }
  50% { opacity: 1; }
}

.story-scroll {
  position: relative;
  z-index: 1;
  padding: 32px 22px 30px;
  max-width: 780px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .story-scroll {
    padding: 40px 38px 34px;
  }
}

.story-heading {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .8;
  margin: 0 0 8px;
}

.story-subtitle {
  font-size: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .7;
  margin: 0 0 14px;
}

.story-eyebrow {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .65;
  margin-bottom: 10px;
}

.story-body {
  font-size: 15px;
  line-height: 1.7;
  max-width: 70ch;
}

.story-body p {
  margin: 0 0 1em;
}

.story-body p:last-child {
  margin-bottom: 0;
}

.story-emphasis {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 10px;

  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;

  color: #ffdf8b;
  background: rgba(12, 6, 0, 0.45);
  border-radius: 4px;
  border: 1px solid rgba(255, 223, 139, 0.55);

  text-shadow:
0 0 3px rgba(255, 223, 139, .7),
0 0 8px rgba(255, 190, 80, .5);

  /* softer, slower fade in/out */
  animation: transmissionPulse 3.5s ease-in-out infinite paused;
}

@keyframes transmissionPulse {
  0%, 100% { opacity: .8; }
  50% { opacity: 1; }
}

/* ===== POWERUP GRID ===== */

#powerups {
  padding-top: 40px;
  padding-bottom: 60px;
}

.powerups-section-header {
  margin-bottom: 26px;
}

.powerups-section-header .section-lead {
  max-width: 70ch;
}

.powerups-grid {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.powerups-row-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .16em;
  opacity: .75;
  margin-bottom: 10px;
}

.powerups-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr));
  gap: 16px;
}

.powerup-card {
  container-type: inline-size;
  min-width: 0;
  background: radial-gradient(circle at top, #1a2138 0, #080a12 65%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px 10px 12px;
  box-shadow:
    0 12px 30px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.powerup-card.offensive {
  box-shadow:
    0 0 18px rgba(255,120,40,0.4),
    0 12px 30px rgba(0,0,0,0.8),
    0 0 0 1px rgba(255,255,255,0.04);
}

.powerup-card.defensive {
  box-shadow:
    0 0 18px rgba(110,190,255,0.35),
    0 12px 30px rgba(0,0,0,0.8),
    0 0 0 1px rgba(255,255,255,0.04);
}

.powerup-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.powerup-type-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .18em;
  opacity: .7;
}

.powerup-desc {
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  opacity: .9;
  min-height: 2.6em;
}

/* Powerup Codex icons use the same 4 by 6 sprite sheet as the game. */
.powerup-icon {
    --pu-size: min(140px, 100cqi);
    width: var(--pu-size);
    height: var(--pu-size);
    border-radius: 16px;
    background-color: #111;
    background-image: url('../assets/block_sprites.webp');
    background-repeat: no-repeat;
    background-size: calc(4 * var(--pu-size)) calc(6 * var(--pu-size));
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* Offensive blocks: column 2, letter rows B U R N E R. */
.pu-off-b      { background-position: calc(-1 * var(--pu-size)) 0; }
.pu-off-u      { background-position: calc(-1 * var(--pu-size)) calc(-1 * var(--pu-size)); }
.pu-off-r1     { background-position: calc(-1 * var(--pu-size)) calc(-2 * var(--pu-size)); }
.pu-off-n      { background-position: calc(-1 * var(--pu-size)) calc(-3 * var(--pu-size)); }
.pu-off-e      { background-position: calc(-1 * var(--pu-size)) calc(-4 * var(--pu-size)); }
.pu-off-r2     { background-position: calc(-1 * var(--pu-size)) calc(-5 * var(--pu-size)); }

/* Defensive blocks: column 3, letter rows B U R N E R. */
.pu-def-b      { background-position: calc(-2 * var(--pu-size)) 0; }
.pu-def-u      { background-position: calc(-2 * var(--pu-size)) calc(-1 * var(--pu-size)); }
.pu-def-r1     { background-position: calc(-2 * var(--pu-size)) calc(-2 * var(--pu-size)); }
.pu-def-n      { background-position: calc(-2 * var(--pu-size)) calc(-3 * var(--pu-size)); }
.pu-def-e      { background-position: calc(-2 * var(--pu-size)) calc(-4 * var(--pu-size)); }
.pu-def-r2     { background-position: calc(-2 * var(--pu-size)) calc(-5 * var(--pu-size)); }

/* Special blocks: column 4. */
.pu-off-medusa { background-position: calc(-3 * var(--pu-size)) calc(-3 * var(--pu-size)); }
.pu-def-midas  { background-position: calc(-3 * var(--pu-size)) 0; }

/* Keep fragment headings below the wrapping sticky navigation. */
html { scroll-behavior: smooth; }
section.block { scroll-margin-top: var(--header-height, 180px); }
.btn { min-height: 44px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
#desert-bg { background: linear-gradient(#020713, #07152d 40%, #02050d); }
.story-heading, .story-emphasis { overflow-wrap: anywhere; }

/* Only the selected block in each row uses the game's cell effects. */
.powerup-icon[data-power-preview] {
  --cell: var(--pu-size);
  --sprite-step: var(--pu-size);
  --sprite-inset: 0px;
  --sheet-w: calc(4 * var(--pu-size));
  --sheet-h: calc(6 * var(--pu-size));
  --vy: 0;
  --power-phase: 0s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.powerup-icon[data-var="off"] { --vx: 1; }
.powerup-icon[data-var="def"] { --vx: 2; }
.powerup-icon[data-type="M"] { --vx: 3; }
.powerup-icon[data-var="medusa"] { --vy: 3; }
.powerup-icon[data-type="U"] { --vy: 1; }
.powerup-icon[data-type="R"] { --vy: 2; }
.powerup-icon[data-type="N"] { --vy: 3; }
.powerup-icon[data-type="E"] { --vy: 4; }
.powerup-icon[data-type="r"] { --vy: 5; }
#powerups [data-power-preview]::before,
#powerups [data-power-preview]::after {
  animation-play-state: paused;
}
html[data-motion="running"] #powerups.is-visible [data-power-preview]::before,
html[data-motion="running"] #powerups.is-visible [data-power-preview]::after,
html[data-motion="running"] .story-block.is-visible .layer-stars,
html[data-motion="running"] .story-block.is-visible .layer-stars-2,
html[data-motion="running"] .story-block.is-visible .story-emphasis {
  animation-play-state: running;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .btn::before { transition: none; }
}

