:root {
  --bg: #0b1020;
  --panel: #121a34;
  --panel-2: #0f1630;
  --text: #f2f5ff;
  --muted: #b6c0e0;
  --primary: #4da3ff;
  --primary-2: #2d7af0;
  --accent: #f0b90b;
  --danger: #ff5577;
  --success: #00d38b;
  --safe: #ff9f0a;
  --ring: rgba(255,255,255,0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 50% -20%, #243b92 0%, #101a3c 35%, #0b1020 70%),
    radial-gradient(1000px 600px at 20% 120%, #0d1638 10%, transparent 70%),
    #0b1020;
  overflow: auto;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 80% at 50% 0%, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(120% 140% at 50% 120%, rgba(0,0,0,0.6), transparent 60%);
}
body::after {
  content: "";
  position: fixed;
  inset: -20% -20% -10% -20%;
  pointer-events: none;
  background: conic-gradient(from 210deg at 60% 40%, rgba(77,163,255,0.08), rgba(240,185,11,0.06), rgba(0,0,0,0) 20%, rgba(77,163,255,0.08) 40%, rgba(0,0,0,0) 60%);
  filter: blur(32px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(20,28,60,0.85), rgba(20,28,60,0.4));
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(6px);
}
.brand .app-title { font-weight: 800; font-size: 22px; letter-spacing: 0.3px; }
.brand .k-to-infinity { font-family: "Source Serif Pro", serif; font-size: 18px; opacity: 0.9; }
.header-actions .ghost { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.2); padding: 8px 12px; border-radius: 8px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; padding: 16px 24px 24px; height: calc(100vh - 64px); }
.game { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; }
.game-top { display: flex; align-items: center; justify-content: space-between; width: min(900px, 100%); }
.meta { display: flex; align-items: center; gap: 16px; }
.player-name { font-weight: 600; opacity: 0.9; }
.timer { background: #17224b; padding: 6px 10px; border-radius: 8px; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }

.lifelines { display: flex; gap: 8px; }
.lifeline { background: #17224b; color: var(--text); border: 1px solid rgba(255,255,255,0.12); padding: 8px 12px; border-radius: 999px; cursor: pointer; transition: 140ms ease; }
.lifeline:disabled { opacity: 0.4; cursor: not-allowed; }
.lifeline:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(45,122,240,0.25); }

.question-card { background: linear-gradient(180deg, #0f1738, #0c1532); border-radius: 18px; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,0.25), inset 0 0 0 1px var(--ring); width: min(900px, 100%); position: relative; overflow: auto; }
.question-card::after { content:""; position:absolute; inset:0; background: radial-gradient(100% 60% at 50% -10%, rgba(255,255,255,0.06), transparent 40%); pointer-events:none; }
.question-number { color: var(--muted); margin-bottom: 8px; }
.question-text { font-size: 24px; line-height: 1.5; background: linear-gradient(180deg, #0d1634, #0a1230); border-radius: 14px; padding: 16px; box-shadow: inset 0 0 0 1px var(--ring); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.answer { background: linear-gradient(180deg, #0f1b45, #0c1535); border: 1px solid rgba(255,255,255,0.12); padding: 14px 16px 14px 52px; border-radius: 999px; cursor: pointer; transition: 160ms ease; position: relative; box-shadow: 0 6px 18px rgba(0,0,0,0.25), inset 0 0 0 1px var(--ring); color: var(--text); text-align: left; }
.answer::before { content: attr(data-label); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #0b1020; background: linear-gradient(180deg, var(--accent), #c69209); box-shadow: 0 2px 0 rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.3); }
.answer:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(0,0,0,0.35); }
.answer.selected { outline: 2px solid var(--primary); background: linear-gradient(180deg, #102050, #0d1a42); }
.answer.correct { outline: 2px solid var(--success); background: linear-gradient(180deg, #0b2a20, #092417); }
.answer.incorrect { outline: 2px solid var(--danger); background: linear-gradient(180deg, #321424, #2a0f1c); }
.answer .label { display: none; }
.answer[hidden] { display: none; }

.actions-row { display: flex; justify-content: space-between; margin-top: 12px; }
button.primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); color: #fff; border: none; padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 700; }
button.walk { background: transparent; color: var(--accent); border: 1px solid rgba(240,185,11,0.5); padding: 10px 16px; border-radius: 10px; cursor: pointer; }
button.ghost { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.2); padding: 10px 16px; border-radius: 10px; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.explanation { background: #101a3a; border-radius: 14px; padding: 14px; box-shadow: inset 0 0 0 1px var(--ring); width: min(900px, 100%); }
.explanation-title { font-weight: 800; margin-bottom: 8px; }
.post-explanation-actions { margin-top: 10px; }
.correct-answer-line { margin-bottom: 8px; background: #0f1738; padding: 8px 10px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--ring); }
.correct-answer-line .text { margin-left: 6px; }
.explanation-detail { margin-top: 8px; }

.mathematician-panel { display: flex; gap: 12px; align-items: center; background: #101a3a; border-radius: 14px; padding: 12px; box-shadow: inset 0 0 0 1px var(--ring); width: min(900px, 100%); }
.mathematician-panel[hidden] { display: none; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #2443a5, #9b59ff); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2); display: grid; place-items: center; font-weight: 800; color: #fff; }
.math-name { font-weight: 700; }
.math-quote { color: var(--muted); font-size: 14px; }

.sidebar { background: var(--panel); border-radius: 16px; padding: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.25), inset 0 0 0 1px var(--ring); overflow: auto; position: sticky; top: 16px; align-self: start; height: fit-content; }
.ladder-title { font-weight: 800; margin-bottom: 6px; }
.ladder-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: level 16; }
.ladder-list li { background: linear-gradient(180deg, #0f1738, #0c1330); padding: 8px 10px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px var(--ring); }
.ladder-list li.safe { color: var(--safe); }
.ladder-list li.active { outline: 2px solid var(--accent); box-shadow: 0 0 0 4px rgba(240,185,11,0.15); }

dialog { border: none; border-radius: 14px; padding: 16px; background: #0f1734; color: var(--text); box-shadow: 0 20px 80px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.08); }
dialog::backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
dialog input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18); background: #0e1530; color: var(--text); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
dialog table { width: 100%; border-collapse: collapse; }
dialog th, dialog td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }

#celebration-canvas { position: fixed; inset: 0; pointer-events: none; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; height: auto; overflow: auto; }
  body { overflow: auto; }
  .answers { grid-template-columns: 1fr; }
  .game-top { gap: 8px; flex-wrap: wrap; }
}


