/* T-Quiz — dark, neon-magenta theme. No frameworks, no web fonts. */

:root {
  --bg: #070509;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1ecf2;
  --muted: #a99eac;
  --dim: #706675;
  --magenta: #e20074;
  --magenta-hi: #ff3ea5;
  --magenta-lo: #a3005a;
  --magenta-glow: rgba(226, 0, 116, 0.55);
  --good: #22c55e;
  --bad: #f43f5e;
  --gold: #facc15;
  --silver: #d6dbe3;
  --bronze: #e08a3c;
  --radius: 20px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 560px at 50% -12%, rgba(226, 0, 116, 0.24), transparent 62%),
    radial-gradient(800px 480px at 105% 108%, rgba(226, 0, 116, 0.14), transparent 60%),
    radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1.2px);
  background-size: auto, auto, 24px 24px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.center { text-align: center; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.grad {
  background: linear-gradient(180deg, #ff6dbb 0%, var(--magenta) 55%, var(--magenta-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --------------------------------------------------------------- icons */

.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* --------------------------------------------------------------- brand */

.brand { text-decoration: none; display: inline-flex; align-items: center; }
.brand-mark {
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}
.brand-t {
  background: var(--magenta);
  color: #fff;
  padding: 0.05em 0.35em;
  border-radius: 8px;
  box-shadow: 0 6px 18px -6px var(--magenta-glow);
}
.brand-quiz { padding-left: 0.12em; }

/* -------------------------------------------------------------- layout */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 16px;
}
.nav-links { display: flex; align-items: center; gap: 1.1rem; font-weight: 600; }
.nav-links a { text-decoration: none; color: var(--muted); }
.nav-links a:hover { color: var(--text); }
.nav-links .btn { color: #fff; }

.container { max-width: 1120px; margin: 0 auto; padding: 1rem 16px 4rem; }
.container.narrow { max-width: 820px; }

.footer {
  text-align: center;
  color: var(--dim);
  font-size: 0.9rem;
  padding: 2.5rem 16px 3rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--magenta-hi), var(--magenta) 55%, var(--magenta-lo));
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 10px 26px -10px var(--magenta-glow);
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.btn:focus-visible, .link:focus-visible, .icon-btn:focus-visible, .answer:focus-visible {
  outline: 3px solid rgba(255, 62, 165, 0.6);
  outline-offset: 2px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  box-shadow: none;
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger { color: #ff8094; border-color: rgba(244, 63, 94, 0.4); }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.9rem; }
.btn-lg { padding: 1rem 2.6rem; font-size: 1.15rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }
.btn-block { width: 100%; }

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.link:hover { color: var(--text); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { color: #ff8094; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(6px);
}

.alert {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #ff9cab;
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
}

/* -------------------------------------------------------------- inputs */

.input {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: #6c6170; }
.input:focus { border-color: var(--magenta); box-shadow: 0 0 0 3px rgba(226, 0, 116, 0.22); }
textarea.input { resize: vertical; min-height: 3.2rem; }
select.input { width: auto; padding: 0.45rem 0.7rem; cursor: pointer; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.hint { font-size: 0.82rem; color: var(--dim); }
.hint.bad { color: #ff8094; }

/* ---------------------------------------------------------------- home */

.hero {
  max-width: 1120px;
  margin: 0 auto;
  padding: 3.5rem 16px 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(226, 0, 116, 0.35);
  background: rgba(226, 0, 116, 0.08);
  color: #ff8cc6;
  font-size: 0.85rem;
  font-weight: 600;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--magenta-hi);
  box-shadow: 0 0 0 0 var(--magenta-glow);
  animation: live 1.8s infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(255, 62, 165, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(255, 62, 165, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 62, 165, 0); }
}
.display {
  margin-top: 1.6rem;
  font-size: clamp(2.6rem, 8vw, 5.6rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.02;
}
.display .grad { filter: drop-shadow(0 6px 22px rgba(226, 0, 116, 0.35)); }
.lead {
  margin-top: 1.3rem;
  max-width: 40rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.15rem);
}

.choice-grid {
  margin-top: 2.6rem;
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  text-align: left;
}
.choice { display: flex; flex-direction: column; gap: 0.7rem; padding: 1.6rem; }
.choice h2 { font-size: 1.45rem; font-weight: 800; }
.choice-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(226, 0, 116, 0.14);
  color: var(--magenta-hi);
  font-size: 1.3rem;
}
.choice-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: auto; padding-top: 0.4rem; }

.code-pill {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  border-radius: 999px;
  background: #000;
  border: 1px solid rgba(226, 0, 116, 0.3);
  box-shadow: 0 6px 24px -10px var(--magenta-glow);
}
.code-pill .icon { color: var(--dim); font-size: 1.2rem; }
.code-pill input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.5rem 0;
}
.code-pill input::placeholder { color: #4c4350; letter-spacing: 0.22em; }

.flow { max-width: 1120px; margin: 0 auto; padding: 3rem 16px 0; }
.section-title { text-align: center; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 900; letter-spacing: -0.02em; }
.steps {
  margin-top: 1.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.step { display: flex; gap: 1rem; align-items: flex-start; }
.step-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--magenta-hi), var(--magenta-lo));
  font-weight: 900;
}
.step h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }

/* ---------------------------------------------------------------- auth */

.auth-wrap { min-height: calc(100dvh - 80px); display: grid; place-items: center; padding: 1rem 16px 4rem; }
.auth-card { width: 100%; max-width: 430px; padding: 2rem 1.6rem; box-shadow: 0 20px 60px -30px var(--magenta-glow); }
.auth-card h1 { font-size: 1.8rem; font-weight: 900; text-align: center; letter-spacing: -0.02em; }
.auth-card .sub { text-align: center; margin: 0.4rem 0 1.4rem; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 1.5rem;
}
.tabs a {
  text-align: center;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
}
.tabs a.active { background: var(--magenta); color: #fff; }

/* ----------------------------------------------------------- dashboard */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.2rem 0 2rem;
}
.page-title { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 900; letter-spacing: -0.02em; }
.page-head p { margin-top: 0.3rem; }
.section { margin-top: 2.2rem; }
.section-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.9rem;
}
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.quiz-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.25rem; transition: border-color 0.15s ease; }
.quiz-card:hover { border-color: rgba(226, 0, 116, 0.4); }
.quiz-card h3 { font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.quiz-card .desc {
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta { color: var(--dim); font-size: 0.85rem; }
.card-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 0.6rem; }
.list { display: flex; flex-direction: column; gap: 0.6rem; }
.row-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.9rem 1.1rem;
}
.row-item .grow { flex: 1; min-width: 12rem; }
.row-item .grow strong { display: block; overflow-wrap: anywhere; }
.pin-tag {
  font-family: var(--mono);
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--magenta-hi);
  background: rgba(226, 0, 116, 0.1);
  border: 1px solid rgba(226, 0, 116, 0.3);
  border-radius: 8px;
  padding: 0.15rem 0.5rem;
}
.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; }
.loading { color: var(--muted); padding: 3rem 0; text-align: center; }

