/* Dual Threat: mobile-first styles. Sister look to ModiDex (same navy, fonts and shapes),
   with its own pink + cyan accent. Colors live in :root so the look is easy to change. */
:root {
  --bg: #0b1020;
  --bg-2: #121933;
  --panel: #161f3d;
  --panel-2: #1d284d;
  --line: #2a376a;
  --text: #eef2ff;
  --muted: #9aa6cf;
  --accent: #ff5ca8;      /* Dual Threat pink */
  --accent-2: #22d3ee;    /* cyan, shared with ModiDex */
  --lime: #c6ff3d;        /* ModiDex lime, used sparingly */
  --hit: #22c55e;
  --athlete: #3b82f6;
  --poke: #eab308;
  --danger: #f43f5e;
  --radius: 14px;
  --font-display: 'Russo One', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 92, 168, 0.16), transparent 70%),
    radial-gradient(800px 400px at 100% 0, rgba(34, 211, 238, 0.10), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.3px; }
.small { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: rgba(11, 16, 32, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-actions { display: flex; gap: 6px; }
.brand { display: flex; align-items: center; gap: 7px; color: var(--text); text-decoration: none; min-width: 0; }
.brand-name { font: 22px/1 var(--font-display); letter-spacing: 0.5px; white-space: nowrap; }
.brand-name span { color: var(--accent); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 17px; font-weight: 800; cursor: pointer;
}
.icon-btn:active { transform: scale(0.95); }
@media (max-width: 370px) {
  .brand-name { font-size: 18px; }
  .brand img { width: 28px; height: 28px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* ---------- tabs ---------- */
.kinds {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  max-width: 560px; margin: 12px auto 0; padding: 0 12px;
}
.kind-tab {
  height: 40px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  font: 13px/1 var(--font-display); letter-spacing: 0.4px; color: var(--muted);
}
.kind-tab.is-active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.modes {
  display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 6px;
  max-width: 560px; margin: 8px auto 0; padding: 0 12px;
}
.mode-tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
}
.mode-tab .mode-emoji { font-size: 18px; line-height: 1; }
.mode-tab .mode-label { font: 11px/1 var(--font-display); letter-spacing: 0.5px; color: var(--muted); }
.mode-tab.is-active { border-color: var(--accent-2); background: var(--panel-2); box-shadow: 0 0 0 1px var(--accent-2) inset; }
.mode-tab.is-active .mode-label { color: var(--accent-2); }
.mark {
  position: absolute; top: -5px; right: -5px;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
  background: var(--hit); color: #04140a;
}

main { max-width: 560px; margin: 0 auto; padding: 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- panels ---------- */
.panel {
  margin-top: 12px; padding: 16px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line);
}
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.eyebrow { margin: 0 0 6px; font: 12px/1.2 var(--font-display); letter-spacing: 0.8px; text-transform: uppercase; color: var(--accent-2); }
.intro h2 { margin: 0 0 12px; font-size: 21px; line-height: 1.2; }
.intro h2 em { font-style: normal; color: var(--accent); }
.intro-points { margin: 0 0 16px; padding-left: 18px; display: grid; gap: 6px; color: var(--muted); }
.intro-points b { color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  height: 44px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); font-weight: 800;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); color: #1a0613; border-color: var(--accent); }
.btn-block { display: block; width: 100%; }
.btn-big { height: 52px; font-size: 16px; margin-top: 12px; }
.btn-small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.link-btn { background: none; border: 0; padding: 4px; color: var(--accent-2); cursor: pointer; text-decoration: underline; font-size: 13px; }

.run-bar {
  display: flex; justify-content: space-between; gap: 8px; margin: 4px 2px 8px;
  font: 12px/1.2 var(--font-display); letter-spacing: 0.5px; color: var(--muted);
}
.run-bar b { color: var(--text); font-size: 14px; }

/* ---------- question ---------- */
.qcard {
  padding: 14px; border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 92, 168, 0.14), transparent 45%),
    linear-gradient(340deg, rgba(34, 211, 238, 0.10), transparent 45%),
    var(--panel);
  border: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.q-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 10px; margin-bottom: 10px; }
