/* Apples to Ablations — shared styles.
   Dark by default: the projector view lives in a dim room, and the phone views are
   held in that same dim room, so a light theme would be forty little flashlights. */

:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1f242d;
  --line: #2b323d;
  --ink: #e8edf4;
  --muted: #8b95a5;
  --green: #3fa96a;
  --green-ink: #0d2016;
  --red: #c0453f;
  --red-ink: #24090a;
  --gold: #d6a94a;
  --accent: #5b8def;
  --radius: 14px;
  --pad: clamp(12px, 3vw, 20px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { min-height: 100dvh; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--pad);
}

h1, h2, h3 { margin: 0 0 0.5em; line-height: 1.15; }
p { line-height: 1.5; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--pad);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .who { font-weight: 600; }
.topbar .meta { color: var(--muted); font-size: 0.85rem; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.judge { background: var(--gold); color: #241a05; border-color: transparent; }
.badge.rep { background: var(--accent); color: #08152e; border-color: transparent; }
.badge.out { background: #3a2f2f; color: #d9a7a7; border-color: transparent; }

/* ---------- cards ---------- */

.green-card, .red-card {
  border-radius: var(--radius);
  padding: clamp(14px, 4vw, 22px);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.green-card {
  background: var(--green);
  color: var(--green-ink);
  font-size: clamp(1.3rem, 5vw, 2rem);
  text-align: center;
}

.red-card {
  background: var(--red);
  color: #fff;
  font-size: clamp(0.95rem, 3.4vw, 1.15rem);
  border: 3px solid transparent;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.red-card:active { transform: scale(0.98); }
.red-card[aria-pressed="true"], .red-card.selected { border-color: var(--gold); }
.red-card:disabled { opacity: 0.45; cursor: default; }
.red-card.winner { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(214,169,74,0.25); }
.red-card.mine { outline: 2px dashed rgba(255,255,255,0.5); outline-offset: -8px; }

.card-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.card-note {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 6px;
  display: block;
}

/* ---------- panels & controls ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 13px 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  font-weight: 700;
  background: var(--accent);
  color: #08152e;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--red); color: #fff; }
button.gold { background: var(--gold); color: #241a05; }
button.wide { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }

.double-down {
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  background: var(--panel-2);
  color: var(--ink);
  border: 2px solid var(--line);
}
.double-down[aria-pressed="true"] {
  background: var(--gold);
  color: #241a05;
  border-color: var(--gold);
}

.error {
  background: #3a1e1e;
  border: 1px solid #6b3030;
  color: #ffc9c9;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 50;
}

/* ---------- leaderboard ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
td.score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
tr.leader td { color: var(--gold); }

/* ---------- projector ---------- */

body.board { font-size: clamp(16px, 1.6vw, 22px); }
.board-wrap { max-width: 1600px; margin: 0 auto; padding: clamp(16px, 2.5vw, 32px); }
.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(12px, 2vw, 24px);
  flex-wrap: wrap;
}
.board-head h1 { font-size: clamp(1.4rem, 3vw, 2.4rem); margin: 0; }
.board-grid { display: grid; grid-template-columns: 1fr 340px; gap: clamp(16px, 2vw, 28px); }
@media (max-width: 900px) { .board-grid { grid-template-columns: 1fr; } }

.board .green-card { font-size: clamp(2rem, 5.5vw, 4rem); padding: clamp(20px, 4vw, 48px); }
.board .red-card { font-size: clamp(1.1rem, 2.2vw, 1.8rem); cursor: default; }
.board .card-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: clamp(10px, 1.5vw, 18px); }
.board table { font-size: clamp(0.95rem, 1.5vw, 1.3rem); }

.phase-pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8em;
}
.phase-pill.anti { background: #4a2020; color: #ffb3b3; border-color: #6b3030; }
.phase-pill.blank { background: #1f3a2a; color: #a7e6c0; border-color: #2f5c42; }
.phase-pill.model { background: #2a2440; color: #c7b8ff; border-color: #443a6b; }

.countdown { font-size: clamp(2rem, 6vw, 4rem); font-weight: 800; font-variant-numeric: tabular-nums; }

.waiting-list { color: var(--muted); font-size: 0.9em; line-height: 1.6; }

.qr-hint {
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
