*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#0e192a;color:#ecf3fb;font-family:system-ui,sans-serif;overscroll-behavior:none}main{position:fixed;inset:0;width:100%;height:100dvh;display:flex;justify-content:center;align-items:center}#stage{position:relative;width:min(100vw,46.05263158dvh,460px);height:auto;aspect-ratio:350 / 760;flex-shrink:0;isolation:isolate}.desktop-steer{display:none}canvas{position:absolute;inset:0;display:block;width:100%;height:100%;touch-action:none;outline:none;-webkit-touch-callout:none;user-select:none}button{font:inherit;color:inherit;background:#172b3b;border:1px solid #355164;border-radius:10px;min-height:44px;padding:10px 14px;cursor:pointer;touch-action:manipulation}button:hover{background:#234359}button:focus-visible{outline:3px solid #6ce7d4;outline-offset:2px}#menu-toggle{position:absolute;z-index:4;top:max(10px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));width:44px;height:44px;padding:0;border:0;background:#0b1725a6;color:#bad8db;font-size:23px;line-height:44px}#overlay,#menu{position:absolute;inset:0;display:grid;place-items:center;padding:20px;background:#09111b8c}#overlay.hidden,#menu[hidden]{display:none}#overlay{z-index:3}#menu{z-index:5;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));background:#081320e8}.card,.menu-card{width:100%;max-width:390px;border:1px solid #34536c;border-radius:16px;background:#101d30f5;padding:24px;box-shadow:0 16px 60px #0005}.card{text-align:center}.eyebrow{font-size:9px;letter-spacing:1.6px;color:#8ba3bb}h2{font-size:27px;letter-spacing:-.8px;margin:9px 0}.card p{font-size:14px;line-height:1.55;color:#b3c4d5;margin:0 0 20px}.card #action,#resume{background:#6ce7d4;color:#08241f;font-weight:700;border:0;min-width:170px}.menu-card{max-width:450px;margin:auto}.menu-header{display:flex;align-items:center;justify-content:space-between;gap:14px}.menu-header h2{font-size:25px}.menu-header button{padding:5px;width:44px;flex-shrink:0}#round-status{font-size:12px;color:#a9bdcb;margin:12px 0}#resume,#restart{display:block;width:100%;margin-top:8px}#resume[hidden]{display:none}nav{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin-top:20px}nav button{text-align:left;padding:10px;font-size:12px;min-height:67px}nav strong{display:block;font-size:12px;font-weight:550;line-height:1.4}nav small{font-size:10px;color:#8ca6bb}nav button.active{border-color:#6ce7d4;background:#12332f}.medal{color:#ffdb7e;font-size:10px;margin-right:6px}.help{font-size:11px;color:#8ca6bb;line-height:1.7;margin:18px 0 0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}@media(max-width:360px){#overlay{padding:12px}.card,.menu-card{padding:17px}h2{font-size:25px}nav button{padding:8px}}@media(max-height:620px){#menu{display:block}.menu-card{padding:17px}.card{padding:18px}.card p{font-size:13px}}

/* Gameplay always renders the same 350×760 world.
   iPhone 13 portrait (390×844) nearly fills the screen; other aspect ratios
   get unused surrounding space instead of unequal lookahead or squeezed gaps. */
