/* ==========================================================================
   Knobbel: design tokens + components
   ========================================================================== */
:root {
  --bg: #f6f5fb;
  --bg-glow-1: #e4dcff;
  --bg-glow-2: #d6f3ff;
  --surface: #ffffff;
  --surface-2: #f1eff9;
  --ink: #17142b;
  --muted: #6b6785;
  --line: #e5e2f1;
  --shade: rgba(23, 20, 43, 0.12);

  --primary: #6c4cf5;
  --primary-shade: #4b2fd0;
  --on-primary: #ffffff;
  --good: #14b37a;
  --good-shade: #0c8a5d;
  --good-soft: #dcf7ec;
  --bad: #f0475b;
  --bad-shade: #c42d40;
  --bad-soft: #fde3e6;

  --violet: #7c5cff;
  --coral: #ff7a59;
  --sky: #2fb4ff;
  --lime: #8fd64e;
  --sun: #ffbf2f;
  --mint: #22c9a0;
  --pink: #ff5fa2;

  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Bricolage Grotesque", "DM Sans", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0d1a;
    --bg-glow-1: #2a1d63;
    --bg-glow-2: #0d3a4d;
    --surface: #1a1729;
    --surface-2: #242036;
    --ink: #f3f1ff;
    --muted: #a29dbf;
    --line: #2f2a47;
    --shade: rgba(0, 0, 0, 0.45);
    --good-soft: #0f3527;
    --bad-soft: #3d1620;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0d1a;
  --bg-glow-1: #2a1d63;
  --bg-glow-2: #0d3a4d;
  --surface: #1a1729;
  --surface-2: #242036;
  --ink: #f3f1ff;
  --muted: #a29dbf;
  --line: #2f2a47;
  --shade: rgba(0, 0, 0, 0.45);
  --good-soft: #0f3527;
  --bad-soft: #3d1620;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 10% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 640px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 1.2rem;
  box-shadow: 0 4px 0 var(--primary-shade);
  transform: rotate(-6deg);
}
.brand-logo { width: 40px; height: 40px; transform: rotate(-6deg); filter: drop-shadow(0 3px 0 var(--primary-shade)); }
.brand small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }

