/* Layout: one-screen portrait game, HUD band on top, glass container centered under a night-mountain sky. */
:root {
  --sky-top: #0a0e2c;
  --sky-mid: #1b2366;
  --sky-low: #3b2d6e;
  --fg: #f4f6ff;
  --muted: #a8b1e6;
  --gold: #ffc83d;
  --gold-deep: #ff8a1f;
  --panel: rgba(16, 20, 58, 0.86);
  --font-display: "Fredoka", "Baloo 2", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html { touch-action: manipulation; }
/* fixed body: iPhone Safari can't scroll or rubber-band the page out from under the game */
body {
  position: fixed; inset: 0; box-sizing: border-box;
  margin: 0;
  background:
    radial-gradient(120% 60% at 50% 110%, #5a3f8a 0%, transparent 60%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
  background-color: var(--sky-top);
  color: var(--fg);
  font: 14px var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#app {
  box-sizing: border-box;
  height: 100%; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px; position: relative;
  padding-block: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-bottom, 0px));
}

.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.stat { display: flex; flex-direction: column; }
.stat.right { align-items: flex-end; }
.label { font: 800 10px/1.2 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.value { font: 700 26px/1.05 var(--font-display); font-variant-numeric: tabular-nums; }
.next { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.next-ball { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 700 14px var(--font-display); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); box-shadow: inset -4px -6px 10px rgba(0,0,0,.25), inset 4px 5px 8px rgba(255,255,255,.35); transition: transform .2s; }
.toolbar { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255,255,255,.75); background: rgba(255,255,255,.06); color: var(--fg); display: grid; place-items: center; cursor: pointer; padding: 0; }
.icon-btn:focus-visible, .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }

.meta { display: flex; justify-content: space-between; align-items: center; font: 800 12px var(--font-body); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: rgba(255,255,255,.07); }
.chip i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.combo { color: var(--gold); font: 700 14px var(--font-display); opacity: 0; transition: opacity .2s; }
.combo.on { opacity: 1; }

.powers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.power { appearance: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: var(--fg); font: 600 15px var(--font-display); cursor: pointer; min-width: 0; }
.power:not(:disabled):active { transform: translateY(1px); }
.power:disabled { opacity: .45; cursor: default; }
.power:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.power span { flex: 1; text-align: left; }
.pw-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font-display); font-style: normal; color: #fff; flex: none; }
.pw-icon.rainbow { background: conic-gradient(#ff5a5a, #ffc83d, #34d399, #60a5fa, #a78bfa, #f472b6, #ff5a5a); text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.pw-icon.tilt { background: linear-gradient(180deg, #ffd34d, #ff9b1f); color: #3a1d00; }
.pw-icon svg { width: 18px; height: 18px; fill: currentColor; }
.pw-tag { font: 800 10px var(--font-body); letter-spacing: .08em; padding: 3px 7px; border-radius: 999px; background: var(--gold); color: #3a1d00; white-space: nowrap; }
.tilt-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.tilt-choice .btn { font-size: 18px; padding: 14px 8px; }

.stage { flex: 1; min-height: 0; position: relative; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 5; background: rgba(8, 10, 34, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.card { width: min(320px, 100%); box-sizing: border-box; background: var(--panel); border: 1px solid rgba(255,255,255,.12); border-radius: 26px; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.logo { font: 700 52px/0.9 var(--font-display); letter-spacing: -.01em; }
.logo .m { display: block; background: linear-gradient(90deg, #ff5a5a, #ffc83d 30%, #34d399 55%, #60a5fa 78%, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #2a1f5c); }
.logo .g { display: block; background: linear-gradient(180deg, #ffe066, var(--gold) 45%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #5b2a86); }
.tag { font: 600 18px var(--font-display); }
.sub { font-size: 14px; color: var(--muted); max-width: 26ch; line-height: 1.45; margin: 0; }
.ladder { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.ladder span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 10px var(--font-display); color: #fff; }
.btn { appearance: none; border: 0; cursor: pointer; width: 100%; padding: 14px 18px; border-radius: 999px; font: 700 20px var(--font-display); color: #fff; background: linear-gradient(180deg, #4fb6ff, #2463ff); box-shadow: 0 5px 0 #173a9c, 0 10px 24px rgba(36, 99, 255, .45); transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #173a9c; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.gold { background: linear-gradient(180deg, #ffd34d, #ff9b1f); box-shadow: 0 5px 0 #b45d0a, 0 10px 24px rgba(255,155,31,.4); color: #3a1d00; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px solid rgba(255,255,255,.3); font-size: 16px; padding: 10px; }
.btn small { display: block; font: 800 11px var(--font-body); letter-spacing: .06em; opacity: .8; }
.big-score { font: 700 54px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.newbest { color: var(--gold); font: 700 22px var(--font-display); letter-spacing: .02em; }
.row { display: flex; gap: 18px; justify-content: center; font-size: 13px; color: var(--muted); }
.row b { display: block; color: var(--fg); font: 700 20px var(--font-display); }
.hint { font-size: 12px; color: var(--muted); }
.hint a { color: var(--muted); }
.online-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.online { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.25); }
.link-btn { appearance: none; background: none; border: 0; padding: 4px 2px; color: var(--gold); font: 800 13px var(--font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.rank { font: 700 17px var(--font-display); color: var(--gold); }
.board { gap: 12px; max-height: 100%; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; padding: 4px; border-radius: 999px; background: rgba(255,255,255,.07); box-sizing: border-box; }
.tab { appearance: none; border: 0; border-radius: 999px; padding: 7px; background: none; color: var(--muted); font: 700 14px var(--font-display); cursor: pointer; }
.tab.on { background: rgba(255,255,255,.14); color: var(--fg); }
.tab:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.board-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 4px; min-height: 120px; overflow-y: auto; }
.board-list li { display: grid; grid-template-columns: 26px 16px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; font-size: 14px; text-align: left; }
.board-list li.me { background: rgba(255,200,61,.14); }
.board-list .pos { color: var(--muted); font: 700 13px var(--font-display); text-align: right; }
.board-list .dot { width: 14px; height: 14px; border-radius: 50%; }
.board-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.board-list .pts { font: 700 15px var(--font-display); font-variant-numeric: tabular-nums; }
.board-list .note { display: block; text-align: center; color: var(--muted); padding: 24px 0; }
.board-you { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.board-you b { color: var(--fg); }

/* demo ad overlay (ads.js builds it; real SDKs draw their own) */
.ad-demo { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(4, 6, 20, .88); padding: 16px; }
.ad-box { width: 100%; aspect-ratio: 16 / 10; max-width: 100%; box-sizing: border-box; border-radius: 16px; border: 2px dashed rgba(255,255,255,.25); display: grid; place-items: center; color: var(--muted); font-size: 13px; padding: 12px; }
.ad-count { font: 700 40px var(--font-display); color: var(--fg); }

.toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px) scale(.9); z-index: 4; padding: 10px 20px; border-radius: 22px; background: var(--panel); border: 1px solid rgba(255,255,255,.18); font: 700 18px/1.25 var(--font-display); width: max-content; max-width: 86%; box-sizing: border-box; text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

@media (prefers-reduced-motion: reduce) { .toast, .next-ball, .btn { transition: none; } }