/* Keep mobile portrait edge-to-edge. Desktop adds clickable side gutters. */
@media (min-width:600px) and (min-aspect-ratio:4/3) and (hover:hover) and (pointer:fine) {
  main{background:radial-gradient(ellipse at center,#172b3a 0%,#080f1b 78%)}
  #stage{box-shadow:0 0 0 1px #436b7360,0 0 80px #0009}
  .desktop-steer{display:flex;flex:1;align-self:stretch;min-width:0;align-items:center;justify-content:flex-end;min-height:0;padding:24px clamp(16px,3vw,52px);border:0;border-radius:0;background:transparent;color:#8aa8ba;text-align:right;touch-action:none;user-select:none}
  #desktop-right{justify-content:flex-start;text-align:left}
  .desktop-steer:hover{background:#6ce7d409}
  .desktop-steer:active{background:#6ce7d415}
  .desktop-hint{display:flex;flex-direction:column;gap:4px;pointer-events:none}
  .desktop-hint strong{font-size:clamp(20px,2.5vw,32px);font-weight:500;color:#d1f5eb;letter-spacing:2px}
  .desktop-hint small{font-size:11px;font-style:normal;letter-spacing:2px}
  .desktop-hint em{font-size:11px;font-style:normal;opacity:.55}
}

/* Nonintrusive progress, mobile control switch and compact game overlays */
#run-progress{position:absolute;z-index:2;top:0;left:0;right:0;height:4px;pointer-events:none;background:#ffffff20;overflow:hidden}
#progress-fill{height:100%;width:100%;transform:scaleX(0);transform-origin:left center;background:#6ce7d4;box-shadow:0 0 10px #6ce7d4}
.control-settings{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:14px 0 6px;font-size:12px;color:#b2c8d6}
.control-options{display:flex;gap:6px}
.control-options button{min-width:72px;min-height:42px;padding:7px 10px;font-size:12px;border-radius:9px}
.control-options button.selected{border-color:#6ce7d4;background:#173e3b;color:#d8fff5}
#overlay .card{max-width:330px;padding:22px}
#overlay .card p{max-width:250px;margin:0 auto 16px}
#overlay .card h2{font-size:24px}
#menu .menu-card{max-width:420px}
#menu nav{gap:6px;margin-top:14px}
#menu nav button{min-height:55px;padding:8px}
#menu nav small{display:block;margin-top:3px}
#menu .help{margin:14px 0 0}
@media(max-height:680px){#menu .menu-card{padding:14px}#menu nav button{min-height:50px}#menu .help{font-size:10px}}

/* Elastic-style full-screen level selector, scoped to Gravity only. */
#menu{position:fixed;inset:0;z-index:20;display:flex;justify-content:center;align-items:flex-start;overflow-y:auto;padding:max(22px,env(safe-area-inset-top)) 14px max(24px,env(safe-area-inset-bottom));background:#06111ded;backdrop-filter:blur(12px)}
#menu[hidden]{display:none}
#menu .menu-card{width:min(900px,100%);max-width:none;max-height:none;margin:0 auto;padding:18px 20px 24px;border-radius:20px;background:#11263a;border:1px solid #41677b;box-shadow:0 20px 80px #0008}
#menu .menu-header{margin-bottom:12px}
#menu .menu-header h2{margin:3px 0;font-size:26px}
#menu .menu-header .eyebrow{font-size:11px;color:#77cfbc;letter-spacing:2px}
#menu .menu-header button{height:44px;width:44px;border-radius:11px;font-size:23px}
#menu .menu-actions{display:flex;gap:9px;margin:8px 0 18px}
#menu .menu-actions button{flex:1;min-height:44px;margin:0}
#menu #resume{background:#6ce7d4;color:#092923}
#menu #restart{background:#1c3448}
#menu .level-chapter{margin:0 0 24px}
#menu .level-chapter h3{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin:0 0 10px;font-size:15px;font-weight:850;letter-spacing:.4px;color:#e4fffb}
#menu .level-chapter h3 small{font-size:11px;font-weight:500;color:#90abba}
#menu .level-chapter nav{display:grid;grid-template-columns:repeat(auto-fill,minmax(70px,1fr));gap:9px;margin:0}
#menu .level-chapter nav button{position:relative;aspect-ratio:1;min-height:0;min-width:0;padding:7px 2px 4px;border-radius:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;background:#203a4d;border:1px solid #47687b;text-align:center}
#menu .level-chapter nav button.active{background:#25625e;border-color:#8dffe0}
#menu .level-chapter nav button:hover{background:#33556a}
#menu .level-chapter nav button strong{font-size:23px;font-weight:850;line-height:1.1}
#menu .level-chapter nav button .tile-stars{display:flex;justify-content:center;gap:1px;font-size:12px;line-height:1.2;color:#65818a}
#menu .level-chapter nav button .tile-stars .earned{color:#ffda88;text-shadow:0 0 8px #ffd98577}
#menu .level-chapter nav button .tile-progress{font-size:10px;color:#8aa8b8;line-height:1.1}
#menu .control-settings{border-top:1px solid #355267;padding:16px 0 0;margin:2px 0 0;gap:16px}
#menu .control-options button{min-width:85px}
@media(max-width:470px){
 #menu{padding:0}
 #menu .menu-card{border-radius:0;border:0;min-height:100dvh;padding:22px 16px max(22px,env(safe-area-inset-bottom))}
 #menu .level-chapter nav{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
 #menu .level-chapter nav button{min-height:0;padding:5px 0}
 #menu .menu-actions{margin-bottom:22px}
}
@media(max-height:620px) and (min-width:471px){#menu .menu-card{padding:12px 20px 18px}#menu .level-chapter nav{grid-template-columns:repeat(8,minmax(0,1fr))}}

/* Ensure fixed menu covers side-control siblings on wide desktop viewports. */
#stage.menu-open{z-index:30}

/* Small, distinct visual options: only presentation, never gameplay geometry. */
:root{--gravity-accent:#77caff;--gravity-overlay:#101b39;--gravity-border:#626db1;--gravity-active:#334c80;--gravity-muted:#abc3d4}
#menu .menu-card{background:var(--gravity-overlay);border-color:var(--gravity-border)}
#menu .menu-header .eyebrow{color:var(--gravity-accent)}
#menu .level-chapter nav button.active{background:var(--gravity-active);border-color:var(--gravity-accent)}
#menu #resume{background:var(--gravity-accent);color:#06192a}
#menu .control-settings{border-top:1px solid var(--gravity-border)}
#overlay .card{background:var(--gravity-overlay);border-color:var(--gravity-border)}
#overlay .result-actions{display:flex;gap:10px;justify-content:center;align-items:stretch}
#overlay .result-actions button{min-width:0;flex:1;min-height:49px;padding:9px}
#overlay .result-actions #retry-level{background:#ffffff16;color:#f2efff;border:1px solid var(--gravity-border)}
#overlay .result-actions #retry-level[hidden]{display:none}
#overlay .result-actions #action{background:var(--gravity-accent);color:#091c29}
#progress-fill{background:var(--gravity-accent)}
#menu .control-options button.selected{border-color:var(--gravity-accent);background:var(--gravity-active)}
/* Browser game touch hygiene: selection/callouts must not escape canvas.
   Keep menu scrolling and accessible button activation intact. */
main,#stage,.desktop-steer,#overlay,#menu,#menu button,#menu .menu-card,
#menu-toggle,#retry-level,#action,#control-hint{
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
}
#game,.desktop-steer{touch-action:none}
#menu,#menu .menu-card,#menu nav,#menu .level-chapter{touch-action:pan-y}
#menu button,#menu-toggle,#overlay button{touch-action:manipulation}
#control-hint{
  position:absolute;z-index:2;bottom:max(11%,24px);left:50%;
  transform:translateX(-50%);width:max-content;max-width:calc(100% - 20px);
  padding:10px 17px;border:1px solid #b1d3ff66;border-radius:24px;
  pointer-events:none;background:#101e38c9;
  box-shadow:0 0 24px #030b2277;
  font-size:12px;letter-spacing:1.2px;color:#e3f2ff;text-align:center;
  font-weight:750;white-space:nowrap;
}
#control-hint[hidden]{display:none}
#control-hint .hint-touch,#control-hint .hint-keyboard{display:none;align-items:center;gap:11px}
#control-hint .hint-touch{display:flex}
#control-hint .hint-touch>span,#control-hint .hint-keyboard>span{font-size:11px;letter-spacing:1px}
@media(hover:hover) and (pointer:fine){
  #control-hint .hint-touch{display:none}
  #control-hint .hint-keyboard{display:flex}
}
@media(max-width:360px){#control-hint{font-size:10px;padding:9px 12px}}

/* Player UI v6: a legible numeric percentage, not a thin progress meter. */
#run-progress{
  position:absolute;top:max(12px,env(safe-area-inset-top));left:50%;right:auto;
  z-index:2;transform:translateX(-50%);width:auto;height:auto;overflow:visible;
  padding:3px 11px;border-radius:13px;background:#0a1735c9;border:1px solid #6f92bc44;
  color:#e8f7ff;box-shadow:0 0 14px #0e2d5c55;
  font-size:24px;font-weight:800;line-height:1.35;letter-spacing:.5px;
  text-align:center;white-space:nowrap;pointer-events:none;
  font-variant-numeric:tabular-nums;
}
/* Results follow the player's thumbs instead of occupying the screen centre. */
#overlay{display:flex;align-items:flex-end;justify-content:center;
  padding:16px 16px max(52px,env(safe-area-inset-bottom) + 28px)}
#overlay .card{max-width:345px;padding:24px 22px;border-radius:20px}
#overlay .card h2{font-size:clamp(31px,6.6vw,38px);line-height:1.1;margin:6px 0 9px}
#overlay .card p{font-size:28px;font-weight:750;letter-spacing:.5px;line-height:1.25;margin:0 auto 14px}
#overlay .card p:empty{display:none}
#overlay .card .eyebrow:empty{display:none}
#overlay .result-actions{margin-top:18px;gap:10px}
#overlay .result-actions button{min-height:56px;font-size:17px;font-weight:800}
.result-stars{display:flex;align-items:center;justify-content:center;gap:11px;margin:14px auto 6px}
.result-stars[hidden]{display:none}
.result-star{
  display:block;width:37px;height:37px;flex-shrink:0;
  background:#405a75;filter:drop-shadow(0 0 2px #102037);
  clip-path:polygon(50% 0%,61% 34%,98% 35%,68% 57%,79% 93%,
                    50% 72%,21% 93%,32% 57%,2% 35%,39% 34%);
}
.result-star.earned{background:#ffd586;filter:drop-shadow(0 0 7px #ffdc85a0)}
#menu .menu-actions,#menu .control-settings{display:none}
#menu .menu-card{padding-bottom:max(22px,env(safe-area-inset-bottom) + 10px)}
@media(max-height:520px){
  #overlay{padding-bottom:12px}
  #overlay .card{padding:12px 16px}
  #overlay .card h2{font-size:29px}
  .result-star{width:28px;height:28px}
  #overlay .result-actions button{min-height:45px}
}

/* Text-free stage picker. Only the actual level tiles, close and mute icons. */
#menu .menu-card{max-width:980px;padding:16px 18px 22px}
#menu .menu-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;gap:12px}
#menu .menu-top button{width:44px;height:44px;flex:none;padding:0;font-size:22px;min-height:44px;line-height:1}
#menu #audio-toggle{color:#b7d8f3;background:#19304b;border-color:#416480}
#menu #audio-toggle[aria-pressed="true"]{opacity:.45;text-decoration:line-through}
#menu .level-chapter{margin:0}
#menu .level-chapter nav{margin:0}
#menu .level-chapter nav button.keyboard-selected{
  outline:3px solid #e7f6ff;outline-offset:2px;
  box-shadow:0 0 19px #7bc5ff55;
}
#menu .level-chapter nav button{transition:border-color .13s,box-shadow .13s,background .13s}
@media(max-width:470px){
 #menu .menu-card{padding:16px 14px max(20px,env(safe-area-inset-bottom))}
 #menu .menu-top{margin-bottom:22px}
}

/* Death feedback sits over live gameplay, then disappears on auto-retry. */
.death-notice{
  position:absolute;z-index:5;left:50%;top:34%;
  transform:translate(-50%,-50%);min-width:160px;
  display:flex;flex-direction:column;align-items:center;gap:3px;
  pointer-events:none;text-align:center;
  font-variant-numeric:tabular-nums;
  text-shadow:0 2px 13px #030a21,0 0 22px #1d4a88;
}
.death-notice[hidden],.death-notice .death-best[hidden]{display:none}
.death-notice .death-best{font-size:clamp(16px,3vw,23px);font-weight:900;letter-spacing:2.2px;color:#ffd586}
.death-notice strong{font-size:clamp(42px,11vw,72px);line-height:1.05;color:#eff8ff;letter-spacing:-1px}
.death-notice .result-stars{margin:6px 0 0;gap:8px}
.death-notice .result-star{width:29px;height:29px}
@media(max-height:470px){.death-notice{top:31%}.death-notice strong{font-size:40px}}

/* Pause screen is intentionally button-only: no headline, label or description. */
#overlay .card h2:empty,
#overlay .card p:empty,
#overlay .card .eyebrow:empty{display:none}
#overlay .card:has(h2:empty) {padding:15px;max-width:330px}
#overlay .card:has(h2:empty) .result-actions{margin:0}

/* Touch tablets and landscape phones: surrounding side gutters are live
   left/right steering targets, not dead areas next to the fitted playfield. */
@media(min-width:600px) and (hover:none) {
  .desktop-steer{
    display:flex;flex:1;min-width:0;height:100%;align-items:center;
    justify-content:center;border:0;border-radius:0;background:transparent;
    padding:0;touch-action:none;user-select:none;
  }
  .desktop-steer .desktop-hint{display:none}
}
