:root {
  --bg: #0d0f14;
  --surface: #151923;
  --surface-2: #1e2433;
  --line: #2a3347;
  --line-strong: #3e4c68;
  --ink: #f5f7fa;
  --muted: #a4b0c6;
  --pink: #ff2e63;
  --teal: #00e0c6;
  --gold: #ffc400;
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', 'Golos Text', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body {
  background:
    linear-gradient(180deg, rgba(10, 12, 20, 0.8), rgba(10, 12, 20, 0.92)),
    url('/img/mdkm/bg-neon-stage.jpg') center / cover no-repeat fixed;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
}
h1, h2, .teamname, .clock .num, .opt .l, .btn, .score-pill { font-family: var(--display); }
input, textarea { font-family: var(--font); }

header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--pink); }
.teamname {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--ink);
  font: 800 20px/1.2 var(--font);
  text-align: left;
  cursor: pointer;
}
.teamname small { font-size: 13px; color: var(--muted); margin-left: 6px; font-weight: 500; }
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(245, 183, 0, 0.14);
  border: 1px solid rgba(245, 183, 0, 0.45);
  color: var(--gold);
  font-weight: 800;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: 700 14.5px var(--font);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }

main { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }

/* ---- Join Card ---- */
.join { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; text-align: center; padding: 12px 0; }
.invite-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1.5px solid rgba(255, 46, 99, 0.55);
  box-shadow: 0 0 34px rgba(255, 46, 99, 0.22), 0 0 44px rgba(0, 224, 198, 0.14);
  padding: 26px 20px;
  background:
    linear-gradient(180deg, rgba(13, 16, 26, 0.72), rgba(13, 16, 26, 0.9)),
    url('/img/mdkm/cover-poster-neon.jpg') center / cover no-repeat;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.invite-card img { height: 28px; width: auto; }
.invite-svg { width: 112px; height: 28px; display: block; margin: 4px 0; }
.join h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.join p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }

/* ---- Wait Screen ---- */
.wait { flex: 1; display: grid; place-items: center; text-align: center; padding: 20px 0; }
.wait-inner { display: grid; justify-items: center; gap: 14px; }
.wait-badge {
  width: 96px;
  height: 96px;
  border-radius: 26px;
  background: var(--surface);
  border: 2px solid var(--pink);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
  color: var(--pink);
  letter-spacing: 0.14em;
  padding-left: 0.14em;
}
.wait h2 { margin: 0; font-size: 24px; }
.wait p { margin: 0; color: var(--muted); max-width: 320px; }

/* ---- Question Header & Clock ---- */
.qhead { display: flex; gap: 12px; align-items: flex-start; }
.qhead .txt { flex: 1; min-width: 0; }
.qlabel { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal); }
.qru { font-size: 21px; font-weight: 700; line-height: 1.25; margin: 6px 0 4px; }
.worth { margin-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--gold); }

.clock { position: relative; width: 62px; height: 62px; flex: none; }
.clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.clock .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.clock.low .num { color: var(--pink); }
.clock.low .arc { stroke: var(--pink); }
.clock.paused .arc { stroke: var(--muted); }
.clock.paused .num { color: var(--muted); font-size: 15px; }

