/* ==========================================================================
   Trivia Titans — setup, game (timer, options, scoreboard) and results.
   Builds on ../assets/core.css.
   ========================================================================== */

.page-trivia {
  --accent: #f4c96b;
  --accent-2: #ff9a5a;
  --on-accent: #2a1805;
}

.trivia { padding-block: clamp(18px, 4vw, 40px) 0; }

.crown-badge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  color: #3a2406;
  background: radial-gradient(circle at 32% 26%, #fff4cf, var(--gold) 50%, #b5832a);
  box-shadow:
    0 0 0 10px rgb(244 201 107 / 0.1),
    0 0 0 22px rgb(244 201 107 / 0.05),
    0 20px 46px -12px var(--gold);
  animation: crown-in 0.9s var(--spring) both;
}
.crown-badge .icon { width: 32px; height: 32px; }
.crown-badge--big { width: 92px; height: 92px; }
.crown-badge--big .icon { width: 44px; height: 44px; }
@keyframes crown-in { from { opacity: 0; transform: scale(0.5) rotate(-20deg); } }

/* ---------- Setup ---------- */
.view--setup { gap: 22px; }
.setup-hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 6px 0 4px;
}
.setup-hero .crown-badge { margin-bottom: 22px; }
.setup-hero .lede { margin-inline: auto; }

.setup-card {
  display: grid;
  gap: 26px;
  padding: 22px 18px;
  border-radius: var(--r-xl);
}
.setting { display: grid; gap: 12px; }
.setting__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.setting__label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.setting__links { display: flex; gap: 4px; }
.setting__links button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 99px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 750;
  transition: background-color 0.2s, color 0.2s;
}
.setting__links button:hover { background: rgb(255 255 255 / 0.08); color: var(--text); }
.setting-row { display: grid; gap: 26px; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper output {
  min-width: 34px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 560;
}
.stepper .icon-btn:disabled { opacity: 0.35; }

.player-inputs { display: grid; gap: 10px; min-height: 52px; }
.player-input {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: view-in 0.45s var(--spring);
}
.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pc);
  color: #1d0b13;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 8px 18px -8px var(--pc);
}

.cat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-grid .chip { min-height: 40px; padding: 0 14px; }
.cat-grid .chip[aria-pressed="true"]::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.start-row { display: grid; gap: 10px; justify-items: center; }
.btn--lg { min-height: 60px; font-size: 18px; }
.pool { color: var(--text-3); font-size: 14px; font-weight: 650; text-align: center; min-height: 1.4em; }
.pool.is-warn { color: #ffb38a; }

@media (min-width: 720px) {
  .setting-row { grid-template-columns: 1fr 1fr; }
  .setup-card { padding: 30px 30px; }
  .view--setup { max-width: 760px; margin-inline: auto; width: 100%; }
}

/* ---------- Game ---------- */
.view--game {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 720px;
  width: 100%;
  min-height: calc(100svh - 100px);
  margin-inline: auto;
}
.view--game[hidden] { display: none; }

.scoreboard {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: calc(-1 * var(--gutter));
  padding: 2px var(--gutter);
}
.scoreboard::-webkit-scrollbar { display: none; }
.score-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 5px 14px 5px 5px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  font-weight: 700;
  font-size: 14px;
}
.score-pill .avatar { width: 30px; height: 30px; font-size: 12px; box-shadow: none; }
.score-pill b {
  min-width: 1.4em;
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.score-pill.is-up b { animation: bump-up 0.7s var(--spring); color: var(--good); }
.score-pill.is-down b { animation: bump-down 0.6s var(--ease-out); color: var(--bad); }
.score-pill.is-lead { border-color: color-mix(in oklab, var(--gold) 60%, transparent); }
@keyframes bump-up { 30% { transform: translateY(-6px) scale(1.35); } }
@keyframes bump-down { 30% { transform: translateY(4px) scale(0.85); } }

.game-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.q-progress { flex: 1; display: grid; gap: 10px; }
.q-label {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 520;
}
.q-label small { color: var(--text-3); font-size: 0.75em; }
.q-progress .meter { height: 7px; }

.timer {
  --p: 1;
  position: relative;
  width: 64px;
  height: 64px;
  flex: none;
}
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 6; }
.timer__track { stroke: rgb(255 255 255 / 0.08); }
.timer__fill {
  stroke: var(--timer-color, var(--gold));
  stroke-linecap: round;
  stroke-dasharray: 175.93;
  stroke-dashoffset: calc(175.93 * (1 - var(--p)));
  transition: stroke 0.3s;
}
.timer__value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.timer.is-low { --timer-color: var(--bad); }
.timer.is-low .timer__value { color: #ffb0b0; animation: pulse 1s var(--ease-in-out) infinite; }
.timer.is-off { opacity: 0.35; }
@keyframes pulse { 50% { transform: scale(1.14); } }

.q-card {
  display: grid;
  gap: 14px;
  padding: 22px 20px;
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 90% at 0% 0%, rgb(244 201 107 / 0.12), transparent 60%),
    linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.025));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.q-card.is-in { animation: q-in 0.5s var(--ease-out); }
