:root {
  --ink: #eef2c9;
  --muted: #a9b595;
  --panel: #10261e;
  --panel-dark: #07130f;
  --line: #34513b;
  --lime: #c8ed61;
  --gold: #f4c64e;
  --orange: #e97838;
  --deep-jungle: #06130e;
  --leaf-shadow: #0a2419;
}

* { box-sizing: border-box; }

html { background: var(--deep-jungle); }

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #071a18 0%, #12362a 44%, #0a1c14 76%, #050d09 100%);
  font-family: "Courier New", Courier, monospace;
  overflow-x: hidden;
  overscroll-behavior: none;
}

.site-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.site-backdrop::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(3, 10, 7, .15) 3px 4px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 5px);
}

.pixel-sun {
  position: absolute;
  top: clamp(34px, 8vh, 94px);
  right: clamp(5vw, 11vw, 180px);
  width: clamp(92px, 12vw, 176px);
  aspect-ratio: 1;
  background: linear-gradient(180deg, #ffe075 0 54%, #e98a39 54% 100%);
  clip-path: polygon(25% 0, 75% 0, 75% 5%, 86% 5%, 86% 12%, 94% 12%, 94% 25%, 100% 25%, 100% 75%, 94% 75%, 94% 88%, 86% 88%, 86% 95%, 75% 95%, 75% 100%, 25% 100%, 25% 95%, 14% 95%, 14% 88%, 6% 88%, 6% 75%, 0 75%, 0 25%, 6% 25%, 6% 12%, 14% 12%, 14% 5%, 25% 5%);
  box-shadow: 0 0 0 10px rgba(244, 198, 78, .06), 0 0 0 22px rgba(244, 198, 78, .035);
  opacity: .82;
}

.pixel-stars,
.pixel-fireflies {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #c8ed61;
}

.pixel-stars {
  top: 7vh;
  left: 8vw;
  opacity: .32;
  box-shadow:
    11vw 9vh 0 #e4d66c, 24vw 1vh 0 #8eb866, 39vw 13vh 0 #d9dc7e,
    55vw 3vh 0 #87aa61, 69vw 16vh 0 #e4d66c, 83vw 5vh 0 #8eb866,
    4vw 27vh 0 #6b985c, 32vw 25vh 0 #d9dc7e, 75vw 29vh 0 #6b985c;
}

.pixel-ridge {
  position: absolute;
  right: -3vw;
  bottom: 14vh;
  left: -3vw;
  transform-origin: bottom;
}

.ridge-far {
  height: 52vh;
  background: #164a38;
  clip-path: polygon(0 72%, 5% 72%, 5% 62%, 10% 62%, 10% 52%, 16% 52%, 16% 65%, 22% 65%, 22% 43%, 28% 43%, 28% 56%, 34% 56%, 34% 68%, 41% 68%, 41% 48%, 48% 48%, 48% 31%, 54% 31%, 54% 49%, 61% 49%, 61% 64%, 67% 64%, 67% 44%, 74% 44%, 74% 58%, 81% 58%, 81% 37%, 87% 37%, 87% 51%, 93% 51%, 93% 67%, 100% 67%, 100% 100%, 0 100%);
  opacity: .55;
}

.ridge-near {
  height: 39vh;
  background: #0b2d21;
  clip-path: polygon(0 68%, 7% 68%, 7% 50%, 13% 50%, 13% 71%, 20% 71%, 20% 39%, 26% 39%, 26% 59%, 34% 59%, 34% 76%, 42% 76%, 42% 49%, 49% 49%, 49% 67%, 56% 67%, 56% 35%, 63% 35%, 63% 56%, 69% 56%, 69% 74%, 76% 74%, 76% 46%, 83% 46%, 83% 64%, 90% 64%, 90% 42%, 96% 42%, 96% 61%, 100% 61%, 100% 100%, 0 100%);
  opacity: .84;
}

.pixel-canopy {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 22vh;
  background:
    repeating-linear-gradient(90deg, #06130e 0 7vw, #081a12 7vw 11vw, #06130e 11vw 18vw);
  clip-path: polygon(0 30%, 4% 30%, 4% 18%, 9% 18%, 9% 36%, 14% 36%, 14% 8%, 20% 8%, 20% 28%, 27% 28%, 27% 16%, 34% 16%, 34% 39%, 41% 39%, 41% 12%, 47% 12%, 47% 30%, 54% 30%, 54% 4%, 61% 4%, 61% 35%, 68% 35%, 68% 17%, 75% 17%, 75% 29%, 83% 29%, 83% 9%, 90% 9%, 90% 32%, 96% 32%, 96% 20%, 100% 20%, 100% 100%, 0 100%);
}

.pixel-fireflies {
  left: 4vw;
  bottom: 17vh;
  box-shadow:
    9vw -8vh 0 #d6f273, 17vw 2vh 0 #f4c64e, 29vw -12vh 0 #a7d85d,
    43vw -3vh 0 #f4c64e, 58vw -15vh 0 #d6f273, 71vw 0 0 #a7d85d,
    84vw -10vh 0 #f4c64e, 91vw 4vh 0 #d6f273;
  animation: firefly-pulse 2.8s steps(2, end) infinite;
}

@keyframes firefly-pulse {
  0%, 100% { opacity: .22; }
  50% { opacity: .8; }
}

button, kbd { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 36px) 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 8px;
  padding: 12px 14px 11px;
  border: 1px solid rgba(89, 124, 80, .45);
  background: rgba(5, 17, 12, .78);
  box-shadow: 5px 5px 0 rgba(2, 9, 6, .62), inset 0 -3px 0 rgba(27, 68, 43, .45);
  backdrop-filter: blur(3px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-copy { min-width: 0; }

.pixel-idol {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 58px;
  background: var(--gold);
  clip-path: polygon(22% 0, 78% 0, 78% 8%, 91% 8%, 91% 24%, 100% 24%, 100% 70%, 87% 70%, 87% 86%, 70% 86%, 70% 100%, 30% 100%, 30% 86%, 13% 86%, 13% 70%, 0 70%, 0 24%, 9% 24%, 9% 8%, 22% 8%);
  filter: drop-shadow(5px 5px 0 #5e3020);
}

.pixel-idol::before {
  position: absolute;
  top: 20px;
  left: 13px;
  width: 8px;
  height: 8px;
  content: "";
  background: #122217;
  box-shadow: 20px 0 0 #122217;
}

.pixel-idol::after {
  position: absolute;
  bottom: 13px;
  left: 17px;
  width: 20px;
  height: 5px;
  content: "";
  background: #9e542c;
  box-shadow: -5px -5px 0 #9e542c, 15px -5px 0 #9e542c;
}

.eyebrow,
.panel-kicker,
.help-label {
  margin: 0;
  color: var(--lime);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.domain-name { color: var(--gold); }

h1 {
  display: flex;
  gap: .18em;
  margin: 5px 0 0;
  font-family: "Arial Black", Impact, Haettenschweiler, sans-serif;
  font-size: clamp(32px, 4.3vw, 57px);
  line-height: .82;
  letter-spacing: -.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.logo-word {
  display: inline-block;
  color: #e9f3b5;
  -webkit-text-stroke: 1px #15261a;
  text-shadow: 0 3px 0 #688445, 0 6px 0 #23432c, 5px 9px 0 rgba(0,0,0,.5);
}

.logo-relic {
  color: var(--gold);
  text-shadow: 0 3px 0 #b56b2d, 0 6px 0 #65351f, 5px 9px 0 rgba(0,0,0,.5);
}

.header-actions { display: flex; gap: 8px; }

.icon-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(7, 19, 15, .75);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--lime);
  color: var(--ink);
  outline: none;
}

.icon-button:disabled {
  border-color: #24382c;
  color: #526258;
  cursor: not-allowed;
  opacity: .72;
}

.game-frame {
  position: relative;
  padding: 7px;
  background: linear-gradient(135deg, #5d7b3c, #263f2c 45%, #b58c36 46%, #574426 49%, #1a3024 50%);
  box-shadow: 0 24px 80px rgba(0,0,0,.48), inset 0 0 0 1px rgba(255,255,255,.15);
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #14251b;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  outline: none;
  touch-action: none;
}

canvas:focus-visible { box-shadow: inset 0 0 0 3px rgba(200, 237, 97, .85); }

.start-panel,
.result-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 52px);
  text-align: center;
  background: linear-gradient(180deg, rgba(5,18,13,.28), rgba(5,18,13,.86));
  backdrop-filter: blur(2px);
}

.start-panel[hidden],
.result-panel[hidden] { display: none; }

.start-panel h2,
.result-panel h2 {
  max-width: 720px;
  margin: 8px 0 8px;
  color: #fff5b6;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(32px, 5.2vw, 66px);
  font-weight: 400;
  letter-spacing: .03em;
  line-height: .98;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #582d1d, 8px 8px 0 rgba(0,0,0,.25);
}

.start-panel > p:not(.panel-kicker):not(.small-note),
.result-panel > p:not(.panel-kicker) {
  max-width: 600px;
  margin: 6px 0 18px;
  color: #d7dfbd;
  font-size: clamp(12px, 1.7vw, 16px);
  line-height: 1.55;
}

.mission-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 120px));
  gap: 1px;
  margin: 0 0 20px;
  background: rgba(196, 231, 92, .28);
}

