/* Why it Turned Out? (海龜湯) — "Midnight Broth": cozy-noir, deep teal + ember, late-night warmth.
   Fraunces (serif headline) + Inter (UI) + Noto Serif TC (Chinese). Dark-native,
   mobile-first, colour+glyph verdicts for accessibility. */

:root {
  --bg: #0d1b1e;
  --bg-2: #102327;
  --panel: #14282d;
  --panel-2: #163036;
  --ember: #e8643c;
  --ember-soft: #f08a64;
  --gold: #e8b04c;
  --cream: #f3ece1;
  --muted: #8aa1a3;
  --line: rgba(232,176,76,.16);
  --yes: #4fae6b;
  --yes-bg: rgba(79,174,107,.16);
  --no: #e8643c;
  --no-bg: rgba(232,100,60,.16);
  --irr: #6f8487;
  --irr-bg: rgba(111,132,135,.16);
  --serif: 'Fraunces', 'Noto Serif TC', Georgia, serif;
  --serif-zh: 'Noto Serif TC', 'Fraunces', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --scroll-thumb: rgba(232,176,76,.42);
  --scroll-thumb-hover: rgba(232,176,76,.62);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--cream); font-family: var(--sans);
  min-height: 100%; max-width: 100%; overflow-x: clip;
}

/* Unified scrollbars (Firefox + WebKit) for every scrollable surface */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover); background-clip: padding-box;
}
body {
  display: flex; flex-direction: column; height: 100vh; height: 100svh; height: 100dvh; overflow: hidden;
  min-width: 280px;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(232,100,60,.14), transparent 62%),
    radial-gradient(700px 500px at 90% 110%, rgba(232,176,76,.07), transparent 60%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}

/* steam wisps rising behind the card */
.steam { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.steam span {
  position: absolute; bottom: -120px; width: 200px; height: 320px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(232,176,76,.10), transparent);
  filter: blur(14px); animation: rise 14s linear infinite;
}
.steam span:nth-child(1) { left: 12%; animation-delay: 0s; }
.steam span:nth-child(2) { left: 48%; animation-delay: 5s; }
.steam span:nth-child(3) { left: 78%; animation-delay: 9s; }
@keyframes rise { 0% { transform: translateY(0) scale(.8); opacity: 0; }
  20% { opacity: .8; } 100% { transform: translateY(-90vh) scale(1.4); opacity: 0; } }
html:not(.fx-on) .steam { display: none; }

/* top bar — mobile-first: logo only + actions (Race / menu / account / lang) */
.topbar {
  position: relative; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); min-height: 56px;
  flex: none;
  background: rgba(13, 27, 30, .92);
  backdrop-filter: blur(8px);
  isolation: isolate;
}
.brand {
  display: flex; align-items: center; gap: 7px; min-width: 0; flex: 0 0 auto;
  overflow: hidden; pointer-events: none; /* decorative; don't steal taps from actions */
}
.logo {
  width: 28px; height: 28px; flex: none; border-radius: 7px;
  display: block; transform: translateY(2px);
  box-shadow: 0 0 0 1px rgba(252, 233, 195, 0.08);
  pointer-events: none;
}
.wordmark {
  display: none; /* mobile: logo only — wordmark from 760px up */
  min-width: 0; max-width: 100%;
  font-family: var(--serif); font-size: clamp(0.92rem, 3.6vw, 1.25rem); font-weight: 600;
  letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--cream);
}
.wordmark b { color: var(--ember); font-weight: 600; }
/* Mobile: hide Chinese wordmark */
.brand .zh { display: none; }
.top-actions {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  position: relative; z-index: 2;
  margin-left: auto;
}
.more-wrap { position: relative; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; background: var(--panel); color: var(--cream);
  border: 1px solid var(--line); font-size: 1.05rem; cursor: pointer;
  transition: background .2s, border-color .2s;
  display: grid; place-items: center; font-family: var(--serif-zh); flex: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--panel-2); border-color: rgba(232,100,60,.4); }
.icon-btn .icon-user {
  width: 22px; height: 22px; display: block;
}
.race-top-btn {
  min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(232,176,76,.35); background: rgba(232,176,76,.1);
  color: var(--gold); font-family: var(--sans); font-size: .82rem; font-weight: 700;
  letter-spacing: .04em; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex: none;
}
.race-top-btn:hover { background: rgba(232,176,76,.18); }
.more-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 5;
  min-width: 168px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}
.more-menu[hidden] { display: none; }
.more-item {
  display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--cream);
  font-family: var(--sans); font-size: .92rem; cursor: pointer;
  transition: background .15s;
}
.more-item:hover { background: rgba(232,176,76,.1); color: var(--gold); }

