:root {
  --bg: #04261a;
  --bg-glow: #0b5a3a;
  --card: #0d3a28;
  --card-line: #1a5a3f;
  --text: #f4fbf6;
  --muted: #a3c7b3;
  --green: #00a35c;
  --green-dark: #006b3c;
  --yellow: #ffd23f;
  --yellow-dark: #c99d00;
  --good: #11a85a;
  --bad: #d93a41;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg) radial-gradient(120% 60% at 50% 0%, var(--bg-glow) 0%, var(--bg) 70%) no-repeat;
  -webkit-tap-highlight-color: transparent;
}

h2 { font-size: 1.6rem; line-height: 1.15; margin: 8px 0 16px; }
h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--muted); }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; }
.header-btns { display: flex; gap: 8px; }
.icon-btn.off { opacity: .4; }

.cheer {
  display: inline-block;
  margin: 0 0 12px;
  background: var(--yellow);
  color: #1d1a05;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 1.2rem;
  font-weight: 800;
  animation: cheer .6s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes cheer { from { transform: scale(.3); opacity: 0; } }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }

#app { max-width: 480px; margin: 0 auto; padding: 0 16px 40px; }
.screen { animation: enter .25s ease-out; }
.screen.still { animation: none; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: inherit;
  cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn + .btn { margin-top: 12px; }
.btn small { display: block; font-weight: 500; font-size: .85rem; opacity: .85; }
.btn.big { padding: 18px; font-size: 1.2rem; }
.btn.small { padding: 10px 14px; font-size: .95rem; }
.btn.primary { background: var(--yellow); color: #1d1a05; box-shadow: 0 4px 0 var(--yellow-dark); }
.btn.secondary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.btn.ghost { background: transparent; color: var(--muted); border: 2px solid var(--card-line); }

.icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.back { background: none; border: 0; padding: 8px 0; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }

/* ---------- home ---------- */
.home { text-align: center; padding-top: 24px; }
.logo { display: flex; flex-direction: column; line-height: .9; margin: 16px 0 12px; }
.logo-top { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.logo-big {
  font-size: 4.2rem;
  font-weight: 800;
  color: var(--yellow);
  text-shadow: 0 5px 0 var(--green-dark);
  transform: rotate(-3deg);
}
.tagline { margin: 0 0 28px; color: var(--muted); font-size: 1.1rem; }

.modes { display: grid; gap: 12px; margin-bottom: 14px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .08s;
}
.mode-card:hover { border-color: var(--yellow); }
.mode-card:active { transform: scale(.98); }
.mode-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--yellow);
  font-size: 1.5rem;
}
.mode-card:nth-child(2) .mode-icon { background: var(--green); }
.mode-card:nth-child(3) .mode-icon { background: #2f7de1; }
.mode-card:nth-child(4) .mode-icon { background: #e0569b; }
.mode-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mode-text strong { font-size: 1.15rem; line-height: 1.2; }
.mode-text small { color: var(--muted); font-size: .9rem; }
.mode-arrow { font-size: 1.8rem; line-height: 1; color: var(--muted); }
.best { margin-top: 20px; color: var(--muted); }
.best strong { color: var(--yellow); }

.rules { list-style: none; padding: 0; margin: 0 0 24px; }
.rules li { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }

/* ---------- setup ---------- */
.player-row { display: flex; gap: 8px; margin-bottom: 10px; }
.player-row input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
}
.player-row input:focus { outline: none; border-color: var(--yellow); }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 92px;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .08s;
}
.cat-card:active { transform: scale(.98); }
.cat-card.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 10px; }
.cat-card.wide small { margin-left: auto; }
.cat-emoji { font-size: 1.6rem; line-height: 1.2; }
.cat-name { font-weight: 700; line-height: 1.2; }
.cat-card small { color: var(--muted); font-size: .8rem; }
.cat-card.on { background: #103f2b; border-color: var(--yellow); }
.cat-card.on::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  color: #1d1a05;
  font-size: .8rem;
  font-weight: 800;
}
.cat-card.wide.on::after { position: static; flex-shrink: 0; }

.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 12px;
  padding: 10px;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.seg.on { border-color: var(--yellow); color: var(--yellow); }
.note { color: var(--yellow); font-size: .95rem; }
.setup-start { margin-top: 28px; }

