/* ==========================================================================
   Panel (318px wide, up to 496px tall) and mobile. Uses tokens from theme.css.
   ========================================================================== */

html, body { height: 100%; }
body.panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* --- header ---------------------------------------------------------------- */

.hdr {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.hdr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hdr-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xs);
  line-height: 1.3;
  white-space: nowrap;
  animation: rise var(--t-med) var(--ease);
}
.icon-btn {
  flex: none;
  width: 26px;
  height: 26px;
  margin-left: -4px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="false"] { opacity: 0.7; }
.hdr-title { font-size: var(--fs-sm); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-score { display: flex; align-items: baseline; gap: 4px; flex: none; }
.hdr-score .num { font-size: var(--fs-xl); color: var(--gold); line-height: 1; display: inline-block; }
.hdr-score .num.bump { animation: bump 480ms var(--ease); }
.hdr-score .faint { font-size: var(--fs-xs); }

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

.stack { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-5); }
.card { padding: var(--s-4); }
.center { text-align: center; }
.small { font-size: var(--fs-sm); }
[hidden] { display: none !important; }

/* --- waiting / countdown ---------------------------------------------------- */

#waiting-screen { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-5) var(--s-4); }
.countdown { font-size: 40px; line-height: 1; color: var(--text); letter-spacing: 0.02em; }
#waiting-screen h2 { font-size: var(--fs-xl); }

/* --- question ------------------------------------------------------------- */

.question { padding: var(--s-4); animation: rise var(--t-med) var(--ease); }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-3); }
.q-text { font-size: var(--fs-lg); line-height: 1.35; font-weight: 600; margin-bottom: var(--s-3); overflow-wrap: anywhere; }
.spoiler { display: flex; align-items: center; gap: 6px; margin-bottom: var(--s-2); padding: 4px 10px; border-radius: var(--r-sm); background: var(--gold-soft); color: var(--gold); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; }
.spoiler::before { content: "!"; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1; }

.timer { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-bottom: var(--s-3); }
.timer-fill { height: 100%; width: 100%; background: var(--accent); border-radius: 2px; transition: width 240ms linear, background var(--t-med); }
.timer-fill.urgent { background: var(--bad); }

.choices { display: flex; flex-direction: column; gap: var(--s-2); }

.choice-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 44px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  animation: rise var(--t-med) var(--ease) both;
}
.choice-button:nth-child(2) { animation-delay: 40ms; }
.choice-button:nth-child(3) { animation-delay: 80ms; }
.choice-button:nth-child(4) { animation-delay: 120ms; }
.choice-button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice-button:active:not(:disabled) { transform: scale(0.99); }
.choice-button:disabled { cursor: default; }

.chip {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
}
.choice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-md); }
.choice-share { flex: none; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }

.choice-button.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice-button.selected .chip { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.choice-button.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice-button.correct .chip { background: var(--ok); border-color: var(--ok); color: #06130b; }
/* One pulse on the answer at reveal: scale on the button, a ring on the chip. */
.choice-button.pop { animation: pop 520ms var(--ease) 1; }
.choice-button.pop .chip { animation: ring 700ms var(--ease) 1; }
.choice-button.wrong { opacity: 0.6; }
.choice-button.wrong.selected { opacity: 1; border-color: var(--bad); background: var(--bad-soft); }
.choice-button.wrong.selected .chip { background: var(--bad); border-color: var(--bad); color: #fff; }

.result {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-2);
  animation: rise var(--t-med) var(--ease);
}
.result .points { display: block; font-family: var(--font-display); font-size: var(--fs-xl); color: var(--gold); line-height: 1.2; }
.result.good { background: var(--ok-soft); }
.result.good .points { color: var(--ok); }
.result .streak-line { margin-top: 4px; color: var(--gold); font-weight: 600; }
.result .nudge { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px var(--s-2); margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--line); color: var(--text-2); }

/* --- leaderboard ------------------------------------------------------------ */

.board { padding: var(--s-3) var(--s-4) var(--s-4); }
.tabs { display: flex; gap: var(--s-1); margin-bottom: var(--s-3); border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: var(--s-2) 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.board-list li, .board-me { display: flex; align-items: center; gap: var(--s-2); padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.board-list li:last-child { border-bottom: 0; }
.rank { flex: none; width: 22px; font-family: var(--font-display); font-weight: 600; color: var(--text-3); text-align: center; }
.rank.r1 { color: var(--gold); }
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.board-list li.me, .board-me { color: var(--text); background: var(--accent-soft); margin: 0 calc(-1 * var(--s-3)); padding-left: var(--s-3); padding-right: var(--s-3); border-radius: var(--r-sm); border-bottom: 0; }
.link-btn { background: none; border: 0; padding: 0 2px; color: var(--accent); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }
.board-me { margin-top: var(--s-2); }
.board-empty { color: var(--text-3); font-size: var(--fs-sm); padding: var(--s-2) 0; }

/* --- account rows ----------------------------------------------------------- */

.account { display: flex; flex-direction: column; gap: var(--s-2); padding: 0 var(--s-1); }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.row.wrap { flex-wrap: wrap; }
#link-discord-result { flex-basis: 100%; color: var(--text-2); line-height: 1.5; }
#link-discord-result:empty { display: none; }
#link-discord-result code { display: inline-block; padding: 3px 8px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--gold); user-select: all; margin: 2px 0; }

/* --- mobile ----------------------------------------------------------------- */

body.mobile .stack { padding: var(--s-4); gap: var(--s-4); }
body.mobile .choice-button { min-height: 52px; }
body.mobile .q-text { font-size: var(--fs-xl); }
body.mobile .countdown { font-size: 48px; }

/* --- motion ----------------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.035); } 100% { transform: scale(1); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--ok); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.18); } 100% { transform: scale(1); } }
