:root { color-scheme: dark; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #111b26; color: #e0e8e4; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.game-shell { width: min(100%, 1120px); background: #203641; }
.game-session { position: relative; margin: auto; max-width: 100%; }
.game-bar { min-height: 62px; padding: 10px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.game-logo { display: block; width: 156px; height: 44px; object-fit: contain; }
.level-nav { display: flex; align-items: center; gap: 8px; margin: 0 auto; font-size: 12px; }
#level-label { margin: 0; min-width: 12ch; text-align: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.game-actions { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
#deaths { margin-right: 8px; color: #f2d076; white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid #738681; border-radius: 3px; padding: 7px 10px; background: transparent; touch-action: none; }
button:hover:not(:disabled) { background: #334d56; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, canvas:focus-visible { outline: 2px solid #f2d076; outline-offset: 3px; }
button[aria-pressed='true'] { color: #f2d076; border-color: #f2d076; }
.playfield { position: relative; background: #f6f1e3; }
.canvas-frame { position: relative; }
.skip-scene { position: absolute; right: 2%; bottom: 3%; min-height: 40px; z-index: 3; background: #203641; color: #f6f1e3; border-color: #7c8b87; font-size: clamp(11px, 1.5vw, 14px); }
.skip-scene span { margin-left: 10px; color: #efc65d; font-size: .8em; }
.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 (any-pointer: coarse) { .skip-scene span { display: none; } .skip-scene { min-height: 44px; } }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; touch-action: none; }
.home-screen { max-width: 480px; padding: clamp(20px, 5vh, 48px) 24px; margin: auto; text-align: center; }
h1 { margin: 0; }
.home-logo { display: block; width: min(100%, 264px); height: auto; margin: auto; }
.intro { margin: 14px 0 24px; color: #b8c6c3; font-size: 14px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 30px; text-align: left; margin: 0; }
.controls dt { font-size: 12px; color: #b8c6c3; margin-bottom: 6px; }
.controls dd { margin: 0; white-space: nowrap; font-size: 13px; }
.controls span { color: #a6b8b7; margin: 0 3px; font-size: 11px; }
kbd { display: inline-block; border: 1px solid #6d8387; border-radius: 3px; min-width: 23px; padding: 2px 5px; text-align: center; font: 12px system-ui, sans-serif; }
.home-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; }
.home-actions button { min-height: 40px; padding: 9px 20px; }
.start-button { background: #f2d076; color: #203641; border-color: #f2d076; font-weight: 800; }
.start-button:hover:not(:disabled) { background: #ffe29b; }
.touch-note { display: none; color: #b8c6c3; font-size: 11px; }
.touch { position: relative; left: 50%; transform: translateX(-50%); width: min(600px, calc(100vw - 16px)); display: none; justify-content: space-between; align-items: center; gap: 20px; padding: 12px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); background: #111b26; border-top: 1px solid #526875; touch-action: none; }
.cluster { display: flex; gap: 10px; }
.touch button { min-width: 60px; min-height: 54px; background: #203641; border-color: #aebfbd; user-select: none; -webkit-user-select: none; }
.game-shell:fullscreen, .game-shell.expanded { width: 100%; height: 100dvh; padding: 0; margin: 0; max-width: none; display: grid; place-items: center; background: #111b26; overflow: auto; }
.game-shell.expanded { position: fixed; inset: 0; z-index: 100; }
.game-shell::backdrop { background: #111b26; }
@media (any-pointer: coarse) { .touch { display: flex; } .touch-note { display: block; } }
@media (max-width: 700px) {
 body { padding: 8px; }
 .game-bar { gap: 8px 12px; padding: 8px 10px; }
 .game-logo { width: 125px; height: 35px; }
 .game-actions { margin-left: auto; gap: 6px; }
 .game-actions button { padding: 7px; }
 #level-label { margin-right: 0; }
 .controls { gap: 14px 18px; }
}
@media (max-height: 450px) {
 .home-screen { padding: 16px 24px; max-width: 520px; }
 .home-logo { width: 215px; }
 .intro { margin: 7px 0 12px; }
 .controls { gap: 10px 24px; }
 .home-actions { margin-top: 14px; }
 .touch-note { margin: 8px 0 0; }
}
@media (max-width: 420px) {
 .game-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; row-gap: 8px; }
}
.game-bar { position: relative; }
.header-player { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; pointer-events: none; z-index: 2; }

.practice-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 12px; font-size: 12px; background: #203641; color: #f6f1e3; }
.practice-tools select, .practice-tools button { font: inherit; padding: 5px 8px; }
.practice-tools select { max-width: 100%; }
/* Fit controls to the game width, including narrow landscape fullscreen. */
.game-session { container-type: inline-size; }
@container (max-width: 700px) {
 .game-bar { gap: 8px 12px; padding: 8px 10px; }
 .game-logo { width: 125px; height: 35px; }
 .game-actions { margin-left: auto; gap: 6px; }
 .game-actions button { padding: 7px; }
}
@container (max-width: 420px) {
 .game-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; row-gap: 8px; }
}
/* Reserve a real control strip below the canvas, including short landscape screens.
   Presentation.fit measures this strip along with the canvas and header. */
@media (any-pointer: coarse) and (max-height: 500px) {
 body { padding: 4px; }
 .game-bar { min-height: 34px; padding: 4px 6px; gap: 6px; flex-wrap: nowrap; }
 .game-logo { display: none; }
 .level-nav { gap: 3px; margin: 0 auto; flex-shrink: 0; }
 #level-label { min-width: 0; font-size: 9px; }
 .level-nav button { padding: 3px 7px; font-size: 0; min-height: 26px; }
 #previous-level::after { content: '‹'; font-size: 16px; }
 #next-level::after { content: '›'; font-size: 16px; }
 .game-actions { width: auto; margin: 0; gap: 4px; flex-wrap: nowrap; flex-shrink: 0; font-size: 9px; }
 .game-actions button { padding: 5px 4px; font-size: 9px; }
 #fullscreen { padding: 3px 7px; min-height: 26px; font-size: 0; }
 #fullscreen::after { content: '⛶'; font-size: 16px; }
 #deaths { margin-right: 2px; }
 .touch { padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
 .touch button { min-width: 56px; min-height: 48px; }
 @container (max-width: 370px) {
  .game-bar { flex-wrap: wrap; }
  .game-actions { width: 100%; justify-content: center; }
 }
}