@media (min-width: 760px) {
  .topbar {
    padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
    gap: 12px;
  }
  .brand { flex: 1 1 auto; pointer-events: auto; }
  .logo { width: 32px; height: 32px; border-radius: 8px; }
  .wordmark { display: inline-block; flex: 0 1 auto; font-size: 1.4rem; }
  .brand .zh {
    display: inline; font-family: var(--serif-zh); color: var(--cream); font-size: .95rem; letter-spacing: .06em;
    flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .top-actions { gap: 8px; }
}

/* stage */
.stage {
  position: relative; z-index: 1; flex: 1; min-height: 0; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 8px;
}

.card {
  flex: none; max-height: 44dvh; overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  position: relative; box-shadow: 0 14px 48px rgba(0,0,0,.5);
  overscroll-behavior: contain;
}
.card-meta, .title, .scene-img { flex: none; }
.scene-img {
  width: 100%; height: 96px; object-fit: cover; border-radius: 10px; margin-bottom: 10px;
  border: 1px solid var(--line); background: var(--bg-2);
}
.scene-img[hidden] { display: none; }
.card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(360px 160px at 50% -30%, rgba(232,100,60,.14), transparent);
}
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.meta-right { display: flex; align-items: center; gap: 10px; }
.puzzle-num { font-size: .78rem; letter-spacing: .14em; color: var(--ember); text-transform: uppercase; font-weight: 600; }
.streak-chip { font-size: .85rem; color: var(--gold); font-variant-numeric: tabular-nums; }

/* remaining questions / guesses — on puzzle card + profile (not "AI") */
.quota-meters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 10px;
}
.quota-meters[hidden] { display: none; }
.quota-meter {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; padding: 7px 9px;
  border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
}
.quota-label {
  min-width: 0; font-size: .62rem; line-height: 1.2; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; overflow-wrap: anywhere;
}
.quota-n {
  flex: none; font-family: var(--serif); font-size: 1.12rem; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1;
}
.quota-meters.low .quota-n { color: var(--ember-soft); }
.quota-meters.acct {
  margin: 12px 0 0; text-align: left;
}
.quota-meters.acct .quota-meter { align-items: flex-start; flex-direction: column; }
.quota-meters.acct .quota-n { font-size: 1.35rem; }
.badge {
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border: 1px solid rgba(138,161,163,.35); border-radius: 999px; padding: 3px 9px;
}
.title {
  max-width: 100%; font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.28rem, 6vw, 1.55rem); line-height: 1.2; margin-bottom: 8px;
  overflow-wrap: anywhere; word-break: normal; text-wrap: balance;
}
.surface { font-family: var(--serif); font-size: 1.3rem; line-height: 1.55; color: #ece3d4;
  flex: none; min-height: 0; overflow-wrap: anywhere; }
:lang(zh) .title, :lang(zh) .surface { font-family: var(--serif-zh); }

