:root { color-scheme: light; font-family: Arial, Helvetica, sans-serif; color: #213b42; background: #aebbb3; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 240px; min-height: 100dvh; }
button, input { font: inherit; }
.masthead { height: 76px; max-width: 1120px; margin: auto; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.wordmark { color: inherit; text-decoration: none; border: 0; background: transparent; padding: 0; cursor: pointer; font-size: 13px; font-weight: 800; letter-spacing: .035em; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.mark { display: grid; place-items: center; background: #213b42; color: #f2efdf; font-size: 21px; width: 27px; height: 27px; }
.edition { font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.edition span { color: #acb4a8; padding: 0 8px; }
.header-actions { display: flex; align-items: center; gap: 20px; }
#sound, #account { min-height: 36px; min-width: 70px; border: 1px solid #9caaa4; border-radius: 3px; background: transparent; color: #213b42; font: 700 10px Arial, sans-serif; letter-spacing: .07em; cursor: pointer; }
#sound[aria-pressed="true"] { background: #213b42; color: #f4edda; }
#sound:focus-visible { outline: 2px solid #c95132; outline-offset: 3px; }
main { display: flex; flex-direction: column; align-items: center; padding: 0 16px 16px; }
.stage { position: relative; container-type: inline-size; width: min(100%, 480px, calc((100svh - 145px) * 2 / 3)); aspect-ratio: 2 / 3; overflow: hidden; background: #a3b8b4; box-shadow: 0 15px 40px #243b4220; border-radius: 4px; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; cursor: pointer; }
.stage { -webkit-user-select: none; user-select: none; }
/* The whole canvas receives taps; browser tap feedback must not tint the flight. */
.stage, .stage canvas { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
.stage:focus-within { outline: 2px solid #315a61; outline-offset: 4px; }
.mobile-thrust { display: none; }
@media (pointer: coarse), (max-width: 700px) {
  .mobile-thrust {
    position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: max(38px, env(safe-area-inset-bottom, 0px));
    z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    width: 100px; height: 100px; padding: 0; border: 2px solid #f8eac5; border-radius: 50%;
    background: #ee8957; color: #203c45; box-shadow: 0 2px 8px #203c4566;
    font-size: 10px; font-weight: 900; letter-spacing: .06em; cursor: pointer;
    touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none;
  }
  .stage canvas { cursor: default; }
  .thrust-arrow { font-size: 50px; line-height: 1; }
  .mobile-thrust:active { background: #f4b17b; transform: scale(.95); }
  .mobile-thrust:focus-visible { outline: 3px solid #203c45; outline-offset: 3px; }
}
.hud, .flight-label, .message { pointer-events: none; position: absolute; }
.hud { inset: 0 0 auto; padding: 5% 5.5% 9%; display: flex; justify-content: space-between; align-items: flex-start; color: #203c43; background: linear-gradient(#bdcebbf5, #bdcebbdb 65%, #bdcebb00); }
.location, .best-label { font-size: clamp(8px, 1.5svh, 11px); font-weight: 800; letter-spacing: .09em; line-height: 1.65; }
.hud-sub { font-size: .75em; font-weight: 500; letter-spacing: .03em; }
.point-feedback, .record-feedback, .debug-label { position: absolute; pointer-events: none; font-weight: 800; }
.point-feedback { top: 11%; left: 50%; transform: translateX(-50%); color: #c64426; font-size: 16px; }
.record-feedback { top: 15%; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 7px 11px; font-size: 10px; letter-spacing: .08em; background: #f7e6bb; color: #73341f; border-radius: 3px; }
.debug-label { bottom: 7%; left: 50%; transform: translateX(-50%); width: calc(100% - 16px); white-space: pre-line; color: #fff; background: #223b48dc; padding: 5px; font-size: 9px; line-height: 1.4; }
[hidden] { display: none !important; }
.live-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #d95436; margin: 0 4px 1px 0; }
.score { position: absolute; left: 50%; transform: translateX(-50%); font-size: clamp(28px, 6svh, 48px); font-weight: 800; line-height: 1; letter-spacing: -.06em; }
.best-label { text-align: right; }
#best { font-size: 19px; font-weight: 700; letter-spacing: 0; }
.message { left: 8%; right: 8%; top: 14%; text-align: center; }
.message[hidden] { display: none; }
.eyebrow { font-size: clamp(8px, 1.4svh, 10px); font-weight: 800; letter-spacing: .2em; }
.message h2 { font-size: clamp(22px, 8.5cqw, 40px); letter-spacing: -.055em; line-height: 1.06; margin: 12px 0; font-weight: 900; }
.message p { font-size: clamp(11px, 3cqw, 14px); line-height: 1.55; margin: 0; }
.message .network-result { margin-top: 7px; font-size: clamp(8px, 2.3cqw, 11px); font-weight: 700; color: #456066; }
.action-hint { display: inline-block; margin-top: 18px; padding: 11px 14px; color: #f5f1df; background: #213b42; border-radius: 3px; font-size: clamp(9px, 1.5svh, 11px); }
.keycap { display: inline-block; font-size: .8em; letter-spacing: .07em; border: 1px solid #8ea8a8; border-radius: 2px; padding: 3px 5px; margin-right: 5px; }
.message:not(.is-dead):not(.is-paused) .action-hint { margin-top: clamp(45px, 14cqw, 70px); }
.message.is-dead { top: 29%; background: #efeddeed; border: 1px solid #ffffff80; padding: 22px 10px; box-shadow: 0 8px 30px #1b384226; }
.message.is-paused { top: 30%; background: #efeddeef; padding: 25px 8px; }
.flight-label { bottom: 1.8%; left: 5.5%; right: 5.5%; display: flex; justify-content: space-between; color: #bbc6b8; font-size: clamp(7px, 1.15svh, 9px); font-weight: 700; letter-spacing: .1em; }
.controls { display: flex; align-items: center; gap: 9px; margin: 19px 0 0; color: #53696c; font-size: 9px; letter-spacing: .06em; }
kbd { font-family: inherit; font-size: inherit; }
.controls > span:not(.control-note) { opacity: .4; }
.control-note { margin-left: 12px; font-size: 10px; letter-spacing: 0; }
.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: 600px) { .masthead { height: 64px; padding: 0 20px; } .wordmark { font-size: 11px; } .edition { font-size: 8px; } .edition span { padding: 0 3px; } .stage { width: min(100%, 480px, calc((100svh - 125px) * 2 / 3)); } .controls { gap: 7px; } .control-note { margin-left: 5px; } }
@media (max-width: 370px) { .edition { display: none; } .control-note { display: none; } }
@media (max-width: 600px) { .header-actions .edition { display: none; } .header-actions { gap: 0; } }

/* Release shell: art-directed title artwork with real controls layered above it. */
.title-screen { position: fixed; inset: 0; min-height: 100dvh; overflow: hidden; background: #25414d; color: #f5f0df; z-index: 10; }
.title-art, .title-art img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.title-art img { object-fit: cover; object-position: center; }
.title-actions { position: absolute; inset: 0; pointer-events: none; }
.title-actions button, .legal-links { pointer-events: auto; }
.title-start { position: absolute; left: calc(50vw - max(12.75vw, 22.68dvh)); bottom: calc(50dvh - max(40.9dvh, 23vw)); width: max(25.55vw, 45.45dvh); height: max(6.3dvh, 3.54vw); min-height: 48px; border: 1px solid #ffc5aa; border-radius: 7px; color: #fff7e7; background: linear-gradient(#e56c60, #cf554b); box-shadow: 0 4px 0 #8c332d, 0 8px 24px #0b1c2766; font-weight: 900; font-size: clamp(16px, 1.75vw, 28px); letter-spacing: .055em; cursor: pointer; }
.title-start:disabled { cursor: wait; filter: saturate(.45); opacity: .82; }
.title-start:not(:disabled):hover { filter: brightness(1.08); transform: translateY(-1px); }
.title-start:focus-visible, .title-secondary button:focus-visible, .legal-links a:focus-visible { outline: 3px solid #fff2ca; outline-offset: 3px; }
.title-secondary { position: absolute; top: max(18px, env(safe-area-inset-top)); right: max(22px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.title-secondary button { min-height: 38px; border: 1px solid #d4e0dabb; border-radius: 3px; padding: 0 14px; color: #f5f1df; background: #173241d9; font-weight: 800; font-size: 10px; letter-spacing: .08em; cursor: pointer; }
#title-status { position: absolute; left: 50%; bottom: 2.2%; transform: translateX(-50%); margin: 0; padding: 4px 9px; border-radius: 3px; color: #d6ded8; background: #102a38b8; font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.legal-links { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(11px, env(safe-area-inset-bottom)); display: flex; gap: 15px; }
.legal-links a { color: #e4e7dc; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; }
.view-title .game-shell { display: none; }
.view-game .title-screen { display: none; }
.view-game .game-shell { display: flex; flex-direction: column; min-height: 100dvh; }
.game-shell > .masthead { flex: 0 0 auto; width: 100%; margin: 0 auto; }

.panel-dialog { width: min(92vw, 420px); max-height: min(86dvh, 680px); overflow: auto; border: 1px solid #91aaa6; border-radius: 5px; padding: 28px; color: #213b42; background: #efedde; box-shadow: 0 22px 80px #102a38aa; }
.panel-dialog::backdrop { background: #102a38c8; backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border: 0; background: transparent; color: #213b42; font-size: 25px; cursor: pointer; }
.panel-kicker { margin: 0 0 8px; color: #c54b3b; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.panel-dialog h2 { margin: 0 0 20px; font-size: 32px; letter-spacing: -.04em; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.auth-tabs button { padding: 10px; border: 1px solid #9fafaa; background: transparent; color: #526c70; font-size: 10px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.auth-tabs button[aria-pressed="true"] { background: #213b42; color: #f4edda; }
.panel-dialog form { display: grid; gap: 13px; }
.panel-dialog label { display: grid; gap: 5px; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.panel-dialog input { width: 100%; min-height: 44px; border: 1px solid #8fa4a0; border-radius: 3px; padding: 10px 12px; color: #213b42; background: #fffdf4; font-size: 16px; }
.panel-primary, .panel-actions button { min-height: 44px; border: 0; border-radius: 3px; padding: 0 15px; color: #f5f1df; background: #213b42; font-size: 11px; font-weight: 900; letter-spacing: .07em; cursor: pointer; }
.panel-note, .panel-status { font-size: 11px; line-height: 1.5; color: #5d7172; }
.panel-status { min-height: 18px; margin: 16px 0 0; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-actions .danger { color: #8b3027; background: transparent; border: 1px solid #b16960; }
.profile-stats, .own-rank { padding: 13px; background: #dfe3d5; font-weight: 700; line-height: 1.5; }
.leaderboard-dialog { width: min(94vw, 540px); }
.leaderboard-dialog table { width: 100%; border-collapse: collapse; font-size: 12px; }
.leaderboard-dialog th, .leaderboard-dialog td { padding: 9px 7px; border-bottom: 1px solid #c7cec1; text-align: left; }
.leaderboard-dialog th:last-child, .leaderboard-dialog td:last-child { text-align: right; }
.legal-page { background: #dce2d7; color: #213b42; }
.legal-page main { display: block; width: min(760px, calc(100% - 32px)); margin: auto; padding: 48px 0; }
.legal-page h1 { font-size: clamp(34px, 7vw, 58px); letter-spacing: -.05em; }
.legal-page h2 { margin-top: 34px; }
.legal-page p { line-height: 1.65; }
.legal-blocker { padding: 16px; border-left: 5px solid #c64d3c; background: #f5efdd; line-height: 1.5; }

/* Keep real controls in flow on phones/tablets, independently of artwork crop.
   Hide the artwork's baked-in buttons underneath the shared control area. */
@media (max-width: 1100px), (pointer: coarse), (orientation: portrait) {
  .title-art { clip-path: inset(0 0 max(24%, 180px)); }
  .title-actions { top: auto; min-height: max(24dvh, 180px); padding: 14px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #102734; }
  .title-start { position: static; flex: 0 0 auto; width: min(100%, 460px); height: 54px; min-height: 54px; font-size: 21px; }
  .title-secondary { position: static; width: min(100%, 460px); display: grid; grid-template-columns: 1fr 1fr minmax(64px, .7fr); gap: 8px; }
  .title-secondary button { min-width: 0; min-height: 44px; padding: 0 6px; background: #173241; overflow-wrap: anywhere; }
  #title-status { position: static; transform: none; margin: 0; padding: 0; max-width: 100%; font-size: 9px; line-height: 1.4; text-align: center; white-space: normal; background: transparent; }
  .legal-links { top: max(8px, env(safe-area-inset-top)); bottom: auto; }
  .panel-dialog { padding: 26px 20px max(20px, env(safe-area-inset-bottom)); }
}

/* Desktop reveals a wider world at the same vertical scale; sprites never stretch. */
@media (min-width: 701px) and (orientation: landscape) {
  .game-shell > .masthead { max-width: 1488px; }
  .game-shell > main { padding: 0 24px 12px; }
  .stage { width: min(100%, 1440px, calc((100dvh - 116px) * 1.6)); aspect-ratio: 8 / 5; }
  .hud { padding: 24px 32px 56px; }
  .message { left: 50%; right: auto; width: min(84%, 410px); transform: translateX(-50%); }
  .controls { margin-top: 10px; }
}

/* Portrait uses the available height. Keep the 480×720 simulation and sprite
   proportions: the narrower camera window is anchored on the drone's x=126.
   126/480 = 26.25%; 26.25% × the canvas' 2/3 aspect = 17.5cqh. */
@media (max-width: 1100px) and (orientation: portrait) {
  body.view-game { height: 100dvh; }
  .view-game .game-shell { height: 100dvh; min-height: 0; }
  .masthead {
    flex: 0 0 auto; width: 100%; max-width: none;
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }
  .game-shell > main {
    flex: 1; min-height: 0;
    padding: 0 max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  }
  .stage {
    flex: 1; min-height: 0; width: 100%; aspect-ratio: auto; container-type: size;
    max-width: calc((100dvh - 80px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 2 / 3);
  }
  canvas { position: absolute; top: 0; left: calc(26.25% - 17.5cqh); width: auto; height: 100%; }
  .controls { flex: 0 0 14px; height: 14px; margin: 6px 0 0; gap: 6px; font-size: 8px; }
  .control-note { margin-left: 5px; font-size: 9px; }
  .message:not(.is-dead):not(.is-paused) .action-hint { margin-top: 12px; }
  .debug-label { text-align: center; }
}

@media (max-width: 370px) {
  .game-shell > .masthead { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .wordmark { gap: 6px; font-size: 9px; }
  #sound, #account { min-width: 54px; }
}

/* Legal storage identifiers must wrap on narrow mobile screens. */
.legal-page code, .legal-page a { overflow-wrap: anywhere; }
.legal-page li { margin-bottom: 8px; line-height: 1.6; }

/* Brief record celebration stays below the HUD, outside the flight corridor. */
.record-feedback { font-size: clamp(11px, 1.8vw, 14px); padding: 10px 16px; border: 1px solid #dba566; box-shadow: 0 3px 16px #203e4930; border-radius: 20px; }

.legal-links #open-feedback { border: 0; padding: 0; min-height: 24px; background: transparent; color: #e4e7dc; font: inherit; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.legal-links { align-items: center; }
#open-feedback:focus-visible { outline: 2px solid #fff2ca; outline-offset: 4px; }
#feedback-form { display: grid; gap: 10px; }
#feedback-form textarea, #feedback-form select { width: 100%; padding: 10px; border: 1px solid #8fa4a0; border-radius: 4px; background: #fffdf4; color: #213b42; font: inherit; font-size: 16px; }
#feedback-form textarea { resize: vertical; min-height: 110px; max-height: 30dvh; }
#feedback-form .panel-note { margin: 0; }
#feedback-form a { color: inherit; text-decoration: underline; }
/* Preserve the complete portrait logo on tall phones: cover was cropping both sides.
   Only the artwork's baked-in controls (bottom 19.3%) are masked. */
@media (orientation: portrait) {
  .title-screen { --title-panel: max(180px, 24dvh); background: linear-gradient(#648d96, #25414d 65%, #102734 82%); }
  .title-art { height: calc(100% - var(--title-panel)); clip-path: none; overflow: hidden; }
  .title-art img { inset: 0 auto auto 50%; width: min(100%, calc((100dvh - var(--title-panel)) * .697)); height: auto; transform: translateX(-50%); object-fit: contain; object-position: top; clip-path: inset(0 0 19.3%); }
  .title-art::after { content: ''; position: absolute; inset: auto 0 0; height: 16%; background: linear-gradient(transparent, #102734); pointer-events: none; }
}
/* Low landscape screens need space for the image and a separate control column. */
@media (orientation: landscape) and (max-height: 540px) {
  .title-art { width: 60%; height: 100%; clip-path: none; overflow: hidden; }
  .title-art img { object-fit: cover; }
  .title-actions { left: 60%; top: 0; width: 40%; min-height: 0; padding: 42px 14px 12px; gap: 10px; }
  .title-start { height: 48px; min-height: 48px; font-size: 16px; }
  .title-secondary { grid-template-columns: 1fr 1fr; }
  .title-secondary #title-sound { grid-column: 1 / -1; }
  .legal-links { z-index: 1; top: 8px; bottom: auto; }
}
@media (orientation: portrait) {
  .title-art img { top: 50%; transform: translate(-50%, -40.35%); mask-image: linear-gradient(#000 0 76%, transparent 80.7%); }
  .legal-links { padding: 3px 6px; border-radius: 3px; background: #102734aa; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .title-screen { background: linear-gradient(#648d96, #102734); }
  .title-art { top: 35px; height: calc(100% - 35px); }
  .title-art img { inset: 0 auto auto 50%; width: min(100%, calc((100dvh - 35px) * .697)); height: auto; transform: translateX(-50%); object-fit: contain; clip-path: inset(0 0 19.3%); mask-image: linear-gradient(#000 0 76%, transparent 80.7%); }
  .view-game .game-shell { height: 100dvh; min-height: 0; }
  .game-shell > .masthead { height: 42px; padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); }
  .edition { display: none; }
  .game-shell > main { flex: 1; min-height: 0; padding: 0 max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
  .stage { flex: 1; width: 100%; max-width: none; min-height: 0; aspect-ratio: auto; }
  .hud { padding: 8px 12px 30px; }
  .controls { margin: 4px 0 0; height: 12px; font-size: 8px; }
  .mobile-thrust { width: 64px; height: 64px; bottom: 24px; right: 12px; }
  .thrust-arrow { font-size: 36px; }
  .message, .message.is-dead, .message.is-paused { top: 18%; left: 50%; right: auto; width: min(70%, 340px); transform: translateX(-50%); padding: 10px; }
  .message h2 { font-size: 24px; margin: 5px 0; }
  .message p { font-size: 11px; }
  .message .action-hint, .message:not(.is-dead):not(.is-paused) .action-hint { margin-top: 8px; padding: 7px 10px; }
}

@media (orientation: portrait) {
 .title-art { top: 40px; height: calc(100% - var(--title-panel) - 40px); }
 .title-art img { width: min(100%, calc((100dvh - var(--title-panel) - 40px) * .697)); }
}
@media (max-width: 350px) {
  .title-secondary button { font-size: 8px; letter-spacing: .04em; padding: 0 4px; }
}
