
:root{color-scheme:dark;--ink:#f7fbff;--sub:#c0d7e6;--accent:#ffda79;--glass:rgba(11,29,45,.85)}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#091421;color:var(--ink);font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;overscroll-behavior:none}body{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:22px 16px 14px;gap:13px;background:radial-gradient(ellipse at 50% -10%,#243f55 0%,#111f30 50%,#091421 100%)}
.wrap{width:min(1150px,100%)}.topline{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:0 1px 11px}.brand{display:flex;align-items:center;gap:10px;letter-spacing:.15em;font-size:13px;font-weight:900}.brand-icon{width:29px;height:29px;background:#ffcb75;border-radius:9px;display:grid;place-items:center;color:#152c40;transform:rotate(-8deg);font-size:20px}.top-hint{font-size:12px;color:#abc5d3;letter-spacing:.025em;text-align:right}
.shell{position:relative;aspect-ratio:12/7;overflow:hidden;border-radius:23px;isolation:isolate;box-shadow:0 16px 72px #050f1fbb,0 0 0 1px #ffffff24;background:#8cdbf5;touch-action:none}canvas{display:block;width:100%;height:100%;object-fit:contain;touch-action:none}.hud{position:absolute;inset:0 0 auto 0;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:17px 20px;pointer-events:none;z-index:2}.hud-left{display:flex;flex-wrap:wrap;gap:9px}.chip{padding:9px 12px;display:flex;align-items:center;gap:9px;border:1px solid #ffffff30;border-radius:13px;background:#102d45b8;backdrop-filter:blur(12px);box-shadow:0 4px 13px #09283e27;font-size:12px;font-weight:900;letter-spacing:.035em}.chip .num{font-size:16px;letter-spacing:0}.gem{color:#ffe389}.heart{color:#ff7e83}.hud-right{display:flex;gap:9px;align-items:center}.levelchip{display:flex;flex-direction:column;gap:5px;min-width:130px}.levelchip span{font-size:11px;color:#d2e9f4}.track{height:5px;background:#d0e6f355;border-radius:10px;overflow:hidden}.track i{display:block;height:100%;background:#ffda79;border-radius:9px;width:0;transition:width .15s}.pause-btn,.mute-btn{pointer-events:auto;border:1px solid #ffffff3b;background:#122e46b9;color:white;width:40px;height:40px;border-radius:12px;display:grid;place-items:center;font-size:17px;cursor:pointer;backdrop-filter:blur(8px)}button{font:inherit}.pause-btn:hover,.mute-btn:hover{background:#2a5069}
.overlay{position:absolute;inset:0;z-index:4;display:flex;align-items:center;justify-content:center;padding:20px;background:linear-gradient(125deg,#0c3048bc,#102a3db2);backdrop-filter:blur(5px);transition:opacity .2s}.overlay.hidden{opacity:0;pointer-events:none;visibility:hidden}.panel{width:min(500px,100%);position:relative;text-align:center;padding:35px 32px 30px;background:#10283de8;border:1px solid #cde8fa45;border-radius:28px;box-shadow:0 18px 85px #00121e78}.eyebrow{font-size:11px;font-weight:900;letter-spacing:.26em;color:#a9d7e4;text-transform:uppercase}.mascot{display:flex;justify-content:center;margin:15px auto 9px}.mascot svg{width:100px;height:99px;filter:drop-shadow(0 9px 4px #0003)}h1{margin:4px 0 8px;font-size:clamp(40px,7vw,72px);font-weight:1000;line-height:.98;letter-spacing:-.065em;color:#ffda80;text-shadow:0 5px 0 #d18e57}.panel h2{margin:12px 0 8px;font-size:32px;letter-spacing:-.04em}.panel p{font-size:14px;color:#d0e6ed;line-height:1.6;margin:14px auto 23px;max-width:355px}.primary{border:0;padding:14px 28px;background:#ffdb80;color:#1d3140;box-shadow:inset 0 -4px #d99b54,0 7px 0 #0a1a29;border-radius:15px;font-size:16px;font-weight:1000;cursor:pointer;min-width:215px;transition:transform .1s}.primary:hover{transform:translateY(-2px)}.primary:active{transform:translateY(3px);box-shadow:inset 0 -2px #d99b54,0 3px 0 #0a1a29}.secondary{display:block;margin:14px auto 0;border:none;background:none;color:#bfd8e8;cursor:pointer;font-size:13px;text-decoration:underline;text-underline-offset:4px}.tiny-help{display:flex;justify-content:center;gap:14px;margin:24px auto 0;color:#b5cfda;font-size:11px;flex-wrap:wrap}.key{display:inline-flex;align-items:center;justify-content:center;border:1px solid #b8dceb80;border-radius:5px;min-width:22px;height:22px;padding:1px 5px;font-size:11px;color:white;margin-right:3px;background:#ffffff12}.stat-line{color:#d6e9ef;display:flex;justify-content:center;gap:24px;font-size:13px;margin-bottom:20px}.stat-line strong{color:#ffe18d}.touch{position:absolute;z-index:3;inset:auto 0 15px;display:none;align-items:end;justify-content:space-between;padding:0 24px;pointer-events:none}.touch-left{display:flex;gap:13px}.touch-btn{pointer-events:auto;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none;width:67px;height:67px;border-radius:19px;border:2px solid #ffffff80;color:white;background:#0d32458c;backdrop-filter:blur(8px);font-size:30px;font-weight:900;display:grid;place-items:center;box-shadow:0 5px 12px #17334844}.touch-btn:active,.touch-btn.pressed{background:#f6c773b0;transform:scale(.96)}.touch-btn.jump{border-color:#ffe4a1;background:#ffbe6bba;color:#26384a;width:76px;height:76px;font-size:18px;font-weight:1000}.footer{display:flex;justify-content:space-between;gap:16px;align-items:center;color:#819dac;font-size:12px;padding:2px 4px}.footer span b{color:#b3d1df;font-weight:700}.footer .best{white-space:nowrap}.toast{position:absolute;z-index:3;top:86px;left:50%;transform:translateX(-50%) translateY(-8px);color:#183344;font-weight:1000;background:#fff0b6;box-shadow:0 8px 24px #15293a45;border-radius:14px;padding:9px 18px;font-size:15px;pointer-events:none;opacity:0;transition:opacity .2s,transform .2s;white-space:nowrap}.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
@media (hover:none),(pointer:coarse){.touch{display:flex}.top-hint{display:none}.footer .keyboard-hint{display:none}}
@media(max-width:690px){body{padding:8px 6px;justify-content:flex-start;gap:6px}.topline{margin:3px 5px 7px}.brand{font-size:11px}.shell{border-radius:14px}.hud{padding:8px;gap:5px}.hud-left{gap:4px}.chip{font-size:10px;gap:5px;padding:7px 8px;border-radius:9px}.chip .num{font-size:13px}.levelchip{min-width:82px}.levelchip span{font-size:9px}.hud-right{gap:5px}.pause-btn,.mute-btn{width:29px;height:29px;border-radius:9px;font-size:14px}.touch{padding:0 15px 10px}.touch-left{gap:8px}.touch-btn{width:54px;height:54px;border-radius:14px;font-size:23px}.touch-btn.jump{width:60px;height:60px;font-size:14px}.panel{padding:18px;border-radius:19px}.mascot{display:none}h1{font-size:43px}.panel p{font-size:12px;margin:10px auto 13px}.panel h2{font-size:25px}.tiny-help{display:none}.primary{padding:11px 20px;font-size:14px;min-width:180px}.toast{top:45px;font-size:12px;padding:6px 12px}.footer{font-size:10px}}
@media (max-width:500px) and (orientation:portrait){.shell{aspect-ratio:8/9;background:#12344b}.shell canvas{height:auto}.touch{padding:0 10px 11px}.overlay{padding:10px}.chip:nth-child(2){display:none}.levelchip{display:none}.panel{width:90%;padding:23px 16px}.panel p{margin-bottom:16px}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important}}

/* Menu and persistent save-state controls */
.level-select{display:grid;gap:7px;margin:11px auto 15px;max-width:370px;text-align:left}
.level-select[hidden]{display:none}
.level-card{background:#163c53de;color:#e8f8fa;border:1px solid #d4e5ef55;border-radius:11px;min-height:41px;padding:8px 12px;display:flex;justify-content:space-between;gap:8px;align-items:center;cursor:pointer;text-align:left;font-size:12px;font-weight:800}
.level-card .record{font-size:11px;color:#fce39e;white-space:nowrap}
.level-card:focus-visible,.primary:focus-visible,.secondary:focus-visible,.pause-btn:focus-visible,.mute-btn:focus-visible{outline:3px solid #ffe9a1;outline-offset:2px}
.level-card:disabled{opacity:.46;cursor:not-allowed}
.level-card:not(:disabled):hover{border-color:#ffdc85;background:#1b5268}
.save-note{font-size:11px;color:#d4f3db;min-height:1em;margin:8px auto 0}
.overlay{overflow:auto}.panel{max-height:100%;overflow:auto;overscroll-behavior:contain}
@media(max-width:500px) and (orientation:portrait){.panel{padding:13px 14px;max-height:96%}.panel h2{margin:6px 0;font-size:22px}.level-select{gap:5px;margin:8px auto}.level-card{min-height:36px;padding:6px 9px;font-size:11px}.panel p{margin:8px auto 10px}.primary{padding:10px 18px}.secondary{margin-top:9px}}
@media(max-width:690px){.pause-btn,.mute-btn{min-width:38px;min-height:38px}.hud{padding-top:7px}}

/* v0.5: exact 16:9 game surface at every breakpoint. Controls are independent. */
.game-stage{position:relative;width:100%}
.shell{aspect-ratio:16/9;min-height:0}
.shell canvas{width:100%;height:100%;object-fit:fill}
.top-actions{display:flex;align-items:center;justify-content:flex-end;gap:13px;min-width:0}
.lang-switch{display:flex;align-items:center;gap:3px;border:1px solid #88b8ce65;padding:3px;border-radius:11px;background:#152c40}
.lang-switch button{min-width:37px;min-height:33px;padding:5px 7px;border:0;border-radius:8px;background:transparent;color:#bed6e4;cursor:pointer;font-size:12px;font-weight:900}
.lang-switch button[aria-pressed="true"]{background:#ffda79;color:#192b3b}
.lang-switch button:focus-visible{outline:2px solid #fff;outline-offset:2px}
@media (max-width:690px){.top-actions{gap:6px}.top-hint{font-size:10px}.topline{gap:6px}.lang-switch button{min-width:36px;min-height:34px}}
@media (max-width:500px) and (orientation:portrait){
  .shell{aspect-ratio:16/9}
  .shell canvas{height:100%}
  .touch{position:relative;inset:auto;display:flex;min-height:110px;align-items:center;margin:12px 0 0;padding:14px 19px;border:1px solid #ffffff25;border-radius:17px;background:#112a3e;gap:12px}
  .touch-left{gap:12px}
  .touch-btn{width:72px;height:72px;font-size:27px;border-radius:18px}
  .touch-btn.jump{width:90px;height:78px;font-size:17px}
  .overlay{position:fixed;inset:0;z-index:30;max-height:100dvh;padding:calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom));overflow:auto;background:#091c2be8}
  .panel{width:min(480px,100%);max-height:calc(100dvh - 35px);overflow:auto;padding:22px 18px}
  .levelchip{display:none}
}
@media (orientation:landscape) and (max-height:540px){
  body{padding:3px;justify-content:center}
  .wrap{width:min(100%,calc((100dvh - 8px)*12/7))}
  .topline,.footer{display:none}
  .touch{bottom:7px;padding:0 8px}
  .touch-btn{width:54px;height:54px}
  .touch-btn.jump{width:63px;height:63px}
}
@media (pointer:coarse) and (min-width:501px){.touch{display:flex}}
@media (min-width:501px) and (orientation:portrait) and (pointer:coarse){.touch{bottom:12px}}

.panel-languages{display:flex;justify-content:center;gap:6px;margin:-12px 0 10px}
.panel-languages button{min-width:48px;min-height:32px;border:1px solid #ffffff55;border-radius:9px;background:#ffffff14;color:#d7ecf4;font-size:12px;font-weight:900;cursor:pointer}
.panel-languages button[aria-pressed="true"]{background:#ffda79;color:#1d3040;border-color:#ffda79}
.panel-languages button:focus-visible{outline:2px solid #fff;outline-offset:2px}
@media (orientation:landscape) and (max-height:540px){.panel{padding:12px 16px}.panel-languages{margin:0 0 6px}.panel p{margin:5px auto 10px}.level-select{margin:5px auto}.level-card{min-height:32px;padding:4px 9px}.mascot{display:none}.primary{padding:8px 15px}.eyebrow{letter-spacing:.14em}}

/* v0.6 — short, replayable first-run teaching. No tutorial blocks movement. */
.guide-toggle{display:block;margin:4px auto 8px;padding:6px 13px;min-height:34px;border:1px solid #ffdb80a3;border-radius:10px;color:#ffe7a7;background:#284a5c;font-size:11px;font-weight:900;letter-spacing:.07em;cursor:pointer}
.guide-toggle[hidden],.tutorial-guide[hidden],.tutorial-cue[hidden]{display:none!important}
.guide-toggle:focus-visible{outline:3px solid #fff;outline-offset:2px}
.tutorial-guide{display:grid;gap:5px;max-width:410px;margin:3px auto 12px;text-align:left}
.guide-step{display:flex;align-items:center;gap:10px;padding:7px 11px;border-radius:9px;background:#21435bc4;border:1px solid #c8e8ec3b;color:#e4f6f9;font-size:12px;line-height:1.35}
.guide-icon{display:grid;place-items:center;flex:0 0 24px;width:24px;height:24px;border-radius:8px;background:#f6ce75;color:#263544;font-weight:1000;font-size:14px}
.controls-touch{display:none}
@media (hover:none),(pointer:coarse){.controls-desktop{display:none}.controls-touch{display:inline}}
.overlay.guide-open .mascot{display:none}
.overlay.guide-open .panel{padding-top:20px;padding-bottom:17px}
.overlay.guide-open h1{font-size:clamp(36px,5vw,54px)}
.overlay.guide-open .panel p{margin:9px auto 10px}
.overlay.guide-open .tiny-help{margin-top:12px}
.tutorial-cue{position:absolute;z-index:3;top:72px;left:50%;transform:translateX(-50%);width:max-content;max-width:min(82%,470px);display:flex;align-items:center;gap:9px;padding:9px 13px;background:#163348e8;border:1px solid #fff0baaa;box-shadow:0 7px 22px #092c3970;border-radius:12px;color:#f8f8eb;font-size:13px;font-weight:800;text-align:left;line-height:1.35;pointer-events:none}
.tutorial-dot{color:#ffdf83;font-size:20px;line-height:1}
@media(max-width:690px){.tutorial-cue{top:50px;font-size:11px;padding:6px 9px}.guide-step{font-size:11px;padding:6px 8px}}
@media(max-width:500px) and (orientation:portrait){.tutorial-cue{position:relative;z-index:1;inset:auto;transform:none;max-width:100%;width:100%;margin:10px auto 0;font-size:12px;padding:10px 12px}.overlay.guide-open .panel{padding-top:16px}.tutorial-guide{gap:5px}}
@media(orientation:landscape) and (max-height:540px){.tutorial-cue{top:50px;max-width:55%;font-size:11px}.overlay.guide-open .panel{padding:9px 12px}.guide-step{padding:4px 8px;font-size:10px}.guide-icon{width:20px;height:20px;flex-basis:20px}.overlay.guide-open .panel p{margin:4px auto 6px}.overlay.guide-open .level-select{gap:3px;margin:4px auto}.overlay.guide-open .level-card{padding:3px 8px;min-height:28px}.overlay.guide-open .tiny-help{display:none}}

/* v0.9 portal builds: the game fills the portal iframe, site chrome hidden */
.portal body{padding:0;justify-content:center;min-height:100dvh}
.portal .topline,.portal .footer{display:none}
.portal .wrap{width:min(100vw,calc(100dvh*12/7))}
.portal .shell{border-radius:0}
@media (max-height:480px) and (orientation:landscape){
 .overlay{padding:8px}
 .panel{max-height:calc(100dvh - 16px);overflow:auto;padding:12px 18px}
 .panel h1,h1{font-size:38px;margin:2px 0 4px}
 .panel p{margin:6px auto 10px;font-size:12px}
 .panel-languages{margin:-4px 0 6px}
 .mascot{display:none}
 #primaryBtn{position:sticky;bottom:0;z-index:2}
 #levelSelect button,#levelSelect>*{padding-top:6px;padding-bottom:6px}
 .panel-languages,#eyebrow{display:none}
}

/* v0.9 phone portrait (ux-mobile-1106): the canvas is a 480×540 window onto the
   same world (twice the scale of the old 16:9 strip). HUD is a strip above the
   field, the cue and the controls sit below — nothing covers the play area.
   Whole game fits one screen at 390×844 and 360×780. */
@media (max-width:600px) and (orientation:portrait){
  html:not(.portal) body{padding:max(6px,env(safe-area-inset-top)) 8px max(8px,env(safe-area-inset-bottom));min-height:100svh;gap:0;justify-content:flex-start}
  html:not(.portal) .wrap{display:flex;flex-direction:column;min-height:calc(100svh - 16px)}
  .topline{margin:2px 2px 8px}
  .brand{font-size:12px;letter-spacing:.12em}
  .lang-switch button{min-width:44px;min-height:40px}
  .shell{aspect-ratio:auto;display:flex;flex-direction:column;border-radius:18px;background:#102a3d}
  .shell canvas{aspect-ratio:8/9;width:100%;height:auto;order:2}
  .hud{position:relative;inset:auto;order:1;padding:8px 8px 8px 10px;gap:8px;background:#102a3d;border-bottom:1px solid #ffffff1f;pointer-events:auto;align-items:center}
  .hud-left{gap:6px;flex-wrap:nowrap}
  .chip{font-size:13px;padding:8px 10px;border-radius:11px;gap:6px}
  .chip .num{font-size:16px}
  .chip:nth-child(2){display:flex}
  .levelchip{display:none}
  .pause-btn,.mute-btn{width:44px;height:44px;min-width:44px;min-height:44px;font-size:18px;border-radius:12px}
  .toast{top:70px;font-size:13px}
  .tutorial-cue{margin:10px 0 0;font-size:14px;line-height:1.4;padding:11px 14px;border-radius:14px}
  .touch{margin:auto 0 0;padding:14px 12px;min-height:118px;justify-content:space-between}
  .touch-left{gap:12px}
  .touch-btn{width:84px;height:84px;font-size:30px;border-radius:20px}
  .touch-btn.jump{width:120px;height:92px;font-size:20px}
  .footer{font-size:12px;padding:10px 4px 0;margin:0}
  .panel h1,h1{font-size:46px}
  .panel p{font-size:15px;line-height:1.5}
  .eyebrow{font-size:12px}
  .primary{min-height:56px;font-size:17px;width:100%}
  .secondary{min-height:48px;font-size:15px;width:100%}
  .guide-toggle{min-height:44px;font-size:13px;padding:10px 16px}
  .guide-step{font-size:14px;padding:10px 12px}
  .level-card{min-height:52px!important;font-size:14px!important;padding:10px 14px!important}
  .panel-languages button{min-width:56px;min-height:44px;font-size:14px}
}
@media (max-width:374px) and (orientation:portrait){
  .touch-btn{width:76px;height:76px}
  .touch-btn.jump{width:106px;height:86px}
  .chip{padding:7px 8px}
}
@media (max-width:600px) and (orientation:portrait){
  html:not(.portal) .game-stage{flex:1;display:flex;flex-direction:column}
}
@media (max-width:600px) and (orientation:portrait){.lang-switch button{min-height:44px!important}}