/* question log — the scrollable chat area */
.log {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 2px;
}
.log:empty::before {
  content: attr(data-empty); display: block; text-align: center; color: var(--muted);
  font-family: var(--serif); font-style: italic; font-size: .9rem; line-height: 1.3; padding: 6px 8px;
}
.qa {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px;
  background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.05);
  animation: rise-in .22s ease both;
}
.qa.has-player { align-items: flex-start; }
.qa-player {
  flex: 0 0 auto; max-width: 7.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em; line-height: 1.4;
  color: #1a1410; background: var(--qa-player, var(--gold)); border-radius: 999px; padding: 2px 8px;
  margin-top: 2px;
}
.qa.peer { border-style: dashed; opacity: .94; }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } }
.qa .qtext {
  flex: 1; min-width: 0; font-family: var(--serif); font-size: 1.05rem; line-height: 1.4;
  color: #e0d7c8; overflow-wrap: anywhere;
}
:lang(zh) .qa .qtext { font-family: var(--serif-zh); }
.verdict {
  font-size: .82rem; font-weight: 700; letter-spacing: .02em; padding: 4px 11px; border-radius: 8px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; animation: pop .3s ease;
}
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.verdict.yes { background: var(--yes-bg); color: #8fe0a3; }
.verdict.no  { background: var(--no-bg); color: var(--ember-soft); }
.verdict.irrelevant { background: var(--irr-bg); color: #b6c6c8; }
.verdict.pending { background: rgba(255,255,255,.05); padding: 7px 13px; animation: none; }
.verdict.pending .dots { display: inline-flex; gap: 4px; }
.verdict.pending .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1.1s infinite both; }
.verdict.pending .dots i:nth-child(2) { animation-delay: .18s; }
.verdict.pending .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.qa .src { font-size: .68rem; color: var(--muted); }
.qa.hint { background: rgba(232,176,76,.09); border-color: rgba(232,176,76,.25); }
.qa.hint .qtext { font-style: italic; color: var(--gold); }
.qa.system { background: var(--no-bg); border-color: rgba(232,100,60,.3); justify-content: center; }
.qa.system .qtext { flex: none; text-align: center; color: var(--ember-soft); font-style: italic; }
.qa.guess { align-items: flex-start; }
.qa.guess .guess-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px;
}
.qa.guess .guess-label {
  font-family: var(--sans); font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.qa.guess .guess-text {
  font-family: var(--serif); font-size: 1.08rem; line-height: 1.45; color: #e0d7c8;
  white-space: pre-wrap; word-break: break-word;
}
:lang(zh) .qa.guess .guess-text { font-family: var(--serif-zh); }
.qa.guess .guess-reply {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .18); border: 1px solid rgba(255, 255, 255, .06);
}
.qa.guess .guess-reply-head {
  font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .02em;
}
.qa.guess.correct .guess-reply-head { color: #8fe0a3; }
.qa.guess.wrong .guess-reply-head { color: var(--ember-soft); }
.qa.guess .guess-reply-body {
  font-family: var(--serif); font-size: .95rem; line-height: 1.45;
  color: var(--gold); font-style: italic;
}
:lang(zh) .qa.guess .guess-reply-body { font-family: var(--serif-zh); }
.qa.guess.correct .guess-reply-body { color: #b7e6c2; font-style: normal; }
.qa.guess.correct { background: rgba(79,174,107,.1); border-color: rgba(79,174,107,.28); }
.qa.guess.wrong { background: rgba(232,100,60,.07); border-color: rgba(232,100,60,.22); }

/* ask row */
.ask-row { display: flex; gap: 8px; flex: none; }
.ask-input {
  flex: 1; min-width: 0; background: var(--bg-2); color: var(--cream); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: 48px; font-family: var(--serif); font-size: 1rem;
}
:lang(zh) .ask-input { font-family: var(--serif-zh); }
.ask-input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(232,100,60,.18); }
.ask-btn {
  flex: none; white-space: nowrap; background: var(--ember); color: #1a0d08; border: none;
  border-radius: 12px; padding: 0 22px; min-height: 44px; font-family: var(--sans); font-weight: 700; font-size: .95rem;
  cursor: pointer; transition: background .2s, opacity .2s;
}
.ask-btn:hover { background: var(--ember-soft); }
.ask-btn:disabled { opacity: .5; cursor: wait; }
.ask-btn.wide { width: 100%; padding: 14px; }

/* controls — mobile first: destructive action gets a separate, harder-to-mistap row. */
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; flex: none; }
.ctrl {
  min-width: 0; min-height: 44px; white-space: normal; line-height: 1.2;
  background: transparent; color: var(--cream); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 8px; font-family: var(--sans); font-size: .88rem;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.controls .ctrl:last-child { grid-column: 1 / -1; }
.ctrl:hover { background: rgba(255,255,255,.04); }
.ctrl-primary { border-color: rgba(232,176,76,.45); color: var(--gold); }
.ctrl-primary:hover { background: rgba(232,176,76,.12); }
.ctrl-danger { border-color: rgba(232,100,60,.4); color: var(--ember-soft); }
.ctrl-danger:hover { background: var(--no-bg); }

/* focus rings (keyboard) — keep mouse clicks clean */
:where(button, a, input, textarea, .hof-tab, .acct-row):focus { outline: none; }
:where(button, a, input, textarea, .hof-tab, .acct-row):focus-visible {
  outline: 2px solid var(--ember-soft);
  outline-offset: 2px;
}

/* modals */
.modal-wrap {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(4,10,11,.86);
  padding: max(12px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
.modal-wrap[hidden] { display: none; }

/* While a modal is open: stop steam animation + drop backdrop blurs (main jank source). */
body.modal-open .steam,
body.modal-open .steam span {
  animation: none !important;
  visibility: hidden;
}
body.modal-open .topbar,
body.modal-open .race-bar {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.modal {
  position: relative;
  background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 20px 16px max(18px, env(safe-area-inset-bottom));
  width: 100%; max-width: 460px; max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.66); animation: rise-in .25s ease both;
  overscroll-behavior: contain;
}
.modal.stats {
  max-width: 520px; padding: 0; overflow: hidden;
  display: flex; flex-direction: column; max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
}
.modal.stats .modal-head { flex: none; padding: 16px 16px 10px; margin-bottom: 0; }
.modal.stats .modal-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 16px 18px;
}
.modal.stats .modal-foot {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,35,39,.92), var(--bg-2));
}
.modal.stats .modal-foot .ask-btn { width: min(100%, 280px); }
.modal.stats .modal-foot .feedback { margin: 0; min-height: 1.1em; text-align: center; }
.modal.upgrade { max-width: 480px; padding: 20px 16px max(18px, env(safe-area-inset-bottom)); }
.modal h2 { font-family: var(--serif); font-size: 1.5rem; margin-bottom: 8px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.modal-head h2 { margin: 0; }
.modal-kicker {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ember); font-weight: 600;
}
.icon-close {
  width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.icon-close:hover { color: var(--cream); border-color: rgba(232,100,60,.4); background: rgba(255,255,255,.04); }
.modal-sub, .onboard-lead { color: var(--muted); font-size: .98rem; margin-bottom: 14px; line-height: 1.5; }
.modal textarea {
  width: 100%; background: var(--bg); color: var(--cream); resize: vertical; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-family: var(--serif); font-size: 1.1rem; margin-top: 6px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-actions.center { justify-content: center; }

/* Upgrade plans */
.plan-list { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.plan {
  padding: 16px 16px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,.02);
}
.plan-plus { border-color: rgba(232,100,60,.35); background: linear-gradient(165deg, rgba(232,100,60,.1), rgba(255,255,255,.02)); }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.plan-head h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0; color: var(--cream); }
.plan-price { margin: 0; color: var(--gold); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-perks {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  margin: 0 0 14px; padding: 0; color: var(--muted); font-size: .9rem; line-height: 1.4;
}
.plan-perks li {
  position: relative; padding-left: 1.1em;
}
.plan-perks li::before {
  content: "·"; position: absolute; left: 0; color: var(--ember-soft); font-weight: 700;
}
.plan-actions { display: flex; flex-direction: column; gap: 8px; }
.plan-actions .ask-btn,
.plan-actions .ghost-btn { width: 100%; justify-content: center; }
.plan-owned {
  opacity: .55;
  filter: grayscale(.25);
}
.plan-owned .plan-actions .ask-btn,
.plan-owned .plan-actions .ghost-btn {
  cursor: not-allowed;
  opacity: .85;
}
.plan-badge {
  flex: none;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(232,176,76,.35);
  background: rgba(232,176,76,.12);
  color: var(--gold);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.plan-footnote {
  margin: 14px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; text-align: center;
}
.plan-list[hidden],
.plan[hidden],
.plan-footnote[hidden],
#upgradeSignIn[hidden],
#rewardOffer[hidden],
#giveUpOffer[hidden],
#revealBtn[hidden] { display: none !important; }

.reward-offer { margin: 4px 0 16px; }
.reward-offer .ask-btn { width: 100%; }
.giveup-offer { margin: 16px 0 0; }
.giveup-offer .ghost-btn { width: 100%; justify-content: center; }
.giveup-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
  text-align: center;
}
.reward-hint {
  margin: 8px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.4; text-align: center;
}
.modal.reward { max-width: 440px; }

.ghost-btn {
  background: transparent; color: var(--gold); border: 1px solid rgba(232,176,76,.4); border-radius: 10px;
  padding: 11px 16px; min-height: 44px; font-family: var(--sans); font-size: .9rem; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.ghost-btn:hover { background: rgba(232,176,76,.1); }
.danger-btn {
  display: block; width: 100%; margin-top: 14px; min-height: 44px; padding: 12px 16px;
  background: transparent; color: var(--ember-soft); border: 1px solid rgba(232,100,60,.35);
  border-radius: 12px; font-family: var(--sans); font-size: .92rem; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.danger-btn:hover { background: var(--no-bg); border-color: rgba(232,100,60,.55); }
.feedback { margin-top: 12px; font-family: var(--serif); font-size: 1.05rem; color: var(--gold); min-height: 1.2em; }
@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
}

/* onboarding */
.onboard { text-align: center; }
.onboard-logo { margin-bottom: 10px; line-height: 0; }
.onboard-logo img {
  width: 56px; height: 56px; border-radius: 14px; display: block; margin: 0 auto;
  box-shadow: 0 0 0 1px rgba(252, 233, 195, 0.1);
}
.onboard-demo { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; text-align: left; }
.onboard-foot { color: var(--muted); font-size: .92rem; margin-bottom: 4px; }

/* result */
.result { text-align: center; }
.result-close { position: absolute; top: 14px; right: 14px; z-index: 1; }
.result-icon { font-size: 2.8rem; margin-bottom: 4px; }
.reveal-label { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ember); margin-top: 12px; }
.solution { font-family: var(--serif); font-size: 1.22rem; line-height: 1.55; color: #ece3d4; margin-top: 6px; text-align: left; }
:lang(zh) .solution { font-family: var(--serif-zh); }
.share-img {
  display: block; width: 100%; max-width: min(360px, 92vw); margin: 18px auto 4px; border-radius: 14px;
  border: 1px solid var(--line); box-shadow: 0 12px 34px rgba(0,0,0,.5);
  aspect-ratio: 1 / 1; object-fit: cover;
}
.play-as {
  display: block; width: 100%; min-height: 44px; padding: 8px; border: 0; background: transparent;
  text-align: center; color: var(--muted); font-family: var(--sans); font-size: .9rem; margin: 6px 0 0; cursor: pointer;
  transition: color .15s;
}
.play-as:hover { color: var(--gold); }

/* stats */
.stats-section { margin-top: 4px; padding-top: 14px; border-top: 1px solid rgba(232,176,76,.1); }
.stat-hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px;
}
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 6px; }
.stat-grid.four { grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  text-align: center; background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.05);
  border-radius: 12px; padding: 12px 6px; min-height: 72px;
  display: flex; flex-direction: column; justify-content: center;
}
.stat.featured {
  padding: 16px 8px; min-height: 92px;
  background: linear-gradient(165deg, rgba(232,100,60,.12), rgba(255,255,255,.02));
  border-color: rgba(232,100,60,.28);
}
.stat-n { display: block; font-family: var(--serif); font-size: 1.55rem; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat.featured .stat-n { font-size: 2rem; color: var(--ember-soft); }
.stat-l { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.dist-title {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 10px; font-weight: 600;
}
.dist-title.hof-head { color: var(--gold); }

/* achievement tiles — SVG icons, not emoji (separate from .badge difficulty pill) */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px; border-radius: 12px;
  background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.05); opacity: .42;
  transition: opacity .2s, border-color .2s, background .2s, transform .2s;
}
.ach.earned {
  opacity: 1; border-color: rgba(232,176,76,.45); background: rgba(232,176,76,.1);
}
.ach.earned:hover { transform: translateY(-1px); }
.ach-ic {
  width: 28px; height: 28px; color: var(--muted); display: grid; place-items: center;
}
.ach-ic svg { width: 22px; height: 22px; display: block; }
.ach.earned .ach-ic { color: var(--gold); }
.ach-l { font-size: .66rem; color: var(--cream); text-align: center; line-height: 1.25; }

