:root {
  --bg: #1d1033;
  --bg2: #2a1650;
  --card: #fffaf0;
  --ink: #1f1530;
  --muted: #6d6282;
  --accent: #ff4f7b;
  --accent2: #ffc83d;
  --good: #23c48b;
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #4b1f7a 0, transparent 40%),
    radial-gradient(circle at 90% 80%, #6b1d55 0, transparent 45%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
}
.logo {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
  text-decoration: none;
}
.logo span { color: var(--accent2); }
.pill {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 1rem 3rem; }

.hero { color: #fff; text-align: center; padding: 2rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.05; margin: 0 0 0.8rem; font-weight: 900; }
.hero em { color: var(--accent2); font-style: normal; }
.sub { font-size: 1.1rem; opacity: 0.85; }
.hero .sub { max-width: 34rem; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
}
.card-alt { background: var(--accent2); }
.card h2 { margin-top: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.section-title { color: #fff; margin: 2rem 0 1rem; }

.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }

.flash {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

label { display: block; font-weight: 600; margin-bottom: 1rem; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-weight: 400;
  border: 3px solid #e2d8ee;
  border-radius: 12px;
  background: #fff;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.code-input {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  text-align: center;
}

.btn {
  display: inline-block;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  background: var(--accent);
  padding: 0.85rem 1.4rem;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 4px 0 #b8264f;
  transition: transform 0.05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b8264f; }
.btn-alt { background: var(--ink); box-shadow: 0 4px 0 #000; }
.btn-ghost { background: #ece3f5; color: var(--ink); box-shadow: 0 4px 0 #cbbbe0; }

.question-list { padding-left: 1.5rem; }
.question-list li { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.question-list input { margin: 0; }
.x {
  border: 0;
  background: none;
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.big-code {
  font-size: clamp(4rem, 18vw, 8rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--accent);
  line-height: 1;
  margin: 0.5rem 0;
}
.phase { font-size: clamp(2rem, 7vw, 3rem); font-weight: 900; color: var(--accent); }

.players { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.players li {
  background: #ece3f5;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
  animation: pop 0.25s ease-out;
}
.players li.done { background: var(--good); color: #fff; }
.players li.done::after { content: " ✓"; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.q-num {
  display: inline-grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 50%;
  background: var(--accent2);
  font-weight: 900;
  font-size: 0.9em;
  margin-right: 0.3rem;
}
.question { margin-bottom: 1.5rem; }

.mark-group { margin-bottom: 1.75rem; }
.mark-card {
  position: relative;
  display: block;
  cursor: pointer;
  font-weight: 400;
  background: #fff;
  border: 3px solid #e2d8ee;
  border-radius: 14px;
  padding: 1rem 1rem 1rem 1rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.1s, background 0.1s;
}
.mark-card input { position: absolute; opacity: 0; pointer-events: none; }
.mark-text { white-space: pre-wrap; }
.mark-badge {
  display: none;
  margin-top: 0.5rem;
  font-weight: 800;
  color: var(--accent);
}
.mark-card:has(input:checked) { border-color: var(--accent); background: #fff0f4; }
.mark-card:has(input:checked) .mark-badge { display: block; }

.chart { list-style: none; padding: 0; margin: 0 0 1rem; }
.chart li {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) 1fr 4rem;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.7rem;
}
.chart-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { background: #ece3f5; border-radius: 10px; height: 2.2rem; overflow: hidden; }
.chart-bar {
  display: block;
  height: 100%;
  width: var(--w);
  background: #9a7bc4;
  border-radius: 10px;
  animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.chart li:nth-child(2) .chart-bar { animation-delay: 0.1s; }
.chart li:nth-child(3) .chart-bar { animation-delay: 0.2s; }
.chart li:nth-child(n+4) .chart-bar { animation-delay: 0.3s; }
.chart li.winner .chart-bar { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.chart li.winner .chart-name { color: var(--accent); }
.chart li.me .chart-name { text-decoration: underline; }
.chart-val { font-weight: 900; font-size: 1.2rem; text-align: right; }
.chart-val small { font-size: 0.7rem; color: var(--muted); }
@keyframes grow { from { width: 0; } }

.reveal { border-left: 5px solid #e2d8ee; padding: 0.4rem 0 0.4rem 1rem; margin-bottom: 0.8rem; }
.reveal.won { border-color: var(--accent2); background: #fff6d9; border-radius: 0 12px 12px 0; }
.reveal p { margin: 0.3rem 0 0; white-space: pre-wrap; }
.reveal-head { display: flex; justify-content: space-between; gap: 1rem; }
.count { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

.join-card { max-width: 420px; margin-left: auto; margin-right: auto; }
.join-card .btn { display: block; margin: 0 auto; }
.join-head { display: flex; align-items: baseline; gap: 0.75rem; }
.host-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: auto;
}
.host-link:hover { color: #d93563; }
