:root {
  --bg: #1a1033;
  --bg2: #2a1850;
  --panel: rgba(32, 20, 64, 0.92);
  --panel-solid: #251646;
  --card: rgba(255, 255, 255, 0.07);
  --card-strong: rgba(255, 255, 255, 0.13);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff8ec;
  --muted: #c9bde6;
  --gold: #ffcf5c;
  --gold-deep: #e08a1e;
  --accent: #ff7a59;
  --good: #6fe3a0;
  --bad: #ff7d8a;
  --sky-top: #ff9a6b;
  --sky-bottom: #5b2a6e;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}
.hc {
  --panel: #000;
  --panel-solid: #000;
  --card: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.6);
  --muted: #fff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overscroll-behavior: none; }
body { overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; user-select: text; -webkit-user-select: text; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#sky {
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom) 70%, var(--bg));
  transition: background 0.8s;
}
#sky::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff8, transparent), radial-gradient(1.5px 1.5px at 70% 20%, #fff7, transparent),
    radial-gradient(2px 2px at 40% 70%, #ffe9a088, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #fff6, transparent),
    radial-gradient(1px 1px at 10% 85%, #fff8, transparent), radial-gradient(2px 2px at 60% 45%, #ffd27a77, transparent);
  animation: drift 18s linear infinite alternate;
}
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-24px); } }
.reduced #sky::after, .reduced * { animation: none !important; transition: none !important; }
#screen { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- common ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; font-size: 17px; min-height: 48px;
  background: linear-gradient(180deg, #ffe08a, var(--gold) 45%, var(--gold-deep)); color: #4a2306;
  box-shadow: 0 4px 0 #a2560c, 0 8px 18px rgba(0, 0, 0, 0.35); transition: transform 0.08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a2560c; }
.btn.secondary { background: linear-gradient(180deg, #8fd3ff, #4a9de0); color: #0d2846; box-shadow: 0 4px 0 #24599a, 0 8px 18px rgba(0, 0, 0, 0.35); }
.btn.ghost { background: var(--card-strong); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; min-height: 38px; }
.btn:disabled { filter: grayscale(0.8) brightness(0.7); cursor: not-allowed; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; font-size: 20px; flex: none;
}
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.chip img { width: 22px; height: 22px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c0, #ffcf5c 50%, #d9881c); box-shadow: 0 0 8px #ffcf5c99; vertical-align: -3px; }
.star { color: var(--gold); text-shadow: 0 0 8px #ffcf5c88; }
.star.off { color: rgba(255, 255, 255, 0.22); text-shadow: none; }
.bar { height: 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ffd27a, #ff9b3d); border-radius: inherit; transition: width 0.3s; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.page { padding: calc(14px + var(--safe-top)) 16px 16px; max-width: 640px; width: 100%; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.section-title { font-size: 18px; margin: 18px 4px 10px; color: var(--gold); }

/* ---------- top bar & nav ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-top)) 12px 8px; position: relative; z-index: 3; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--panel); border: 2px solid var(--gold); overflow: hidden; flex: none; padding: 0; }
.avatar img { width: 100%; height: 100%; }
.nav {
  display: flex; justify-content: space-around; padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--panel-solid); border-top: 1px solid var(--line); position: relative; z-index: 3;
}
.nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); flex: 1 1 0; min-width: 0; max-width: 76px; min-height: 52px; padding: 4px 2px; border-radius: 12px; position: relative; white-space: nowrap; }
.badge-dot { position: absolute; top: 6px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.fr-code { font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 3px; text-align: center; color: var(--gold); margin: 6px 0 10px; user-select: all; }
.fr-row .rm { background: none; border: 0; color: var(--muted); min-width: 36px; min-height: 36px; border-radius: 10px; font-size: 18px; }
.fr-row .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
#lb-scope { margin-bottom: 8px; }
[hidden] { display: none !important; }

/* ---------- 0.21 UI polish ---------- */
/* Wide screens: the top bar and tab bar line up with the content column. */
@media (min-width: 700px) {
  .topbar { padding-left: max(12px, calc((100% - 640px) / 2)); padding-right: max(12px, calc((100% - 640px) / 2)); }
  .nav { padding-left: max(8px, calc((100% - 660px) / 2)); padding-right: max(8px, calc((100% - 660px) / 2)); border-radius: 22px 22px 0 0; }
  .nav button { max-width: none; font-size: 13px; }
}
/* Slim, warm scrollbars instead of the grey system ones. */
.scroll { scrollbar-width: thin; scrollbar-color: rgba(255, 233, 176, 0.35) transparent; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: rgba(255, 233, 176, 0.3); border-radius: 8px; }
/* Screens fade in softly when switching tabs. */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.page, .map { animation: rise 0.28s ease-out both; }
.reduced .page, .reduced .map { animation: none; }
/* Map: the next level is always one tap away. */
.play-fab { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-bottom)); z-index: 4; display: inline-flex; align-items: center; gap: 10px; padding: 10px 22px 10px 16px; border: 0; border-radius: 999px; font: inherit; font-weight: 700; font-size: 17px; color: #4a2306; background: linear-gradient(#ffe07a, #ff9d2e); box-shadow: 0 5px 0 #a8560f, 0 10px 28px rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 190, 90, 0.55); cursor: pointer; white-space: nowrap; }
.play-fab:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 2px 0 #a8560f, 0 6px 18px rgba(0, 0, 0, 0.35); }
.play-fab .sub { display: block; font-size: 12px; font-weight: 600; opacity: 0.75; line-height: 1.1; text-align: left; }
.play-fab .tri { width: 0; height: 0; border-left: 14px solid #4a2306; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
.map { padding-bottom: 70px; }
/* Map: levels that introduce something new. */
.node .new { position: absolute; top: -10px; right: -14px; background: #ff5ca8; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
/* Map realms */
.realm-seg { margin: 6px 14px 12px; }
.realm-seg button { font-size: 14px; }
.realm-seg button:disabled { opacity: 0.55; }
.chapter.collapsed { margin-bottom: 10px; }
.chapter.collapsed .chapter-head { border-radius: 18px; }
/* Win screen score counts up. */
.score-count { font-variant-numeric: tabular-nums; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: grid; gap: 8px; justify-items: center; text-align: center; }
.theme.on { border-color: var(--gold); }
.theme .swatch { position: relative; width: 96px; height: 64px; border-radius: 10px; background: conic-gradient(var(--a) 0 25%, var(--b) 0 50%, var(--a) 0 75%, var(--b) 0) 0 0 / 32px 32px, #1a1033; box-shadow: inset 0 0 0 2px var(--l); }
.theme .swatch i { position: absolute; width: 4px; height: 4px; border-radius: 50%; top: 18px; left: 24px; }
.theme .swatch i + i { top: 40px; left: 66px; }
.acct-buttons { display: grid; gap: 8px; margin-bottom: 8px; }
.btn.prov { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.prov-apple { background: #000; color: #fff; box-shadow: none; }
.prov-google { background: #fff; color: #1f1f1f; box-shadow: none; }
.prov-gamecenter { background: linear-gradient(90deg, #7b5cff, #ff5ca8); color: #fff; box-shadow: none; }
.prov-playgames { background: #01875f; color: #fff; box-shadow: none; }
.prov-email { background: var(--card); color: inherit; box-shadow: none; border: 1px solid var(--line); }
.gsi-slot { display: flex; justify-content: center; min-height: 44px; }
.acct-methods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.acct-methods .chip { display: inline-flex; align-items: center; gap: 6px; }
.acct-methods .rm { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 0 2px; min-width: 24px; min-height: 24px; }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { background: var(--bad); color: #fff; box-shadow: none; }
.fld { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
.fld input { margin-top: 4px; width: 100%; box-sizing: border-box; }
button.link { background: none; border: 0; color: var(--gold); text-decoration: underline; font: inherit; padding: 4px; min-height: 32px; }
.nav button .ic { font-size: 22px; line-height: 1; }
.nav button.on { color: var(--gold); background: var(--card); }
.badge { position: absolute; top: 2px; right: 10px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px; font-weight: 700; }

/* ---------- splash ---------- */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center; }
.logo { font-size: clamp(46px, 13vw, 84px); font-weight: 700; letter-spacing: 1px; line-height: 1;
  background: linear-gradient(180deg, #fff6d0, #ffcf5c 45%, #ff8a3d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #7a2c10) drop-shadow(0 0 24px #ffb34788); }
.tagline { color: #ffe9d0; font-size: 18px; max-width: 320px; }
.splash .hero img { width: 170px; height: 170px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px); } }
.loading { width: 220px; }

/* ---------- map ---------- */
.map { position: relative; }
.chapter { position: relative; margin: 0 auto 18px; max-width: 520px; }
.chapter-head {
  margin: 0 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; position: relative; z-index: 2;
}
.chapter-head img { width: 56px; height: 56px; }
.chapter-head h2 { font-size: 20px; }
.chapter-path { position: relative; margin-top: -8px; }
.chapter-path svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.node {
  position: absolute; width: 60px; height: 60px; margin-left: -30px; border-radius: 50%; border: 3px solid #fff6; display: grid; place-items: center;
  font-weight: 700; font-size: 20px; color: #fff; background: radial-gradient(circle at 35% 30%, #8a7bd8, #4a3a99); box-shadow: 0 4px 0 #2a1e60, 0 6px 14px #0006;
}
.node.done { background: radial-gradient(circle at 35% 30%, #ffe9a0, #ffb347 55%, #d96d1c); color: #5a2306; border-color: #fff8; box-shadow: 0 4px 0 #9a4a0c, 0 0 18px #ffb34766; }
.node.current { background: radial-gradient(circle at 35% 30%, #a8f0ff, #36b4ef 55%, #1673b8); border-color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.node.locked { background: #3a3155; color: #8a80a8; box-shadow: 0 3px 0 #1d1733; border-color: #fff2; }
.node.boss { width: 76px; height: 76px; margin-left: -38px; border-width: 4px; }
.node.boss img { position: absolute; width: 44px; height: 44px; top: -30px; }
.node .stars { position: absolute; bottom: -18px; font-size: 14px; white-space: nowrap; letter-spacing: -1px; }
@keyframes pulse { 50% { box-shadow: 0 4px 0 #0d4f84, 0 0 0 10px #36b4ef44; } }
.event-banner { margin: 6px 14px 14px; padding: 12px 14px; border-radius: var(--radius); background: linear-gradient(90deg, #ff8a3d, #b0367a); display: flex; align-items: center; gap: 10px; border: 1px solid #fff4; }
.event-banner b { font-size: 16px; }

/* ---------- game ---------- */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 620px; width: 100%; margin: 0 auto; }
.hud { display: flex; align-items: stretch; gap: 8px; padding: calc(8px + var(--safe-top)) 10px 6px; }
.hud-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 76px; }
.hud-box .big { font-size: 28px; font-weight: 700; line-height: 1; }
.hud-box .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.hud-box.warn .big { color: var(--bad); animation: pulse-text 0.8s ease-in-out infinite; }
@keyframes pulse-text { 50% { transform: scale(1.12); } }
.scorebox { flex: 1; align-items: stretch; }
.scorebox .top { display: flex; justify-content: space-between; align-items: baseline; }
.starbar { position: relative; height: 12px; margin-top: 6px; }
.starbar .mark { position: absolute; top: -6px; font-size: 16px; transform: translateX(-50%); }
.goals { display: flex; gap: 6px; padding: 0 10px 6px; flex-wrap: wrap; justify-content: center; }
.goal { display: flex; align-items: center; gap: 4px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 17px; }
.goal img { width: 30px; height: 30px; }
.goal.done { border-color: var(--good); color: var(--good); }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 8px; position: relative; }
.board-wrap canvas { display: block; touch-action: none; border-radius: 14px; }
.target-banner { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 5; }
.dock { display: flex; align-items: center; gap: 8px; padding: 6px 10px calc(10px + var(--safe-bottom)); }
.friend { position: relative; width: 72px; height: 72px; border-radius: 50%; border: 0; padding: 0; background: var(--panel); flex: none; }
.friend img { position: absolute; inset: 6px; width: 60px; height: 60px; }
.friend svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.friend.ready { animation: ready 1s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 6px #ffcf5c55, 0 0 26px #ffcf5c; } }
.bubble { position: absolute; bottom: 82px; left: 8px; background: #fff; color: #3a1a4a; padding: 8px 12px; border-radius: 14px; font-weight: 600; font-size: 14px; max-width: 220px; z-index: 6; box-shadow: 0 6px 16px #0006; pointer-events: none; }
.bubble::after { content: ''; position: absolute; left: 24px; bottom: -8px; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; }
.boosters { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding: 4px 2px; scrollbar-width: none; }
.boosters::-webkit-scrollbar { display: none; }
.booster { position: relative; flex: none; width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 24px; display: grid; place-items: center; }
.booster .n { position: absolute; right: -4px; bottom: -4px; background: var(--gold); color: #4a2306; font-size: 12px; font-weight: 700; border-radius: 9px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 4px; }
.booster.empty { opacity: 0.55; }
.booster.empty .n { background: #8fd3ff; color: #0d2846; }
.booster.on { border-color: var(--gold); box-shadow: 0 0 0 3px #ffcf5c88; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(8, 4, 20, 0.62); backdrop-filter: blur(3px); animation: fade 0.18s ease-out; }
.modal .sheet { width: 100%; max-width: 420px; max-height: calc(100% - 20px); overflow-y: auto; background: linear-gradient(180deg, #3a2470, #23153f); border: 2px solid #ffffff22; border-radius: 26px; padding: 20px 18px; box-shadow: 0 20px 60px #000a; animation: pop 0.26s cubic-bezier(.2,1.4,.4,1); position: relative; }
.modal .sheet.wide { max-width: 560px; }
.modal h2 { text-align: center; font-size: 26px; margin-bottom: 8px; }
.modal .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.modal .close { position: absolute; top: 10px; right: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.big-stars { display: flex; justify-content: center; gap: 10px; font-size: 54px; margin: 6px 0; }
.big-stars span { transform: scale(0); transition: transform 0.35s cubic-bezier(.2,1.6,.4,1); }
.big-stars span.in { transform: scale(1); }
.big-stars span:nth-child(2) { font-size: 66px; margin-top: -12px; }
.rewards { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.goal-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.goal-list .goal { justify-content: flex-start; border-radius: 14px; font-size: 16px; padding: 6px 12px 6px 6px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row input[type=range] { width: 46%; accent-color: var(--gold); }
.switch { width: 52px; height: 30px; border-radius: 15px; background: #ffffff33; border: 0; position: relative; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch.on { background: var(--good); }
.switch.on::after { left: 25px; }
.dialog { display: flex; gap: 14px; align-items: flex-start; }
.dialog img { width: 96px; height: 96px; flex: none; }
.dialog .who { color: var(--gold); font-weight: 700; margin-bottom: 4px; }
.dialog .say { font-size: 17px; line-height: 1.4; }
.pre-boosts { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.pre-boosts .booster { width: 64px; height: 64px; font-size: 28px; }

/* ---------- lists ---------- */
.grid-chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.char-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; position: relative; }
.char-card img { width: 96px; height: 96px; }
.char-card.locked img { filter: brightness(0) opacity(0.5); }
.char-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px #ffcf5c66; }
.char-card .nm { font-weight: 700; }
.char-card .sp { font-size: 12px; color: var(--muted); }
.quest { display: flex; align-items: center; gap: 12px; }
.quest .txt { flex: 1; }
.quest .bar { margin-top: 6px; }
.ach { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ach:last-child { border-bottom: 0; }
.ach .medal { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #ffffff1a; flex: none; }
.ach.got .medal { background: radial-gradient(circle at 35% 35%, #fff2b0, #ffcf5c 60%, #d9881c); }
.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.inv .item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.inv .item .head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.inv .item .ic { font-size: 28px; }
.inv .item p { margin: 0; font-size: 13px; color: var(--muted); flex: 1; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar .day { border-radius: 12px; background: var(--card); padding: 6px 2px; text-align: center; font-size: 11px; border: 1px solid transparent; }
.calendar .day b { display: block; font-size: 18px; }
.calendar .day.got { opacity: 0.45; }
.calendar .day.today { border-color: var(--gold); background: #ffcf5c22; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats div { background: var(--card); border-radius: 12px; padding: 8px 10px; }
.stats b { display: block; font-size: 20px; }
textarea.code { width: 100%; min-height: 80px; border-radius: 12px; background: #0006; color: var(--text); border: 1px solid var(--line); padding: 8px; font-size: 12px; }
input.name { width: 100%; border-radius: 12px; background: #0006; color: var(--text); border: 1px solid var(--line); padding: 10px; font-size: 17px; }
.help-list { display: grid; gap: 8px; }
.help-list .hl { display: flex; gap: 10px; align-items: center; }
.help-list img { width: 44px; height: 44px; flex: none; }
.frames { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- leaderboard ---------- */
.lb-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lb-row:last-child { border-bottom: 0; }
.lb-row .rk { font-weight: 700; color: var(--muted); }
.lb-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-row .val { color: var(--gold); font-weight: 600; white-space: nowrap; }
.lb-row.me { background: #ffcf5c22; border-radius: 10px; }
.lb-row.top1 .rk { color: #ffd23f; } .lb-row.top2 .rk { color: #dfe6f2; } .lb-row.top3 .rk { color: #e8a36a; }
.seg { display: flex; gap: 6px; background: var(--card); padding: 4px; border-radius: 999px; }
.seg button { flex: 1; border: 0; border-radius: 999px; padding: 8px 10px; background: none; font-weight: 600; min-height: 40px; }
.seg button.on { background: var(--gold); color: #4a2306; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; }
.consent input { width: 22px; height: 22px; flex: none; accent-color: var(--gold); }
#rank-note { text-align: center; min-height: 22px; color: var(--gold); font-weight: 600; }

/* ---------- toasts ---------- */
#toast-root { position: fixed; left: 0; right: 0; top: calc(12px + var(--safe-top)); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #fff; color: #3a1a4a; padding: 10px 16px; border-radius: 14px; font-weight: 600; box-shadow: 0 8px 24px #0007; animation: pop 0.25s ease-out; max-width: 90vw; }

@media (min-width: 900px) {
  .hud, .goals, .dock { padding-left: 0; padding-right: 0; }
}
@media (max-height: 640px) {
  .hud-box .big { font-size: 22px; }
  .goal img { width: 24px; height: 24px; }
  .friend { width: 60px; height: 60px; }
  .friend img { inset: 5px; width: 50px; height: 50px; }
  .booster { width: 46px; height: 46px; font-size: 21px; }
}
@media (max-width: 440px) {
  .dock { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .friend { width: 62px; height: 62px; }
  .friend svg { width: 62px; height: 62px; }
  .friend img { inset: 5px; width: 52px; height: 52px; }
  .booster { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; }
  .boosters { gap: 5px; }
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* Leaderboard: switch levels in place without a flash */
.lb-stepper { justify-content: center; margin-top: 10px; }
.lb-stepper b { min-width: 110px; text-align: center; font-variant-numeric: tabular-nums; }
.lb-stepper .icon-btn:disabled { opacity: 0.35; cursor: default; }
.lb-list { min-height: 120px; transition: opacity 0.15s; }
.lb-list.is-loading { opacity: 0.55; }

/* Achievement tiers */
.ach .tier { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 2px 7px; border-radius: 999px; vertical-align: 2px; background: #ffffff1a; color: var(--muted); }
.tier-bronze .tier { color: #e8a36a; } .tier-silver .tier { color: #dfe6f2; } .tier-gold .tier { color: #ffd23f; }
.tier-legend .tier { color: #fff; background: linear-gradient(90deg, #b06cff, #ff6fc1); }
.ach.got.tier-bronze .medal { background: radial-gradient(circle at 35% 35%, #ffd6b0, #c97a3c); }
.ach.got.tier-silver .medal { background: radial-gradient(circle at 35% 35%, #ffffff, #9aa6bb); }
.ach.got.tier-legend .medal { background: radial-gradient(circle at 35% 35%, #f3d6ff, #8a4be0); }

/* Leaderboard device and verified marks */
.lb-dev { display: inline-flex; gap: 3px; margin-left: 6px; color: var(--muted); vertical-align: -2px; }
.lb-ok { display: inline-flex; margin-left: 4px; color: var(--good); vertical-align: -2px; }
