:root {
  --bg: #0f1020;
  --bg-soft: #1a1b34;
  --card: #20223f;
  --card-2: #282a4d;
  --line: #34375f;
  --txt: #f3f4ff;
  --muted: #a3a7d4;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --accent: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #2a2c63 0%, var(--bg) 55%);
  color: var(--txt);
  font-family: "Segoe UI", "Heebo", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Generic ---------- */
.screen { animation: fade .35s ease; display: flex; flex-direction: column; gap: 18px; flex: 1; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

.title {
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  font-weight: 900;
  text-align: center;
  margin: 6px 0 0;
  background: linear-gradient(120deg, var(--accent), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -1px;
}
.subtitle { text-align: center; color: var(--muted); margin-top: -8px; font-weight: 600; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.center { text-align: center; }
.grow { flex: 1; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: 1.05rem;
  color: #fff; padding: 16px 20px; border-radius: 14px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(99,102,241,.35);
  transition: transform .08s ease, filter .2s ease, opacity .2s;
  width: 100%;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; filter: grayscale(.4); cursor: default; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--txt); box-shadow: none; }
.btn.accent { background: linear-gradient(120deg, var(--accent), #3b82f6); box-shadow: 0 8px 20px rgba(34,211,238,.3); }
.btn.danger { background: linear-gradient(120deg, #ef4444, #f97316); box-shadow:none; }
.btn.sm { padding: 10px 14px; font-size: .95rem; width: auto; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.3rem; font-weight: 900;
  background: var(--card-2); border: 1px solid var(--line); color: var(--txt); cursor: pointer;
}

/* ---------- Inputs ---------- */
.input, .answer-input {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  background: #15162c; border: 1.5px solid var(--line); color: var(--txt);
  font-family: inherit; font-size: 1.05rem; outline: none; transition: border-color .15s;
}
.input:focus, .answer-input:focus { border-color: var(--brand); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; color: var(--muted); font-size: .9rem; }

.stepper { display: flex; align-items: center; gap: 14px; justify-content: center; }
.stepper .val { font-size: 2rem; font-weight: 900; min-width: 50px; text-align: center; }

/* ---------- Players list ---------- */
.player-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.player-row .input { flex: 1; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 1.1rem;
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #15162c; color: var(--muted); font-weight: 700; cursor: pointer;
  transition: all .15s; user-select: none;
}
.chip.on { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }

/* ---------- Letter reveal ---------- */
.letter-big {
  font-size: clamp(7rem, 40vw, 12rem); font-weight: 900; text-align: center;
  line-height: 1; margin: 10px 0;
  background: linear-gradient(160deg, var(--accent), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop .5s ease;
  text-shadow: 0 0 60px rgba(139,92,246,.4);
}
.turn-banner { text-align: center; font-size: 1.1rem; color: var(--muted); }
.turn-banner b { color: var(--txt); font-size: 1.4rem; }

/* ---------- Timer ---------- */
.timer-wrap { display: grid; place-items: center; margin: 4px 0; }
.timer {
  font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums;
  padding: 6px 22px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line);
}
.timer.low { color: var(--bad); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------- Category answer row ---------- */
.cat-block { margin-bottom: 14px; }
.cat-block .field label { display: flex; align-items: center; gap: 8px; font-size: 1rem; color: var(--txt); }
.cat-emoji { font-size: 1.2rem; }

/* ---------- Scoring ---------- */
.score-cat { margin-bottom: 16px; }
.score-cat h3 { margin: 0 0 8px; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.ans-line {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 12px; background: #15162c; border: 1px solid var(--line); margin-bottom: 8px;
}
.ans-line .who { font-weight: 800; flex: 0 0 auto; }
.ans-line .val { flex: 1; color: var(--txt); }
.ans-line .val.empty { color: var(--muted); font-style: italic; }
.ans-line .pts {
  font-weight: 900; min-width: 42px; text-align: center; padding: 4px 8px; border-radius: 8px;
  background: var(--card-2); cursor: pointer; user-select: none; border:1px solid var(--line);
}
.ans-line .pts.p0 { color: var(--bad); }
.ans-line .pts.p5 { color: var(--warn); }
.ans-line .pts.p10 { color: var(--good); }

/* ---------- Standings ---------- */
.stand-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #15162c; border: 1px solid var(--line); margin-bottom: 10px; }
.stand-row .rank { font-size: 1.3rem; font-weight: 900; width: 32px; text-align: center; }
.stand-row .nm { flex: 1; font-weight: 800; }
.stand-row .sc { font-weight: 900; font-size: 1.3rem; color: var(--accent); }
.stand-row.lead { background: linear-gradient(120deg, rgba(139,92,246,.25), rgba(34,211,238,.15)); border-color: var(--brand); }

.footer-note { text-align: center; color: var(--muted); font-size: .85rem; margin-top: auto; padding-top: 14px; }
.install-bar { position: sticky; bottom: 8px; }

.badge { display:inline-block; padding: 3px 10px; border-radius:999px; background: var(--card-2); border:1px solid var(--line); font-size:.8rem; font-weight:700; color: var(--muted); }
.hide { display: none !important; }