/* ---------- question ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 10px; font-weight: 700; }
.topbar .who { color: var(--yellow); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .progress { color: var(--muted); font-size: .9rem; }

.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.level-tag { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: .85rem; font-weight: 700; color: #0b1f17; }
.lvl-1 { background: #7fe0a8; }
.lvl-2 { background: #9fd3ff; }
.lvl-3 { background: #ffd23f; }
.lvl-4 { background: #ffa25c; }
.lvl-5 { background: #ff7a8a; }
.handoff .level-tag { margin-top: 10px; }

.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 14px;
  padding: 10px 4px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.stage-num { font-size: 1.3rem; font-weight: 800; line-height: 1.2; }
.stage small { color: var(--muted); font-size: .72rem; }
.stage.on { border-color: var(--yellow); background: #103f2b; }
.stage.on .stage-num { color: var(--yellow); }
.stage.locked { opacity: .45; cursor: not-allowed; }
.sub.stage-note { margin: 12px 0 0; font-size: .9rem; }
.stage-result { margin: 12px 0 0; background: var(--card); border-radius: 14px; padding: 12px 14px; font-weight: 700; }
.stage-result.passed { border: 2px solid var(--yellow); }
.legal { margin-top: 24px; font-size: .85rem; }
.legal a { color: var(--muted); }
.cat-tag { display: inline-block; background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: .9rem; color: var(--muted); }

.countdown { position: relative; flex-shrink: 0; width: 64px; height: 64px; }
.countdown svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown circle { fill: none; stroke-width: 6; }
.ring-bg { stroke: var(--card); }
.ring { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .1s linear, stroke .3s; }
.countdown span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; }
.countdown.low .ring { stroke: var(--bad); }
.countdown.low span { color: #ff9a9e; }
.countdown.beat { animation: beat .4s ease-out; }
@keyframes beat { 30% { transform: scale(1.18); } }
.question { font-size: 1.45rem; margin: 12px 0 18px; }

.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, opacity .2s;
}
.option:hover:not(:disabled) { border-color: var(--yellow); }
.option:disabled { cursor: default; }
.option .key {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--card-line);
  font-weight: 800;
  font-size: .9rem;
}
.option.correct { background: var(--good); border-color: #5dffad; }
.option.wrong { background: var(--bad); border-color: #ff9a9e; animation: shake .35s; }
.option.removed { opacity: .2; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.lifeline { display: inline-block; width: auto; margin-top: 14px; }

.feedback {
  margin-top: 18px;
  background: var(--card);
  border-left: 6px solid var(--good);
  border-radius: var(--radius);
  padding: 16px;
  animation: enter .2s ease-out;
}
.feedback.bad { border-left-color: var(--bad); }
.reaction { margin: 0; font-size: 1.35rem; font-weight: 800; }
.gained { margin: 4px 0 0; color: var(--muted); }
.gained strong { color: var(--text); }
.fact { margin: 10px 0 0; font-size: .95rem; color: var(--muted); }
.feedback .btn { margin-top: 14px; }

/* ---------- party handoff ---------- */
.handoff { text-align: center; padding-top: 32px; }
.round-label { margin: 0; color: var(--muted); font-weight: 700; }
.pass { margin: 24px 0 0; font-size: 1.2rem; }
.handoff-name { margin: 4px 0 28px; font-size: 2.8rem; color: var(--yellow); word-break: break-word; }
.scoreboard { list-style: none; padding: 0; margin: 28px 0 0; text-align: left; }
.scoreboard li { display: flex; justify-content: space-between; background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }

/* ---------- online ---------- */
.sub { margin: -8px 0 8px; color: var(--muted); }
.sub code { background: var(--card); border-radius: 6px; padding: 1px 6px; }
.hint { margin: 12px 0 0; font-size: .9rem; }
.section-title { margin: 32px 0 0; font-size: 1.3rem; }
.join-note { margin: -4px 0 10px; font-size: .9rem; }
.lobby-cat { margin: -8px 0 16px; color: var(--muted); }
.lobby-cat strong { color: var(--text); }
.text-input {
  width: 100%;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
}
.text-input:focus { outline: none; border-color: var(--yellow); }
.join-row { display: flex; gap: 8px; }
.join-row .btn { width: auto; flex-shrink: 0; }
.code-input { flex: 1; text-align: center; text-transform: uppercase; letter-spacing: .3em; font-weight: 800; }
.note.error { color: #ff9a9e; }

.lobby { text-align: center; }
.room-code { margin: 0 0 16px; font-size: 3.6rem; font-weight: 800; letter-spacing: .15em; line-height: 1.1; color: var(--yellow); }
.player-list { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; }
.player-list li { display: flex; justify-content: space-between; align-items: center; background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.player-list li.offline { opacity: .5; }
.tag { background: var(--green); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .8rem; }
.status { text-align: center; color: var(--muted); font-weight: 600; }

.option.picked { background: #3d3a10; border-color: var(--yellow); }
.scoreboard li.me { border: 2px solid var(--yellow); }
.scoreboard .plus { color: #5dffad; }
.action-slot { margin-bottom: 12px; }
.leave-link { display: block; margin: 16px auto 0; font-size: .9rem; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  max-width: 448px;
  margin: 0 auto;
  background: #101010;
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  z-index: 10;
  animation: enter .2s ease-out;
}

/* ---------- results ---------- */
.results { text-align: center; padding-top: 16px; }
.result-label { margin: 0; color: var(--muted); font-weight: 700; }
.big-score { margin: 8px 0 8px; font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--yellow); }
.big-score small { margin-left: 6px; font-size: 1.2rem; color: var(--muted); }
.badge { display: inline-block; margin: 0; background: var(--green); border-radius: 999px; padding: 4px 14px; font-weight: 700; }
.title-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 20px 0 24px; }
.title-card p { margin: 0; color: var(--muted); }
.title-card h3 { margin: 6px 0 0; font-size: 1.5rem; color: var(--text); text-transform: none; letter-spacing: 0; }

.podium { list-style: none; padding: 0; margin: 16px 0 24px; text-align: left; }
.podium li { display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.podium li:first-child { border-color: var(--yellow); }
.podium .medal { font-size: 1.6rem; }
.podium div { flex: 1; min-width: 0; }
.podium small { display: block; color: var(--muted); }
.podium .pts { font-size: 1.2rem; font-weight: 800; color: var(--yellow); }