.player-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 2px 0 var(--shade);
  font-weight: 700; font-size: 0.9rem;
}
.player-level {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sun); color: #3a2a00; font-family: var(--font-display); font-weight: 800; font-size: 0.85rem;
}
.player-xp { width: 64px; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.player-xp > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .6s ease; }
.player-flame { color: var(--coral); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-shade: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: 2px solid var(--btn-shade); border-radius: 16px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; font-size: 1rem; cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-shade);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-shade); }
.btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.btn:disabled { cursor: default; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-shade: var(--primary-shade); }
.btn-light { --btn-bg: #fff; --btn-fg: #17142b; --btn-shade: rgba(0,0,0,.18); border-color: transparent; }
.btn-good { --btn-bg: var(--good); --btn-fg: #fff; --btn-shade: var(--good-shade); }
.btn-bad { --btn-bg: var(--bad); --btn-fg: #fff; --btn-shade: var(--bad-shade); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.08rem; border-radius: 18px; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; min-height: 40px; padding: 6px 10px; }
.btn-ghost:active:not(:disabled) { transform: none; box-shadow: none; }

/* ---------- Home: hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 28px;
  background: linear-gradient(135deg, #6c4cf5 0%, #8b5cf6 45%, #ff5fa2 100%);
  color: #fff;
  box-shadow: 0 6px 0 #4b2fd0, 0 30px 60px -30px rgba(108, 76, 245, .7);
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.18);
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 14px 0 10px; font-weight: 800; }
.hero p { margin: 0 0 20px; opacity: .92; max-width: 46ch; font-size: 1.05rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hero-meta { font-size: .9rem; opacity: .9; }
.hero-meta strong { font-variant-numeric: tabular-nums; }
.hero-art { position: relative; height: 220px; }
.hero-art .flag-float {
  position: absolute; width: 120px; border-radius: 10px; overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); border: 3px solid rgba(255,255,255,.9);
  animation: float 6s ease-in-out infinite;
}
.hero-art .flag-float:nth-child(1) { top: 6px; left: 8%; transform: rotate(-10deg); }
.hero-art .flag-float:nth-child(2) { top: 40px; right: 4%; width: 140px; transform: rotate(8deg); animation-delay: -2s; }
.hero-art .flag-float:nth-child(3) { bottom: 6px; left: 28%; width: 130px; transform: rotate(-3deg); animation-delay: -4s; }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

.daily-done {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 16px;
  background: rgba(255,255,255,.18); font-weight: 700;
}
.daily-grid { letter-spacing: 1px; }

/* ---------- Section headings ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { font-size: 1.6rem; font-weight: 800; }
.section-head p { margin: 0; color: var(--muted); }

/* ---------- Game cards ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.game-card {
  --c: var(--primary);
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 5px 0 var(--line);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 200px;
}
a.game-card:hover { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 9px 0 var(--c); }
a.game-card:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--c); }
.game-card .icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 1.8rem;
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.game-card h3 { font-size: 1.2rem; font-weight: 800; }
.game-card p { margin: 0; color: var(--muted); font-size: .94rem; flex: 1; }
.game-card .foot { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; font-weight: 700; }
.game-card .best { color: var(--muted); font-weight: 600; }
.game-card .play { color: var(--c); }
.game-card .badge {
  position: absolute; top: 16px; right: 16px; padding: 3px 10px; border-radius: 99px;
  background: var(--c); color: #fff; font-size: .72rem; font-weight: 800; letter-spacing: .03em;
}
.game-card.soon { opacity: .65; border-style: dashed; box-shadow: none; }
.game-card.soon .badge { background: var(--muted); }

.c-violet { --c: var(--violet); } .c-coral { --c: var(--coral); } .c-sky { --c: var(--sky); }
.c-lime { --c: var(--lime); } .c-sun { --c: var(--sun); } .c-mint { --c: var(--mint); } .c-pink { --c: var(--pink); }

/* ---------- Profile / stats ---------- */
.profile { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.panel { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat small { display: block; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stat strong { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 14px 10px; border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: .82rem; font-weight: 700;
}
.badge-tile .b-icon { font-size: 1.8rem; line-height: 1; }
.badge-tile span:last-child { color: var(--muted); font-weight: 500; font-size: .74rem; }
.badge-tile.locked { opacity: .45; }
.badge-tile.locked .b-icon { filter: grayscale(1); }

.footer { padding: 30px 0 50px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ==========================================================================
   Play screen
   ========================================================================== */
.play-shell { min-height: 100vh; display: flex; flex-direction: column; }
.play-top { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; }
.play-top .close { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem; color: var(--muted); }
.play-top .close:hover { background: var(--surface-2); color: var(--ink); }
.progress { flex: 1; height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress > span {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--pink));
  transition: width .35s ease;
}
.progress.timer > span { background: linear-gradient(90deg, var(--sun), var(--coral)); transition: width .25s linear; }
.progress.timer.low > span { background: var(--bad); }

.hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.hud-title { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
.hud-items { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 800; font-variant-numeric: tabular-nums; font-size: .95rem;
}
.chip.combo { background: var(--sun); color: #3a2a00; border-color: transparent; }
.chip.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.18); } }

.q-card {
  background: var(--surface); border: 2px solid var(--line); border-radius: 26px;
  padding: 22px; box-shadow: 0 6px 0 var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.q-ask { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.3rem, 4vw, 1.7rem); text-align: center; }
.q-ask .country { color: var(--primary); }
.q-flag { position: relative; width: min(100%, 360px); aspect-ratio: 3 / 2; }
.q-flag img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 14px var(--shade)) drop-shadow(0 0 1px var(--shade)); }
.q-flag.enter { animation: flagIn .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes flagIn { from { opacity: 0; transform: scale(.9) rotate(-2deg); } }

.reveal-grid { position: absolute; inset: 0; border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, 1fr); }
.reveal-grid i {
  background: var(--surface-2); border: 1px solid var(--line);
  transition: opacity .35s ease, transform .35s ease;
}
.reveal-grid i.gone { opacity: 0; transform: scale(.6); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.option {
  --btn-bg: var(--surface); --btn-shade: var(--line);
  position: relative; min-height: 64px; padding: 12px 14px 12px 44px;
  justify-content: flex-start; text-align: left; line-height: 1.25;
}
.option .key {
  position: absolute; left: 12px; top: 50%; translate: 0 -50%;
  width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center;
  border: 2px solid var(--line); color: var(--muted); font-size: .75rem; font-weight: 800;
}
.option.flag-option { flex-direction: column; padding: 12px; gap: 8px; justify-content: center; text-align: center; }
.option.flag-option .key { left: 10px; top: 10px; translate: none; background: var(--surface); z-index: 1; }
.option.flag-option img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; filter: drop-shadow(0 2px 6px var(--shade)) drop-shadow(0 0 1px var(--shade)); }
.option .opt-label { font-weight: 800; }
.option .opt-detail { font-size: .85rem; font-weight: 600; color: var(--muted); }
.option .opt-detail[hidden] { display: none; }
.option.correct { --btn-bg: var(--good-soft); --btn-shade: var(--good); border-color: var(--good); }
.option.wrong { --btn-bg: var(--bad-soft); --btn-shade: var(--bad); border-color: var(--bad); animation: shake .35s ease; }
.option.correct .key { background: var(--good); border-color: var(--good); color: #fff; }
.option.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.option.dim { opacity: .5; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.points-float {
  position: fixed; pointer-events: none; z-index: 50;
  font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; color: var(--good);
  text-shadow: 0 2px 0 var(--surface);
  animation: rise .9s ease forwards;
}
@keyframes rise { from { opacity: 1; transform: translate(-50%, 0) scale(.9); } to { opacity: 0; transform: translate(-50%, -60px) scale(1.15); } }

/* Feedback sheet (slides up from bottom) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 18px 0 calc(18px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
  background: var(--surface);
  transform: translateY(110%); visibility: hidden;
  transition: transform .25s cubic-bezier(.2,.9,.3,1), visibility 0s linear .25s;
}
.sheet.show { transform: none; visibility: visible; transition: transform .25s cubic-bezier(.2,.9,.3,1); }
.sheet.good { background: var(--good-soft); border-color: var(--good); }
.sheet.bad { background: var(--bad-soft); border-color: var(--bad); }
.sheet .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sheet h3 { font-size: 1.35rem; font-weight: 800; }
.sheet.good h3 { color: var(--good); }
.sheet.bad h3 { color: var(--bad); }
.sheet .facts { margin-top: 4px; font-size: .92rem; color: var(--ink); opacity: .85; }
.sheet .btn { min-width: 160px; }
.sheet-spacer { height: 120px; }

/* Results */
.results { text-align: center; padding: 10px 0 40px; }
.results .trophy { font-size: 4rem; line-height: 1; animation: flagIn .5s ease; }
.results h1 { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 800; margin: 10px 0 4px; }
.results .sub { color: var(--muted); margin: 0 0 20px; }
.results .big-score { font-family: var(--font-display); font-size: 4rem; font-weight: 800; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.results .stat-grid { grid-template-columns: repeat(3, 1fr); margin: 22px 0; }
.results .grid-share { font-size: 1.5rem; letter-spacing: 2px; margin: 8px 0 18px; word-break: break-all; }
.results .actions { display: grid; gap: 10px; }
.level-up { margin: 16px 0; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; }
.level-up .row { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; font-size: .9rem; }
.level-up .bar { height: 12px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.level-up .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), var(--coral)); border-radius: 99px; transition: width 1s ease .3s; }
.new-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0; }
.new-badges .badge-tile { min-width: 130px; background: color-mix(in srgb, var(--sun) 25%, var(--surface)); animation: pop .5s ease; }
.pill-new { display: inline-block; padding: 4px 12px; border-radius: 99px; background: var(--sun); color: #3a2a00; font-weight: 800; font-size: .85rem; margin-top: 8px; }

.loading { display: grid; place-items: center; min-height: 50vh; color: var(--muted); font-weight: 700; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 60;
  padding: 10px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700;
  animation: flagIn .25s ease;
}

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- Navigation ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  font-weight: 700; font-size: .92rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 0 var(--shade);
}
.nav-link:hover { border-color: var(--primary); }
.nav-link.install { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 3px 0 var(--primary-shade); cursor: pointer; }
.nav-link[hidden] { display: none; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; }
.back-link:hover { color: var(--ink); }

.btn-coral { --btn-bg: var(--coral); --btn-fg: #fff; --btn-shade: #d4552f; }

/* ---------- Online card (results) ---------- */
.online-card {
  text-align: left; margin: 16px 0; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line);
}
.online-card h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; }
.online-card p { margin: 0 0 12px; color: var(--muted); }
.online-actions { display: grid; gap: 10px; margin-top: 14px; }
.rank-big { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; line-height: 1.1; color: var(--primary); }
.rank-big span { font-family: var(--font-body); font-size: 1rem; font-weight: 600; color: var(--muted); }
.rank-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-weight: 600; }
.spinner.small { width: 18px; height: 18px; border-width: 3px; margin: 0 8px 0 0; display: inline-block; vertical-align: middle; }

.mini-flag { width: 24px; height: 18px; object-fit: contain; flex: none; }
.mini-flag.none { display: inline-grid; place-items: center; font-size: .9rem; }

.standings { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.standings li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2);
  font-weight: 600;
}
.standings li.me { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); outline: 2px solid var(--primary); }
.standings .pos { width: 28px; font-family: var(--font-display); font-weight: 800; color: var(--muted); text-align: center; }
.standings li:nth-child(1) .pos { color: #d59a00; }
.standings .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings strong { font-variant-numeric: tabular-nums; }

.chip.duel { background: var(--coral); color: #fff; border-color: transparent; }

/* ---------- Name form ---------- */
.name-form label { display: block; font-weight: 800; margin-bottom: 8px; }
.name-row { display: grid; grid-template-columns: 1fr 140px; gap: 8px; margin-bottom: 12px; }
.name-form input, .name-form select, .select {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
}
.name-form input:focus, .name-form select:focus, .select:focus { outline: none; border-color: var(--primary); }
.form-error { color: var(--bad); font-weight: 700; margin: 8px 0 0 !important; min-height: 1em; }

/* ---------- Leaderboard page ---------- */
.lb-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--line); font-weight: 700; font-size: .92rem; white-space: nowrap;
}
.lb-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 10px 0 14px; }
.lb-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; }
.lb-head p { margin: 4px 0 0; color: var(--muted); }
.lb-head .select { width: auto; min-width: 180px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; margin: 10px 0 18px; }
.podium .step {
  text-align: center; padding: 14px 8px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
}
.podium .step .medal { font-size: 2rem; line-height: 1; }
.podium .step .who { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .step strong { font-family: var(--font-display); font-size: 1.3rem; color: var(--primary); }
.podium .first { order: 2; padding-top: 26px; border-color: var(--sun); box-shadow: 0 5px 0 var(--sun); }
.podium .second { order: 1; }
.podium .third { order: 3; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 3rem; }

/* ---------- Duel landing ---------- */
.duel-hero {
  text-align: center; padding: 30px 22px; border-radius: 28px; color: #fff;
  background: linear-gradient(135deg, #ff7a59 0%, #ff5fa2 55%, #6c4cf5 100%);
  box-shadow: 0 6px 0 #c9452f;
}
.duel-hero .vs { font-size: 3.4rem; line-height: 1; }
.duel-hero h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; margin: 10px 0 6px; }
.duel-hero p { margin: 0 0 18px; opacity: .92; }
.duel-hero .target { font-family: var(--font-display); font-size: 3rem; font-weight: 800; line-height: 1; }

/* ---------- Home: leaderboard teaser ---------- */
.teaser { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.teaser .panel h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.app-card { background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--primary) 12%, var(--surface))); }
.app-card p { color: var(--muted); margin: 0 0 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 22px; }
  .hero-art { display: none; }
  .profile, .teaser { grid-template-columns: 1fr; }
  .nav-link .label { display: none; }
  .player-xp { display: none; }
}
@media (max-width: 420px) {
  .options { gap: 10px; }
  .option { min-height: 58px; font-size: .95rem; }
  .q-card { padding: 16px; }
  .results .stat-grid { gap: 8px; }
  .results .stat { padding: 10px 8px; }
  .results .stat strong { font-size: 1.3rem; }
  .brand small { display: none; }
  .name-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.sponsor-card { margin: 24px 0; padding: 24px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.sponsor-card small { display: block; font-weight: 700; }
.sponsor-card p { line-height: 1.65; margin: 16px 0; }
.sponsor-card input[type=password] { padding: 12px; max-width: 100%; margin: 12px 0; }
.recovery-code { display: block; overflow-wrap: anywhere; padding: 16px; background: var(--surface-2); border-radius: var(--radius-sm); }

/* ---------- Ad slot (pages/templates/pages/_ad.html) ---------- */
.ad-slot { margin: 32px 0; padding: 12px 16px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; }
.ad-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.ad-head span { text-transform: uppercase; letter-spacing: 0.08em; }
.ad-head a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.ad-head a:hover { color: var(--primary); }
.ad-sponsor strong { font-family: var(--font-display); font-size: 1.15rem; }
.ad-sponsor p { margin: 6px 0 10px; color: var(--muted); line-height: 1.55; }
.ad-sponsor a { font-weight: 700; color: var(--primary); }
.ad-slot .adsbygoogle { min-height: 90px; }
/* Google slot stays invisible until an ad is actually served: no empty boxes when
   there is no fill, no consent or an ad blocker. */
.ad-slot.is-google:not(:has(ins[data-ad-status="filled"])) { display: none; }
.results .ad-slot { margin-top: 28px; }

.audience-note { padding: 20px; text-align: center; font-size: 0.85rem; color: var(--muted); }

/* Mini-escape: a code-native room, usable by keyboard and on narrow screens. */
.escape-shell { max-width: 1160px; }
.escape-intro { padding: 32px 0 20px; max-width: 720px; }
.escape-intro h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin: 12px 0; }
.escape-intro p, .escape-footnote { line-height: 1.7; }
.escape-hud { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px 0; font-weight: 700; }
.escape-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
.escape-room { position: relative; min-height: 430px; border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #18333b 0%, #264b50 70%, #493b31 70%); border: 8px solid #183039; }
.escape-window { position: absolute; top: 30px; left: 32px; width: 110px; height: 140px; background: #111e30; border: 10px solid #a67c52; box-shadow: inset 0 0 35px #658787; color: #ffe0a0; font-size: 60px; text-align: center; }
.escape-window::after { content: ''; position: absolute; inset: 0; border-top: 4px solid #a67c52; top: 50%; }
.escape-shelf { position: absolute; right: 24px; top: 30px; color: #d5a475; font-size: 42px; border-bottom: 8px solid #795d42; }
.escape-desk { position: absolute; left: 24px; bottom: 82px; width: 60%; height: 110px; background: #8e6243; border-top: 14px solid #c19060; border-radius: 8px; box-shadow: 0 12px 25px #0005; }
.escape-object { position: absolute; border: 2px solid #ffdfa0; border-radius: 12px; background: #f9ead0; color: #302b27; padding: 12px; font-size: 32px; cursor: pointer; box-shadow: 0 6px 16px #0005; }
.escape-object span { display: block; font: 700 12px/1.5 sans-serif; }
.escape-object:disabled { opacity: .65; cursor: default; border-color: #888; }
.escape-object:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
.escape-letter { left: 40px; bottom: 185px; transform: rotate(-5deg); }
.escape-drawer { left: 58px; bottom: 85px; }
.escape-safe { right: 20px; bottom: 85px; background: #b7c3c5; }
.escape-room-caption { position: absolute; bottom: 12px; left: 12px; right: 12px; text-align: center; color: #fff; font-size: 14px; }
.escape-panel { padding: 28px; background: #fff; border: 1px solid #deddd8; border-radius: 24px; color: #252b32; }
.escape-panel h2 { margin-top: 0; }
.escape-panel p { line-height: 1.65; }
.escape-panel blockquote { margin: 20px 0; padding: 18px; background: #f5ecd9; border-left: 4px solid #b88645; line-height: 2; }
.escape-answer-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.escape-answer-row input { min-width: 0; flex: 1; border: 1px solid #aab0b6; border-radius: 10px; padding: 12px; font: inherit; width: 160px; }
.escape-calendar div { display: flex; justify-content: space-between; padding: 8px 12px; background: #f5ecd9; border-bottom: 1px solid #deddd8; }
.escape-calendar dd { font-weight: 800; }
.escape-mirror { text-align: center; font-size: 36px; letter-spacing: .2em; padding: 24px; background: #edf3f5; border: 5px solid #87989d; border-radius: 50%; }
.escape-hint { padding: 10px; background: #fff6d6; border-radius: 8px; }
#escapeMessage { min-height: 24px; }
#escapeFinish .btn { margin: 8px 4px 0 0; }
.escape-footnote { color: #65717c; font-size: 13px; margin: 24px 0; }
@media (max-width: 760px) { .escape-layout { grid-template-columns: 1fr; } .escape-room { min-height: 350px; } .escape-panel { padding: 20px; } }
.escape-shell [hidden] { display: none !important; }

.expert-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.expert-sidebar { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; }
.expert-sidebar h2 { font-size: 1.1rem; margin: 20px 0 12px; }
.expert-sky { border-radius: 16px; padding: 24px; background: radial-gradient(ellipse at bottom, #393a79, #111529); color: #c9c3fc; font-size: 32px; text-align: center; }
.expert-sky span { font-size: 80px; display: block; color: #ebc593; }
.expert-sky small { display: block; font: 10px/2 monospace; letter-spacing: .15em; }
#expertDossiers button { display: block; width: 100%; text-align: left; padding: 12px; margin: 6px 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; }
#expertDossiers button[aria-current=true] { border-color: var(--primary); box-shadow: inset 3px 0 var(--primary); }
.expert-sidebar label { display: block; font-weight: 700; margin: 24px 0 8px; }
#expertNotes { width: 100%; resize: vertical; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; }
.expert-sidebar > small { display: block; line-height: 1.5; color: var(--muted); margin-top: 8px; }
.expert-panel ol, .expert-panel ul { padding-left: 24px; line-height: 1.8; }
.expert-panel li { margin: 6px 0; }
.expert-table-scroll { overflow-x: auto; margin: 20px 0; }
.expert-panel table { border-collapse: collapse; width: 100%; font-size: 14px; }
.expert-panel th, .expert-panel td { padding: 10px 12px; border-bottom: 1px solid #ddd; text-align: left; }
.expert-panel th { background: #f1eff9; }
.expert-cipher { background: #182435; color: #e4d9b3; border-radius: 12px; padding: 20px; font: 700 20px/1.8 monospace; letter-spacing: .12em; overflow-wrap: anywhere; margin: 20px 0; }
.expert-grid { display: grid; grid-template-columns: 64px repeat(5, 36px); gap: 4px; margin: 18px 0; width: max-content; }
.expert-grid .grid-clue { text-align: center; font: 13px/1.3 monospace; align-self: center; }
.expert-grid button { width: 36px; height: 36px; border: 1px solid #8691a1; border-radius: 4px; background: #fff; color: #555; cursor: pointer; font: 20px/1 monospace; }
.expert-grid button[data-mark=filled] { background: #292447; color: #fff; }
.expert-grid button:focus-visible { outline: 3px solid #7c5cff; outline-offset: 1px; }
.expert-panel .expert-solved { background: #e2f4e8; padding: 12px; border-radius: 10px; font-weight: 700; }
#expertFinish .btn { margin: 8px 4px 0 0; }
@media (max-width: 760px) { .expert-layout { grid-template-columns: 1fr; } .expert-sky { display: none; } .expert-sidebar h2 { margin-top: 0; } #expertDossiers { display: flex; flex-wrap: wrap; gap: 5px; } #expertDossiers button { width: auto; flex: 1 1 120px; } #expertNotes { min-height: 100px; } }

/* ---------- Map quiz ---------- */
.wrap-map { max-width: 980px; }
.map-q { flex-direction: row; justify-content: center; gap: 14px; padding: 14px 18px; }
.map-q .q-ask { font-size: clamp(1.15rem, 3.6vw, 1.55rem); text-align: left; }
.map-q-flag { width: 64px; aspect-ratio: 3 / 2; object-fit: contain; filter: drop-shadow(0 2px 6px var(--shade)); flex: none; }
.map-host { margin-top: 12px; }
.map-host > .loading { min-height: 300px; }
.map-help { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: .85rem; }

.world-map {
  --sea: #cfe8ff; --land: #e4e1ee; --country: #fdfcff; --border: #aaa3c4; --hover: #d9d0ff;
  position: relative; border-radius: 22px; overflow: hidden; border: 2px solid var(--line);
  background: var(--sea); box-shadow: 0 6px 0 var(--line);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .world-map { --sea: #13243b; --land: #26233a; --country: #3a3557; --border: #6b648f; --hover: #57499c; }
}
:root[data-theme="dark"] .world-map { --sea: #13243b; --land: #26233a; --country: #3a3557; --border: #6b648f; --hover: #57499c; }
.wm-svg { height: min(62vh, 560px, max(300px, 95vw)); touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; }
.wm-svg.dragging { cursor: grabbing; }
.wm-svg svg { display: block; width: 100%; height: 100%; }
.wm-svg .sea { fill: var(--sea); }
.wm-svg .graticule path { fill: none; stroke: color-mix(in srgb, var(--border) 35%, transparent); stroke-width: .6; vector-effect: non-scaling-stroke; }
.wm-svg .land path { fill: var(--land); stroke: var(--border); stroke-width: .5; vector-effect: non-scaling-stroke; }
.wm-svg .countries path { fill: var(--country); stroke: var(--border); stroke-width: .7; vector-effect: non-scaling-stroke; transition: fill .15s ease; }
.wm-svg .dots circle { fill: var(--country); stroke: var(--primary); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
@media (hover: hover) {
  .wm-svg:not(.locked):not(.dragging) .countries path:hover,
  .wm-svg:not(.locked):not(.dragging) .dots circle:hover { fill: var(--hover); }
}
.wm-svg .countries path.good, .wm-svg .dots circle.good { fill: var(--good); stroke: var(--good-shade); animation: mapPulse 1s ease 2; }
.wm-svg .countries path.bad, .wm-svg .dots circle.bad { fill: var(--bad); stroke: var(--bad-shade); }
@keyframes mapPulse { 50% { opacity: .55; } }
.wm-zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 6px; }
.wm-zoom .btn { min-height: 40px; width: 40px; padding: 0; font-size: 1.2rem; border-radius: 12px; box-shadow: 0 3px 0 var(--btn-shade); }

/* ---------- Live duel ---------- */
.live-hero { margin-top: 8px; }
.live-cards { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin: 20px 0 40px; align-items: start; }
.live-cards h2 { font-size: 1.35rem; font-weight: 800; margin-bottom: 12px; }
.live-form fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.live-form legend, .live-form > label:not(.check) { display: block; font-weight: 800; margin-bottom: 8px; padding: 0; }
.live-form .hint, .lobby-action .hint { margin: 4px 0 14px; color: var(--muted); font-size: .85rem; }
.name-slot { margin-top: 16px; padding-top: 16px; border-top: 2px dashed var(--line); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface-2); font-weight: 700; cursor: pointer;
}
.seg input:checked + span { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 16%, var(--surface)); }
.seg input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--coral); }
.code-input {
  width: 100%; min-height: 60px; margin-bottom: 12px; padding: 8px 12px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); text-align: center; text-transform: uppercase;
  font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: .3em;
}
.code-box { display: inline-block; margin: 4px 0 12px; padding: 10px 26px; border-radius: 18px; background: #fff; color: #17142b; }
.code-box small { display: block; font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: #6b6785; }
.code-box strong { font-family: var(--font-display); font-size: clamp(2.4rem, 10vw, 3.6rem); font-weight: 800; letter-spacing: .14em; line-height: 1.1; }
.duel-hero .join-hint { font-size: .92rem; word-break: break-word; }
.live-shell .panel { margin-top: 16px; }
.lobby-players li.empty { justify-content: center; color: var(--muted); padding: 18px; }
.standings .tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--coral); }
.lobby-action { margin-top: 16px; }
.waiting { text-align: center; color: var(--muted); font-weight: 700; margin: 8px 0; }

.live-hud { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.live-hud .code-chip { margin-left: auto; letter-spacing: .12em; }
.live-shell .progress { margin-bottom: 14px; height: 12px; }
.live-shell .progress > span { transition: none; }
.answered { text-align: center; color: var(--muted); font-weight: 700; margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.option.picked { --btn-bg: color-mix(in srgb, var(--primary) 18%, var(--surface)); --btn-shade: var(--primary); border-color: var(--primary); opacity: 1; }
.option.picked .key { background: var(--primary); border-color: var(--primary); color: #fff; }

.countdown { text-align: center; padding: 60px 0; color: var(--muted); font-weight: 700; }
.countdown-num { font-family: var(--font-display); font-size: 7rem; font-weight: 800; line-height: 1; color: var(--coral); animation: pop 1s ease infinite; }

.reveal-card { margin-top: 16px; padding: 16px 18px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); }
.reveal-card.good { background: var(--good-soft); border-color: var(--good); }
.reveal-card.bad { background: var(--bad-soft); border-color: var(--bad); }
.reveal-card h3 { font-size: 1.3rem; font-weight: 800; }
.reveal-card.good h3 { color: var(--good); }
.reveal-card.bad h3 { color: var(--bad); }
.reveal-country { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; }
.reveal-card .facts { margin: 0; font-size: .92rem; opacity: .85; }
.round-picks .pick, .podium .pick { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.round-picks .pick.ok { color: var(--good); }
.round-picks .pick.no { color: var(--bad); }
.round-picks .pick.late, .podium .pick { color: var(--muted); }
.round-picks strong, .podium strong { min-width: 52px; text-align: right; }
.podium .pos { font-size: 1.2rem; }
.section-head h3 { font-size: 1.15rem; font-weight: 800; }

@media (max-width: 760px) {
  .live-cards { grid-template-columns: 1fr; }
  .map-q { padding: 12px; }
  .map-q-flag { width: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .countdown-num, .wm-svg .countries path.good { animation: none; }
}

/* ---------- Categories ---------- */
.cat-nav { display: flex; gap: 8px; overflow-x: auto; margin: 28px 0 -12px; padding: 4px 2px 8px; scrollbar-width: none; }
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav a {
  flex: none; padding: 8px 14px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: .92rem; white-space: nowrap;
}
.cat-nav a:hover { border-color: var(--primary); }
.category { scroll-margin-top: 16px; }

/* ---------- Science: element tile, periodic table board ---------- */
.element-tile {
  position: relative; width: 150px; aspect-ratio: 1; border-radius: 22px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--mint) 18%, var(--surface)); border: 3px solid var(--mint); box-shadow: 0 6px 0 var(--mint);
}
.element-tile.enter { animation: flagIn .35s cubic-bezier(.2,.9,.3,1.3); }
.element-tile small { position: absolute; left: 14px; top: 10px; font-weight: 800; color: var(--muted); }
.element-tile strong { font-family: var(--font-display); font-size: 4.2rem; font-weight: 800; line-height: 1; }
.option.big-option .opt-label { font-family: var(--font-display); font-size: 1.6rem; }

.map-q-flag[hidden] { display: none; }
.map-host.board-elements .world-map { --sea: var(--surface-2); }
.map-host.board-elements .wm-svg { height: auto; aspect-ratio: 1016 / 540; max-height: 70vh; }
.map-host.board-elements .wm-zoom { right: auto; left: 39%; top: 8px; translate: -50% 0; grid-auto-flow: column; }
.wm-svg .cells rect { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; vector-effect: non-scaling-stroke; transition: fill .15s ease; }
.wm-svg .cells text { fill: var(--ink); pointer-events: none; font-family: var(--font-body); }
.wm-svg .cells text.n { font-size: 10px; font-weight: 700; fill: var(--muted); }
.wm-svg .cells text.s { font-size: 21px; font-weight: 800; text-anchor: middle; font-family: var(--font-display); }
.wm-svg .cells .ph rect { fill: transparent; stroke-dasharray: 4 3; }
.wm-svg .cells .ph text.n { text-anchor: middle; font-size: 9px; }
@media (hover: hover) {
  .wm-svg:not(.locked):not(.dragging) .cells [data-c]:hover rect { fill: var(--hover); }
}
.wm-svg .cells g.good rect { fill: var(--good); stroke: var(--good-shade); animation: mapPulse 1s ease 2; }
.wm-svg .cells g.bad rect { fill: var(--bad); stroke: var(--bad-shade); }
.wm-svg .cells g.good text, .wm-svg .cells g.bad text { fill: #fff; }
.options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option > span { min-width: 0; overflow-wrap: anywhere; }
.option .opt-detail:not([hidden]) { display: block; }
@media (max-width: 760px) {
  .category .section-head { flex-direction: column; align-items: flex-start; gap: 2px; }
}

/* ---------- Physics: formula prompt ---------- */
.formula-box {
  padding: 18px 26px; border-radius: 20px; background: var(--surface-2); border: 2px solid var(--line);
  font-family: var(--font-display); font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 800; white-space: nowrap;
}
.formula-box.enter { animation: flagIn .35s cubic-bezier(.2,.9,.3,1.3); }
.formula-box .blank {
  display: inline-block; min-width: 1.4em; padding: 0 .2em; border-radius: 10px; text-align: center;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--surface)); border: 2px dashed var(--primary);
}

/* ---------- Estimation games ---------- */
.q-flag-small { width: min(60%, 200px); }
.estimate { margin-top: 18px; padding: 20px 18px; border-radius: 26px; background: var(--surface); border: 2px solid var(--line); box-shadow: 0 6px 0 var(--line); text-align: center; }
.est-value {
  display: block; font-family: var(--font-display); font-size: clamp(1.7rem, 7vw, 2.4rem); font-weight: 800;
  color: var(--primary); font-variant-numeric: tabular-nums; margin-bottom: 14px; transition: color .2s ease;
}
.est-value.good { color: var(--good); }
.est-value.near { color: #c98a00; }
.est-value.bad { color: var(--bad); }
.est-track { position: relative; padding: 6px 0; }
.est-track input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 99px; margin: 0;
  background: linear-gradient(90deg, var(--sky), var(--primary), var(--pink)); outline: none; cursor: pointer;
}
.est-track input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: 4px solid var(--primary); box-shadow: 0 3px 0 var(--primary-shade);
}
.est-track input[type=range]::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 4px solid var(--primary);
}
.est-track input[type=range]:focus-visible { outline: 3px solid var(--sky); outline-offset: 6px; }
.est-track input[type=range]:disabled { cursor: default; opacity: .75; }
.est-true {
  position: absolute; top: -8px; bottom: -8px; width: 6px; margin-left: -3px; border-radius: 3px;
  background: var(--good); box-shadow: 0 0 0 3px var(--surface); pointer-events: none; animation: pop .5s ease;
}
.est-true::after {
  content: "echt"; position: absolute; top: 100%; left: 50%; translate: -50% 4px;
  font-size: .75rem; font-weight: 800; color: var(--good);
}
.est-scale { display: flex; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.est-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.est-actions .btn[data-nudge] { width: 56px; padding: 0; }
.est-actions #estGo { flex: 1; max-width: 340px; }
.sheet.near { background: color-mix(in srgb, var(--sun) 22%, var(--surface)); border-color: var(--sun); }
.sheet.near h3 { color: #a87200; }
.btn-near { --btn-bg: var(--sun); --btn-fg: #3a2a00; --btn-shade: #c98a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet.near h3 { color: var(--sun); } }
:root[data-theme="dark"] .sheet.near h3 { color: var(--sun); }

/* ---------- History: event card, timeline ---------- */
.event-card {
  max-width: 460px; padding: 18px 22px; border-radius: 20px; text-align: center;
  background: color-mix(in srgb, var(--sun) 18%, var(--surface)); border: 2px solid var(--sun); box-shadow: 0 5px 0 var(--sun);
  font-family: var(--font-display); font-size: clamp(1.2rem, 5vw, 1.5rem); font-weight: 800; line-height: 1.25;
}
.event-card.enter { animation: flagIn .35s cubic-bezier(.2,.9,.3,1.3); }
.tl-help { text-align: center; color: var(--muted); font-size: .85rem; margin: 14px 0 8px; }
.timeline { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.tl-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 18px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line);
}
.tl-item.moved { animation: pop .3s ease; }
.tl-item.good { background: var(--good-soft); border-color: var(--good); box-shadow: 0 4px 0 var(--good); }
.tl-item.bad { background: var(--bad-soft); border-color: var(--bad); box-shadow: 0 4px 0 var(--bad); }
.tl-pos {
  flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); font-family: var(--font-display); font-weight: 800;
}
.tl-item.good .tl-pos { background: var(--good); color: #fff; }
.tl-item.bad .tl-pos { background: var(--bad); color: #fff; }
.tl-text { flex: 1; min-width: 0; font-weight: 700; line-height: 1.3; }
.tl-year { display: block; margin-top: 2px; font-size: .85rem; font-weight: 800; color: var(--muted); }
.tl-moves { display: flex; flex-direction: column; gap: 6px; flex: none; }
.tl-moves .btn { min-height: 38px; width: 44px; padding: 0; border-radius: 12px; box-shadow: 0 3px 0 var(--btn-shade); }
.tl-moves .btn:disabled { opacity: .35; }
.side-cards { display: grid; gap: 16px; align-content: start; }
.push-card { background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--sun) 16%, var(--surface))); }
.panel[hidden] { display: none; }
