:root {
  --ink: #211811;
  --navy: #202b29;
  --deep: #172525;
  --ocean: #27676b;
  --cyan: #769b91;
  --sky: #9da99a;
  --cream: #e8d9b5;
  --orange: #a94f2d;
  --yellow: #d4a84f;
  --white: #f4e7c1;
  --line: rgba(33, 24, 17, 0.25);
  --shadow: 0 22px 70px rgba(18, 10, 5, 0.38);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(194, 133, 54, .17), transparent 25rem),
    repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 2px, transparent 2px 8px),
    #1c1510;
  font-family: "Nunito", system-ui, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1480px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  background: var(--cream);
  border: 3px double #8c672f;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.masthead {
  height: 82px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 42px;
  border-bottom: 4px solid #6e4d27;
  background:
    linear-gradient(90deg, rgba(123,82,38,.12), transparent 25%, rgba(123,82,38,.12)),
    #dfcea5;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 44px; height: 44px; border: 4px double var(--ink); border-radius: 50%;
  display: grid; place-items: center; font: 800 17px "Barlow Condensed"; letter-spacing: -1px;
  box-shadow: inset 0 0 0 4px var(--yellow), 0 0 0 2px #9a7135;
}
.brand strong, .brand small { display: block; line-height: 1; }
.brand strong { font: 800 21px "Barlow Condensed"; letter-spacing: 1.4px; }
.brand small { margin-top: 5px; font-size: 9px; letter-spacing: 3.2px; }
.unit-badge { font-size: 13px; font-weight: 800; letter-spacing: .06em; }
.unit-badge span { background: var(--ink); color: var(--yellow); padding: 7px 10px; margin-right: 10px; border: 2px solid #8c672f; }

.screen { min-height: calc(100vh - 114px); }
.is-hidden { display: none !important; }

.welcome-screen { display: grid; grid-template-columns: minmax(480px, .9fr) minmax(500px, 1.1fr); }
.hero-copy { min-width: 0; padding: clamp(55px, 7vw, 110px) clamp(38px, 6vw, 96px); position: relative; z-index: 2; }
.eyebrow { color: #77542d; font: 800 12px "Nunito"; letter-spacing: .25em; }
h1 { margin: 18px 0 24px; font: 800 clamp(64px, 7vw, 112px)/.78 "Barlow Condensed"; text-transform: uppercase; letter-spacing: -.035em; }
h1 em { color: var(--orange); font-style: normal; text-shadow: 2px 2px 0 #d9b76e; }
.hero-description { max-width: 540px; font-size: 18px; line-height: 1.65; color: #544639; }
.pilot-form { margin-top: 42px; max-width: 590px; }
.pilot-form label, #answer-form label { display: block; margin-bottom: 9px; font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.name-entry { display: flex; border-bottom: 3px solid var(--ink); }
.name-entry input { min-width: 0; flex: 1; border: 0; background: transparent; outline: 0; padding: 12px 5px; font-size: 19px; font-weight: 700; }
.name-entry input::placeholder { color: #8c9896; }
.primary-button {
  border: 3px double var(--ink); background: linear-gradient(#c07a3a, #954426); color: var(--white); padding: 14px 20px; font-weight: 900;
  letter-spacing: .05em; box-shadow: 5px 5px 0 var(--ink), inset 0 0 0 2px #d9a750; transition: transform .15s, box-shadow .15s;
}
.primary-button:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.primary-button span { margin-left: 15px; }
.curriculum-path { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 52px; gap: 12px 28px; max-width: 590px; }
.curriculum-path span { padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; font-weight: 800; color: #52666c; }
.curriculum-path b { color: var(--orange); margin-right: 8px; font-family: "Barlow Condensed"; }

.hero-art { min-height: 690px; position: relative; overflow: hidden; background: linear-gradient(#849d94 0 49.5%, #326f70 49.5% 62%, #173f47 62% 100%); }
.hero-art::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(234,203,133,.12) 1px, transparent 1px), repeating-linear-gradient(90deg, transparent 0 79px, rgba(32,23,17,.06) 80px); background-size: 100% 65px, 80px 100%; }
.sun { position: absolute; right: 12%; top: 10%; width: 105px; height: 105px; border-radius: 50%; background: radial-gradient(circle, #e0bd65 0 48%, #9d6b31 50% 59%, #38261a 61% 64%, #c38a3e 66%); box-shadow: 0 0 0 13px rgba(207,162,70,.16); }
.cloud { position: absolute; height: 8px; border-radius: 50%; background: rgba(237,218,174,.68); box-shadow: 25px -8px 0 6px rgba(237,218,174,.68), 54px 0 0 1px rgba(237,218,174,.68); }
.cloud-one { width: 70px; top: 19%; left: 12%; }
.cloud-two { width: 45px; top: 31%; right: 17%; transform: scale(.8); }
.water-line { position: absolute; left: 0; right: 0; top: calc(49.5% - 7px); height: 14px; background: repeating-linear-gradient(90deg, #d7b96e 0 24px, transparent 24px 43px); opacity: .8; }
.depth-lines { position: absolute; inset: 50% 0 0; background: repeating-radial-gradient(ellipse at 40% -10%, transparent 0 40px, rgba(255,255,255,.06) 41px 43px); }
.hero-plane { position: absolute; width: 370px; height: 155px; top: 39%; left: 12%; z-index: 3; transform: rotate(-5deg); filter: drop-shadow(0 20px 16px rgba(0,32,50,.25)); }
.hero-plane.raster-hero-plane { width: 420px; height: 560px; top: 9%; left: 9%; transform: none; background-image: url('/assets/sprites/abyssal-arrow-sheet.png'); background-repeat: no-repeat; background-size: 400% 100%; background-position: 0 0; filter: drop-shadow(0 18px 9px rgba(21,14,8,.4)); }
.raster-hero-plane > * { display: none; }
.plane-body { position: absolute; width: 305px; height: 74px; border-radius: 55% 46% 46% 55%; left: 18px; top: 48px; background: linear-gradient(#bd6939, #873f26); border: 5px solid var(--ink); box-shadow: inset 0 7px 0 rgba(232,190,100,.35); }
.plane-body::after { content: "AA-07"; position: absolute; left: 120px; top: 38px; color: var(--ink); font: 900 13px "Barlow Condensed"; letter-spacing: 2px; }
.plane-window { position: absolute; width: 78px; height: 37px; border: 6px double var(--ink); border-radius: 60% 55% 15% 20%; background: #769b91; top: 5px; left: 177px; }
.plane-window::before { content: ""; position: absolute; height: 100%; width: 4px; background: var(--ink); left: 33px; }
.plane-nose { position: absolute; width: 12px; height: 28px; background: var(--yellow); border: 4px solid var(--ink); border-left: 0; right: -11px; top: 19px; border-radius: 0 50% 50% 0; }
.plane-wing { position: absolute; left: 105px; background: linear-gradient(#d2a74c, #9b6b2f); border: 5px solid var(--ink); z-index: 2; }
.plane-wing-top { width: 130px; height: 42px; border-radius: 50% 15% 10% 10%; top: 18px; transform: skewX(-12deg); }
.plane-wing-bottom { width: 155px; height: 38px; border-radius: 12% 15% 60% 40%; top: 106px; transform: skewX(17deg); }
.plane-tail { position: absolute; left: 14px; top: 17px; width: 60px; height: 73px; background: #a94f2d; border: 5px solid var(--ink); transform: skewX(16deg); }
.propeller { position: absolute; right: 24px; top: 4px; height: 145px; width: 7px; background: var(--ink); border-radius: 50%; animation: propeller .18s linear infinite alternate; }
@keyframes propeller { to { transform: scaleY(.65); opacity: .55; } }
.boiler-rivets { position: absolute; left: 80px; top: 14px; width: 72px; height: 8px; border-top: 6px dotted #d4a84f; }
.steam-puff { position: absolute; z-index: -1; border-radius: 50%; background: rgba(232,217,181,.65); animation: steam 1.7s ease-out infinite; }
.steam-puff-one { left: 4px; top: 18px; width: 30px; height: 30px; }
.steam-puff-two { left: -17px; top: 2px; width: 45px; height: 45px; animation-delay: .55s; }
@keyframes steam { to { translate: -38px -25px; scale: 1.5; opacity: 0; } }
.gear { position: absolute; border: 12px dotted rgba(74,47,25,.28); border-radius: 50%; box-shadow: inset 0 0 0 9px rgba(190,135,54,.2), 0 0 0 5px rgba(47,31,20,.15); animation: gear-turn 24s linear infinite; }
.gear::after { content: ""; position: absolute; inset: 32%; border-radius: 50%; background: rgba(36,28,20,.24); }
.gear-one { width: 180px; height: 180px; right: -45px; bottom: 15%; }
.gear-two { width: 105px; height: 105px; left: -28px; top: 12%; animation-direction: reverse; }
@keyframes gear-turn { to { rotate: 360deg; } }
.rock { position: absolute; bottom: -45px; background: #06445e; border-radius: 45% 48% 0 0; }
.rock-one { left: 2%; width: 210px; height: 155px; transform: rotate(8deg); }
.rock-two { right: 4%; width: 320px; height: 220px; transform: rotate(-7deg); }
.bubble { position: absolute; border: 2px solid rgba(255,255,255,.3); border-radius: 50%; }
.bubble-one { width: 18px; height: 18px; right: 24%; top: 68%; }
.bubble-two { width: 9px; height: 9px; right: 28%; top: 74%; }
.hero-caption { position: absolute; right: 24px; bottom: 23px; color: white; text-align: right; }
.hero-caption span { display: block; font-size: 8px; font-weight: 900; letter-spacing: .26em; opacity: .65; }
.hero-caption strong { font: 800 25px "Barlow Condensed"; letter-spacing: .12em; }

.game-screen { background: #1e1712; color: var(--white); padding: 24px; box-shadow: inset 0 0 80px rgba(0,0,0,.5); }
.game-topbar { height: 65px; display: flex; align-items: center; gap: 38px; max-width: 1410px; margin: auto; }
.mission-info { flex: 1; }
.mission-info > span { display: block; font: 800 14px "Barlow Condensed"; letter-spacing: .16em; margin-bottom: 8px; }
.progress-track { height: 7px; padding: 1px; border: 1px solid #8f6d39; background: #100c09; }
#progress-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, #d4a84f 0 13px, #9a642d 13px 16px); transition: width .4s; }
.stat, .hull { border-left: 1px solid rgba(255,255,255,.16); padding-left: 24px; min-width: 80px; }
.stat small, .hull small { display: block; color: #b28c51; font-size: 8px; font-weight: 900; letter-spacing: .2em; }
.stat strong { font: 800 25px "Barlow Condensed"; }
#hull-pips { display: flex; margin-top: 2px; }
.life-pip { color: #c45f31; font-style: normal; font-size: 25px; line-height: 1; filter: drop-shadow(2px 2px 0 #5a2e1e); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; max-width: 1410px; margin: auto; border: 4px double #8f6d39; box-shadow: 0 0 0 3px #100c09; }
.viewport-frame { position: relative; min-width: 0; background: #27676b; overflow: hidden; border-right: 3px solid #5b4228; }
#game-canvas { display: block; width: 100%; height: min(650px, calc(100vh - 195px)); min-height: 480px; image-rendering: pixelated; }
.altimeter { position: absolute; left: 22px; top: 22px; background: linear-gradient(#352a20, #1c1712); border: 4px double #b68a45; padding: 12px 16px; min-width: 130px; box-shadow: 5px 5px 0 rgba(25,15,9,.5), inset 0 0 0 2px #15100c; }
.altimeter::before, .altimeter::after { content: "•"; position: absolute; top: 1px; color: #d4a84f; }
.altimeter::before { left: 5px; } .altimeter::after { right: 5px; }
.altimeter small, .altimeter span { display: block; font-size: 8px; letter-spacing: .18em; color: #c7a86b; font-weight: 900; }
.altimeter strong { display: block; font: 800 34px "Barlow Condensed"; line-height: 1; margin: 5px 0 2px; }
.danger-gauge { position: absolute; left: 22px; bottom: 22px; width: min(390px, calc(100% - 44px)); padding: 11px 13px 13px; background: rgba(29,21,16,.92); border: 3px double #a47b3e; color: var(--white); box-shadow: 5px 5px 0 rgba(12,8,5,.45); }
.danger-copy { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.danger-copy span { font-size: 9px; font-weight: 900; letter-spacing: .15em; color: #e0bd70; }
.danger-copy strong { font: 800 20px "Barlow Condensed"; color: #f1dfb2; }
.danger-track { height: 10px; padding: 2px; border: 1px solid #7d5b32; background: #0f0b08; }
#danger-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, #c35a31 0 10px, #74321f 10px 13px); transition: width .08s linear; }
.feedback-toast { position: absolute; left: 50%; top: 24px; translate: -50% -12px; padding: 10px 18px; color: var(--ink); background: var(--yellow); border: 3px double var(--ink); box-shadow: 4px 4px 0 rgba(25,15,9,.55); font-size: 13px; font-weight: 900; opacity: 0; transition: .2s; pointer-events: none; }
.feedback-toast.show { opacity: 1; translate: -50% 0; }
.feedback-toast.wrong { color: white; background: var(--orange); }
.challenge-panel { position: relative; background: repeating-linear-gradient(0deg, rgba(96,66,33,.035) 0 1px, transparent 1px 5px), var(--cream); color: var(--ink); padding: 32px; display: flex; flex-direction: column; box-shadow: inset 8px 0 18px rgba(48,30,13,.17); }
.challenge-panel::before, .challenge-panel::after { content: "●"; position: absolute; right: 7px; color: #7f5c31; font-size: 10px; }
.challenge-panel::before { top: 5px; } .challenge-panel::after { bottom: 5px; }
.challenge-heading { display: flex; justify-content: space-between; font-size: 10px; font-weight: 900; letter-spacing: .14em; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.difficulty-dots { display: flex; gap: 4px; }
.difficulty-dots i { width: 7px; height: 7px; border: 1px solid #6d5132; background: #c6b58f; }
.difficulty-dots i.active { background: var(--orange); }
.question-context { color: #76542f; font-size: 9px; font-weight: 900; letter-spacing: .2em; margin: 34px 0 7px; }
.challenge-panel h2 { font: 800 30px/1.05 "Barlow Condensed"; text-transform: uppercase; margin: 0; min-height: 64px; }
.expression { display: grid; place-items: center; min-height: 118px; margin: 22px 0 27px; background: #2c2821; color: #e9c571; border: 5px double #806139; box-shadow: inset 0 0 20px #100c09; font: 800 48px "Barlow Condensed"; letter-spacing: .03em; text-shadow: 0 0 8px rgba(231,188,92,.3); }
.answer-row { display: grid; grid-template-columns: 42px 1fr; gap: 8px; }
.sign-button { grid-row: span 1; border: 3px double #76552d; background: #c8b78e; font-weight: 900; color: #3e2c1d; }
#answer-input { min-width: 0; width: 100%; height: 52px; border: 3px double var(--ink); background: #f0e2be; padding: 0 12px; outline: 0; font-size: 24px; font-weight: 900; }
#answer-input { appearance: textfield; -moz-appearance: textfield; }
#answer-input::-webkit-inner-spin-button,
#answer-input::-webkit-outer-spin-button { margin: 0; appearance: none; }
#answer-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(169,79,45,.22); }
.launch-button { grid-column: 1 / -1; height: 52px; border: 4px double #2b1d13; color: var(--white); background: linear-gradient(#bd6938, #8c4026); font-size: 12px; font-weight: 900; letter-spacing: .14em; box-shadow: 4px 4px 0 var(--ink), inset 0 0 0 2px #cb914a; }
.launch-button:disabled { opacity: .55; cursor: wait; }
.answer-hint { color: #685a48; font-size: 11px; line-height: 1.5; }
.comparison-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.comparison-controls button { min-height: 86px; border: 4px double #392719; background: linear-gradient(#c79648, #93632f); color: #23170f; box-shadow: 4px 4px 0 #261a12; }
.comparison-controls button:hover { translate: 1px 1px; box-shadow: 3px 3px 0 #261a12; }
.comparison-controls button:disabled { opacity: .55; }
.comparison-controls strong { display: block; font: 800 40px/1 "Barlow Condensed"; }
.comparison-controls span { display: block; margin-top: 5px; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.mission-log { margin-top: auto; border-top: 1px solid var(--line); padding-top: 18px; }
.mission-log span { font-size: 9px; font-weight: 900; letter-spacing: .18em; color: #718084; }
.mission-log p { font-size: 12px; line-height: 1.5; margin-bottom: 0; }

.results-screen { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(380px, .65fr); align-items: stretch; background: radial-gradient(circle at 25% 30%, rgba(212,168,79,.3), transparent 18rem), repeating-linear-gradient(45deg, rgba(57,38,21,.035) 0 2px, transparent 2px 9px), #cbb98f; }
.results-card { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 60px; text-align: center; }
.rank-seal { width: 110px; height: 110px; display: grid; place-items: center; border: 8px double var(--ink); border-radius: 50%; background: radial-gradient(circle, #d7b254 0 52%, #90602f 54%); box-shadow: 8px 8px 0 var(--ink); font: 800 68px "Barlow Condensed"; transform: rotate(-5deg); }
.results-card h1 { font-size: clamp(52px, 6vw, 86px); line-height: .9; margin: 30px 0 15px; }
.results-card > p:not(.eyebrow) { color: #405a62; margin: 0; }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); width: min(600px, 100%); margin: 40px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.results-stats div { padding: 20px 10px; border-right: 1px solid var(--line); }
.results-stats div:last-child { border-right: 0; }
.results-stats small { display: block; font-size: 8px; font-weight: 900; color: #65787b; letter-spacing: .15em; }
.results-stats strong { font: 800 34px "Barlow Condensed"; }
.leaderboard-card { background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 5px), #211811; color: var(--white); padding: 55px clamp(30px, 5vw, 70px); display: flex; flex-direction: column; justify-content: center; border-left: 6px double #8f6d39; }
.leaderboard-title { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid rgba(255,255,255,.2); padding-bottom: 17px; }
.leaderboard-title span { font: 800 27px "Barlow Condensed"; letter-spacing: .05em; }
.leaderboard-title small { color: #7296a3; font-size: 8px; letter-spacing: .15em; }
#leaderboard-list { list-style: none; margin: 0; padding: 0; counter-reset: pilots; }
#leaderboard-list li { counter-increment: pilots; display: grid; grid-template-columns: 35px 1fr auto; align-items: center; min-height: 63px; border-bottom: 1px solid rgba(255,255,255,.11); font-weight: 800; }
#leaderboard-list li::before { content: counter(pilots, decimal-leading-zero); color: var(--orange); font: 800 16px "Barlow Condensed"; }
#leaderboard-list li strong { color: var(--yellow); font: 800 23px "Barlow Condensed"; }
#leaderboard-list li.loading { color: #7296a3; font-size: 12px; }
#leaderboard-list li.loading::before { content: ""; }

@media (max-width: 980px) {
  .welcome-screen { grid-template-columns: 1fr; }
  .hero-copy { padding: 55px 42px; }
  .hero-art { min-height: 520px; }
  .game-layout { grid-template-columns: 1fr; }
  .viewport-frame { border-right: 0; border-bottom: 3px solid #5b4228; }
  #game-canvas { height: 52vh; min-height: 390px; }
  .challenge-panel { min-height: 450px; }
  .game-screen { padding: 14px; }
  .game-topbar { gap: 18px; }
  .results-screen { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .app-shell { width: 100%; min-height: 100vh; margin: 0; }
  .masthead { height: 67px; padding: 0 18px; }
  .brand strong { font-size: 18px; }
  .brand small { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .unit-badge { font-size: 0; }
  .unit-badge span { font-size: 10px; margin: 0; }
  .screen { min-height: calc(100vh - 67px); }
  .hero-copy { padding: 38px 24px 50px; }
  h1 { font-size: clamp(54px, 16.2vw, 64px); }
  .hero-description { max-width: calc(100vw - 48px); font-size: 15px; overflow-wrap: anywhere; }
  .name-entry { display: grid; border-bottom: 0; gap: 12px; }
  .name-entry input { width: 100%; border-bottom: 3px solid var(--ink); }
  .curriculum-path { grid-template-columns: 1fr; margin-top: 35px; }
  .hero-art { min-height: 430px; }
  .hero-plane.raster-hero-plane { width: 330px; height: 440px; top: 0; left: -3%; transform: none; }
  .game-topbar { height: 58px; }
  .mission-info > span { font-size: 11px; }
  .stat { padding-left: 12px; min-width: 55px; }
  .stat strong { font-size: 20px; }
  .hull { padding-left: 10px; min-width: 42px; }
  .life-pip { font-size: 21px; }
  #game-canvas { min-height: 330px; }
  .danger-gauge { left: 12px; bottom: 12px; width: calc(100% - 24px); }
  .challenge-panel { padding: 25px 22px; min-height: 430px; }
  .results-card { padding: 50px 22px; }
  .results-stats strong { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