/* hall-of-fame tabs */
.hof-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.hof-tab {
  flex: 1; min-height: 44px; padding: 10px 6px; border-radius: 10px; background: transparent; color: var(--muted);
  border: 1px solid var(--line); font-family: var(--sans); font-size: .76rem; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.hof-tab:hover { color: var(--cream); border-color: rgba(232,176,76,.3); }
.hof-tab.active { background: rgba(232,176,76,.12); color: var(--gold); border-color: rgba(232,176,76,.45); }
.hof-signin { color: var(--muted); font-family: var(--serif); font-style: italic; text-align: center; padding: 14px 10px; }
.dist { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 48px 1fr 28px; align-items: center; gap: 8px; font-size: .82rem; }
.dist-row .bucket { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-track {
  height: 10px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden;
  border: 1px solid rgba(255,255,255,.04);
}
.bar-track .bar {
  display: block; height: 100%; width: 0; min-width: 0; background: linear-gradient(90deg, var(--ember), var(--gold));
  border-radius: inherit; transition: width .3s ease;
}
.dist-row.empty .bar-n { opacity: .45; }
.bar-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .78rem; }

/* stats share-card name toggle */
.share-section .share-img { margin-top: 4px; }

/* personal play history */
.history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.history-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid rgba(232,176,76,.08);
  text-align: left;
}
.history-row:last-child { border-bottom: 0; }
.history-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history-title {
  font-family: var(--serif); font-size: .98rem; color: var(--cream);
  display: -webkit-box; overflow: hidden; overflow-wrap: anywhere;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
:lang(zh) .history-title { font-family: var(--serif-zh); }
.history-meta { font-size: .78rem; color: var(--muted); }
.history-status { color: var(--gold); }
.history-status.gaveup { color: var(--ember-soft); }
.history-row .ghost-btn { padding: 8px 12px; min-height: 44px; font-size: .82rem; flex: none; }
.history-empty { margin: 4px 0 0; font-size: .9rem; }
.nick-toggle { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 2px;
  color: var(--muted); font-size: .9rem; cursor: pointer; min-height: 44px; }
.nick-toggle input { accent-color: var(--ember); width: 18px; height: 18px; }

/* result rank line + leaderboard */
.rank-line { color: var(--gold); font-family: var(--serif); font-size: 1.15rem; margin: -2px 0 8px; }
.modal.lb { text-align: left; }
.lb-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.05); }
.lb-rank { width: 38px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-family: var(--serif); font-size: 1.1rem; color: #e0d7c8; }
.lb-q { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.lb-me { text-align: center; color: var(--gold); font-family: var(--serif); font-size: 1.05rem; min-height: 1.2em; }

/* profile / account modal */
.modal.account { text-align: center; max-width: 400px; }

/* ── Race / multiplayer (mobile-first) ──────────────────────────────── */
.race-hub, .race-lobby, .race-result, .race-solved { max-width: 440px; text-align: left; }
.race-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin: 0 0 14px; padding: 4px; border-radius: 12px;
  background: rgba(0,0,0,.25);
}
.race-tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 12px 8px; border-radius: 10px; cursor: pointer;
  min-height: 44px;
}
.race-tab.active { background: rgba(255,255,255,.08); color: var(--cream); }
.race-pane { display: flex; flex-direction: column; gap: 12px; }
.race-pane[hidden] { display: none; }
.race-field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--muted); }
.race-field select,
.race-field input {
  font: inherit; color: var(--cream); background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px 14px;
  min-height: 48px; width: 100%;
  color-scheme: dark;
}
/* Native select kept for value/change; custom menu is the visible control. */
.race-field select.race-select-native {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  opacity: 0; pointer-events: none;
}
.race-dd {
  position: relative;
  width: 100%;
}
.race-dd:has(select[hidden]) { display: none; }
.race-dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; font-weight: 500; text-align: left; cursor: pointer;
  color: var(--cream); background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
}
.race-dd-btn:hover { border-color: rgba(232,176,76,.35); }
.race-dd-btn:focus-visible {
  outline: 2px solid rgba(232,176,76,.55); outline-offset: 2px;
}
.race-dd-btn-label {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.race-dd-chevron {
  flex: none; width: 0.55em; height: 0.55em;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); translate: 0 -2px;
  transition: transform .15s ease;
}
.race-dd.is-open .race-dd-chevron { transform: rotate(225deg); translate: 0 2px; }
.race-dd-menu {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  max-height: min(280px, 45vh); overflow-y: auto;
  padding: 6px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.race-dd-menu[hidden] { display: none; }
.race-dd-option {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--cream);
  font: inherit; font-size: .92rem; line-height: 1.35;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
}
.race-dd-option:hover,
.race-dd-option:focus-visible {
  background: rgba(232,176,76,.14); outline: none;
}
.race-dd-option.is-selected {
  background: rgba(232,100,60,.18); color: var(--gold); font-weight: 600;
}
.race-field select[hidden],
.race-readonly[hidden] { display: none; }
.race-readonly {
  margin: 0; padding: 12px 14px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  color: var(--cream); font-size: .95rem; line-height: 1.4;
}
.race-hint { margin: 0; font-size: .82rem; color: var(--muted); line-height: 1.4; }
.race-code-row {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(145deg, rgba(3,56,65,.95), rgba(13,27,30,.98));
  border: 1px solid rgba(255,255,255,.08);
}
.race-code-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.race-code-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.race-code {
  font-family: var(--serif); font-size: clamp(1.2rem, 5vw, 1.55rem);
  letter-spacing: .16em; color: var(--gold); word-break: break-all;
}
.race-code-row .ghost-btn { flex: none; min-height: 44px; }
.race-players {
  list-style: none; margin: 0 0 14px; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.race-players li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 10px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06); font-size: .95rem;
}
.race-players li.you { border-color: rgba(232,100,60,.4); }
.race-player-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--race-badge, var(--gold));
}
.race-settings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.race-lobby-actions, .race-solved-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px;
}
.race-lobby-actions .ghost-btn,
.race-solved-actions .ask-btn,
.race-solved-actions .ghost-btn { width: 100%; justify-content: center; min-height: 48px; }
.race-podium {
  margin: 0 0 14px; padding: 0 0 0 1.2em;
  display: flex; flex-direction: column; gap: 8px;
}
.race-podium li { padding: 8px 0; font-size: 1.05rem; }
.race-podium li.you { color: var(--gold); font-weight: 600; }

