.playing .top { position: relative; padding: 0.75rem max(1rem, 5vw); background: var(--wall); }
.playing .wordmark { font-size: 2rem; }
.playing .nav [aria-current="page"] { color: var(--ink); text-decoration: underline; }
.play-main { width: min(1120px, calc(100% - 3rem)); margin: 1rem auto 3rem; }
.play-heading { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-bottom: 0.8rem; }
.play-heading h1 { font-size: clamp(1.8rem, 3.2vw, 2.8rem); line-height: 1.16; }
.play-heading p { max-width: 33ch; margin: 0; font-size: 0.9rem; }
.chapter-picker { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin-bottom: 0.6rem; border-bottom: 1px solid #d4c5b4; }
.chapter-picker button { min-height: 44px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-soft); padding: 0.35rem 0.2rem; font: 0.85rem var(--sans); }
.chapter-picker button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--gold-deep); }
.play-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem; }
.game { scroll-margin-top: 8px; }
.game-actions { display: flex; align-items: center; gap: 1.4rem; }
.view-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 1rem; }
.view-actions .text-button { min-height: 44px; }
.playing button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.playing button:disabled { opacity: 0.5; cursor: wait; }
.playing .cta { border: 0; min-width: 11.5rem; min-height: 44px; padding: 1rem 1.3rem; font-size: 0.78rem; }
.text-button { border: 0; background: none; color: var(--ink-soft); padding: 0.6rem 0.2rem; font: inherit; font-size: 0.95rem; text-decoration: underline; text-underline-offset: 0.25em; }
.text-button:active { color: var(--gold-deep); }
.focus-guide { height: 32px; display: flex; justify-content: center; align-items: center; gap: calc(var(--separation, 52px) - 6px); }
.focus-guide span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.arena { display: grid; grid-template-columns: 160px minmax(0, 1fr) 110px; column-gap: 18px; row-gap: 6px; align-items: center; }
.screen { min-width: 0; grid-area: 1 / 2; }
.scene-view { position: relative; width: 100%; margin-inline: auto; }
#bridge { width: 100%; height: auto; aspect-ratio: 12 / 5; background: var(--wall); outline-offset: 4px; }
.game-readout { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 0.8rem; padding: 0.6rem 0; border-bottom: 1px solid #e6dccf; font-size: 0.78rem; letter-spacing: 0.07em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.flight-hud { display: inline-flex; gap: 0.4rem; align-items: center; }
.flight-hud[hidden] { display: none; }
.flight-hud meter { width: 70px; height: 10px; accent-color: var(--gold-deep); }
.flight-hud output { min-width: 3.5ch; text-align: right; }
.flight-hud[data-low="true"] { color: #8a452b; }
.docking-hud { display: inline-flex; align-items: center; gap: 0.5rem; }
.docking-hud[hidden] { display: none; }
.docking-hud label { margin: 0; font: inherit; color: inherit; }
.docking-hud progress { width: 70px; height: 8px; accent-color: var(--gold-deep); }
.docking-hud output { min-width: 4ch; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.control-deck { display: contents; }
.dpad { display: grid; grid-template: repeat(3, 46px) / repeat(3, 50px); gap: 3px; grid-area: 1 / 1; }
.dpad button { display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--paper); color: var(--ink); border: 1px solid #a08a72; border-radius: 2px; padding: 0; touch-action: none; font: 500 max(11px, 0.65rem)/1 var(--sans); }
.dpad svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.up { grid-area: 1 / 2; }.left { grid-area: 2 / 1; }.right { grid-area: 2 / 3; }.down { grid-area: 3 / 2; }
.pad-center { grid-area: 2 / 2; align-self: center; justify-self: center; width: 5px; height: 5px; border-radius: 50%; background: var(--gold-line); }
.game[data-level="2"] .dpad { grid-template: 54px / 54px 54px; justify-content: center; gap: 8px; }
.game[data-level="2"] .dpad .left { grid-area: 1 / 1; }
.game[data-level="2"] .dpad .right { grid-area: 1 / 2; }
.game[data-level="2"] .pad-center { display: none; }
.dpad button:active, .dpad button.is-down { background: var(--wall); border-color: var(--gold-deep); }
.keyboard-hint { grid-area: 2 / 2; margin: 0; text-align: center; font-size: 0.75rem; line-height: 1.4; }
.keyboard-hint span { display: inline; }.keyboard-hint span + span::before { content: ' · '; }
.jump-control { grid-area: 1 / 3; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; }
.jump-control button { width: 88px; height: 88px; border: 1px solid var(--gold); background: var(--paper); color: var(--gold-deep); border-radius: 50%; touch-action: none; font: 600 0.85rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; }
.jump-control button:active, .jump-control button.is-down { background: var(--wall); transform: translateY(1px); }
.jump-control span { font-size: 0.85rem; }
.game-status { min-height: 1.8em; margin: 0.5rem 0 1rem; color: var(--ink); text-align: center; font-size: 0.9rem; }
.game-error { color: #8a2f1d; }
.play-notes { border-top: 1px solid #e6dccf; padding-top: 2rem; }
.instructions h2 { font-size: 1.6rem; }.instructions p { font-size: 0.95rem; max-width: 66ch; }
.inline-reveal { font-size: inherit; padding: 0; }
.phone-hint { color: var(--ink-soft); }
.view-options { border-bottom: 1px solid #d4c5b4; background: var(--wall); padding-inline: 12px; }
.view-options summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: var(--ink); font-size: 14px; line-height: 24px; }
.option-body { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 4px 20px; padding-bottom: 10px; }
.option-body label { display: flex; justify-content: space-between; gap: 8px; margin: 0; color: var(--ink); font-size: 14px; line-height: 20px; }
.option-body output, .range-ends, .option-body p { font-size: 12px; line-height: 18px; color: var(--ink-soft); }
.option-body input { display: block; width: 100%; min-height: 44px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.range-ends { display: flex; justify-content: space-between; margin-top: -6px; }
.option-body select { width: 100%; min-height: 44px; margin: 0; border: 1px solid #a08a72; border-radius: 2px; background: var(--paper); color: var(--ink); padding: 4px 8px; font: 14px var(--sans); }
.option-body p { grid-column: 1 / -1; margin: 4px 0 0; }
.option-body .setting-picker { display: none; }
.play-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem max(1rem, 5vw); border-top: 1px solid #e6dccf; font-size: 0.85rem; }
@media (hover: hover) and (pointer: fine) {
  .text-button:hover { color: var(--gold-deep); }
  .dpad button:hover { background: var(--wall); }
  .jump-control button:hover { background: var(--wall); }
}
@media (max-width: 760px) {
  .playing .top { padding: 0.8rem max(1rem, env(safe-area-inset-left)); }
  .playing .wordmark { font-size: 1.75rem; }
  .play-main { width: auto; margin: 0.75rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left)); }
  .play-heading { display: block; margin-bottom: 0.7rem; }
  .play-heading h1 { font-size: clamp(1.4rem, 7vw, 2rem); }
  .play-heading p { margin-top: 0.4rem; max-width: 44ch; font-size: 0.8rem; line-height: 1.4; }
  .play-toolbar { gap: 6px; flex-wrap: wrap; }
  .game-actions { flex-wrap: wrap; gap: 0.6rem; }
  .view-actions { gap: 0.3rem 0.9rem; }
  .playing .cta { min-width: 0; width: auto; height: auto; padding: 12px; font-size: clamp(12px, 3.1vw, 16px); }
  .play-toolbar .text-button { font-size: clamp(12px, 3.4vw, 16px); white-space: nowrap; min-height: 44px; }
  .keyboard-hint { display: none; }
  .arena { display: block; }
  .control-deck { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.8rem; }
  .jump-control { flex-direction: column; gap: 0.4rem; text-align: center; }
  .jump-control span { display: none; }
  .game-readout { font-size: max(11px, 0.65rem); }
  .game-status { font-size: 0.85rem; min-height: 3.3em; }
  .play-notes { padding-top: 1.4rem; }
  .option-body { grid-template-columns: minmax(105px, 0.8fr) minmax(0, 1.3fr); gap: 4px 12px; }
  .option-body .setting-picker { display: flex; align-items: center; }
  .setting-picker span { display: none; }
  .setting-picker select { width: 100%; }
  .option-body .range-ends { display: none; }
  .view-options .view-setting { display: none; }
  .view-options[data-setting="relief"] [data-setting="relief"],
  .view-options[data-setting="spacing"] [data-setting="spacing"],
  .view-options[data-setting="pace"] [data-setting="pace"] { display: block; }
  .play-footer { flex-direction: column; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
}
@media (max-height: 540px) and (orientation: landscape) and (max-width: 1000px) {
  .playing .top { display: none; }
  .playing .wordmark { font-size: 1.4rem; }
  .play-main { width: auto; margin: 6px max(12px, env(safe-area-inset-right)) 1.5rem max(12px, env(safe-area-inset-left)); }
  .play-heading { display: none; }
  .play-toolbar { padding: 0; }
  .playing .cta { min-width: 0; min-height: 44px; font-size: 12px; padding: 10px 12px; }
  .chapter-picker { margin-bottom: 4px; gap: 16px; }
  .chapter-picker button { font-size: 14px; padding-block: 4px; }
  .game-actions, .view-actions { gap: 12px; }
  .play-toolbar .text-button { font-size: 14px; min-height: 44px; white-space: nowrap; }
  .arena { display: grid; grid-template-columns: 104px minmax(0, 1fr) 88px; gap: 12px; align-items: center; }
  .screen { grid-column: 2; grid-row: 1; }
  .screen { width: 100%; justify-self: center; }
  .scene-view { width: min(100%, calc(max(70px, 100svh - 235px) * 2.4)); margin-inline: auto; }
  .game[data-adjusting="true"] .scene-view { width: min(100%, calc(max(65px, 100svh - 300px) * 2.4)); }
  .option-body { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .option-body .setting-picker, .option-body p, .option-body .range-ends { display: none; }
  .view-options .view-setting { display: block; }
  .option-body label, .option-body select, .option-body output { font-size: 12px; }
  .option-body label { gap: 4px; }
  .option-body label[for="spacing"] { flex-wrap: wrap; }
  .focus-guide { height: 18px; }
  .control-deck { display: contents; }.keyboard-hint, .jump-control span { display: none; }
  .dpad { grid-column: 1; grid-row: 1; grid-template: repeat(3, 44px) / repeat(3, 32px); gap: 2px; }
  .dpad .left, .dpad .right { min-width: 44px; z-index: 1; }.dpad .right { justify-self: end; }
  .dpad .up, .dpad .down { min-width: 48px; justify-self: center; }
  .game[data-level="2"] .dpad { grid-template: 48px / 48px 48px; gap: 6px; }
  .jump-control { grid-column: 3; grid-row: 1; }
  .jump-control button { width: 76px; height: 76px; }
  .game-readout { padding: 4px 0; font-size: 12px; line-height: 1.4; }
  .game-status { margin: 4px 0; min-height: 2.7em; font-size: 14px; line-height: 1.35; }
  .play-notes { margin-top: 1rem; }
}
html.game-expanded { overflow: hidden; }
.game.is-expanded {
  position: fixed; inset: 0; z-index: 100; box-sizing: border-box;
  width: 100%; height: 100%; height: 100dvh; overflow: auto;
  display: flex; flex-direction: column; gap: 8px; background: var(--wall);
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.game.is-expanded .play-toolbar { flex-shrink: 0; padding: 0; }
.game.is-expanded .arena { margin-block: auto; }
.game.is-expanded .screen { width: 100%; justify-self: center; }
.game.is-expanded .scene-view { width: min(100%, calc(max(80px, 100dvh - 230px) * 2.4)); margin-inline: auto; }
.game.is-expanded[data-adjusting="true"] .scene-view { width: min(100%, calc(max(70px, 100dvh - 380px) * 2.4)); }
.game.is-expanded .game-status { margin: 0; flex-shrink: 0; }
.game.is-expanded .keyboard-hint { margin-top: 6px; }
@media (max-height: 540px) and (orientation: landscape) {
  .game.is-expanded { padding-block: max(8px, env(safe-area-inset-top)); gap: 4px; }
  .game.is-expanded .focus-guide { height: 16px; }
  .game.is-expanded .game-readout { padding: 4px 0; font-size: 12px; line-height: 1.4; }
  .game.is-expanded .game-status { font-size: 14px; line-height: 1.35; min-height: 1.35em; }
  .game.is-expanded[data-adjusting="true"] .scene-view { width: min(100%, calc(max(70px, 100dvh - 260px) * 2.4)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  .game.is-expanded .screen { max-width: none; }
  .game.is-expanded .arena { margin-block: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .playing button { transition: none; }
}

/* Completion stays inside the scene, including in the expanded playing area. */
.game-result { position: absolute; z-index: 2; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(420px, 100%); padding: 12px; background: var(--paper); border: 1px solid #a08a72; text-align: center; }
.game-result h2 { margin: 0; font-size: clamp(18px, 2vw, 24px); line-height: 1.15; color: var(--ink); }
.game-result p { margin: 6px 0; font-size: 13px; line-height: 1.3; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.result-actions button { min-height: 44px; padding: 6px 10px; border: 1px solid var(--gold); background: var(--paper); color: var(--ink); font: 500 13px/1.2 var(--sans); }
.result-actions button:first-child { background: var(--gold); color: var(--paper); }
.result-create { display: inline-block; font-size: 13px; padding: 8px 0 0; }
.game[data-complete="true"] .scene-view { min-height: 168px; }
.game[data-level="3"] .jump-control button.is-down { border-width: 3px; }
