/* Tumble Bar — floating minimal dioramas in fog. Day: a pastel sky-to-peach
   dawn; night: deep blue into violet with stardust. Glass controls, rounded
   geometric type, tabular numbers. Motion: transform and opacity only. */

:root {
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text: #1c2142;
  --muted: #4d5577;
  --line: rgba(28, 33, 66, 0.12);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-line: rgba(255, 255, 255, 0.75);
  --shadow: 0 18px 40px -22px rgba(42, 46, 96, 0.55), 0 2px 8px -4px rgba(42, 46, 96, 0.25);
  --coral: #ef5f4b;
  --accent: #c23d2b; /* coral, deepened until white text on it reaches 4.5:1 */
  --accent-soft: rgba(239, 95, 75, 0.14);
  --gold: #8a5d00; /* amber text, 5:1 on the light glass */
  --gold-bright: #f5b82e;
  --blue: #2f6fe0;
  --violet: #7c4ddc;
  --ok: #1d7a55;
  --ca-accent: #c23d2b; /* the accounts SDK's sheets and chip */
  --r-btn: 16px;
  --r-card: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --bar-h: 64px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #eef0ff;
  --muted: #b2b9dd;
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(30, 32, 76, 0.56);
  --glass-strong: rgba(34, 36, 84, 0.9);
  --glass-line: rgba(255, 255, 255, 0.13);
  --shadow: 0 22px 50px -24px rgba(0, 0, 0, 0.8), 0 2px 10px -4px rgba(0, 0, 0, 0.5);
  --accent-soft: rgba(255, 140, 120, 0.16);
  --gold: #ffd166;
  --blue: #8db3ff;
  --violet: #c4a6ff;
  --ok: #6ee0ae;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  background: #d9e7f4;
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] body { background: #17183f; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; border-radius: 10px; }

/* ---- sky, stage, veil ---- */
.sky { position: fixed; inset: 0; z-index: -3; pointer-events: none; }
.sky > div { position: absolute; inset: 0; transition: opacity 0.3s ease; }
.sky-day { background: linear-gradient(180deg, #c6e1f6 0%, #dce9f3 42%, #ffe2cf 100%); }
.sky-night { opacity: 0; background: radial-gradient(120% 70% at 50% 0%, #2a2d78 0%, transparent 70%), linear-gradient(180deg, #121540 0%, #1e1a52 50%, #33205a 100%); }
.stardust {
  opacity: 0;
  background-image: radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.8), transparent 60%), radial-gradient(1px 1px at 72% 12%, rgba(255,255,255,.65), transparent 60%),
    radial-gradient(1.5px 1.5px at 35% 64%, rgba(255,255,255,.5), transparent 60%), radial-gradient(1px 1px at 86% 48%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 55% 30%, rgba(255,255,255,.45), transparent 60%), radial-gradient(1.5px 1.5px at 20% 86%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1px 1px at 93% 80%, rgba(255,255,255,.55), transparent 60%), radial-gradient(1px 1px at 46% 92%, rgba(255,255,255,.35), transparent 60%);
  background-size: 360px 360px;
}
:root[data-theme="dark"] .sky-night, :root[data-theme="dark"] .stardust { opacity: 1; }
.stage { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body:not(.in-game) .stage { pointer-events: none; }
.veil { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,0) 30%, rgba(255,244,236,.55) 100%); transition: opacity .3s; }
:root[data-theme="dark"] .veil { background: linear-gradient(180deg, rgba(18,20,60,0) 30%, rgba(24,18,60,.7) 100%); }
body.in-game .veil, body.landing .veil { opacity: 0; }
/* behind lists the diorama steps back */
body[data-screen="levels"] .veil, body[data-screen="daily"] .veil, body[data-screen="board"] .veil, body[data-screen="worlds"] .veil { background: rgba(236, 240, 248, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
:root[data-theme="dark"] body[data-screen="levels"] .veil, :root[data-theme="dark"] body[data-screen="daily"] .veil, :root[data-theme="dark"] body[data-screen="board"] .veil, :root[data-theme="dark"] body[data-screen="worlds"] .veil { background: rgba(20, 20, 58, .62); }
body.landing .bar, body.landing .screens, body.booting .bar, body.booting .screens { visibility: hidden; }
body.no-gl .stage { display: none; }

/* ---- the top bar ---- */
.bar {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 14px) 10px calc(var(--safe-l) + 14px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 10px -4px rgba(40,30,80,.45); flex: none; }
.back:not([hidden]) + .brand .brand-icon { display: none; }
.brand-text { min-width: 0; }
.brand-title { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 14px;
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--text);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow); transition: transform .08s ease, filter .12s ease;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .dot { fill: currentColor; stroke: none; }
.icon-btn:hover { filter: brightness(1.04); }
.icon-btn:active { transform: scale(.96); }
.chip-slot { display: inline-grid; place-items: center; min-width: 40px; height: 44px; }
@media (max-width: 380px) { .brand-sub { display: none; } }
@media (max-width: 360px) { .brand-icon { display: none; } .brand-title { font-size: 17px; } .bar { gap: 6px; } }
/* a screen's title may take two lines rather than lose its end */
.back:not([hidden]) + .brand .brand-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 18px; }

/* ---- screens ---- */
.screens { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; overflow: auto; overscroll-behavior: contain;
  padding: calc(var(--safe-t) + var(--bar-h) + 8px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 16px); }
.screen.game { pointer-events: none; overflow: hidden; padding: 0; }
.screen.enter { animation: screen-in .25s cubic-bezier(.2,.8,.2,1) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px); } }
h2 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.01em; }
h3 { margin: 0; font-size: 17px; font-weight: 700; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: var(--r-btn); border: 1px solid var(--glass-line);
  background: var(--glass); color: var(--text); font-weight: 700; font-size: 16px; line-height: 1.15;
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  transition: transform .08s ease, filter .12s ease, background-color .12s ease; box-shadow: var(--shadow);
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 12px 24px -14px var(--accent); }
.btn.soft { background: var(--glass); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--accent); }
:root[data-theme="dark"] .btn.ghost { color: #ffb4a6; }

.card {
  border-radius: var(--r-card); border: 1px solid var(--glass-line); background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.35); backdrop-filter: blur(16px) saturate(1.35); box-shadow: var(--shadow); color: var(--text);
}
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); font-weight: 700; font-size: 15px; }
.star { width: 18px; height: 18px; fill: rgba(120, 120, 150, .3); }
.star.on { fill: var(--gold-bright); filter: drop-shadow(0 1px 0 rgba(150, 90, 0, .45)); }
.lock { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.badge-ic { width: 18px; height: 18px; fill: #6d5bd0; }
.badge-ic .tick { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .badge-ic { fill: #a993ff; }
:root[data-theme="dark"] .badge-ic .tick { stroke: #1c1d45; }

/* ---- main menu: four big cards in the thumb zone, the diorama above ---- */
.menu { display: flex; flex-direction: column; justify-content: flex-end; }
.menu-cards { display: grid; gap: 10px; width: 100%; max-width: 760px; margin: 0 auto; }
.card.big { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 16px; text-align: left; transition: transform .08s ease, filter .12s ease; }
.card.big:hover { filter: brightness(1.04); }
.card.big:active { transform: scale(.96); }
.card-icon { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; }
.card-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.c-continue .card-icon { background: linear-gradient(145deg, #f37a63, #c23d2b); }
.c-continue .card-icon svg { fill: currentColor; stroke-width: 2; }
.c-campaign .card-icon { background: linear-gradient(145deg, #7aa7f2, #3d5fc9); }
.c-daily .card-icon { background: linear-gradient(145deg, #f7c95b, #d48a15); }
.c-board .card-icon { background: linear-gradient(145deg, #a28cf2, #6a4fd0); }
.card-text { display: grid; gap: 2px; min-width: 0; }
.card-title { font-weight: 750; font-size: 18px; }
.card-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daily-chips { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: var(--line); font-size: 13px; font-weight: 650; color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .55; }
.chip.live .dot { background: var(--gold-bright); opacity: 1; }
.chip.done .dot { background: var(--ok); opacity: 1; }
.chip.streak { background: var(--accent-soft); }
@media (min-width: 640px) { .menu-cards { grid-template-columns: 1fr 1fr; } .card.big { min-height: 88px; } }
@media (orientation: landscape) and (max-height: 520px) { .menu { justify-content: center; align-items: flex-end; } .menu-cards { grid-template-columns: 1fr 1fr; max-width: 640px; margin: 0 0 0 auto; } .card.big { min-height: 64px; } }

/* ---- worlds: a horizontal pager ---- */
.worlds { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.pager-wrap { position: relative; display: flex; align-items: center; }
.pager { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px calc(50% - min(39vw, 160px)); scrollbar-width: none; flex: 1; }
.pager::-webkit-scrollbar { display: none; }
.pager-arrow { position: absolute; z-index: 1; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--glass-line); background: var(--glass-strong); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow); }
.pager-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pager-arrow.prev { left: 0; }
.pager-arrow.next { right: 0; }
@media (pointer: coarse) { .pager-arrow { display: none; } }
.world-card {
  scroll-snap-align: center; flex: none; width: min(78vw, 320px); min-height: 360px; border-radius: 24px; padding: 18px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; text-align: left; color: #fff; border: 1px solid rgba(255,255,255,.35);
  box-shadow: var(--shadow); transition: transform .08s ease, filter .12s ease;
}
.world-card:active { transform: scale(.97); }
.world-card.w1 { background: linear-gradient(160deg, #f6a58b 0%, #b9b4e8 55%, #6f86d6 100%); }
.world-card.w2 { background: linear-gradient(160deg, #f7cf72 0%, #e59a3b 50%, #9a5a2a 100%); }
.world-card.w3 { background: linear-gradient(160deg, #8fd3a8 0%, #4f9fd0 55%, #6a4fc6 100%); }
.world-card.w4 { background: linear-gradient(160deg, #77e3dc 0%, #5d7ee0 50%, #d24ba8 100%); }
.world-card.w5 { background: linear-gradient(160deg, #ffad6b 0%, #c75b8f 50%, #3b2f86 100%); }
.world-card.locked { filter: saturate(.35) brightness(.92); }
.world-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(20,16,50,.55)); pointer-events: none; }
.world-card > * { position: relative; z-index: 1; }
.world-art { position: absolute !important; inset: 0 0 auto 0; height: 62%; z-index: 0 !important; }
.wa-tile, .wa-block { position: absolute; border-radius: 10px; }
.wa-tile { width: 74px; height: 74px; background: rgba(255,255,255,.85); box-shadow: 0 10px 0 rgba(255,255,255,.35), 0 26px 30px -12px rgba(30,20,70,.45); transform: rotateX(56deg) rotateZ(45deg); }
.wa-tile.a { left: 32%; top: 34%; }
.wa-tile.b { left: 52%; top: 46%; }
.wa-tile.c { left: 12%; top: 46%; }
.wa-block { width: 40px; height: 80px; left: calc(32% + 18px); top: calc(34% - 44px); background: linear-gradient(90deg, #ff7a63, #e04c38); border-radius: 8px; box-shadow: inset -10px 0 0 rgba(0,0,0,.12), 0 18px 20px -10px rgba(60,10,10,.5); animation: wa-bob 6s ease-in-out infinite; }
.w2 .wa-tile.b, .w2 .wa-tile.c { background: rgba(255, 210, 120, .95); }
.w3 .wa-tile.b { background: rgba(170, 200, 255, .95); }
.w4 .wa-tile.c { background: rgba(140, 255, 245, .9); }
.w5 .wa-tile.a { background: rgba(255, 170, 110, .95); }
@keyframes wa-bob { 50% { transform: translateY(-6px); } }
.world-num { font-size: 15px; font-weight: 800; opacity: .9; }
.world-name { font-size: 25px; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; text-shadow: 0 2px 10px rgba(20,10,50,.35); }
.world-stars { display: inline-flex; align-items: center; gap: 6px; font-weight: 750; font-size: 16px; }
.world-lock { display: flex; align-items: center; gap: 8px; font-size: 14px; background: rgba(20,16,50,.45); padding: 8px 10px; border-radius: 12px; }
.pager-dots { display: flex; justify-content: center; gap: 8px; }
.pager-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .35; transition: transform .2s, opacity .2s; }
.pager-dots span.on { opacity: 1; transform: scale(1.3); background: var(--coral); }

/* ---- levels ---- */
.levels { display: flex; flex-direction: column; gap: 14px; max-width: 760px; margin: 0 auto; }
.levels-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) and (orientation: portrait) { .level-grid { grid-template-columns: repeat(3, 1fr); } }
.level-btn {
  position: relative; min-height: 104px; border-radius: 18px; border: 1px solid var(--glass-line); background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow);
  display: grid; grid-template-rows: auto auto 1fr; justify-items: center; align-content: center; gap: 4px; padding: 10px 6px; transition: transform .08s ease, filter .12s ease;
}
.level-btn:hover { filter: brightness(1.04); }
.level-btn:active { transform: scale(.96); }
.lv-num { font-size: 24px; font-weight: 800; line-height: 1; }
.lv-name { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.2; max-width: 100%; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lv-stars { display: flex; gap: 2px; }
.lv-stars .star { width: 16px; height: 16px; }
.lv-badge { position: absolute; top: 6px; right: 6px; }
.lv-lock { color: var(--muted); }
.level-btn.locked { opacity: .6; }
.level-btn.locked .lv-num { color: var(--muted); }

/* ---- daily ---- */
.daily { display: flex; flex-direction: column; gap: 14px; max-width: 760px; margin: 0 auto; }
.daily-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
.daily-head p { margin: 2px 0 0; }
.daily-meta { display: grid; justify-items: end; gap: 4px; }
.flame { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: linear-gradient(135deg, #ffcb52, #f0654f); }
.daily-cards { display: grid; gap: 10px; }
@media (min-width: 900px) { .daily-cards { grid-template-columns: repeat(3, 1fr); } }
.daily-card { border-radius: var(--r-card); border: 1px solid var(--glass-line); background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 12px; position: relative; overflow: hidden; }
.daily-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #6cc09a; }
.daily-card.medium::before { background: #f2b647; }
.daily-card.hard::before { background: #ef5f4b; }
.dc-info p { margin: 2px 0 0; }
.dc-status { font-weight: 700; font-size: 15px; }
.dc-status.done { color: var(--ok); }
.dc-status.running, .dc-status.open, .dc-status.elsewhere { color: var(--gold); }
.dc-result { font-weight: 750; font-size: 18px; }
.dc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dc-actions .btn { padding: 0 10px; font-size: 15px; }

/* ---- leaderboard ---- */
.board { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); align-self: flex-start; flex-wrap: wrap; }
.seg button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; color: var(--muted); transition: background-color .15s, color .15s; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--glass-strong); color: var(--text); box-shadow: 0 2px 8px -3px rgba(30,30,80,.35); }
.seg.small button { min-height: 40px; padding: 0 12px; font-size: 15px; }
.board-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.select select { min-height: 44px; border-radius: 14px; border: 1px solid var(--glass-line); background: var(--glass-strong); padding: 0 12px; }
.board-list { min-height: 200px; transition: opacity .2s; }
.board-list.loading { opacity: .5; }
.board-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: calc(100dvh - 260px); overflow: auto; position: relative; }
.board-rows li { display: grid; grid-template-columns: 2.2em 36px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line); }
.board-rows.daily li { grid-template-columns: 2.2em 36px minmax(0, 1fr) auto auto 1.4em; }
.board-rows li.me { background: var(--accent-soft); border-color: rgba(239,95,75,.45); font-weight: 750; position: sticky; bottom: 0; top: 0; z-index: 1; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.board-rows li.fresh { animation: fresh .6s cubic-bezier(.2,.8,.2,1); }
@keyframes fresh { 0% { transform: scale(.96); box-shadow: 0 0 0 0 rgba(239,95,75,.6); } 60% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(239,95,75,0); } }
.br-rank { color: var(--muted); font-weight: 700; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; background: hsl(var(--hue, 220) 46% 46%); }
.br-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-name small { color: var(--muted); font-weight: 500; }
.heart { color: #e8577a; margin-left: 4px; }
.br-val { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.br-val .star, .br-val .badge-ic { width: 16px; height: 16px; }

/* ---- the game's HUD ---- */
.hud-top {
  position: fixed; z-index: 4; top: 0; left: 0; right: 0; pointer-events: none;
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 12px) 8px calc(var(--safe-l) + 12px);
}
.hud-top > * { pointer-events: auto; }
.hud-btn {
  position: relative; width: 48px; height: 48px; border-radius: 16px; border: 1px solid var(--glass-line); background: var(--glass); color: var(--text);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); box-shadow: var(--shadow);
  display: grid; place-items: center; transition: transform .08s ease, filter .12s ease, opacity .15s;
}
.hud-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hud-btn:hover { filter: brightness(1.04); }
.hud-btn:active { transform: scale(.96); }
.hud-btn[disabled] { opacity: .4; cursor: default; }
.hud-btn .badge { position: absolute; top: -5px; right: -5px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--glass-strong); }
.hud-btn.empty .badge { background: #7b809a; }
.hud-info { justify-self: center; text-align: center; min-width: 0; max-width: 100%; padding: 6px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.hud-name { font-weight: 750; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-row { display: flex; align-items: baseline; justify-content: center; gap: 12px; flex-wrap: wrap; row-gap: 0; }
.hud-steps { display: inline-flex; align-items: baseline; gap: 6px; }
.hud-steps .num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.hud-steps .lbl { font-size: 13px; color: var(--muted); }
.hud-thr { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-clock { font-size: 18px; font-weight: 800; color: var(--accent); }
:root[data-theme="dark"] .hud-clock { color: #ffb4a6; }
.hud-tools {
  position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px);
  display: flex; gap: 10px; padding: 8px; border-radius: 22px; background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); pointer-events: auto;
}
.hud-tools .hud-btn { box-shadow: none; background: transparent; border-color: transparent; }
@media (orientation: landscape) and (min-width: 560px) {
  .hud-tools { left: auto; right: calc(var(--safe-r) + 12px); bottom: auto; top: 50%; transform: translateY(-50%); flex-direction: column; }
}
@media (max-width: 340px) { .hud-tools { gap: 4px; padding: 6px; } }
.pad { position: fixed; z-index: 4; left: calc(var(--safe-l) + 14px); bottom: calc(var(--safe-b) + 92px); display: grid; grid-template-columns: 64px 64px; gap: 6px; transform: rotate(0deg); pointer-events: auto; }
.pad .left { order: 1; } .pad .up { order: 2; } .pad .down { order: 3; } .pad .right { order: 4; }
.pad-btn { width: 64px; height: 64px; border-radius: 20px; border: 1px solid var(--glass-line); background: var(--glass); color: var(--text); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); display: grid; place-items: center; touch-action: none; transition: transform .08s; }
.pad-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pad-btn:active { transform: scale(.94); }
@media (orientation: landscape) and (min-width: 560px) { .pad { bottom: calc(var(--safe-b) + 14px); } }
.hud-msg { position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 92px); max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--glass-line); box-shadow: var(--shadow); font-weight: 650; text-align: center; animation: msg-in .25s cubic-bezier(.2,.8,.2,1); }
@keyframes msg-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.tipcard { position: fixed; z-index: 4; left: 50%; top: calc(var(--safe-t) + 92px); transform: translateX(-50%); width: min(92vw, 440px); display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--glass-line); box-shadow: var(--shadow); pointer-events: auto; animation: msg-in .3s cubic-bezier(.2,.8,.2,1); transition: opacity .25s, transform .25s; }
.tipcard.out { opacity: 0; transform: translate(-50%, -8px); }
.tip-art { flex: none; width: 44px; height: 44px; border-radius: 14px; position: relative; background: linear-gradient(145deg, #f37a63, #c23d2b); overflow: hidden; }
.tip-art::after { content: ""; position: absolute; left: 15px; top: 8px; width: 14px; height: 28px; border-radius: 4px; background: #fff; transform-origin: 50% 100%; animation: tip-tip 1.6s ease-in-out infinite; }
.tip-art.fragile { background: linear-gradient(145deg, #f7c95b, #c7891f); }
.tip-art.soft { background: linear-gradient(145deg, #79a6ff, #2f6fe0); }
.tip-art.heavy { background: linear-gradient(145deg, #b394ff, #7c4ddc); }
.tip-art.teleport, .tip-art.teleport2 { background: linear-gradient(145deg, #4fe0d8, #d24ba8); }
.tip-art.split { background: linear-gradient(145deg, #ffb06b, #ef6f2a); }
.tip-art.split::after { width: 12px; height: 12px; top: 16px; animation: tip-split 1.6s ease-in-out infinite; }
@keyframes tip-tip { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: translate(6px, 0) rotate(90deg); } }
@keyframes tip-split { 0%, 30% { transform: translateX(0); box-shadow: 0 0 0 #fff; } 70%, 100% { transform: translateX(-8px); box-shadow: 16px 0 0 #fff; } }
body.split .stage { cursor: pointer; }

/* ---- toast ---- */
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%); max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 16px; background: rgba(28, 33, 66, .92); color: #fff; font-weight: 600; text-align: center; box-shadow: var(--shadow); animation: msg-in .25s; transition: opacity .3s; }
.toast.out { opacity: 0; }

/* ---- sheets ---- */
dialog.sheet {
  border: 1px solid var(--glass-line); border-radius: 24px; padding: 0; width: min(94vw, 460px); max-height: min(88dvh, 760px);
  background: var(--glass-strong); color: var(--text); box-shadow: 0 40px 90px -30px rgba(10, 10, 40, .6);
  -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3); overflow: hidden;
  animation: sheet-in .3s cubic-bezier(.2,.8,.2,1);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet.closing { animation: sheet-out .16s ease forwards; }
dialog.sheet::backdrop { background: rgba(14, 16, 44, .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@media (max-width: 560px) {
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); }
  dialog.sheet.small, dialog.sheet.result { margin: auto; width: min(94vw, 420px); border-radius: 24px; padding-bottom: 0; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 18px 6px 20px; }
.sheet-body { padding: 8px 20px 20px; overflow: auto; }
.sheet-body h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet-body h3:first-child { margin-top: 4px; }
.icon-btn.close { box-shadow: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row.col { flex-wrap: wrap; }
.row input[type="range"] { flex: 1; max-width: 200px; accent-color: var(--accent); min-height: 44px; }
.row output { min-width: 3.2em; text-align: right; color: var(--muted); }
.row select { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); padding: 0 10px; }
.switch { position: relative; flex: none; width: 52px; height: 32px; border-radius: 999px; border: 0; background: #b9bdcb; transition: background-color .2s; }
.switch::before { content: ""; position: absolute; inset: -8px -4px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
:root[data-theme="dark"] .switch { background: #4c5172; }
:root[data-theme="dark"] .switch[aria-checked="true"] { background: var(--accent); }
.stack { display: grid; gap: 10px; }
.lead { font-weight: 700; margin: 0; }
.off-art svg { width: 64px; height: 64px; margin: 0 auto; fill: none; stroke: var(--coral); stroke-width: 3.5; stroke-linecap: round; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 750; text-align: right; }
.awards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.awards li { display: flex; align-items: center; gap: 10px; }

/* ---- the result ---- */
dialog.sheet.result { text-align: center; }
.result .sheet-body { padding-top: 22px; }
.res-kicker { margin: 0 0 4px; }
#res-title { font-size: 28px; }
.res-stars { display: flex; justify-content: center; gap: 8px; margin: 12px 0 6px; }
.res-stars .star { width: 52px; height: 52px; opacity: 0; transform: scale(0); animation: star-pop .42s cubic-bezier(.3,1.6,.5,1) forwards; }
.res-stars .star.on { filter: drop-shadow(0 3px 0 rgba(150,90,0,.45)) drop-shadow(0 0 14px rgba(255,200,80,.6)); }
.res-stars .pop0 { animation-delay: .35s; }
.res-stars .pop1 { animation-delay: .6s; width: 64px; height: 64px; margin-top: -8px; }
.res-stars .pop2 { animation-delay: .85s; }
@keyframes star-pop { 0% { opacity: 0; transform: scale(0); } 70% { opacity: 1; transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }
.res-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(109, 91, 208, .14); color: #4b3bb0; font-weight: 750; margin: 2px auto 8px; animation: star-pop .42s 1.1s cubic-bezier(.3,1.6,.5,1) both; }
:root[data-theme="dark"] .res-badge { color: #cdbfff; background: rgba(169,147,255,.18); }
.res-badge svg { width: 22px; height: 22px; fill: #6d5bd0; }
.res-badge svg .tick { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.res-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin: 10px auto; max-width: 320px; text-align: left; }
.res-facts dt { color: var(--muted); }
.res-facts dd { margin: 0; text-align: right; font-weight: 800; font-size: 18px; }
.res-award p { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; font-weight: 700; }
.res-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.res-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; }
.res-friends { margin-top: 16px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px; }

@media (max-height: 520px) {
  .result .sheet-body { padding-top: 12px; }
  #res-title { font-size: 22px; }
  .res-stars { margin: 4px 0 2px; }
  .res-stars .star { width: 38px; height: 38px; }
  .res-stars .pop1 { width: 46px; height: 46px; margin-top: -4px; }
  .res-facts { margin: 4px auto; }
  .res-actions { margin-top: 8px; }
  dialog.sheet { max-height: 94dvh; }
}

/* ---- help ---- */
.help .sheet-body { display: flex; flex-direction: column; gap: 12px; }
.help-page { display: grid; gap: 8px; animation: screen-in .25s both; }
.help-page p { margin: 0; }
.help-pic { width: 100%; max-width: 280px; height: auto; margin: 0 auto; overflow: visible; }
.help-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.h-tile .top { fill: #f4f0e8; } .h-tile .side-l { fill: #ddd5c6; } .h-tile .side-r { fill: #c8bfae; }
.h-tile.glass .top { fill: #f2b647; } .h-tile.glass .side-l { fill: #d99a30; } .h-tile.glass .side-r { fill: #c78a2b; }
:root[data-theme="dark"] .h-tile .top { fill: #6c7894; } :root[data-theme="dark"] .h-tile .side-l { fill: #4a5470; } :root[data-theme="dark"] .h-tile .side-r { fill: #3d4659; }
.h-block .top { fill: #ffb2a2; } .h-block .side-l { fill: #ef5f4b; } .h-block .side-r { fill: #c94431; }
.h-goal { fill: #3a2508; stroke: #f5b82e; stroke-width: 2; }
.h-soft { fill: #2f6fe0; } .h-x { stroke: #7c4ddc; stroke-width: 3.5; stroke-linecap: round; fill: none; }
.h-strip { stroke: #5b95ff; stroke-width: 2; stroke-dasharray: 3 3; fill: none; opacity: .8; }
.h-ring { fill: none; stroke: #16b5b5; stroke-width: 2.5; stroke-dasharray: 6 4; }
.h-split { fill: #ff8a33; }
.h-crackline { fill: none; stroke: #5a3205; stroke-width: 1.4; }
.h-star { fill: #f5b82e; }
.h-num { fill: #fff; stroke: #f5b82e; stroke-width: 2; }
.h-cal { fill: var(--glass-strong); stroke: var(--coral); stroke-width: 3; }
.h-cal-line { stroke: var(--coral); stroke-width: 3; stroke-linecap: round; fill: none; }
.h-clock { fill: none; stroke: var(--coral); stroke-width: 3; stroke-dasharray: 5 3; transform-origin: 60px 44px; }
.a-stand { animation: a-stand 2.4s ease-in-out infinite; }
.a-lie { animation: a-lie 2.4s ease-in-out infinite; }
@keyframes a-stand { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }
@keyframes a-lie { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
.a-sink { animation: a-sink 2.6s ease-in infinite; }
@keyframes a-sink { 0%, 30% { transform: translateY(-6px); opacity: 1; } 70% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }
.a-crack { animation: a-blink 1.2s steps(2) infinite; }
.a-rise { animation: a-rise 2.4s cubic-bezier(.3,1.5,.5,1) infinite; }
@keyframes a-rise { 0%, 20% { transform: translateY(18px); opacity: 0; } 50%, 100% { transform: translateY(0); opacity: 1; } }
.a-spin { transform-box: fill-box; transform-origin: center; animation: a-spin 6s linear infinite; }
.a-spin.rev { animation-direction: reverse; }
@keyframes a-spin { to { transform: rotate(360deg); } }
.a-blink { animation: a-blink 2.4s ease-in-out infinite; }
@keyframes a-blink { 0%, 45% { opacity: 1; } 55%, 100% { opacity: 0; } }
.a-left { animation: a-left 2.6s ease-in-out infinite; }
.a-right { animation: a-right 2.6s ease-in-out infinite; }
@keyframes a-left { 0%, 20% { transform: translate(13px, -7px); } 60%, 100% { transform: translate(0, 0); } }
@keyframes a-right { 0%, 20% { transform: translate(-13px, -7px); } 60%, 100% { transform: translate(0, 0); } }
.a-pop { transform-box: fill-box; transform-origin: center; animation: a-pop 2.4s cubic-bezier(.3,1.6,.5,1) infinite; }
.a-pop.d1 { animation-delay: .25s; } .a-pop.d2 { animation-delay: .5s; }
@keyframes a-pop { 0% { transform: scale(0); opacity: 0; } 25%, 85% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
table.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
table.keys th, table.keys td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.keys thead th { color: var(--muted); font-weight: 650; }
kbd { font: 600 13px var(--font); padding: 2px 6px; border-radius: 7px; background: var(--line); }
.try-wrap { position: relative; border-radius: 18px; overflow: hidden; height: 220px; background: linear-gradient(180deg, rgba(198,225,246,.6), rgba(255,226,207,.6)); }
:root[data-theme="dark"] .try-wrap { background: linear-gradient(180deg, rgba(42,45,120,.6), rgba(51,32,90,.6)); }
.try-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.try-done { display: grid; gap: 8px; text-align: center; }
.try-done p { margin: 0; font-weight: 700; }

/* ---- reduced motion: crossfades instead of travel ---- */
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation-duration: .2s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
:root[data-motion="reduced"] .screen.enter { animation-name: fade-only; }
:root[data-motion="reduced"] dialog.sheet { animation-name: fade-only; }
:root[data-motion="reduced"] .wa-block, :root[data-motion="reduced"] .a-spin, :root[data-motion="reduced"] .tip-art::after { animation: none !important; }
@keyframes fade-only { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wa-block, .a-spin { animation: none; } }