/* In-race chrome — always under modals (z-index 40 < 60) */
.race-chrome {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.race-chrome[hidden] { display: none; }
.race-bar, .race-chat-sheet { pointer-events: auto; }
.race-bar {
  margin: 0 8px 8px; padding: 8px 10px;
  border-radius: 16px;
  background: rgba(3, 32, 38, .94); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 -8px 28px rgba(0,0,0,.3);
}
.race-bar-code {
  font-size: .72rem; letter-spacing: .14em; color: var(--gold); font-variant-numeric: tabular-nums;
}
.race-bar-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px;
}
.race-chat-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 10px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06);
  color: var(--cream); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.race-chat-toggle[hidden] { display: none; }
.race-unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--ember); color: #1a0c08; font-size: .68rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.race-bar-players {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.race-bar-players::-webkit-scrollbar { display: none; }
.race-bar-players li {
  flex: none; display: flex; align-items: center; gap: 5px;
  padding: 6px 8px; border-radius: 999px; background: rgba(255,255,255,.05);
  font-size: .72rem; white-space: nowrap;
}
.race-bar-players li.you { outline: 1px solid rgba(232,176,76,.45); }
.race-bar-players li.solved { background: rgba(125,206,160,.12); }
.race-bar-players .n { max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; }
.race-bar-players .s { color: var(--muted); }