@keyframes q-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.q-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 11px;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.08);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tag--diff[data-level="easy"] { background: color-mix(in oklab, var(--good) 20%, transparent); color: #9ff0c4; }
.tag--diff[data-level="medium"] { background: color-mix(in oklab, var(--gold) 20%, transparent); color: #ffe3a3; }
.tag--diff[data-level="hard"] { background: color-mix(in oklab, var(--bad) 22%, transparent); color: #ffb0b0; }
.q-text {
  font-family: var(--font-display);
  font-size: clamp(24px, 6.4vw, 36px);
  font-weight: 480;
  line-height: 1.16;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 10px 18px 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 0.04);
  text-align: left;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.3;
  animation: view-in 0.45s var(--ease-out) both;
  transition: transform 0.35s var(--spring), border-color 0.2s, background-color 0.2s, opacity 0.3s, box-shadow 0.3s;
}
.option:nth-child(2) { animation-delay: 0.05s; }
.option:nth-child(3) { animation-delay: 0.1s; }
.option:nth-child(4) { animation-delay: 0.15s; }
.option:hover:not(:disabled) { border-color: color-mix(in oklab, var(--accent) 60%, transparent); background: rgb(255 255 255 / 0.07); }
.option:active:not(:disabled) { transform: scale(0.98); }
.option:disabled { cursor: default; }
.option__key {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 800;
}
.option__mark { margin-left: auto; opacity: 0; transform: scale(0.4); transition: opacity 0.3s, transform 0.5s var(--spring); }
.option__mark .icon { width: 22px; height: 22px; }
.option.is-right {
  border-color: transparent;
  background: linear-gradient(135deg, rgb(95 212 154 / 0.3), rgb(95 212 154 / 0.12));
  box-shadow: 0 0 0 2px var(--good), 0 14px 30px -16px var(--good);
}
.option.is-right .option__key { background: var(--good); border-color: transparent; color: #0d2a1b; }
.option.is-right .option__mark { opacity: 1; transform: none; color: var(--good); }
.option.is-wrong {
  border-color: transparent;
  background: linear-gradient(135deg, rgb(255 107 107 / 0.28), rgb(255 107 107 / 0.1));
  box-shadow: 0 0 0 2px var(--bad);
  animation: shake 0.45s var(--ease-out);
}
.option.is-wrong .option__key { background: var(--bad); border-color: transparent; color: #2a0b0b; }
.option.is-wrong .option__mark { opacity: 1; transform: none; color: var(--bad); }
.option.is-dim { opacity: 0.4; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.feedback {
  min-height: 1.5em;
  text-align: center;
  white-space: pre-line; /* the Chinese lines put the right answer on a line of its own */
  font-weight: 750;
  color: var(--text-2);
}
.feedback.is-good { color: var(--good); }
.feedback.is-bad { color: #ff9a9a; }

.game-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-bottom: 6px;
}
.game-actions #skipBtn,
.game-actions #nextBtn { margin-left: auto; }
.game-actions #nextBtn { min-width: 150px; min-height: 52px; font-size: 16px; }
.game-actions [hidden] { display: none; }

@media (min-width: 720px) {
  .options { grid-template-columns: 1fr 1fr; }
  .q-card { padding: 30px 30px; }
}

/* ---------- Who answered (sheet) ---------- */
.who-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.who-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 12px 8px 8px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 0.04);
  font-weight: 750;
  text-align: left;
  transition: transform 0.35s var(--spring), border-color 0.2s, background-color 0.2s;
}
.who-list button:hover { border-color: var(--pc); background: color-mix(in oklab, var(--pc) 14%, transparent); }
.who-list button:active { transform: scale(0.96); }
.who-list span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Results ---------- */
.view--results { gap: 26px; max-width: 760px; width: 100%; margin-inline: auto; }
.results-hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding-top: 8px;
}
.results-hero .crown-badge { margin-bottom: 30px; }
.results-hero .display { font-size: clamp(40px, 10vw, 84px); }
.results-hero .lede { margin-inline: auto; }

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 250px;
}
.podium:empty { display: none; }
.step-col {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  animation: view-in 0.7s var(--spring) both;
}
.step-col:nth-child(1) { animation-delay: 0.25s; }
.step-col:nth-child(2) { animation-delay: 0.05s; }
.step-col:nth-child(3) { animation-delay: 0.4s; }
.step-col .avatar { width: 48px; height: 48px; font-size: 18px; }
.step-col.is-first .avatar { width: 60px; height: 60px; font-size: 22px; box-shadow: 0 0 0 4px rgb(244 201 107 / 0.3), 0 12px 30px -8px var(--gold); }
.step-col__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.step-col__block {
  width: 100%;
  display: grid;
  place-items: start center;
  padding-top: 10px;
  border-radius: 18px 18px 6px 6px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.02));
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 560;
}
.step-col__block small { display: block; font-family: var(--font-ui); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.step-col.is-first .step-col__block {
  height: 150px;
  border-color: color-mix(in oklab, var(--gold) 50%, transparent);
  background: linear-gradient(180deg, rgb(244 201 107 / 0.35), rgb(244 201 107 / 0.05));
}
.step-col.is-second .step-col__block { height: 110px; }
.step-col.is-third .step-col__block { height: 80px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stats:empty { display: none; }
.stat {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 18px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  text-align: center;
}
.stat b { font-family: var(--font-display); font-size: 34px; font-weight: 560; line-height: 1.1; }
.stat span { color: var(--text-3); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }

.standings { display: grid; gap: 8px; }
.standings:empty { display: none; }
.standing {
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.03);
}
.standing__rank { font-family: var(--font-display); font-style: italic; color: var(--text-3); font-size: 18px; }
.standing .avatar { width: 36px; height: 36px; font-size: 13px; box-shadow: none; }
.standing__name { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing__score { font-family: var(--font-display); font-size: 22px; font-weight: 560; font-variant-numeric: tabular-nums; }
.standing__meta { color: var(--text-3); font-size: 12.5px; font-weight: 650; }

/* ---------- Footer credit ---------- */
.credit strong { color: var(--text); }

/* ---------- 中文 ----------
   Chinese has no capitals, so the tracked-out uppercase labels get normal tracking; serif
   questions get more leading; the categories sit in an even 4 × 3 grid. */
:lang(zh) .trivia .lede { word-break: keep-all; overflow-wrap: anywhere; } /* break after ，。 rather than mid-phrase */
:lang(zh) .setting__label { font-size: 13px; letter-spacing: 0.06em; }
:lang(zh) .cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
:lang(zh) .cat-grid .chip { padding: 0 8px; font-size: 15px; }
:lang(zh) .tag { letter-spacing: 0.04em; }
:lang(zh) .q-label { font-size: 21px; }
:lang(zh) .q-text { font-size: clamp(22px, 6vw, 34px); line-height: 1.42; letter-spacing: 0.02em; }
:lang(zh) .option { line-height: 1.45; }
:lang(zh) .q-text,
:lang(zh) .option__text { word-break: keep-all; overflow-wrap: anywhere; } /* breaks only at the <wbr>s DCG.setWords() puts between words */
:lang(zh) .feedback { text-wrap: balance; }
:lang(zh) .step-col__block small { letter-spacing: 0.04em; }
:lang(zh) .stat span { font-size: 13px; letter-spacing: 0.04em; }
:lang(zh) .standing { grid-template-columns: auto 36px 1fr auto; }
:lang(zh) .standing__rank { font-style: normal; font-size: 14px; }