.mission-stats div {
  padding: 10px 12px 9px;
  background: rgba(6, 23, 16, .86);
}

.mission-stats strong,
.mission-stats span { display: block; }

.mission-stats strong { color: var(--gold); font-size: 20px; }
.mission-stats span { margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }

.primary-button {
  min-width: 240px;
  padding: 15px 24px 13px;
  border: 0;
  border-bottom: 5px solid #8a4a22;
  color: #1b1c0d;
  background: var(--gold);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
  box-shadow: 0 8px 28px rgba(0,0,0,.36);
}

.primary-button:hover,
.primary-button:focus-visible { background: #fff08a; outline: 3px solid rgba(255,255,255,.42); outline-offset: 3px; }
.primary-button:active { transform: translateY(3px); border-bottom-width: 2px; margin-bottom: 3px; }

.small-note { margin: 10px 0 0 !important; color: #879a7c !important; font-size: 10px !important; letter-spacing: .1em; text-transform: uppercase; }

.score-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 210px));
  gap: 1px;
  margin: 2px 0 22px;
  background: rgba(196, 231, 92, .28);
  color: var(--muted);
  text-transform: uppercase;
}

.score-summary div { padding: 10px 18px; background: rgba(6, 23, 16, .9); }
.score-summary span, .score-summary strong { display: block; }
.score-summary span { margin-bottom: 3px; font-size: 9px; letter-spacing: .12em; }
.score-summary strong { color: var(--gold); font-size: 26px; }