.race-chat-sheet {
  margin: 0 8px 8px; max-height: min(48dvh, 360px);
  display: flex; flex-direction: column;
  border-radius: 16px 16px 12px 12px;
  background: rgba(3, 28, 34, .97); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 -12px 36px rgba(0,0,0,.4);
}
.race-chat-sheet[hidden] { display: none; }
.race-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.08); flex: none;
}
.race-chat-feed {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.race-chat-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.race-chat-badge {
  display: inline-flex; align-items: center; max-width: 100%;
  padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700;
  background: color-mix(in srgb, var(--race-badge, var(--gold)) 22%, transparent);
  color: var(--race-badge, var(--gold));
}
.race-chat-body {
  max-width: 100%; padding: 8px 10px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06);
}
.race-chat-kind {
  display: block; font-size: .68rem; color: var(--muted); margin-bottom: 2px; font-weight: 600;
}
.race-chat-q { margin: 0; font-size: .88rem; line-height: 1.35; color: var(--cream); }
.race-chat-a {
  margin: 6px 0 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.race-chat-a.a-yes { color: #7dcea0; }
.race-chat-a.a-no { color: #e87878; }
.race-chat-a.a-irrelevant { color: var(--muted); }

html.race-on,
html.race-on body {
  overflow: hidden;
  overscroll-behavior: none;
  max-height: 100dvh;
}
html.race-on .stage {
  /* Keep content clear of the fixed race bar without growing past the viewport. */
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
html.race-on.race-chat-open .stage {
  /* Chat overlays; don't add its height to layout (avoids page rubber-band scroll). */
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
html.race-on .foot { display: none; }
html.race-on .card { max-height: min(36dvh, 320px); }

.race-bar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.race-bar-leave {
  min-height: 36px; padding: 0 10px; border-radius: 999px;
  border: 1px solid rgba(232,100,60,.35); background: rgba(232,100,60,.12);
  color: var(--ember-soft); font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer;
}

@media (min-width: 640px) {
  .race-chrome { left: 50%; transform: translateX(-50%); width: min(640px, 100%); }
  .race-bar, .race-chat-sheet { margin-left: 12px; margin-right: 12px; }
  .race-lobby-actions, .race-solved-actions { display: flex; justify-content: flex-end; }
  .race-lobby-actions .ghost-btn,
  .race-solved-actions .ask-btn,
  .race-solved-actions .ghost-btn { width: auto; }
}

.acct-hero { padding: 4px 0 6px; }
.acct-avatar-wrap {
  position: relative; width: 80px; height: 80px; margin: 0 auto 12px;
}
.acct-avatar, .acct-avatar-fallback {
  width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid rgba(232,176,76,.35);
  box-shadow: 0 0 0 4px rgba(232,100,60,.08);
}
.acct-avatar { object-fit: cover; display: block; }
.acct-avatar[hidden] { display: none; }
.acct-avatar-fallback {
  background: linear-gradient(160deg, var(--panel-2), var(--bg));
  color: var(--cream); font-family: var(--serif); font-size: 1.8rem; font-weight: 600;
}
.acct-avatar-fallback[hidden] { display: none; }
.modal.account h2 { margin-bottom: 4px; font-size: 1.45rem; }
.acct-email { color: var(--muted); font-size: .9rem; margin: 0 0 10px; word-break: break-all; }
.tier-chip {
  display: inline-block; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; padding: 4px 10px; border-radius: 999px; margin-bottom: 4px;
  color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,.03);
}
.tier-chip[data-tier="plus"] {
  color: #1a0d08; background: linear-gradient(90deg, var(--ember), var(--gold)); border-color: transparent;
}
.tier-chip[data-tier="supporter"] {
  color: var(--gold); border-color: rgba(232,176,76,.45); background: rgba(232,176,76,.1);
}
.acct-nav { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; text-align: left; }
.acct-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  color: var(--cream); font-family: var(--sans); font-size: .95rem; text-align: left;
  transition: background .2s, border-color .2s;
}
.acct-row:hover { background: rgba(232,176,76,.08); border-color: rgba(232,176,76,.28); }
.acct-row.accent { border-color: rgba(232,100,60,.35); color: var(--ember-soft); }
.acct-row-chevron { color: var(--muted); font-size: 1.2rem; line-height: 1; }

@media (max-width: 480px) {
  .stat-grid.four { grid-template-columns: repeat(2, 1fr); }
  .hof-tab { font-size: .7rem; padding: 10px 4px; }
}

/* toast (transient notice, e.g. no more hints) */
#toast {
  position: fixed; left: 50%; bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));
  transform: translateX(-50%) translateY(10px); z-index: 80;
  background: var(--panel-2); color: var(--cream); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 18px; font-family: var(--serif); font-size: 1.05rem; text-align: center; max-width: 86%;
  box-shadow: 0 12px 34px rgba(0,0,0,.55); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* footer */
.foot {
  position: relative; z-index: 1; flex: none; text-align: center;
  padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line);
}
.foot a { color: var(--ember-soft); text-decoration: none; }