/* ------------------------------------------------------------- builder */

.builder-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0;
  margin-bottom: 1rem;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.builder-bar .back { display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; color: var(--muted); font-weight: 600; }
.builder-bar .back:hover { color: var(--text); }
.save-status { margin-left: auto; font-size: 0.85rem; color: var(--dim); }
.save-status.ok { color: #6ee7a0; }
.save-status.bad { color: #ff8094; }
.title-input { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.02em; padding: 0.6rem 0.9rem; }
.q-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.q-card { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.1rem; }
.q-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.q-num {
  font-weight: 900;
  color: var(--magenta-hi);
  background: rgba(226, 0, 116, 0.12);
  border-radius: 8px;
  padding: 0.2rem 0.55rem;
  margin-right: auto;
}
.q-text { font-size: 1.1rem; font-weight: 600; }
.answers-edit { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
@media (min-width: 640px) { .answers-edit { grid-template-columns: 1fr 1fr; } }
.answer-edit { display: flex; align-items: center; gap: 0.5rem; }
.answer-edit .input { padding: 0.6rem 0.8rem; }
.answer-edit.is-correct .input { border-color: rgba(34, 197, 94, 0.55); }
.correct-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
}
.correct-toggle .icon { display: none; }
.correct-toggle.on { background: var(--good); border-color: var(--good); color: #052e14; }
.correct-toggle.on .letter { display: none; }
.correct-toggle.on .icon { display: inline-flex; }
.add-q {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(226, 0, 116, 0.4);
  background: rgba(226, 0, 116, 0.04);
  color: #ff8cc6;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.add-q:hover { background: rgba(226, 0, 116, 0.09); }
.danger-zone { margin-top: 2.5rem; display: flex; justify-content: center; }

/* ----------------------------------------------------------------- join */

.join-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 4rem 16px; position: relative; }
.back-btn { position: absolute; top: 1.1rem; left: 16px; }
.join-card {
  width: 100%;
  max-width: 400px;
  padding: 2.2rem 1.6rem;
  border-color: rgba(226, 0, 116, 0.45);
  box-shadow: 0 20px 60px -28px var(--magenta-glow);
}
.join-card h1 { font-size: 2rem; font-weight: 900; text-align: center; margin-bottom: 1.6rem; letter-spacing: -0.02em; }
.pin-input {
  text-align: center;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  border: 2px solid rgba(226, 0, 116, 0.5);
}
.name-input { text-align: center; font-size: 1.15rem; font-weight: 700; border: 2px solid rgba(226, 0, 116, 0.5); }

/* -------------------------------------------------------------- avatars */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 28%;
  padding: 7%;
  overflow: hidden;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 64px; height: 64px; }
.avatar-lg { width: 84px; height: 84px; }
.avatar-xl { width: 120px; height: 120px; border-radius: 30%; }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.pop { animation: pop 360ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes pop {
  0% { transform: scale(0) translateY(6px); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ----------------------------------------------------------------- live */

.live { min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px 7rem; }
.live-brand { display: flex; justify-content: center; padding: 1.1rem 0 0.5rem; }
.live-screen { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1rem; padding: 1rem 0; }

.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.55rem 16px;
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
  background: #8a1238;
  color: #fff;
}

.host-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 16px calc(0.85rem + env(safe-area-inset-bottom));
  background: rgba(9, 5, 11, 0.86);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.host-bar .host-tag { margin-right: auto; color: var(--dim); font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }

/* lobby */
.code-card {
  margin-top: 1rem;
  padding: 1rem 2.4rem 1.2rem;
  border-radius: 24px;
  border: 1px solid rgba(226, 0, 116, 0.45);
  background: rgba(10, 0, 6, 0.6);
  box-shadow: 0 0 50px -12px var(--magenta-glow);
  text-align: center;
}
.code-label { font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: #ff8cc6; font-size: clamp(0.85rem, 2.4vw, 1.1rem); }
.code-big {
  font-family: var(--mono);
  font-weight: 900;
  font-size: clamp(2.6rem, 11vw, 5rem);
  letter-spacing: 0.18em;
  line-height: 1.1;
  margin: 0.2rem 0 0.4rem;
  padding-left: 0.18em; /* balance trailing letter-spacing */
}
.code-url { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.code-url button { color: #ff8cc6; text-decoration: underline; text-underline-offset: 3px; }
.shout {
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.players-panel { width: 100%; max-width: 900px; margin-top: 1.5rem; text-align: left; }
.players-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.1rem;
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(226, 0, 116, 0.25);
}
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 1rem 0.6rem; }
.player-tile { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; min-width: 0; }
.player-tile span { max-width: 100%; color: var(--muted); font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wait h1 { font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 900; letter-spacing: -0.02em; }
.wait-line { display: inline-flex; align-items: center; gap: 0.7rem; font-size: 1.1rem; }
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(226, 0, 116, 0.25);
  border-top-color: var(--magenta-hi);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* get ready */
.get-ready {
  font-size: clamp(3rem, 14vw, 7.5rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 10px 30px rgba(226, 0, 116, 0.45));
}
.countdown {
  font-family: var(--mono);
  font-weight: 900;
  font-size: clamp(3rem, 12vw, 6rem);
  color: #fff;
}

/* question */
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.6rem 0 1.2rem; }
.q-index { font-weight: 900; font-size: clamp(1.2rem, 4vw, 2rem); color: var(--magenta-hi); letter-spacing: 0.02em; }
.timer { position: relative; width: 64px; height: 64px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .track { stroke: rgba(255, 255, 255, 0.1); }
.timer .ring { stroke: var(--magenta-hi); transition: stroke-dashoffset 0.25s linear, stroke 0.2s ease; }
.timer-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.timer.urgent .ring { stroke: var(--bad); }
.timer.urgent .timer-num { color: var(--bad); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.progress { margin-bottom: 0.6rem; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.prog-label { color: var(--muted); font-weight: 600; }
.prog-count { font-weight: 900; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.prog-count b { color: var(--magenta-hi); }
.prog-count b.good { color: var(--good); }
.trail-track { position: relative; height: 40px; margin: 0.2rem 0; }
.trail {
  position: absolute;
  bottom: 2px;
  display: flex;
  align-items: flex-end;
  transition: left 0.5s ease-out;
}
.trail .avatar { width: 26px; height: 26px; border-radius: 50%; margin-left: -9px; padding: 3px; }
.trail .avatar.lead { width: 36px; height: 36px; margin-left: 0; }
.prog-bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.prog-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--magenta-lo), var(--magenta-hi));
  transition: width 0.5s ease-out;
}
.prog-fill.done { background: linear-gradient(90deg, #16a34a, #4ade80); }
.prog-left { text-align: right; color: var(--dim); font-size: 0.85rem; margin-top: 0.3rem; min-height: 1.3em; }

.q-title {
  text-align: center;
  font-size: clamp(1.4rem, 4.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 1.6rem 0 2rem;
  overflow-wrap: anywhere;
}
.answers { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
@media (min-width: 680px) { .answers { grid-template-columns: 1fr 1fr; gap: 1rem; } }
.answer {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 66px;
  padding: 0.8rem 1.1rem 0.8rem 0.8rem;
  border-radius: 22px;
  border: 1.5px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  font-weight: 700;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.25s ease, transform 0.1s ease;
}
.answer::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  background: rgba(255, 255, 255, 0.07);
  transition: width 0.7s ease-out;
}
.answer > * { position: relative; }
.answer:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); border-color: rgba(226, 0, 116, 0.5); }
.answer:active:not(:disabled) { transform: scale(0.985); }
.answer:disabled { cursor: default; }
.answer-letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}
.answer-text { flex: 1; overflow-wrap: anywhere; }
.answer-mark { display: inline-flex; align-items: center; gap: 0.4rem; flex: none; font-variant-numeric: tabular-nums; }
.answer-count { font-size: 0.95rem; color: var(--muted); }
.answer.selected { border-color: var(--magenta); background: rgba(226, 0, 116, 0.2); box-shadow: 0 0 22px -6px var(--magenta-glow); }
.answer.selected .answer-letter { background: var(--magenta); color: #fff; }
.answer.correct { border-color: var(--good); background: rgba(34, 197, 94, 0.2); box-shadow: none; }
.answer.correct .answer-letter { background: var(--good); color: #052e14; }
.answer.correct .answer-count { color: #bbf7d0; }
.answer.wrong { border-color: rgba(244, 63, 94, 0.65); background: rgba(244, 63, 94, 0.14); box-shadow: none; }
.answer.wrong .answer-letter { background: var(--bad); color: #fff; }
.answer.faded { opacity: 0.45; }

.status-line { min-height: 3.2rem; margin-top: 1.4rem; display: flex; justify-content: center; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-weight: 800;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.status-chip.good { background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.5); color: #bbf7d0; }
.status-chip.bad { background: rgba(244, 63, 94, 0.12); border-color: rgba(244, 63, 94, 0.45); color: #fecdd3; }
.status-chip .pts { font-size: 1.15rem; }

/* leaderboard */
.board-wrap { width: 100%; max-width: 680px; margin: 0 auto; padding-top: 0.5rem; }
.board-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.01em;
}
.board-title .icon { color: var(--magenta-hi); }
.board { list-style: none; margin: 1.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.board-row {
  display: grid;
  grid-template-columns: 2.6rem auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.board-row .rank { font-weight: 900; font-size: 1.15rem; color: var(--dim); }
.board-row .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .score { font-weight: 900; font-size: 1.25rem; color: var(--magenta-hi); font-variant-numeric: tabular-nums; }
.board-row.r1 { background: rgba(250, 204, 21, 0.12); border-color: rgba(250, 204, 21, 0.45); }
.board-row.r1 .rank { color: var(--gold); }
.board-row.r2 { background: rgba(214, 219, 227, 0.1); border-color: rgba(214, 219, 227, 0.4); }
.board-row.r2 .rank { color: var(--silver); }
.board-row.r3 { background: rgba(224, 138, 60, 0.12); border-color: rgba(224, 138, 60, 0.45); }
.board-row.r3 .rank { color: var(--bronze); }
.board-row.mine { outline: 2px solid rgba(255, 62, 165, 0.75); outline-offset: 1px; }
.you-tag {
  margin-left: 0.4rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--magenta);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  vertical-align: 2px;
}
.more { text-align: center; color: var(--dim); font-size: 0.88rem; padding: 0.3rem 0; }
.board-foot { margin-top: 1.4rem; }

/* podium */
.finish-title { text-align: center; font-size: clamp(2rem, 8vw, 3.6rem); font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.finish-sub { text-align: center; color: var(--muted); font-size: clamp(1rem, 3vw, 1.3rem); font-weight: 600; margin-top: 0.3rem; }
.podium {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0 1.6rem;
}
@media (min-width: 640px) {
  .podium { flex-direction: row; justify-content: center; align-items: flex-end; gap: 1.2rem; }
  .podium .p1 { order: 2; }
  .podium .p2 { order: 1; }
  .podium .p3 { order: 3; }
}
.podium-card {
  width: 100%;
  max-width: 17rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 1.1rem 1rem 1.3rem;
  border-radius: 20px;
  border: 1.5px solid;
  text-align: center;
}
@media (min-width: 640px) { .podium-card { width: 11rem; } .podium-card.p1 { width: 13rem; padding-bottom: 2.4rem; } }
.podium-card .place { font-weight: 900; font-size: 1.3rem; }
.podium-card .name { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-card .score { font-weight: 900; font-size: 1.15rem; }
.podium-card.p1 { background: rgba(250, 204, 21, 0.13); border-color: rgba(250, 204, 21, 0.5); color: #fde68a; }
.podium-card.p2 { background: rgba(214, 219, 227, 0.11); border-color: rgba(214, 219, 227, 0.45); color: #e5e7eb; }
.podium-card.p3 { background: rgba(224, 138, 60, 0.13); border-color: rgba(224, 138, 60, 0.5); color: #fdba74; }
.podium-card.mine { outline: 2px solid rgba(255, 62, 165, 0.8); outline-offset: 2px; }
.crown { color: var(--gold); font-size: 1.9rem; }
.my-finish {
  margin: 0 auto 1.4rem;
  max-width: 680px;
  text-align: center;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(226, 0, 116, 0.12);
  border: 1px solid rgba(226, 0, 116, 0.4);
  font-weight: 700;
}
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem; margin-top: 2rem; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 6.2rem;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 32rem);
  padding: 0.75rem 1.2rem;
  border-radius: 14px;
  background: #24131f;
  border: 1px solid rgba(226, 0, 116, 0.45);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.9);
  font-weight: 600;
  text-align: center;
}

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