:root{color-scheme:dark;--cyan:#34e7ff;--pink:#ff5cc8;--violet:#9b5cff;--bg:#0d0726;--text:#eaf0ff}
*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at top,#241155,var(--bg) 65%);color:var(--text);font:500 18px/1.5 var(--type-body);min-height:100dvh}button,a{touch-action:manipulation}button,select{font:inherit;color:inherit;background:#24134b;border:2px solid var(--cyan);border-radius:12px;min-height:48px;padding:8px 16px;cursor:pointer}button:hover,a.card:hover{background:#35205e}button:disabled{opacity:.5;cursor:default}a{color:inherit;text-decoration:none}a:focus-visible,button:focus-visible,select:focus-visible,canvas:focus-visible{outline:3px solid #ffd166;outline-offset:4px}nav{display:flex;gap:12px;flex-wrap:wrap;align-items:center;padding:8px max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left));border-bottom:1px solid #473564}nav a{min-width:44px;padding-inline:8px;justify-content:center;display:flex;align-items:center;min-height:48px;font-size:14px;font-weight:800}nav a:last-child{margin-left:auto}h1,h2{font-family:var(--type-section);letter-spacing:.04em;line-height:1.15}h1{font-size:clamp(26px,5vw,48px);margin:16px 0}h2{font-size:26px;margin:12px 0}.hub{max-width:1232px;margin:auto;padding:24px 16px 50px}.eyebrow{color:var(--pink);letter-spacing:.15em;font-size:14px}.rank{border-left:4px solid var(--cyan);padding:12px;background:#1a0d40;font-weight:800}.local-note{color:#bac2df;font-size:14px}.cards{display:grid;gap:18px;grid-template-columns:1fr}.card{position:relative;display:block;border:1px solid;border-radius:18px;padding:22px;background:#1a0d40;min-height:220px}.card p{font-size:16px}.card-icon{font-size:38px;color:var(--cyan)}.tag{float:right;font-size:12px;font-weight:800;letter-spacing:.06em;background:#30204d;padding:6px 9px;border-radius:7px}.works{opacity:.65}.earned{color:#ffd166;letter-spacing:.15em}.drill{height:100dvh;display:flex;flex-direction:column}.drill nav{flex-shrink:0}.drill nav a{font-size:12px}#tg-frame{position:relative;flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;padding:0 16px 12px;gap:8px}.game-header{display:flex;width:min(100%,900px);align-items:center;justify-content:space-between;gap:12px}.game-header h1{font-size:28px;margin:8px 0}#tg-hud{font-size:14px;min-height:24px;text-align:center;font-variant-numeric:tabular-nums}#tg-options{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}#tg-options:empty{display:none}#tg-field{flex:1;min-height:0;width:100%;display:flex;justify-content:center;align-items:center;position:relative}#tg-field canvas{display:block;max-width:100%;max-height:100%;border:1px solid #5c3c84;border-radius:14px;touch-action:none}.overlay{position:absolute;inset:0;z-index:20;background:#0d0726f5;display:flex;align-items:center;justify-content:center;padding:20px;overflow:auto}.overlay-panel{width:min(100%,460px);text-align:center}.overlay-panel h2{color:var(--cyan);font-size:36px}.overlay-panel p{font-size:16px}.overlay-actions{display:flex;gap:12px;flex-direction:column;margin-top:20px}.overlay-actions a{display:flex;align-items:center;justify-content:center;min-height:48px;border:1px solid var(--violet);border-radius:12px}.result-stars{font-size:42px;color:#ffd166}.countdown{font:900 96px var(--type-display);color:var(--cyan)}#tg-controls{display:none;flex-shrink:0;align-items:center;justify-content:space-between;gap:16px;width:100%;height:170px;padding:8px 12px max(8px,env(safe-area-inset-bottom));touch-action:none}.joystick{position:relative;width:136px;height:136px;border-radius:50%;background:#21123ee8;border:2px solid #9b5cff;touch-action:none;user-select:none}.stick{position:absolute;left:43px;top:43px;width:46px;height:46px;border-radius:50%;background:var(--cyan);pointer-events:none}.control-buttons{display:flex;gap:8px}.control-buttons button{width:64px;height:64px;border-radius:50%;touch-action:none}.memory-grid{display:grid;gap:8px;align-content:center;justify-content:center;width:min(100%,640px);perspective:900px}.memory-card{position:relative;padding:0;aspect-ratio:1;min-height:0;max-height:150px;border:1px solid #9b5cff;background:#26134e;transform-style:preserve-3d;transition:transform .25s}.memory-card img{width:100%;height:100%;object-fit:contain;position:absolute;inset:0;border-radius:10px;backface-visibility:hidden}.memory-card .front{transform:rotateY(180deg)}.memory-card.flipped{transform:rotateY(180deg)}.memory-card.matched{border-color:var(--cyan);opacity:.75}.memory-card:disabled{opacity:.75}.memory-card .back{padding:18%}.level-select{max-width:230px}.memory-game #tg-field{align-items:center}.memory-game #tg-options{flex-shrink:0}
@media(min-width:481px){.cards{grid-template-columns:repeat(2,1fr)}}
@media(pointer:coarse){#tg-controls{display:flex}.action-game #tg-field{min-height:100px}}
@media(pointer:coarse) and (orientation:landscape){#tg-controls{position:absolute;bottom:16px;left:0;z-index:5;height:136px;pointer-events:none}.joystick,.control-buttons{pointer-events:auto}.game-header h1{font-size:22px}.game-header{height:48px}.drill nav{padding-top:0;padding-bottom:0}.drill nav a{min-height:36px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}.memory-card,.memory-card.flipped{transform:none}.memory-card .front{transform:none;display:none}.memory-card.flipped .front{display:block}.memory-card.flipped .back{display:none}}
.card-art{position:absolute;right:16px;bottom:16px;width:42px;height:64px;object-fit:contain;pointer-events:none}.card .earned{padding-right:48px}
/* Remaining drills: keep selectors, calibration and touch controls reachable. */
.rhythm-settings{display:flex;flex-direction:column;gap:10px;text-align:left;max-width:560px;margin:auto}.rhythm-settings select{width:100%;min-height:48px}.rhythm-settings input{width:100%;min-height:44px;accent-color:var(--pink)}#tg-songs{max-width:100%;font-size:14px}#tg-sound{font-size:12px;padding:6px 12px}#tg-refit[hidden],#tg-sound[hidden]{display:none}#rhythm-results{font-variant-numeric:tabular-nums}.zero-g-game .control-buttons button{width:80px;height:80px;font-size:14px}
@media(pointer:coarse) and (orientation:landscape){.zero-g-game #tg-controls{position:static;height:100px;padding:4px;pointer-events:auto}.zero-g-game .joystick{width:88px;height:88px}.zero-g-game .stick{left:21px;top:21px}.zero-g-game #tg-frame{gap:2px}}
/* Phaser's auto-centre margins must not be added to the shared flex centring. */
#tg-field canvas{margin:0!important}select[hidden]{display:none}
.rhythm-settings #tg-songs{height:202px;padding:0;overflow-y:auto}.rhythm-settings #tg-songs option{padding:12px 8px;min-height:48px;line-height:24px}

/* Mission Comic grade: cool ink, warm orange edges, shared type roles. */
:root{--cyan:#ff9650;--pink:#ffb078;--violet:#708398;--bg:#10151d;--text:#f1eee8}
body{background:radial-gradient(ellipse at top,#29323e,var(--bg) 65%)}
nav{border-color:#58616a}h1{font-family:var(--type-display);font-weight:900}h2{font-weight:800}
button,select,nav a,.tag,.overlay-actions a{font-family:var(--type-button);font-weight:600;letter-spacing:.08em}
.eyebrow{font-family:var(--type-eyebrow)}#tg-hud,.rank,.earned{font-family:var(--type-data)}
.card,.rank,.overlay-panel{background:#1c2530}.card{border-color:#b17b54!important;border-radius:4px;box-shadow:5px 5px 0 #080c12}
button,select,.overlay-actions a{background:#26313f;border-color:#d58d58;border-radius:4px}button:hover,a.card:hover{background:#344050}
.overlay{background:#10151df5}.overlay-panel{padding:20px;border:1px solid #b17b54;box-shadow:6px 6px 0 #080c12;max-height:100%;overflow:auto}
.local-note{color:#c0c8d0}.works{opacity:.6}.countdown{background:transparent}
@media(pointer:coarse) and (orientation:landscape){.drill nav a{min-height:44px}}

/* Fit short screens against the field, including rotation. */
.memory-game #tg-field{overflow:auto;align-items:safe center;padding:4px;flex-shrink:1}
.memory-grid{width:max-content;max-width:100%;gap:6px;flex-shrink:0;margin:auto}
.memory-card{min-width:44px;min-height:44px;max-height:none;width:100%;height:100%;aspect-ratio:auto}
@media(pointer:coarse) and (orientation:landscape){
 .zero-g-game #tg-controls{position:absolute;inset:auto 0 6px;height:96px;pointer-events:none;padding:4px 12px}
 .zero-g-game #tg-controls .joystick,.zero-g-game #tg-controls button{pointer-events:auto}
 .zero-g-game #tg-field{width:calc(100% - 216px)}
 .zero-g-game .joystick{background:#21123ea0}
 .zero-g-game #tg-options:has(#tg-difficulty:disabled){display:none}
 .zero-g-game .game-header h1{margin:0;font-size:20px}
 .zero-g-game #tg-frame{gap:2px;padding-bottom:4px}
}

/* Hub: art tiles, rank bar, finish-screen nav. */
.cards{grid-template-columns:repeat(2,1fr)!important;gap:12px}
.card{min-height:0;padding:12px;display:flex;flex-direction:column;gap:4px}
.card h2{font-size:20px;margin:4px 0}.card p{font-size:14px;margin:0}
.card-pic{display:flex;align-items:center;justify-content:center;height:96px;border-radius:3px;background:#10151d;overflow:hidden}
.card-pic img{height:100%;width:auto;object-fit:contain}.card-pic img.wide{width:100%;object-fit:cover}.card-pic.glyph{font-size:52px;color:var(--cyan)}
.card .earned{margin-top:auto;padding-right:0}
.also-label{max-width:1232px;margin:24px auto 8px;font-size:18px;color:var(--pink)}
.rank{display:flex;flex-direction:column;gap:6px}
.rank-track{display:block;height:8px;background:#10151d;border:1px solid #58616a}.rank-track i{display:block;height:100%;width:0;background:var(--cyan)}
#rank-next{font-size:14px;font-weight:500}
.tg-howto{font-size:14px;color:#f6f1e6;margin:8px 0 0;text-shadow:0 1px 6px #000}
.tc-hero.tc-compact{min-height:0;padding:60px 16px 16px}
.tc-compact .tc-card .tc-title{font-size:clamp(34px,9vw,52px);margin-bottom:8px}
.tc-compact .tc-card .tc-title br{display:none}
.tc-compact .tc-card .tc-line{font-size:16px;margin-bottom:0}
.tc-compact .tc-extras{margin-top:8px}
.tc-compact .tc-how summary{min-height:44px;display:inline-flex;align-items:center}
.tc-compact .tc-card .rank{margin-top:10px}
@media(max-height:520px){.tc-hero.tc-compact{padding:52px 16px 10px}.tc-compact .tc-eyebrow,.tc-compact .tc-line,.tc-compact .tc-extras{display:none}.tc-compact .tc-card .rank{margin-top:4px;padding:6px 12px}.tc-compact .tc-card .tc-title{font-size:30px;margin:0}.tc-compact .tg-howto,.tc-compact #rank-next{display:none}.tc-compact .tc-card{width:auto;flex-direction:row;flex-wrap:wrap;justify-content:center;gap:4px 16px}.tc-compact .tc-card .rank{margin:0;flex-direction:row;align-items:center;gap:12px}.tc-compact .rank-track{width:120px}}
@media(max-height:520px) and (orientation:landscape){.tc-hero.tc-compact{padding:44px 16px 4px}.tc-compact .tc-card .tc-title{font-size:24px;line-height:1.1}.tc-compact .tc-card{flex-wrap:nowrap;gap:4px 16px}.tc-compact .tc-card .rank{padding:4px 12px;white-space:nowrap}.hub{display:flex;flex-direction:column;padding-top:12px}.hub #cards{order:1}.hub #daily{order:4;margin-top:16px}.hub .also-label{order:2;align-self:stretch;margin-inline:0}.hub>.cards:not(#cards){order:3}}
.overlay-actions a{border-width:2px}
.overlay-actions a.primary:focus,.overlay-actions button:focus,.overlay-actions a.primary:focus-visible,.overlay-actions button:focus-visible{outline:4px solid #ffd166;outline-offset:3px}
.overlay.sheet .level-picker{flex:1 1 100%;flex-wrap:nowrap}
body.tg-results #tg-controls{display:none!important}
@media(min-width:861px){.card-pic{height:130px}.hub{max-width:992px}.also-label{max-width:960px}.hub #daily.dl-row{max-width:960px;margin-inline:auto;padding-inline:0}}
.overlay-actions a.primary{background:var(--cyan);color:#10151d;border-color:var(--cyan);font-weight:800}
.level-picker{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.level-picker a{flex:0 0 auto;min-width:48px;display:flex;align-items:center;justify-content:center;min-height:48px;border:1px solid #d58d58;border-radius:4px}
.level-picker a.current{background:#344050;border-color:var(--cyan)}
@media(max-height:500px){.overlay{align-items:flex-start}.overlay-panel h2{font-size:26px;margin:4px 0}.overlay-actions{flex-direction:row;flex-wrap:wrap;margin-top:8px}.overlay-actions>*{flex:1 1 140px}.result-stars{font-size:28px;margin:0}}

/* Saved Calm mode uses the same static faces as the OS preference. */
[data-calm="1"] .memory-card{transition:none;transform:none}
[data-calm="1"] .memory-card .front{transform:none;display:none}
[data-calm="1"] .memory-card.flipped .front{display:block}
[data-calm="1"] .memory-card.flipped .back{display:none}
.circuit-status{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.circuit-board{position:relative;flex-shrink:0}.circuit-board canvas{width:100%!important;height:100%!important;max-height:none!important}.circuit-grid{position:absolute;inset:0;display:grid}.circuit-grid button{width:100%;height:100%;background:transparent;border:0;border-radius:0;padding:0;min-width:44px;min-height:44px}.circuit-grid button:focus-visible{outline:3px solid #ffd166;outline-offset:-6px}.circuit-game #tg-field{overflow:auto;justify-content:safe center;align-items:safe center}

/* Drill headers and a structural ready caption, including short touch screens. */
.drill-key-art{display:block;width:100%;height:clamp(72px,17dvh,150px);object-fit:cover;object-position:center 20%;border:1px solid #708398;border-bottom:3px solid #ff9650;margin:0 0 12px}
.entry-panel h2{color:#f1eee8}.ready-panel{border-top:5px solid #ff9650}.ready-panel h2{color:#f1eee8}
.overlay-panel .countdown{font:900 96px/1 var(--type-display);color:#ff9650;margin:12px 0 0}
@media(max-height:500px){.entry-panel{width:min(100%,760px);padding:12px}.entry-panel .entry-content{display:grid;grid-template-columns:180px 1fr;gap:4px 18px}.entry-panel .rhythm-settings{grid-column:2}.entry-panel .drill-key-art{grid-row:1/4;height:100%;min-height:140px;margin:0}.entry-panel p{margin:4px 0}.entry-panel .overlay-actions{margin:0}.ready-panel{padding:12px}.ready-panel p{margin:8px 0}.overlay-panel .countdown{font-size:80px;margin:4px 0}}
@media(pointer:coarse) and (orientation:landscape){.rescue-game #tg-field{width:calc(100% - 300px)}}
@media(max-height:740px) and (orientation:portrait){.entry-panel{padding:12px}.entry-panel .drill-key-art{height:72px;margin-bottom:8px}.entry-panel h2{font-size:28px;margin:8px 0}.entry-panel p{font-size:14px;line-height:1.4;margin:8px 0}.entry-panel .overlay-actions{flex-direction:row;gap:8px;margin-top:12px}.entry-panel .overlay-actions>*{flex:1;padding-inline:8px;font-size:14px}}

/* Keep the primary actions outside the independently scrolling briefing/settings. */
.entry-panel{display:flex;flex-direction:column}.entry-content{overflow:auto;min-height:0}.entry-panel>.overlay-actions{flex-shrink:0}
.drill .sn-mb .sn-btn{min-width:44px;min-height:44px;height:44px}

#tg-field canvas:focus:not(:focus-visible){outline:none}
#tg-pause{display:flex;align-items:center;justify-content:center;min-width:48px}
.overlay.sheet{align-items:flex-end;background:#10151d99;padding:8px}
.overlay.sheet .overlay-panel{width:min(100%,600px);padding:10px;max-height:48%}
.overlay.sheet h2{font-size:24px;margin:0}.overlay.sheet p{margin:4px}.overlay.sheet .overlay-actions{flex-direction:row;flex-wrap:wrap;gap:6px;margin-top:6px}.overlay.sheet .overlay-actions>*{flex:1 1 140px}

.zero-g-game #tg-hud .hp{white-space:nowrap}.zero-g-game #tg-hud .hp+.hp::before{content:" · "}
/* Round 2: reserve a compact drill rail on short screens. */
@media (max-height:500px) and (orientation:landscape){
 .drill #tg-frame{display:grid;grid-template-columns:minmax(0,1fr) 150px;grid-template-rows:48px auto 1fr;padding:4px 12px;gap:4px 12px}
 .drill .game-header{grid-column:2;grid-row:1;justify-content:center}.drill .game-header h1{display:none}
 .drill #tg-hud{grid-column:2;grid-row:2;font-size:12px;line-height:1.4}
 .zero-g-game #tg-hud .hp{display:block;white-space:nowrap}.zero-g-game #tg-hud .hp+.hp::before{content:none}
 .zero-g-game #tg-frame.two-p #tg-hud{font-size:11px;letter-spacing:-.02em}
 .drill #tg-options{grid-column:2;grid-row:3;align-self:start;flex-direction:column}.drill #tg-options>*{max-width:150px;font-size:12px;padding:4px}
 .drill #tg-field{grid-column:1;grid-row:1/4;width:100%;height:100%;min-height:0}
 .drill .overlay{padding:6px;align-items:center}.drill .overlay-panel{width:min(100%,760px);padding:8px}
 .drill .overlay-panel h2{font-size:24px;margin:0}.drill .overlay-panel p{margin:4px;font-size:13px}
 .drill .overlay-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-top:6px}
 .drill .overlay-actions>*{font-size:12px;min-height:44px;padding:4px}
 .drill .level-picker{grid-column:1/-1;flex-wrap:nowrap}.drill .level-picker a{min-height:44px;min-width:44px}
 .drill .overlay.sheet{align-items:flex-end}.drill .overlay.sheet .overlay-panel{max-height:100%}
 .drill .entry-panel .entry-content{grid-template-columns:140px 1fr}.drill .entry-panel .drill-key-art{min-height:100px}
 .drill #tg-controls{grid-column:1;grid-row:1/4;align-self:end;width:100%;bottom:0}
}

#tg-controls-p2{display:none;flex-shrink:0;align-items:center;justify-content:space-between;gap:16px;width:100%;height:112px;padding:4px 12px;touch-action:none}
@media(pointer:coarse){#tg-controls-p2{display:flex}.zero-g-game #tg-frame.two-p #tg-controls{height:112px}.zero-g-game #tg-frame.two-p .joystick{width:96px;height:96px}.zero-g-game #tg-frame.two-p .stick{left:25px;top:25px}.zero-g-game #tg-frame.two-p .control-buttons button{width:72px;height:72px}}
@media(pointer:coarse) and (orientation:landscape){
 .zero-g-game #tg-frame.two-p #tg-controls{inset:auto auto 6px 0;width:auto;gap:12px}
 .zero-g-game #tg-frame.two-p #tg-controls-p2{position:absolute;inset:auto 0 6px auto;width:auto;height:96px;gap:12px;flex-direction:row-reverse;z-index:5;pointer-events:none}
 .zero-g-game #tg-frame.two-p #tg-controls-p2 .joystick,.zero-g-game #tg-frame.two-p #tg-controls-p2 button{pointer-events:auto}
 .zero-g-game #tg-frame.two-p #tg-field{width:100%;margin-inline:auto}
}
@media(pointer:coarse) and (max-height:500px) and (orientation:landscape){
 .zero-g-game #tg-frame.two-p #tg-field{grid-column:1;grid-row:1/4;width:100%}
 .zero-g-game #tg-frame.two-p #tg-controls{height:84px;gap:8px;left:12px;z-index:5}
 .zero-g-game #tg-frame.two-p #tg-controls-p2{height:84px;gap:8px;right:174px}
 .zero-g-game #tg-frame.two-p .joystick{width:80px;height:80px}
 .zero-g-game #tg-frame.two-p .stick{left:20px;top:20px}
 .zero-g-game #tg-frame.two-p .control-buttons button{width:60px;height:60px}
}

.rescue-reunion{position:absolute;top:5%;left:5%;width:90%;display:flex;justify-content:center;align-items:center;gap:8px;background:radial-gradient(ellipse,#ffb07840,#14212c 70%);border-bottom:3px solid #ffb078;padding:12px;pointer-events:none}.rescue-reunion img{height:80px;max-width:12%;object-fit:contain}@media(max-height:500px){.rescue-reunion{top:0;padding:4px}.rescue-reunion img{height:52px}}
@media(max-height:500px) and (orientation:landscape){.rescue-game .overlay:has(.rescue-reunion) .overlay-panel>p:not(.result-stars){display:none}}

/* RT-10: on short landscape phones Star Catch and Rescue Run move the joystick off the playfield into the free bottom
   of the right-hand rail (under PAUSE and the HUD), so it never covers the flight lane or the maze. */
@media (pointer:coarse) and (max-height:500px) and (orientation:landscape){
 .action-game:not(.zero-g-game) #tg-controls{grid-column:2;grid-row:3;left:0;right:0;bottom:max(8px,env(safe-area-inset-bottom));width:100%;height:136px;padding:0;justify-content:center}
 .action-game:not(.zero-g-game) #tg-controls .control-buttons:empty{display:none}
}

/* RT-10: Zero-G uses a dedicated left gutter; the right rail remains HUD/PAUSE.
   Both players keep their own gutter in local two-player mode. */
@media(pointer:coarse) and (max-height:500px) and (orientation:landscape){
 .zero-g-game #tg-frame{grid-template-columns:100px minmax(0,1fr) 150px;grid-template-rows:48px auto 1fr}
 .zero-g-game .game-header,.zero-g-game #tg-hud,.zero-g-game #tg-options{grid-column:3}
 .zero-g-game #tg-field,.zero-g-game #tg-frame.two-p #tg-field{grid-column:2;grid-row:1/4;width:100%}
 .zero-g-game #tg-controls,.zero-g-game #tg-frame.two-p #tg-controls{position:static;grid-column:1;grid-row:1/4;align-self:center;flex-direction:column;justify-content:center;width:100%;height:auto;padding:0;gap:12px;pointer-events:auto}
 .zero-g-game #tg-frame .joystick{width:88px;height:88px;flex-shrink:0}
 .zero-g-game #tg-frame .stick{left:21px;top:21px}
 .zero-g-game #tg-frame .control-buttons button{width:64px;height:64px;font-size:12px}
 .zero-g-game #tg-frame.two-p #tg-controls-p2{position:static;grid-column:3;grid-row:3;align-self:end;flex-direction:row;justify-content:center;gap:6px;width:100%;height:auto;padding:0;pointer-events:auto}
 .zero-g-game #tg-frame.two-p #tg-controls-p2 .joystick{width:80px;height:80px}
 .zero-g-game #tg-frame.two-p #tg-controls-p2 .stick{left:17px;top:17px}
}
