:root {
  --bg: #faf5ee;
  --surface: #fffaf3;
  --board: #fcf3e8;
  --grid: rgba(176, 120, 92, 0.13);
  --line: #e6d6c6;
  --ink: #1d1a22;
  --ink-2: #5b5560;
  --ink-3: #8c8590;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(200, 16, 46, 0.1);
  --ok: #1f9d55;
  --ok-soft: #e3f5ea;
  --warn: #c07a12;
  --warn-soft: #fbefd9;
  --bad: #d62839;
  --bad-soft: #fde4e6;
  --gold: #e0a100;
  --gold-soft: #fff4d1;
  --blue: #2f6fdf;
  --blue-soft: #e5eeff;
  --card: #ffffff;
  --card-border: #eadccd;
  --shadow: 0 1px 2px rgba(60, 30, 20, 0.06), 0 6px 18px rgba(60, 30, 20, 0.07);
  --shadow-lift: 0 10px 30px rgba(60, 30, 20, 0.22);
  --radius: 16px;
  --radius-lg: 22px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16141a; --surface: #1d1a21; --board: #1f1b20; --grid: rgba(255, 220, 200, 0.06);
    --line: #342e33; --ink: #f4eee8; --ink-2: #bdb4b8; --ink-3: #8a8187;
    --accent: #ff4d63; --accent-ink: #1a0b0e; --accent-soft: rgba(255, 77, 99, 0.14);
    --ok: #3ccf7f; --ok-soft: rgba(60, 207, 127, 0.14); --warn: #f0a83a; --warn-soft: rgba(240, 168, 58, 0.14);
    --bad: #ff5d6c; --bad-soft: rgba(255, 93, 108, 0.14); --gold: #ffc53d; --gold-soft: rgba(255, 197, 61, 0.14);
    --blue: #6c9cff; --blue-soft: rgba(108, 156, 255, 0.14);
    --card: #26222a; --card-border: #3a3339;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --shadow-lift: 0 12px 34px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #16141a; --surface: #1d1a21; --board: #1f1b20; --grid: rgba(255, 220, 200, 0.06);
  --line: #342e33; --ink: #f4eee8; --ink-2: #bdb4b8; --ink-3: #8a8187;
  --accent: #ff4d63; --accent-ink: #1a0b0e; --accent-soft: rgba(255, 77, 99, 0.14);
  --ok: #3ccf7f; --ok-soft: rgba(60, 207, 127, 0.14); --warn: #f0a83a; --warn-soft: rgba(240, 168, 58, 0.14);
  --bad: #ff5d6c; --bad-soft: rgba(255, 93, 108, 0.14); --gold: #ffc53d; --gold-soft: rgba(255, 197, 61, 0.14);
  --blue: #6c9cff; --blue-soft: rgba(108, 156, 255, 0.14);
  --card: #26222a; --card-border: #3a3339;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  --shadow-lift: 0 12px 34px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; color: inherit; }
input { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 26px; border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 16px; text-decoration: none;
  transition: transform .12s ease, box-shadow .15s ease, opacity .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(200, 16, 46, 0.28); }
.btn--primary:hover { box-shadow: 0 8px 22px rgba(200, 16, 46, 0.36); }
.btn--primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn--ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink-3); }
.btn--dark { background: var(--ink); color: var(--bg); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 16px; font-size: 14px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); flex: none;
  transition: transform .15s ease, box-shadow .15s ease; text-decoration: none; color: var(--ink);
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.icon-btn--accent { background: var(--accent); color: var(--accent-ink); }

/* ---------- Surfaces ---------- */
.panel {
  position: relative; border: 1.5px solid var(--line); border-radius: var(--radius-lg); padding: 16px;
  background-color: var(--board);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
.card {
  background: var(--card); border: 1.5px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
}
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--gold { background: var(--gold-soft); color: var(--gold); }
.chip--blue { background: var(--blue-soft); color: var(--blue); }
.label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.muted { color: var(--ink-3); }
.big-num { font-family: var(--font-mono); font-weight: 700; }

/* Chat bubble (used by Catch the Bot etc.) */
.bubble {
  position: relative; background: var(--card); border: 1.5px solid var(--card-border); border-radius: 18px 18px 18px 6px;
  padding: 12px 14px; box-shadow: var(--shadow); max-width: 100%;
}
.bubble--me { background: var(--accent); color: var(--accent-ink); border-color: transparent; border-radius: 18px 18px 6px 18px; }

/* ---------- Timer bar ---------- */
.timer {
  position: relative; height: 10px; border-radius: 999px; background: var(--line); overflow: visible; margin: 6px 0 14px;
}
.timer-fill {
  position: absolute; inset: 0; border-radius: 999px; background: var(--ok); transform-origin: left center;
  transition: background-color .3s ease;
}
.timer--warn .timer-fill { background: var(--bad); }
.timer-label {
  position: absolute; right: 0; top: -22px; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.timer--warn .timer-label { color: var(--bad); }

/* ---------- Confidence bet sheet ---------- */
.bet-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 50;
  width: min(560px, 100vw); padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(30, 10, 10, 0.25);
  animation: sheet-in .25s cubic-bezier(.2,.8,.2,1);
}
.bet-sheet--out { animation: sheet-out .18s ease forwards; }
@keyframes sheet-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheet-out { to { transform: translate(-50%, 100%); opacity: 0; } }
.bet-q { margin: 0 0 12px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.bet-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bet-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card); cursor: pointer; transition: transform .12s ease, border-color .12s ease;
}
.bet-btn:active { transform: scale(.96); }
.bet-btn:hover { border-color: var(--accent); }
.bet-emoji { font-size: 26px; line-height: 1.2; }
.bet-label { font-weight: 700; font-size: 14px; }
.bet-odds { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }
.bet-btn--sure { border-color: var(--gold); background: var(--gold-soft); }

/* ---------- Effects ---------- */
.float-text {
  position: fixed; z-index: 90; transform: translate(-50%, 0); pointer-events: none; white-space: nowrap;
  font-family: var(--font-mono); font-weight: 700; font-size: 18px; padding: 4px 10px; border-radius: 999px;
  animation: float-up 1.1s cubic-bezier(.2,.8,.2,1) forwards; box-shadow: var(--shadow);
}
.float-text--good { background: var(--ok); color: #fff; }
.float-text--bad { background: var(--bad); color: #fff; }
.float-text--info { background: var(--ink); color: var(--bg); }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); }
  15% { opacity: 1; transform: translate(-50%, -6px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}
.fx-shake { animation: fx-shake .38s ease; }
@keyframes fx-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.fx-pop { animation: fx-pop .4s cubic-bezier(.2,.8,.2,1.3); }
@keyframes fx-pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 100; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  transition: opacity .2s ease, transform .2s ease; z-index: 110; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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