/* ---- Choice Buttons ---- */
.opts { display: grid; grid-template-columns: 1fr; gap: 10px; }
.opt {
  position: relative;
  min-height: 62px;
  border-radius: 14px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 44px 12px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font: 600 16px/1.3 var(--font);
  transition: transform 100ms, border-color 150ms, background 150ms;
}
.opt:active { transform: scale(0.98); }
.opt .l { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 900; font-size: 16px; flex: none; }
.opt.a .l { background: rgba(255, 46, 99, 0.24); color: #ff6b93; }
.opt.b .l { background: rgba(0, 194, 168, 0.24); color: #38ebd3; }
.opt.c .l { background: rgba(245, 183, 0, 0.24); color: #ffd042; }
.opt.d .l { background: rgba(96, 165, 250, 0.24); color: #93c5fd; }
.opt.sel { border-color: var(--teal); background: rgba(0, 194, 168, 0.16); }
.opt.sel::after { content: "✓"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 900; color: var(--teal); }
.opts.chosen .opt:not(.sel) { opacity: 0.65; }

/* ---- Inputs & Buttons ---- */
.field { display: flex; flex-direction: column; gap: 10px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .field textarea {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.4;
  outline: none;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.16); }
.hint { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin: 0; }

.btn {
  min-height: 52px;
  width: 100%;
  border-radius: 14px;
  border: 0;
  padding: 13px 18px;
  background: linear-gradient(135deg, #ff2e63, #ff4f7d);
  box-shadow: 0 0 24px rgba(255, 46, 99, 0.36);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line-strong); font-weight: 600; }

.got {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: 12px;
  background: rgba(0, 194, 168, 0.12);
  border: 1px solid rgba(0, 194, 168, 0.4);
}
.got b { color: var(--teal); font-size: 18px; }
.got .v { font-size: 16.5px; font-weight: 700; word-break: break-word; white-space: pre-line; }
.got small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- Pairs ---- */
.pair-help { font-size: 14px; color: var(--muted); margin: 0 0 12px; line-height: 1.45; }
.pair-columns { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 4px 0; }
.pair-actors, .pair-roles { display: flex; flex-direction: column; gap: 10px; z-index: 1; }
.pair-actor-row { position: relative; display: flex; align-items: stretch; gap: 4px; }
.pair-columns button.pair-actor, .pair-columns button.pair-role {
  width: 100%;
  min-height: 88px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px;
  font: 600 12.5px/1.3 var(--font);
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}
.pair-identity { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; flex: 1; }
.pair-identity img { width: 58px; height: 50px; border-radius: 7px; object-fit: cover; }
.pair-columns .active { outline: 2.5px solid var(--gold); background: var(--surface-2); }
.pair-columns .paired { border-color: var(--pair-color); }
.pair-columns .paired .pair-badge { color: #081014; background: var(--pair-color); }
.pair-badge { flex: none; min-width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.pair-remove { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--pink); color: #fff; font-weight: 800; cursor: pointer; z-index: 2; }
.pair-connections { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
#pair-selection { font-size: 13.5px; color: var(--teal); margin: 10px 0; min-height: 20px; }
.pair-submit { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 0; margin-top: 10px; display: grid; gap: 8px; }
.pair-submit p { margin: 0; font-size: 13px; color: var(--muted); }
.pair-receipt p { display: grid; gap: 2px; margin: 6px 0; font-size: 13.5px; }
.pair-receipt span { color: var(--muted); }

/* ---- Reveal & Standings ---- */
.phone-reveal h2 { font-size: 24px; color: var(--teal); margin: 6px 0 14px; }
.reveal-caption { font-size: 13px; color: var(--muted); margin: 10px 0 2px; }
.reveal-note { white-space: pre-line; font-size: 15px; line-height: 1.55; margin: 14px 0 0; color: #dbe3f2; }
.reveal-images { display: flex; justify-content: center; gap: 8px; background: var(--bg); border-radius: 12px; padding: 8px; }
.reveal-images img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 8px; }
.reveal-images.two img { width: calc(50% - 4px); max-height: 220px; }
.reveal-pairs { display: grid; gap: 10px; }
.reveal-pairs article { display: flex; gap: 10px; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; align-items: center; }
.reveal-pairs img { width: 58px; height: 50px; object-fit: cover; border-radius: 7px; flex: none; }
.reveal-pairs b { display: block; font-size: 14.5px; }
.reveal-pairs span { display: block; color: var(--muted); font-size: 13.5px; }

.phone-score-table table, .pause-scores { width: 100%; border-collapse: collapse; text-align: left; }
.phone-score-table th, .phone-score-table td, .pause-scores th, .pause-scores td { padding: 12px 8px; border-bottom: 1px solid var(--line); }
.phone-score-table td, .pause-scores td { text-align: right; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.phone-score-table .own, .pause-scores .own th { color: var(--teal); }
.phone-intermission { text-align: center; padding: 36px 20px; display: grid; gap: 12px; }
.phone-intermission h1 { margin: 0; font-size: 28px; }
.phone-intermission p { margin: 0; color: var(--muted); font-size: 16px; }

.closed { text-align: center; padding: 24px 16px; }
.closed h2 { margin: 8px 0 6px; font-size: 24px; }
.closed p { margin: 0; color: var(--muted); }

.conn { font-size: 12.5px; color: var(--pink); text-align: center; font-weight: 600; }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  max-width: calc(100% - 32px);
  text-align: center;
  z-index: 20;
}