/* Share-card export template must never paint (share-card.css is lazy-loaded). */
.share-card-mount,
#shareCardMount {
  display: none !important;
  position: fixed !important;
  left: -99999px !important;
  top: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  z-index: -1 !important;
}

/* noscript / crawler fallback copy */
.seo-about {
  max-width: 720px; margin: 16px auto; padding: 0 16px 24px;
  font-size: .95rem; line-height: 1.55; color: var(--muted);
}
.seo-about h2 {
  margin: 0 0 8px; font-family: var(--serif);
  font-size: 1.1rem; color: var(--cream);
}
.seo-about strong { color: var(--cream); }

/* Standalone legal pages (privacy, etc.) — scrollable, not the game shell */
body.legal-page {
  height: auto; min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden; overflow-y: auto;
  display: block;
}
body.legal-page .topbar { position: sticky; top: 0; backdrop-filter: blur(10px); background: rgba(13,27,30,.88); }
.legal {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding: 28px 20px 48px;
  line-height: 1.65;
}
.legal-kicker {
  font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 8px;
}
.legal h1 {
  font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 4vw, 2.35rem);
  color: var(--cream); margin-bottom: 8px; line-height: 1.2;
}
.legal-meta { color: var(--muted); font-size: .88rem; margin-bottom: 18px; }
.legal-lead { margin-bottom: 22px; color: var(--cream); }
.legal section { margin-top: 26px; padding-top: 6px; }
.legal h2 {
  font-family: var(--serif); font-size: 1.25rem; font-weight: 600;
  color: var(--cream); margin-bottom: 10px;
}
.legal p, .legal li { color: var(--cream); font-size: .98rem; }
.legal p + p, .legal ul + p { margin-top: 10px; }
.legal ul { margin: 8px 0 0 1.15em; }
.legal li { margin: 6px 0; }
.legal a { color: var(--ember-soft); }
.legal code {
  font-size: .86em; padding: 1px 6px; border-radius: 6px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
}

