@font-face {
  font-family: 'Press Start 2P';
  src: url('../../fonts/PressStart2P-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: #45404f;
  background: #fff;
  --ink: #45404f;
  --muted: #77717f;
  --teal: #009688;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #7860ac;
  outline-offset: 4px;
}
.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; }

/* The shared Arcade stylesheet supplies the rail, typography and segmented controls. */
.menu-screen { position: fixed; inset: 0; width: 100%; height: 100dvh; overflow: hidden; font-family: Arial, sans-serif; }
#menu #control-panel-options { width: 100%; height: 100%; min-height: 0; max-height: none; padding: 0; margin: 0; overflow: hidden; }
#menu .game-menu-layout { grid-template-columns: minmax(300px, 26vw) minmax(0, 1fr); width: 100%; height: 100%; min-height: 0; }
#menu .game-menu-main { order: initial; min-height: 0; justify-content: center; padding: clamp(14px, 3vh, 36px) clamp(18px, 2.6vw, 30px); gap: clamp(12px, 2.3vh, 28px); overflow: hidden; }
#menu #options-title-bar { width: 100%; margin: 0; }
#menu #options-arcade-title { position: static; transform: none; width: 100%; margin: 0 0 16px; font-size: clamp(24px, 3vw, 40px); line-height: 1.1; }
#menu #game-title { margin: 0; font-size: clamp(18px, 1.75vw, 26px); line-height: 1.15; }
#menu .mode-choices { width: 100%; max-width: 270px; margin: 0; padding: 0; border: 0; min-width: 0; }
#menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { width: 100%; margin: 0; min-height: 44px; }
#menu .mode-choice { position: relative; flex: 1; margin: 0; min-height: 40px; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: clamp(12px, 1.1vw, 16px); white-space: normal; line-height: 1.15; padding: 9px 7px; }
#menu .mode-choice:not(:last-child) { border-right: clamp(2px, .42vw, 4px) solid #000; }
#menu .mode-choice:has(input:checked) { background: linear-gradient(135deg, #009688, #00796B); color: #fff; box-shadow: 0 2px 8px #0004; }
#menu .mode-choice input { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
#menu .mode-choice:has(input:focus-visible) { outline: 3px solid #7860ac; outline-offset: -5px; }
.difficulty-panel { display: grid; gap: 2px; width: 100%; max-width: 270px; min-width: 0; }
.difficulty-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #1b4b47; font-size: clamp(13px, 1.1vw, 17px); line-height: 1.4; }
.difficulty-heading label { font-weight: 800; }
#difficultyValue { color: #587775; font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--teal); cursor: pointer; }
#difficulty { display: block; width: 100%; height: 30px; margin: 0; }
.difficulty-ticks { display: flex; justify-content: space-between; padding: 0 5px; color: #587775; font-size: clamp(11px, 1vw, 13px); line-height: 1.1; }
#menu #mainAction { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: min(100%, 270px); min-width: 0; min-height: 48px; margin: 0; padding: 14px 20px; border: none; border-radius: 18px; background: #ff5b2e; color: #fff; font-size: clamp(16px, 1.2vw, 20px); font-weight: 700; line-height: 1.2; touch-action: manipulation; box-shadow: none; }
#menu #mainAction:hover { background: #e65229; }
#menu #mainAction:focus-visible { outline: 3px solid #7860ac; outline-offset: 4px; }
#menu #mainAction:active { transform: translateY(1px); }
#menu #mainAction svg { width: 18px; height: 24px; color: #fff5dc; flex: none; }
.menu-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 270px; min-height: 44px; }
.back-link, .settings-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: #1b6860; text-decoration: none; }
.settings-button { padding: 6px 10px; font-size: clamp(13px, 1.1vw, 17px); font-weight: 700; }
.back-link:hover, .settings-button:hover, .icon-button:hover { background: #dff3ed; }
.back-link svg, .settings-button svg, .icon-button svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Scene selection copies the starfield and illuminated cards of Space Adventure. */
#menu .game-menu-art { min-width: 0; min-height: 0; display: flex; order: initial; overflow: hidden; }
#menu .scene-choices.ship-select-panel { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; margin: 0; padding: clamp(14px, 2vw, 36px); display: flex; flex-direction: column; justify-content: center; gap: 18px; border: 1px solid #82b9ff1a; border-radius: 22px; background: #000; color: #fff; box-shadow: inset 0 0 0 1px #ffffff05, 0 16px 36px #0006; overflow: hidden; }
#menu .ship-select-panel::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 0, #416eff1a, transparent 42%), radial-gradient(circle at 50% 100%, #6eb4ff0d, transparent 36%), radial-gradient(circle at 18px 27px, #b9d6ff88 1px, transparent 1.6px) 0 0 / 173px 137px, radial-gradient(circle at 61px 93px, #ffffff70 .8px, transparent 1.4px) 0 0 / 211px 179px; pointer-events: none; }
#menu .scene-panel-title { position: relative; z-index: 1; float: left; width: 100%; margin: 0; padding: 0; font-family: 'Press Start 2P', monospace; font-size: clamp(13px, 1.3vw, 19px); line-height: 1.5; text-align: center; color: #e9f3ff; text-shadow: 0 0 10px #82beff33; }
#menu .scene-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); flex: 1; width: 100%; max-height: min(76dvh, 800px); min-height: 0; gap: 14px; }
#menu .scene-choice { position: relative; grid-column: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: 0; margin: 0; padding: 12px; border: 1px solid #afd2ff24; border-radius: 18px; background: #ffffff09; cursor: pointer; overflow: hidden; color: #c1d4e8; font-size: clamp(13px, 1.2vw, 20px); font-weight: 700; line-height: 1.25; text-align: center; }
#menu .scene-choice::before { content: ''; position: absolute; inset: 0; background: linear-gradient(#ffffff08, #ffffff00); pointer-events: none; }
#menu .scene-choice:hover { border-color: #c8e4ff66; background: #78b4ff0e; }
#menu .scene-choice:has(input:checked) { background: #78b4ff12; border-color: #a0dcff99; box-shadow: 0 0 0 1px #a0dcff22, 0 0 22px #64b4ff33; color: #fff; }
#menu .scene-choice:has(input:focus-visible) { outline: 3px solid #b4e4ff; outline-offset: -5px; }
#menu .scene-choice input { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
#menu .scene-choice svg, #menu .scene-preview { display: block; width: 100%; height: 0; min-height: 0; max-height: 300px; flex: 1; fill: #fff; stroke: #365b59; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: 1; }
#menu .scene-preview { fill: none; stroke: none; }
#menu .scene-choice:has(input:checked) .scene-preview { opacity: 1; filter: drop-shadow(0 0 14px #64b4ff24); }
#menu .scene-choice span { flex: none; }

/* Settings are a true modal. Only one short panel is visible at a time. */
.settings-modal { width: min(600px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 2px solid #008c80; border-radius: 18px; background: #fff; color: #204743; font-family: Arial, sans-serif; box-shadow: 0 20px 80px #001e2855; overflow: hidden; }
.settings-modal::backdrop { background: #051c25b8; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid #d9e9e4; }
.modal-heading h2 { margin: 0; color: #143d3b; font-size: 23px; line-height: 1.2; }
.icon-button { padding: 6px; font-size: 30px; line-height: 1; }
.settings-tabs { display: flex; gap: 8px; padding: 12px 20px; }
.settings-tabs button { flex: 1; min-width: 0; min-height: 42px; padding: 6px 10px; border: 1px solid #bcdcd4; border-radius: 10px; background: #f4faf8; color: #1b6860; font-weight: 700; }
.settings-tabs button[aria-selected=true] { background: #008c80; border-color: #008c80; color: #fff; }
.settings-panel { padding: 0 20px 18px; }
.mode-choices { margin-bottom: 12px; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-choice { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 50px; padding: 9px; border: 2px solid #c8dfda; border-radius: 10px; font-size: 15px; line-height: 1.25; cursor: pointer; }
.mode-choice:has(input:checked) { border-color: var(--teal); background: #e4f5f0; }
.mode-choice input { flex: none; width: 20px; min-width: 20px; height: 20px; margin: 0; accent-color: var(--teal); }
.options-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; min-width: 0; min-height: 52px; padding: 5px 0; border-bottom: 1px solid #e6efec; font-size: 15px; line-height: 1.25; }
.setting:last-child { border-bottom: 0; }
.setting span { min-width: 0; }
.setting select { min-width: 0; width: 100%; height: 40px; padding: 6px 9px; border: 1px solid #91bfb5; border-radius: 8px; background: #fff; font-size: 14px; }
.setting input[type=checkbox] { justify-self: end; width: 24px; height: 24px; margin: 0; accent-color: var(--teal); cursor: pointer; }
.setting input[type=range] { min-width: 0; width: 100%; height: 36px; margin: 0; }


/* Game presentation remains edge-to-edge, with a separate completion sky. */
body.playing { overflow: hidden; overscroll-behavior: none; }
#game { position: fixed; inset: 0; background: #fff; }
.drawing-board { position: relative; z-index: 1; width: 100%; height: 100%; background: transparent; touch-action: manipulation; cursor: none; outline: none; }
#scene { display: block; width: 100%; height: 100%; }
#completionSky { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }



/* Portrait menus keep the same controls and scene cards in two fixed-height areas. */
@media (max-width: 900px) and (orientation: portrait), (max-width: 600px) {
  #menu .game-menu-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: min(360px, 44dvh) minmax(0, 1fr); }
  #menu .game-menu-main { order: initial; padding: 12px 20px; gap: 10px; }
  #menu #options-arcade-title { font-size: 28px; margin-bottom: 8px; }
  #menu #game-title { font-size: 20px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 38px; }
  #menu .mode-choice { min-height: 34px; font-size: 13px; padding: 7px; }
  #menu #mainAction { min-height: 44px; padding: 10px 16px; }
  #menu .game-menu-art { display: flex; }
  #menu .scene-choices.ship-select-panel { padding: 12px; border-radius: 16px 16px 0 0; gap: 10px; }
  #menu .scene-panel-title { font-size: 13px; }
  #menu .scene-grid { max-height: none; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #menu .scene-choice { padding: 6px; gap: 4px; font-size: 13px; border-radius: 12px; }
}
@media (max-height: 620px) {
  #menu .game-menu-main { padding: 10px 18px; gap: 9px; }
  #menu #options-arcade-title { font-size: 26px; margin-bottom: 7px; }
  #menu #game-title { font-size: 18px; }
  #menu .mode-choice { min-height: 34px; font-size: 12px; padding: 7px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 38px; }
  .difficulty-heading { font-size: 13px; line-height: 1.2; }
  #difficulty { height: 26px; }
  .difficulty-ticks { font-size: 11px; }
  #menu #mainAction { min-height: 42px; padding: 9px 16px; font-size: 16px; }
  .menu-actions, .back-link, .settings-button { min-height: 36px; }
  .settings-button { font-size: 13px; }
  #menu .scene-choices.ship-select-panel { padding: 12px; gap: 10px; }
  #menu .scene-panel-title { font-size: 12px; }
  #menu .scene-grid { gap: 8px; }
  #menu .scene-choice { padding: 6px; gap: 4px; font-size: 12px; }
}
@media (max-height: 620px) and (max-width: 600px) {
  #menu .game-menu-layout { grid-template-rows: 232px minmax(0, 1fr); }
  #menu .game-menu-main { gap: 4px; padding: 6px 18px; }
  #menu #options-arcade-title { font-size: 22px; margin-bottom: 4px; }
  #menu #game-title { font-size: 16px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 34px; }
  #menu .mode-choice { min-height: 30px; padding: 5px 7px; }
  #menu #mainAction { min-height: 38px; padding: 7px 16px; }
  .menu-actions, .back-link, .settings-button { min-height: 32px; }
}
@media (max-height: 480px) and (min-width: 480px) {
  #menu .game-menu-layout { grid-template-columns: minmax(230px, 40vw) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #menu .game-menu-main { gap: 6px; padding: 8px 14px; }
  #menu #options-arcade-title { font-size: 24px; margin-bottom: 7px; }
  #menu #game-title { font-size: 18px; }
  #menu .scene-panel-title { font-size: 11px; }
  #menu .scene-choices.ship-select-panel { border-radius: 14px; padding: 8px; gap: 8px; }
  #menu .scene-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  #menu .scene-choice { padding: 5px; font-size: 11px; }
}
@media (max-height: 568px) and (max-width: 479px) {
  #menu .game-menu-layout { grid-template-rows: 204px minmax(0, 1fr); }
  #menu .game-menu-main { padding: 4px 18px; gap: 2px; }
  #menu #options-arcade-title { font-size: 18px; margin-bottom: 2px; }
  #menu #game-title { font-size: 14px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 30px; border-width: 2px; }
  #menu .mode-choice { min-height: 26px; padding: 4px 6px; font-size: 11px; }
  #menu #mainAction { min-height: 34px; padding: 5px 12px; font-size: 14px; }
  .difficulty-heading { font-size: 12px; }
  #difficulty { height: 22px; }
  .menu-actions, .back-link, .settings-button { min-height: 28px; }
  .back-link svg, .settings-button svg { width: 20px; height: 20px; }
  #menu .scene-choices.ship-select-panel { padding: 5px; gap: 3px; }
  #menu .scene-panel-title { font-size: 9px; }
  #menu .scene-grid { gap: 4px; }
  #menu .scene-choice { padding: 3px; gap: 1px; font-size: 10px; border-radius: 7px; }
}
@media (max-height: 520px), (max-width: 380px) {
  .modal-heading { padding: 6px 14px; }
  .modal-heading h2 { font-size: 20px; }
  .icon-button { min-width: 40px; min-height: 40px; }
  .settings-tabs { padding: 6px 14px; }
  .settings-tabs button { min-height: 36px; font-size: 14px; }
  .settings-panel { padding: 0 14px 10px; }
  .setting { min-height: 42px; gap: 10px; font-size: 14px; }
  .setting select { height: 34px; padding: 5px 7px; font-size: 13px; }
}
@media (max-height: 480px) and (min-width: 480px) {
  .settings-panel .options-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; }
  .setting { min-height: 52px; font-size: 14px; }
}
@media (max-height: 380px) and (max-width: 479px) {
  .modal-heading { padding: 4px 12px; }
  .icon-button { min-width: 32px; min-height: 32px; }
  .settings-tabs { padding: 4px 12px; }
  .settings-tabs button { min-height: 32px; font-size: 13px; }
  .settings-panel { padding: 0 12px 8px; }
  .setting { min-height: 34px; padding: 2px 0; font-size: 12px; }
  .setting select { height: 30px; font-size: 12px; }
  .setting input[type=checkbox] { width: 20px; height: 20px; }
  .setting input[type=range] { height: 28px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
/* Recolor: a paper travel map with colour returning to restored worlds. */
#menu #control-panel-options { background: #f5f7f4; }
#menu .game-menu-layout { grid-template-columns: minmax(320px, 29vw) minmax(0, 1fr); }
#menu .game-menu-main { padding: 70px clamp(20px, 2.5vw, 42px) 32px; gap: clamp(15px, 2.3vh, 26px); background: radial-gradient(ellipse at 35% 100%, #f9e8cb55, transparent 55%), #fcfdfa; border-right: 1px solid #d7e0dc; }
#menu #options-arcade-title { position: absolute; top: clamp(23px, 3vh, 40px); left: 50%; transform: translateX(-50%); width: auto; margin: 0; font-size: clamp(11px, 1vw, 16px); line-height: 1.3; letter-spacing: .12em; color: #d97941; text-shadow: none; }
#menu #game-title { margin: 0; color: #234e47; font: 800 clamp(44px, 4.2vw, 68px)/1.13 Arial, sans-serif; letter-spacing: -.04em; }
#menu .menu-story { width: 100%; max-width: 310px; margin: 0 0 5px; color: #61736e; font-size: clamp(14px, 1.15vw, 18px); font-weight: 400; line-height: 1.55; text-align: center; text-wrap: balance; }
#menu .mode-choices { max-width: 286px; }
#menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; align-items: stretch; min-height: 46px; padding: 0; gap: 0; border: 2px solid #2c5149; border-radius: 999px; background: #edf2ef; box-shadow: none; }
#menu .mode-choice { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 42px; padding: 9px 7px; color: #3d5a53; font-size: clamp(13px, 1.05vw, 16px); font-weight: 700; line-height: 1.2; transition: none; }
#menu .mode-choice:not(:last-child) { border-right: 1px solid #2c5149; }
#menu .mode-choice:has(input:checked) { color: #fff; background: #008d80; box-shadow: none; }
#menu .mode-choice input { min-width: 1px; margin: 0; }
#menu .mode-choice:has(input:focus-visible) { outline: 3px solid #e8b94e; outline-offset: -5px; }
#menu .difficulty-panel, #menu .menu-actions { max-width: 286px; }
#menu #mainAction { width: min(100%, 286px); min-height: 54px; padding: 13px 20px; background: #ef7549; box-shadow: 0 4px 0 #c85732; }
#menu #mainAction:hover { background: #df633c; }
#menu #mainAction:active { transform: translateY(2px); box-shadow: 0 2px 0 #c85732; }
#menu .scene-choices.ship-select-panel { padding: clamp(20px, 3vw, 60px); gap: clamp(18px, 3vh, 36px); border: 0; border-radius: 0; background: linear-gradient(160deg, #e7eceb, #f4f3e9 65%, #e3ebe7); color: #4d665b; box-shadow: none; }
#menu .ship-select-panel::before { background: radial-gradient(ellipse 160px 55px at 18% 12%, #ffffff88 95%, transparent 100%), radial-gradient(ellipse 210px 65px at 82% 33%, #ffffff77 95%, transparent 100%), radial-gradient(ellipse 150px 50px at 47% 89%, #ffffff66 95%, transparent 100%); }
#menu .ship-select-panel::after { content: ''; position: absolute; inset: 12% 9%; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 900 700' preserveAspectRatio='none'%3E%3Cpath d='M100 180C220 20 500 15 740 170S800 560 490 580S20 510 200 365' fill='none' stroke='%23bdccc3' stroke-width='4' stroke-linecap='round' stroke-dasharray='6 14'/%3E%3C/svg%3E") center / 100% 100% no-repeat; pointer-events: none; }
#menu .scene-panel-title { color: #587366; font: 700 clamp(13px, 1vw, 17px)/1.5 Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; text-shadow: none; }
#menu .scene-grid { max-height: min(72dvh, 760px); gap: clamp(12px, 1.5vw, 24px); }
#menu .scene-choice { padding: clamp(8px, 1vw, 16px); gap: 10px; border: 2px solid #d0dbd3; border-radius: 24px; background: #fcfdfaeb; color: #748078; box-shadow: 0 6px 15px #607c6b0a; line-height: 1.3; }
#menu .scene-choice::before { background: linear-gradient(135deg, #ffffff88, transparent 40%); }
#menu .scene-choice:hover { border-color: #8fafa4; background: #fffef8; box-shadow: 0 5px 16px #21877610; }
#menu .scene-choice:has(input:checked) { border-color: #007f73; background: #edf9f3; color: #174f43; box-shadow: inset 0 0 0 2px #007f73, 0 7px 22px #21877620; }
#menu .scene-caption { min-height: 2.6em; flex: none; display: flex; align-items: center; justify-content: center; gap: clamp(4px, .55vw, 8px); width: 100%; padding: clamp(1px, .4vh, 5px) 4px; border-radius: 10px; }
#menu .scene-caption > span { min-width: 0; flex: 0 1 auto; }
#menu .scene-choice:has(input:checked) .scene-caption { background: #007f73; color: #fff; }
#menu .scene-choice .scene-caption input { position: static; display: inline-block; width: clamp(14px, 2.5vh, 24px); height: clamp(14px, 2.5vh, 24px); min-width: clamp(14px, 2.5vh, 24px); flex: none; clip: auto; overflow: visible; margin: 0; appearance: auto; accent-color: #007f73; cursor: pointer; }
#menu .scene-choice:has(input:checked) .scene-caption input { accent-color: #005d53; }
#menu .scene-choice:has(input:focus-visible) { outline: 3px solid #a373cb; outline-offset: -6px; }
#menu .scene-choice svg, #menu .scene-preview { opacity: .72; filter: grayscale(1); transition: filter .6s ease, opacity .6s ease; }
#menu .scene-choice svg.scene-preview { fill: none; stroke: none; }
#menu .scene-choice:has(input:checked) .scene-preview, #menu .scene-choice[data-restored=true] .scene-preview { opacity: 1; filter: grayscale(0); }

@media (max-width: 900px) and (orientation: portrait), (max-width: 600px) {
  #menu .game-menu-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: min(410px, 48dvh) minmax(0, 1fr); }
  #menu .game-menu-main { padding: 42px 20px 12px; gap: 7px; }
  #menu #options-arcade-title { top: 14px; font-size: 11px; }
  #menu #game-title { font-size: 42px; }
  #menu .menu-story { font-size: 13px; line-height: 1.4; margin: 0 0 3px; max-width: 290px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 38px; }
  #menu .mode-choice { min-height: 34px; padding: 6px; font-size: 13px; }
  #menu #mainAction { min-height: 42px; padding: 9px 16px; }
  #menu .menu-actions, #menu .back-link, #menu .settings-button { min-height: 32px; }
  #menu .scene-choices.ship-select-panel { padding: 12px; gap: 10px; }
  #menu .scene-panel-title { font-size: 12px; }
  #menu .scene-grid { max-height: none; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #menu .scene-choice { padding: 6px; gap: 5px; border-radius: 16px; font-size: 13px; }
}
@media (max-height: 650px) {
  #menu .game-menu-main { padding: 46px 18px 12px; gap: 9px; }
  #menu #options-arcade-title { top: 15px; font-size: 11px; }
  #menu #game-title { font-size: 40px; }
  #menu .menu-story { font-size: 13px; line-height: 1.35; margin-bottom: 2px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 38px; }
  #menu .mode-choice { min-height: 34px; padding: 6px; font-size: 12px; }
  #menu #mainAction { min-height: 42px; padding: 9px 16px; }
  #menu .scene-choices.ship-select-panel { padding: 12px; gap: 10px; }
  #menu .scene-grid { gap: 8px; }
  #menu .scene-choice { padding: 6px; gap: 4px; border-radius: 16px; }
}
@media (max-height: 650px) and (max-width: 600px) and (min-height: 381px) {
  #menu .game-menu-layout { grid-template-rows: 292px minmax(0, 1fr); }
  #menu .game-menu-main { padding: 32px 18px 8px; gap: 4px; }
  #menu #options-arcade-title { top: 10px; font-size: 10px; }
  #menu #game-title { font-size: 34px; }
  #menu .menu-story { font-size: 12px; line-height: 1.25; max-width: 270px; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 32px; }
  #menu .mode-choice { min-height: 28px; padding: 4px 6px; font-size: 12px; }
  #menu #difficulty { height: 23px; }
  #menu #mainAction { min-height: 36px; padding: 6px 12px; font-size: 15px; }
  #menu .menu-actions, #menu .back-link, #menu .settings-button { min-height: 28px; }
}
@media (max-height: 480px) and (min-width: 480px) {
  #menu .game-menu-layout { grid-template-columns: minmax(230px, 40vw) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #menu .game-menu-main { padding: 35px 16px 10px; gap: 5px; }
  #menu #options-arcade-title { top: 11px; font-size: 10px; }
  #menu #game-title { font-size: 36px; }
  #menu .menu-story { font-size: 12px; line-height: 1.3; }
  #menu .scene-choices.ship-select-panel { padding: 8px; gap: 8px; }
  #menu .scene-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  #menu .scene-choice { padding: 5px; font-size: 11px; }
}
@media (max-height: 568px) and (max-width: 479px) {
  #menu .game-menu-layout { grid-template-columns: 48% minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #menu .game-menu-main { padding: 29px 10px 6px; gap: 4px; }
  #menu #options-arcade-title { top: 10px; font-size: 8px; }
  #menu #game-title { font-size: 29px; }
  #menu .menu-story { font-size: 10px; line-height: 1.3; margin: 0; }
  #menu :is(#stop-action-mode-segmented-control, #input-mode-segmented-control) { min-height: 29px; }
  #menu .mode-choice { min-height: 25px; padding: 4px 2px; font-size: 10px; }
  #menu #difficulty { height: 22px; }
  #menu .difficulty-heading { font-size: 11px; }
  #menu #mainAction { min-height: 32px; padding: 5px; font-size: 12px; gap: 5px; }
  #menu #mainAction svg { width: 13px; height: 19px; }
  #menu .menu-actions, #menu .back-link, #menu .settings-button { min-width: 26px; min-height: 26px; }
  #menu .settings-button { font-size: 10px; padding: 3px; gap: 4px; }
  #menu .back-link svg, #menu .settings-button svg { width: 17px; height: 17px; }
  #menu .scene-choices.ship-select-panel { padding: 5px; gap: 5px; }
  #menu .scene-panel-title { font-size: 9px; letter-spacing: .03em; }
  #menu .scene-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 5px; }
  #menu .scene-choice, #menu .scene-choice:nth-child(4) { grid-column: auto; padding: 3px; font-size: 9px; border-radius: 10px; }
  #menu .scene-choice:nth-child(5) { grid-column: auto; }
  #menu .scene-caption { padding: 1px 0; gap: 3px; }
}
@media (prefers-reduced-motion: reduce) { #menu .scene-choice .scene-preview { transition: none; } }

/* Retain the shared Arcade language control on compact menus. */
@media (max-height: 568px) and (max-width: 479px) {
  #menu #language-toggle { top: 4px; right: 4px; padding: 4px 6px; font-size: 10px; }
}

@media (max-height: 380px) { #menu .menu-story { display: none; } }

/* Optional eye-gaze palette, matching the drawing activities' round swatches. */
#game { --palette-width: clamp(76px, 8vw, 116px); }
#game.has-colour-palette .drawing-board { margin-left: var(--palette-width); width: calc(100% - var(--palette-width)); }
#game.has-colour-palette #completionSky { left: var(--palette-width); width: calc(100% - var(--palette-width)); }
#colourPalette { position: absolute; inset: 0 auto 0 0; z-index: 3; width: var(--palette-width); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 8px; background: #fff; border-right: 1px solid #d7e0dc; }
.colour-swatch { position: relative; flex: none; width: min(84px, calc(var(--palette-width) - 20px), calc((100dvh - 64px) / 7)); height: min(84px, calc(var(--palette-width) - 20px), calc((100dvh - 64px) / 7)); padding: 0; overflow: hidden; border: 4px solid #fff; border-radius: 50%; box-shadow: inset 0 1px 6px #0003, 0 3px 10px #0002; cursor: pointer; }
.colour-swatch[aria-pressed=true]::after { content: ''; position: absolute; inset: 5px; border: 3px solid #111; border-radius: 50%; box-shadow: 0 0 0 2px #fff, inset 0 0 0 1px #fff; pointer-events: none; }
.palette-dwell { position: absolute; inset: 0; background: rgba(255, 0, 0, .52); transform: scale(0); transform-origin: center; border-radius: 50%; pointer-events: none; }

.palette-menu-option { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 286px; min-height: 38px; color: #1b4b47; font-size: 14px; font-weight: 700; cursor: pointer; }
.palette-menu-option input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--teal); cursor: pointer; }
#game[data-input-mode=eyegaze], #game[data-input-mode=touch],
#game[data-input-mode=eyegaze] .colour-swatch,
#game[data-input-mode=touch] .colour-swatch { cursor: none; }
@media (max-height: 650px) { .palette-menu-option { min-height: 32px; font-size: 12px; } }
@media (max-height: 568px) and (max-width: 479px) { .palette-menu-option { min-height: 25px; font-size: 10px; } .palette-menu-option input { width: 20px; height: 20px; } }

#menu #input-mode-segmented-control { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-height: 568px) and (max-width: 479px) {
  #menu #input-mode-segmented-control .mode-choice { font-size: 9px; padding-inline: 1px; }
}