.q-label { font: 13px/1.2 var(--font-display); letter-spacing: 0.5px; }
.q-avail { font-size: 12px; color: var(--muted); }
.q-avail b { color: var(--lime); }
.clue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.clue {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: start; gap: 8px;
  padding: 9px 10px; border-radius: 12px; font-size: 15px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.clue p { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.clue-n {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font: 12px/1 var(--font-display); background: var(--panel-2); color: var(--muted);
}
.clue-x { font: 12px/24px var(--font-display); color: var(--muted); }
.clue.is-open { border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line)); }
.clue.is-open .clue-n { background: var(--accent-2); color: var(--bg); }
.clue.is-new { background: rgba(34, 211, 238, 0.10); animation: clueIn 0.45s ease-out; }
.clue.is-new .clue-x { color: var(--lime); }
.locked-row { display: flex; flex-wrap: wrap; gap: 4px; }
.lock-chip { flex: 1 1 0; min-width: 64px; padding: 5px 6px; border-radius: 10px; border: 1px dashed var(--line); font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }
.lock-chip b { font-family: var(--font-display); font-weight: 400; }
@keyframes clueIn { from { opacity: 0; transform: translateY(-4px); } }

.timer { margin-top: 10px; }
.timer-bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.timer-bar span { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.2s linear; }
.timer.is-final .timer-bar span { background: var(--danger); }
.timer-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.timer-text { font-size: 12px; color: var(--muted); }
.host-note { margin: 10px 2px 0; font-size: 12px; color: var(--muted); text-align: center; }