.noscript-warning {
  display: block;
  padding: 12px;
  border: 1px solid #6f4828;
  color: #ffe7a4;
  background: #372418;
  text-align: center;
  font-size: 12px;
}

.help-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid #223c2d;
  border-top: 0;
  background: rgba(8, 22, 15, .8);
}

.help-block {
  min-height: 62px;
  padding: 11px 14px 9px;
  border-right: 1px solid #223c2d;
}

.help-block:last-child { border-right: 0; }
.help-block p:last-child { margin: 7px 0 0; color: #c6cfad; font-size: 11px; }

kbd {
  display: inline-block;
  min-width: 23px;
  margin-right: 4px;
  padding: 3px 5px 2px;
  border: 1px solid #4a634f;
  border-bottom-width: 3px;
  color: #e9efcb;
  background: #182c20;
  text-align: center;
  font-size: 10px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 13px 4px 0;
  color: #607263;
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.touch-controls { display: none; }

.canvas-wrap:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  background: #020805;
}

.canvas-wrap:fullscreen canvas {
  width: auto;
  height: auto;
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .page-shell { padding: 12px 8px 8px; justify-content: flex-start; }
  .masthead { align-items: center; gap: 7px; margin-bottom: 5px; padding: 8px; }
  .brand-lockup { gap: 7px; }
  .pixel-idol { width: 34px; height: 38px; filter: drop-shadow(3px 3px 0 #5e3020); }
  .pixel-idol::before { top: 13px; left: 8px; width: 5px; height: 5px; box-shadow: 13px 0 0 #122217; }
  .pixel-idol::after { bottom: 8px; left: 11px; width: 13px; height: 3px; box-shadow: -3px -3px 0 #9e542c, 10px -3px 0 #9e542c; }
  .eyebrow { display: none; }
  h1 { margin: 0; font-size: clamp(20px, 6.6vw, 32px); text-shadow: none; }
  .logo-word { text-shadow: 0 2px 0 #688445, 0 4px 0 #23432c; }
  .logo-relic { text-shadow: 0 2px 0 #b56b2d, 0 4px 0 #65351f; }
  .header-actions { gap: 5px; }
  .icon-button { min-height: 31px; padding: 0 7px; font-size: 8px; }
  .help-strip { grid-template-columns: repeat(2, 1fr); }
  .help-block:nth-child(2) { border-right: 0; }
  .help-block:nth-child(-n+2) { border-bottom: 1px solid #223c2d; }
  .start-panel { justify-content: center; }
  .start-panel > p:not(.panel-kicker):not(.small-note) { display: none; }
  .mission-stats { margin-bottom: 12px; }
  .mission-stats { grid-template-columns: repeat(4, minmax(60px, 1fr)); }
  .mission-stats div { padding: 7px 4px; }
  .mission-stats strong { font-size: 16px; }
  .primary-button { min-width: 190px; padding: 11px 16px 9px; font-size: 12px; }
  footer { display: none; }
}

@media (hover: none), (pointer: coarse) {
  body { padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .canvas-wrap { overflow: visible; margin-bottom: 76px; }
  .touch-controls {
    position: absolute;
    top: calc(100% + 10px);
    left: 3px;
    right: 3px;
    display: flex;
    gap: 7px;
    height: 58px;
  }
  .touch-controls button {
    flex: 0 0 58px;
    border: 1px solid #4a634f;
    border-bottom: 4px solid #1c3325;
    color: var(--ink);
    background: #173123;
    font-weight: 900;
    touch-action: none;
  }
  .canvas-wrap:fullscreen { margin-bottom: 0; }
  .canvas-wrap:fullscreen canvas { align-self: flex-start; max-height: calc(100vh - 72px); }
  .canvas-wrap:fullscreen .touch-controls { top: auto; bottom: 7px; left: 8px; right: 8px; }
  .touch-controls .jump-button {
    flex: 0 0 92px;
    margin-left: auto;
    border-color: #aa8432;
    border-bottom-color: #6c451d;
    color: #28200b;
    background: var(--gold);
  }
  .touch-controls button.is-pressed { transform: translateY(3px); border-bottom-width: 1px; }
  .help-strip { display: none; }
}

@media (max-height: 820px) and (orientation: landscape) {
  .page-shell { width: min(1000px, 100%); min-height: auto; padding-top: 6px; }
  .masthead { padding-bottom: 6px; }
  .eyebrow, .help-strip, footer { display: none; }
  .masthead { padding-block: 5px; }
  .pixel-idol { width: 31px; height: 34px; }
  h1 { font-size: 28px; }
  .game-frame { width: min(100%, 130vh); margin-inline: auto; }
}

@media (hover: none) and (max-height: 600px) and (orientation: landscape) {
  .game-frame { width: min(100%, 120vh); }
}

@media (max-height: 600px) and (orientation: landscape) {
  .start-panel,
  .result-panel { padding: 8px 14px; }
  .start-panel .panel-kicker,
  .start-panel .small-note,
  .start-panel > p:not(.panel-kicker):not(.small-note),
  .result-panel > p:not(.panel-kicker) { display: none; }
  .start-panel h2,
  .result-panel h2 { margin: 0 0 6px; font-size: clamp(26px, 8vh, 42px); }
  .mission-stats { margin-bottom: 8px; }
  .mission-stats div { padding: 5px 6px 4px; }
  .mission-stats strong { font-size: 16px; }
  .primary-button { min-width: 220px; padding: 9px 18px 7px; font-size: 12px; }
  .score-summary { margin: 2px 0 8px; }
  .score-summary div { padding: 6px 12px; }
  .score-summary strong { font-size: 20px; }
}

@media (max-width: 430px) {
  .brand-lockup { gap: 5px; }
  .pixel-idol { width: 28px; height: 32px; }
  .pixel-idol::before { top: 11px; left: 7px; width: 4px; height: 4px; box-shadow: 11px 0 0 #122217; }
  .pixel-idol::after { bottom: 7px; left: 9px; width: 11px; height: 3px; box-shadow: -3px -3px 0 #9e542c, 8px -3px 0 #9e542c; }
  h1 { font-size: clamp(18px, 6vw, 25px); }
  .header-actions { gap: 3px; }
  .icon-button { padding: 0 5px; font-size: 7px; }
  .mission-stats { width: 100%; }
  .score-summary { grid-template-columns: 1fr 1fr; width: 100%; }
  .score-summary div { padding: 8px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .pixel-fireflies { animation: none; opacity: .55; }
}