@media (min-width: 340px) {
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls .ctrl:last-child { grid-column: auto; }
}

@media (min-width: 640px) {
  .stage { padding: 16px 18px 14px; gap: 12px; }
  .card { max-height: 40dvh; border-radius: 16px; padding: 18px 20px 20px; }
  .scene-img { height: 120px; border-radius: 12px; margin-bottom: 12px; }
  .title { font-size: 1.55rem; margin-bottom: 12px; }
  .surface { font-size: 1.3rem; }
  .log:empty::before { font-size: 1.05rem; padding: 24px 12px; }
  .quota-meters { gap: 8px; margin-bottom: 12px; }
  .quota-meter { padding: 8px 10px; }
  .quota-label { font-size: .66rem; letter-spacing: .08em; }
  .quota-n { font-size: 1.25rem; }
  .modal-wrap {
    align-items: center;
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  .modal {
    border-radius: 18px; padding: 26px; max-height: min(90dvh, 920px);
  }
  .modal.stats { max-height: min(90dvh, 920px); }
  .modal.stats .modal-head { padding: 18px 22px 10px; }
  .modal.stats .modal-body { padding: 0 22px 18px; }
  .modal.stats .modal-foot { padding: 14px 22px 16px; }
  .modal.upgrade { padding: 22px 22px 18px; }
  .stat-grid.four { grid-template-columns: repeat(4, 1fr); }
  .foot { padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); font-size: .8rem; }
}

@media (max-width: 360px) {
  .top-actions { gap: 4px; }
  .race-top-btn { padding: 0 10px; font-size: .78rem; }
  .surface { font-size: 1.08rem; }
  .ask-btn { padding-inline: 14px; }
  .foot-domain { display: none; }
}

@media (max-width: 339px) {
  .card { max-height: 40dvh; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .topbar { min-height: 48px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .stage { padding-top: 6px; gap: 6px; }
  .card { max-height: 46dvh; padding: 10px 12px; }
  .scene-img { display: none; }
  .foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