.boxes { display: grid; gap: 10px; margin-top: 12px; }
.abox { padding: 10px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.abox[data-box="athlete"] { border-left: 4px solid var(--athlete); }
.abox[data-box="pokemon"] { border-left: 4px solid var(--poke); }
.abox.is-hit { border-color: var(--hit); background: rgba(34, 197, 94, 0.10); }
.abox.is-out { opacity: 0.75; }
.abox-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.abox-title { font: 12px/1 var(--font-display); letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.tries { display: flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); }
.dot.used { background: var(--line); }
.abox-locked { font-size: 15px; color: var(--hit); }
.abox-locked b { color: var(--text); }
.abox-locked span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.abox-out { font-size: 13px; color: var(--muted); }
.misses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.miss-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(244, 63, 94, 0.15); color: #fda4af; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.ac-wrap { position: relative; }
.ans-input {
  width: 100%; height: 46px; padding: 0 12px;
  border-radius: 12px; border: 2px solid var(--line); background: var(--bg);
  color: var(--text); font: 16px var(--font-body); /* 16px stops iOS zooming */
}
.ans-input:focus { outline: none; border-color: var(--accent-2); }
.ac-list {
  position: absolute; max-height: min(260px, 40vh); left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  list-style: none; margin: 0; padding: 4px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.ac-item { display: flex; justify-content: space-between; gap: 8px; padding: 10px; border-radius: 8px; cursor: pointer; }
.ac-item.is-active, .ac-item:hover { background: rgba(34, 211, 238, 0.15); }
.ac-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ac-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ac-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.q-foot { text-align: center; margin-top: 8px; }

/* ---------- reveal ---------- */
.reveal { margin-top: 12px; padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.reveal-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.reveal-side {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  padding: 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line);
}
.reveal-side.is-hit { border-color: var(--hit); }
.reveal-label { font: 10px/1 var(--font-display); letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.reveal-name { font: 17px/1.15 var(--font-display); overflow-wrap: anywhere; }
.reveal-sub { font-size: 12px; color: var(--muted); }
.reveal-mark { margin-top: auto; padding-top: 4px; font-weight: 800; color: var(--danger); }
.reveal-side.is-hit .reveal-mark { color: var(--hit); }
.reveal-link { align-self: center; font-size: 20px; color: var(--accent); }
.why {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: linear-gradient(90deg, rgba(255, 92, 168, 0.12), rgba(34, 211, 238, 0.10));
  border: 1px dashed rgba(255, 92, 168, 0.5);
}
.why span { display: block; font: 10px/1 var(--font-display); letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.pts-line { margin: 10px 0 0; text-align: center; color: var(--muted); }
.pts-line b { color: var(--lime); }

/* ---------- results ---------- */
.results { text-align: center; }
.big-score { margin: 4px 0; font-family: var(--font-display); }
.big-score b { font-size: 54px; font-weight: 400; color: var(--accent); }
.big-score span { font-size: 18px; color: var(--muted); margin-left: 6px; }
.grid-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 12px 0 4px; font-size: 26px; line-height: 1; }
.next-in { margin-top: 12px; font-size: 13px; color: var(--muted); }
.next-in b { font: 15px var(--font-display); color: var(--text); }
.recap { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.recap li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.recap li:last-child { border-bottom: 0; }
.recap-names { min-width: 0; overflow-wrap: anywhere; }
.cta-row { margin-top: 12px; }

/* ---------- leaderboard ---------- */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board li { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 10px; background: var(--bg-2); font-size: 14px; }
.board li.is-me { outline: 2px solid var(--accent); }
.board li.gap { background: none; display: block; text-align: center; color: var(--muted); padding: 0; }
.board .rank { font-family: var(--font-display); color: var(--muted); text-align: center; }
.board .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .grid-mini { font-size: 9px; letter-spacing: -1px; white-space: nowrap; }
.board-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; padding: 10px; border-radius: 12px; background: rgba(255, 92, 168, 0.10); font-size: 13px; }
@media (max-width: 420px) { .board .grid-mini { display: none; } .board li { grid-template-columns: 28px 1fr auto; } }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 10px; }
.seg-btn { height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); font-size: 12px; cursor: pointer; }
.seg-btn.is-active { border-color: var(--accent-2); color: var(--accent-2); }

/* ---------- dialogs ---------- */
.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); overflow: auto;
}
.dialog::backdrop { background: rgba(3, 6, 15, 0.7); backdrop-filter: blur(3px); }
.dlg-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 14px; }
.dlg-body p { margin: 0 0 10px; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 12px; }
.steps li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.step-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 16px/1 var(--font-display); background: var(--accent); color: var(--bg); }
.email-form { display: flex; gap: 6px; margin: 10px 0; }
.email-form input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text); font: 16px var(--font-body); }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 10px; }
.stats-table th, .stats-table td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.stats-table thead th { font: 11px/1 var(--font-display); color: var(--muted); text-transform: uppercase; }
.stats-table tbody th { text-align: left; font-weight: 600; }

/* ---------- footer, toast ---------- */
.footer { max-width: 560px; margin: 24px auto 0; padding: 16px 16px 32px; text-align: center; color: var(--muted); font-size: 12px; }
.footer p { margin: 0 0 8px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
.legal { font-size: 11px; opacity: 0.8; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; transition: 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- join page (Host Mode viewers) ---------- */
.join-status { font-size: 12px; color: var(--muted); text-align: right; min-width: 0; }
.join-status b { color: var(--text); }
.code-tag { padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--bg); font-family: var(--font-display); letter-spacing: 1px; }
.join-panel h2 { margin: 0 0 12px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input { height: 48px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text); font: 16px var(--font-body); }
.field input:focus { outline: none; border-color: var(--accent-2); }
.field .code-input { font: 28px/1 var(--font-display); letter-spacing: 0.3em; text-transform: uppercase; text-align: center; height: 60px; }
.form-msg { margin: 10px 0 0; padding: 10px; border-radius: 10px; background: rgba(244, 63, 94, 0.12); color: #fda4af; font-size: 14px; }
.center .board { text-align: left; }
