/* ==========================================================================
   Entropic Brainwaves — visual design
   Dark-first, mobile-first, one accent per state. Everything is CSS variables
   so the palette can be retuned in one place.
   ========================================================================== */

:root {
  --bg: #100e1c;
  --bg-elevated: #1c1830;
  --bg-raised: #262045;
  --surface-border: rgba(255, 255, 255, 0.09);

  --text: #f5f0ff;
  --text-muted: #ac9fd6;
  --text-faint: #6f6a8c;

  /* Wing palette — three colors a trail can move through, like light off a
     butterfly's wing, rather than one flat accent. */
  --accent: #8a5cf7;
  --accent-soft: rgba(138, 92, 247, 0.18);
  --accent-strong: #b083ff;
  --accent2: #ff59c4;
  --accent2-soft: rgba(255, 89, 196, 0.16);
  --accent3: #35e0d0;
  --accent3-soft: rgba(53, 224, 208, 0.16);
  --trail: linear-gradient(120deg, var(--accent) 0%, var(--accent2) 52%, var(--accent3) 100%);

  --correct: #2fd48f;
  --correct-soft: rgba(47, 212, 143, 0.15);
  --wrong: #ff5c78;
  --wrong-soft: rgba(255, 92, 120, 0.15);
  --gold: #ffc857;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.8);

  --max-width: 620px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f2ff;
    --bg-elevated: #ffffff;
    --bg-raised: #efe7ff;
    --surface-border: rgba(30, 20, 70, 0.1);
    --text: #1c1533;
    --text-muted: #5a5180;
    --text-faint: #8c86a8;
    --accent-soft: rgba(138, 92, 247, 0.12);
    --accent2-soft: rgba(255, 89, 196, 0.12);
    --accent3-soft: rgba(11, 158, 145, 0.12);
    --shadow: 0 16px 36px -22px rgba(40, 20, 90, 0.5);
    /* The dark-mode gold, green and teal are too pale to read on a light surface. */
    --gold: #a86a00;
    --correct: #12855a;
    --wrong: #d61f43;
    --accent3: #0b9e91;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(60rem 38rem at 12% -8%, rgba(138, 92, 247, 0.26), transparent 60%),
    radial-gradient(46rem 32rem at 105% 6%, rgba(255, 89, 196, 0.16), transparent 58%),
    radial-gradient(52rem 36rem at 30% 108%, rgba(53, 224, 208, 0.13), transparent 60%);
  background-attachment: fixed;
  background-size: 140% 140%, 140% 140%, 140% 140%;
  animation: wing-drift 36s ease-in-out infinite alternate;
  color: var(--text);
  font-family: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* A slow, barely-there drift across the three wing-colored glows — a trail,
   not a distraction. Respects reduced-motion below. */
@keyframes wing-drift {
  0% { background-position: 0% 0%, 100% 0%, 20% 100%; }
  100% { background-position: 8% 6%, 92% 10%, 32% 92%; }
}
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 12px) 16px max(env(safe-area-inset-bottom), 20px);
  min-height: 100dvh;
}

/* --- Screens -------------------------------------------------------------- */

.screen {
  display: none;
  animation: screen-in 0.32s var(--ease-out);
}
.screen.is-active {
  display: block;
}
.screen--game.is-active {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 40px);
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Boot ----------------------------------------------------------------- */

.boot {
  display: grid;
  place-items: center;
  gap: 18px;
  min-height: 70dvh;
}
.boot__text {
  color: var(--text-muted);
  margin: 0;
}
.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Panels / cards ------------------------------------------------------- */

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel--centered {
  text-align: center;
  margin-top: 8dvh;
  position: relative;
}
/* A soft, blurred wing-trail glow behind the hero panel — the app's one
   signature flourish, kept off the busier in-game screens. */
.panel--centered::before {
  content: '';
  position: absolute;
  inset: -18% -12% auto -12%;
  height: 220px;
  z-index: -1;
  background: conic-gradient(from 200deg, var(--accent), var(--accent2), var(--accent3), var(--accent));
  filter: blur(46px);
  opacity: 0.35;
  border-radius: 50%;
  pointer-events: none;
}
.panel--flush {
  margin-top: 4px;
}
.panel__icon {
  font-size: 44px;
  margin-bottom: 6px;
}
.panel__title {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.panel__title--hero {
  font-size: 34px;
  background: var(--trail);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: trail-shimmer 8s ease-in-out infinite alternate;
}
@keyframes trail-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .panel__title--hero {
    animation: none;
  }
}
.panel__subtitle {
  font-size: 15px;
  margin: 0 0 6px;
}
.panel__body {
  color: var(--text-muted);
  margin: 0 0 18px;
}
.panel__body--small {
  font-size: 14px;
}

.coverlist {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 12px;
}
.coverlist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.4;
}
.coverlist__icon {
  flex: none;
  font-size: 18px;
  line-height: 1.3;
}
.coverlist__categories {
  justify-content: center;
  margin-bottom: 20px;
}
.coverlist__categories .chip {
  color: var(--text-muted);
}

.rule {
  border: 0;
  border-top: 1px solid var(--surface-border);
  margin: 20px 0;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  transition: transform 0.12s var(--ease-out), filter 0.16s, background 0.16s;
}
.btn:active {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 10px 24px -12px var(--accent);
}
.btn--secondary {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--surface-border);
}
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--surface-border);
}
.btn--block {
  display: block;
  width: 100%;
  margin-top: 12px;
}
.btn--small {
  padding: 8px 14px;
  font-size: 13px;
}
.linkbtn {
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--accent-strong);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkbtn--centered {
  display: block;
  margin: 18px auto 0;
}
.iconbtn {
  background: var(--bg-raised);
  border: 1px solid var(--surface-border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex: none;
}

/* --- Forms ---------------------------------------------------------------- */

.form {
  text-align: left;
  margin-top: 4px;
}
.form--tight {
  margin-top: 14px;
}
.field {
  display: block;
  margin-bottom: 10px;
}
.field__label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field__input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
}
.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.form__error {
  color: var(--wrong);
  font-size: 13px;
  margin: 6px 0 0;
}
/* --- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 16px;
}
.topbar--sub {
  padding-bottom: 12px;
}
.topbar__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar__title {
  font-size: 18px;
  margin: 0;
  flex: 1;
  text-align: center;
}
.topbar__spacer {
  width: 38px;
  flex: none;
}
/* --- Stats strip ---------------------------------------------------------- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
}
.stat strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
}
.stat span {
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  /* Keep two-word labels like "Best streak" on one line in narrow tiles. */
  white-space: nowrap;
}

/* --- Home cards ----------------------------------------------------------- */

.stack > * + * {
  margin-top: 18px;
}
.card {
  display: block;
  width: 100%;
  text-align: left;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent2-soft) 55%, var(--accent3-soft) 100%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform 0.14s var(--ease-out);
}
.card:active {
  transform: scale(0.985);
}
.card__label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.card__title {
  font-size: 19px;
  font-weight: 700;
  margin: 4px 0 2px;
}
.card__meta {
  font-size: 13px;
  color: var(--text-muted);
}
.card.is-done {
  background: var(--bg-elevated);
}

.section__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.section__header .section__title {
  margin: 0;
}

.chipgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.chip--small {
  padding: 6px 13px;
  font-size: 13px;
}
.chip.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.chip.is-complete {
  border-color: var(--correct);
}
.chip.is-complete::after {
  content: '✓';
  margin-left: 6px;
  color: var(--correct);
  font-weight: 700;
}
.chip.is-complete.is-selected {
  background: var(--correct-soft);
  color: var(--correct);
}

/* The leaderboard matrix always fits the screen — no sideways scrolling. Fixed
   layout plus explicit column widths give the player name whatever is left
   over; it truncates with an ellipsis instead of pushing the table wider. On
   narrow screens the five category headers switch to short labels. */
.lbmatrix-scroll {
  overflow: hidden;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.lbmatrix {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}
.lbmatrix th,
.lbmatrix td {
  padding: 9px 3px;
  text-align: right;
  white-space: nowrap;
}
.lbmatrix th:first-child,
.lbmatrix td:first-child {
  padding-left: 8px;
}
.lbmatrix th:last-child,
.lbmatrix td:last-child {
  padding-right: 8px;
}
.lbmatrix th:nth-child(1) { width: 32px; }
.lbmatrix th:nth-child(3) { width: 15%; }
.lbmatrix th:nth-child(n + 4) { width: 11%; }
.lb-long { display: none; }
.lb-short { display: inline; }
@media (max-width: 419px) {
  .lbmatrix { font-size: 11px; }
  .lbmatrix th:nth-child(n + 3),
  .lbmatrix td:nth-child(n + 3) { padding-left: 1px; padding-right: 1px; }
}
@media (max-width: 339px) {
  .lbmatrix { font-size: 10px; }
}
@media (min-width: 540px) {
  .lbmatrix { font-size: 13px; }
  .lbmatrix th,
  .lbmatrix td { padding: 10px 6px; }
  .lbmatrix th:first-child,
  .lbmatrix td:first-child { padding-left: 12px; }
  .lbmatrix th:last-child,
  .lbmatrix td:last-child { padding-right: 12px; }
  .lbmatrix th:nth-child(1) { width: 44px; }
  .lbmatrix th:nth-child(3) { width: 13%; }
  .lbmatrix th:nth-child(n + 4) { width: 12.5%; }
  .lb-long { display: inline; }
  .lb-short { display: none; }
  .lbmatrix thead th { white-space: normal; vertical-align: bottom; }
}
.lbmatrix th:first-child,
.lbmatrix td:first-child,
.lbmatrix th:nth-child(2),
.lbmatrix td:nth-child(2) {
  text-align: left;
}
.lbmatrix thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 700;
  border-bottom: 1px solid var(--surface-border);
}
.lbmatrix tbody tr + tr {
  border-top: 1px solid var(--surface-border);
}
.lbmatrix__rank {
  color: var(--text-faint);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.lbmatrix__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lbmatrix__score,
.lbmatrix__cat {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.lbmatrix__score {
  color: var(--text);
  font-weight: 700;
}
.lbmatrix tr.is-you {
  background: var(--accent-soft);
}
.lbmatrix tr.is-you td {
  color: var(--accent-strong);
  font-weight: 800;
}
.lbmatrix .empty {
  text-align: center;
  color: var(--text-faint);
  padding: 18px 12px;
  white-space: normal;
}

/* --- Game ----------------------------------------------------------------- */

.gamebar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
}
.progress {
  flex: 1;
  min-width: 0;
}
.progress__bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-raised);
  overflow: hidden;
}
.progress__bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.35s var(--ease-out);
}
.progress__text {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}
.scorepill {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.scorepill small {
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}
.scorepill.is-bumped {
  animation: bump 0.4s var(--ease-out);
}
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.timer {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-raised);
  overflow: hidden;
  margin-bottom: 20px;
}
.timer span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--correct);
  transform-origin: left;
  transition: transform 0.2s linear, background 0.4s;
}
.timer span.is-low {
  background: var(--wrong);
}
.timer span.is-holding {
  background: var(--text-faint);
}

.question {
  flex: 1;
}
.question__tags {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}
.tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-muted);
  font-weight: 700;
}
.question__text {
  font-size: 22px;
  line-height: 1.3;
  margin: 0 0 22px;
  letter-spacing: -0.01em;
}

.answers {
  display: grid;
  gap: 10px;
}
.answer {
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.12s var(--ease-out), border-color 0.16s, background 0.16s;
  animation: answer-in 0.3s var(--ease-out) backwards;
}
.answer:nth-child(1) { animation-delay: 0.02s; }
.answer:nth-child(2) { animation-delay: 0.06s; }
.answer:nth-child(3) { animation-delay: 0.1s; }
.answer:nth-child(4) { animation-delay: 0.14s; }
@keyframes answer-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.answer:not(:disabled):hover {
  border-color: var(--accent);
}
.answer:active {
  transform: scale(0.99);
}
.answer__key {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bg-raised);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-faint);
  flex: none;
}
.answer.is-correct {
  border-color: var(--correct);
  background: var(--correct-soft);
  animation: pop 0.4s var(--ease-out);
}
.answer.is-correct .answer__key {
  background: var(--correct);
  color: #06251a;
}
.answer.is-wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
  animation: shake 0.4s;
}
.answer.is-wrong .answer__key {
  background: var(--wrong);
  color: #2e0510;
}
.answer.is-dimmed {
  opacity: 0.42;
}
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.feedback {
  position: sticky;
  bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 20px;
  box-shadow: var(--shadow);
  animation: slide-up 0.3s var(--ease-out);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}
.feedback__verdict {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}
.feedback__verdict[data-correct='true'] { color: var(--correct); }
.feedback__verdict[data-correct='false'] { color: var(--wrong); }
.feedback__points {
  margin: 2px 0 10px;
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.feedback__explanation {
  margin: 0 0 8px;
  font-size: 14.5px;
  color: var(--text-muted);
}
.feedback__source {
  font-size: 12px;
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-faint);
}

/* --- Results -------------------------------------------------------------- */

.results {
  text-align: center;
  padding-top: 5dvh;
}
.results__label {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin: 0;
}
.results__score {
  font-size: 62px;
  font-weight: 800;
  margin: 2px 0 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, var(--accent2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: score-in 0.5s var(--ease-out);
}
@keyframes score-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}
.results__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.results__grid div {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.results__grid strong {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.results__grid span {
  font-size: 12px;
  color: var(--text-faint);
}
.results__actions {
  text-align: left;
}

.review {
  text-align: left;
  margin-top: 18px;
  display: grid;
  gap: 10px;
}
.review__item {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-left: 3px solid var(--wrong);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.review__item[data-correct='true'] {
  border-left-color: var(--correct);
}
.review__q {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}
.review__a {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.review__src {
  font-size: 12px;
  color: var(--text-faint);
}

/* --- Today's board --------------------------------------------------------- */

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.board__row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.board__row.is-you {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.board__rank {
  width: 26px;
  font-weight: 800;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.board__row:nth-child(1) .board__rank { color: var(--gold); }
.board__row:nth-child(2) .board__rank { color: #cfd3e6; }
.board__row:nth-child(3) .board__rank { color: #d99a6c; }
.board__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board__meta {
  font-size: 12px;
  color: var(--text-faint);
}
.board__value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
}
.code--block {
  display: block;
  text-align: center;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: 19px;
}

/* --- Toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(env(safe-area-inset-bottom), 22px);
  transform: translate(-50%, 12px);
  background: var(--bg-raised);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s var(--ease-out);
  pointer-events: none;
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 32px 16px;
  font-size: 14px;
}

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

@media (min-width: 560px) {
  .question__text { font-size: 26px; }
  .results__score { font-size: 74px; }
  .results__grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Entropic Labs v2 — cover, onboarding and home screens.

   showScreen() mirrors the active screen onto <body data-view>, so everything
   here is scoped to those three views and every other screen keeps the base
   look above. The base tokens are re-pointed at the brand palette so shared
   components (forms, panels, toasts) pick it up unchanged; the brand tokens
   themselves (--ink-*, --acid, ...) live here too.
   ========================================================================== */

:root {
  --ink-0: #0b0b0d;
  --ink-1: #16161a;
  --ink-2: #26262c;
  --ink-3: #1e1e24;
  --paper: #f4f1ea;
  --mute: #8e8e98;
  --acid: #c8ff3d;
  --mint: #8cf0a8;
  --sky: #59c8ff;
  --coral: #ff5b38;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, Menlo, monospace;
  --font-sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body:is([data-view='cover'], [data-view='onboarding'], [data-view='home']) {
  color-scheme: dark;
  --bg: var(--ink-0);
  --bg-elevated: var(--ink-1);
  --bg-raised: var(--ink-1);
  --surface-border: var(--ink-2);
  --text: var(--paper);
  --text-muted: var(--mute);
  --text-faint: var(--mute);
  --accent: var(--acid);
  --accent-soft: rgba(200, 255, 61, 0.1);
  --accent-strong: var(--acid);
  --correct: var(--mint);
  --wrong: var(--coral);
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: none;

  background-color: var(--ink-0);
  background-image: radial-gradient(#1a1a20 1px, transparent 1.2px);
  background-size: 24px 24px;
  background-attachment: fixed;
  animation: none;
  font-family: var(--font-sans);
}

/* The one place a section label is styled; reused across the three views. */
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home'])
  :is(.section__title, .playcard__label, .panel__kicker, .field__label) {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mute);
}

/* --- Ambient: one oversized Pulse mark, drifting, faded out downwards ------- */

.ambient {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
body:is([data-view='cover'], [data-view='onboarding'], [data-view='home']) .ambient {
  display: block;
}
#app {
  position: relative;
  z-index: 1;
}
.ambient__mark {
  position: absolute;
  width: min(120vw, 760px);
  height: min(120vw, 760px);
  right: -40%;
  top: -22%;
  opacity: 0.14;
}
.ambient__fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0) 0%, rgba(11, 11, 13, 0.55) 55%, #0b0b0d 100%);
}

/* --- The Pulse mark, wherever it's inline ------------------------------------ */

.pulse-mark {
  display: block;
  flex: none;
  overflow: visible;
}
.pulse-mark--header {
  width: 32px;
  height: 32px;
}
.pulse-mark--hero {
  width: 72px;
  height: 72px;
  margin: 4px auto 26px;
  filter: drop-shadow(0 0 28px rgba(200, 255, 61, 0.25));
}

/* --- Shared controls ------------------------------------------------------------ */

:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home']) .btn {
  min-height: 48px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  transition: transform 0.12s var(--ease-out), border-color 0.18s, background 0.18s, color 0.18s;
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home']) .btn--primary {
  min-height: 52px;
  background: var(--acid);
  border-color: var(--acid);
  color: var(--ink-0);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(200, 255, 61, 0.15), 0 14px 36px -16px rgba(200, 255, 61, 0.7);
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home']) .btn--primary:hover {
  background: var(--paper);
  border-color: var(--paper);
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home'])
  :is(.btn--secondary, .btn--ghost) {
  background: transparent;
  border-color: var(--ink-2);
  color: var(--paper);
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home'])
  :is(.btn--secondary, .btn--ghost):hover {
  border-color: var(--acid);
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding'], .screen[data-screen='home'])
  :is(.btn, .chip, .linkbtn, .iconbtn):focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

/* --- Cover + onboarding ----------------------------------------------------------- */

:is(.screen[data-screen='cover'], .screen[data-screen='onboarding']) .panel--centered {
  margin-top: 6dvh;
  padding: 32px 22px 26px;
  background: var(--ink-1);
  border-color: var(--ink-2);
  border-radius: 8px;
}
:is(.screen[data-screen='cover'], .screen[data-screen='onboarding']) .panel--centered::before {
  display: none;
}
.screen[data-screen='cover'] .panel__title--hero {
  font-family: var(--font-mono);
  font-size: clamp(20px, 6.2vw, 28px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-wrap: balance;
  margin-bottom: 8px;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--paper);
  animation: none;
}
.panel__kicker {
  margin: 0 0 22px;
}
.screen[data-screen='cover'] .panel__kicker {
  font-weight: 500;
  letter-spacing: 0.16em;
}
.screen[data-screen='cover'] .panel__subtitle {
  font-size: 16px;
  line-height: 1.5;
  color: var(--mute);
  margin-bottom: 24px;
}
.screen[data-screen='cover'] .coverlist {
  margin-bottom: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--ink-2);
}
.screen[data-screen='cover'] .coverlist li {
  align-items: baseline;
  color: var(--mute);
  font-size: 14.5px;
}
.screen[data-screen='cover'] .coverlist__icon {
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
  background: var(--acid);
  transform: translateY(-2px);
}
.screen[data-screen='cover'] .coverlist__categories {
  margin-bottom: 8px;
}
.screen[data-screen='cover'] .chip {
  border-radius: 6px;
  background: transparent;
  border-color: var(--ink-2);
  color: var(--mute);
}
.screen[data-screen='onboarding'] .panel__title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.screen[data-screen='onboarding'] .field__input {
  background: var(--ink-0);
  border-color: var(--ink-2);
  border-radius: 6px;
}
.screen[data-screen='onboarding'] .field__input:focus-visible {
  outline-color: var(--acid);
}

/* --- Home ---------------------------------------------------------------------- */

.screen[data-screen='home'].is-active {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 8px 0 12px;
}

/* Top bar: mark + wordmark on the left; name pill and settings on the right. */
.screen[data-screen='home'] .topbar {
  padding: 0;
}
.screen[data-screen='home'] .topbar__identity {
  flex: 0 1 auto;
  gap: 10px;
}
.topbar__wordmark {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.topbar__brand {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 16px;
  white-space: nowrap;
}
.topbar__date {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  line-height: 12px;
  color: var(--mute);
  white-space: nowrap;
}
/* Phones too narrow for the one-line wordmark get the stacked lockup. */
@media (max-width: 419px) {
  .topbar__brand {
    white-space: normal;
  }
}
.topbar__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.namepill {
  height: 40px;
  min-width: 0;
  max-width: 132px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-1);
  border: 1px solid var(--ink-2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
}
.namepill > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.namepill__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--acid);
}
.screen[data-screen='home'] .iconbtn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: transparent;
  border-color: var(--ink-2);
  color: var(--mute);
  transition: border-color 0.18s, color 0.18s;
}
.screen[data-screen='home'] .iconbtn:hover {
  border-color: var(--acid);
  color: var(--paper);
}

/* Stats strip. */
.screen[data-screen='home'] .stats-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}
.screen[data-screen='home'] .stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--ink-1);
  border-color: var(--ink-2);
  border-radius: 6px;
  padding: 12px 8px 10px;
}
.screen[data-screen='home'] .stat strong {
  font-size: 22px;
  line-height: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.screen[data-screen='home'] .stat span {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--mute);
}

.screen[data-screen='home'] .stack > * + * {
  margin-top: 28px;
}

/* Play card: step 1 pick a category, step 2 play it. */
.playcard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--ink-1);
  border: 1px solid var(--ink-2);
  border-radius: 8px;
  padding: 18px 16px 16px;
}
.playcard__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.playcard__label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  line-height: 1.4;
}
.playcard__resets {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--mute);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The step markers: a 10px acid square built from 4×4 shards, which fly
   apart on Play (app.js sets each shard's --x/--y/--r). */
.marker {
  flex: none;
  width: 10px;
  height: 10px;
  display: grid;
  grid-template-columns: repeat(4, 2.5px);
  grid-auto-rows: 2.5px;
}
.marker__shard {
  background: var(--acid);
  border-radius: 0.5px;
  transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.playcard.is-dissolving .marker__shard {
  opacity: 0;
  transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(0.3);
}

.screen[data-screen='home'] .chipgrid {
  gap: 8px;
  margin: 0;
}
.screen[data-screen='home'] .chip {
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  border: 1px solid var(--ink-2);
  background: transparent;
  color: var(--mute);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}
.screen[data-screen='home'] .chip:hover {
  border-color: var(--mute);
  color: var(--paper);
}
.screen[data-screen='home'] .chip.is-complete {
  border-color: var(--ink-2);
}
.screen[data-screen='home'] .chip.is-complete::after {
  content: none;
}
.screen[data-screen='home'] .chip.is-selected,
.screen[data-screen='home'] .chip.is-selected:hover {
  border-color: var(--acid);
  background: rgba(200, 255, 61, 0.1);
  color: var(--paper);
}
.chip__dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
  background: var(--paper);
}
[data-category='current-events'] .chip__dot { background: #ff5b38; }
[data-category='science'] .chip__dot { background: #59c8ff; }
[data-category='geography'] .chip__dot { background: #8cf0a8; }
[data-category='general-knowledge'] .chip__dot { background: #c8ff3d; }
[data-category='entertainment'] .chip__dot { background: #f4f1ea; }
.chip__done {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--mint);
}

.screen[data-screen='home'] .playcard__play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 0 16px;
}

/* Leaderboard. */
.screen[data-screen='home'] .section__header {
  align-items: center;
  margin-bottom: 12px;
}
.screen[data-screen='home'] .section__title {
  margin: 0;
}
.screen[data-screen='home'] .linkbtn {
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--acid);
}
.screen[data-screen='home'] .linkbtn:hover {
  color: var(--paper);
}

/* Fixed columns (# · player · all · five categories); on screens too narrow
   for them, the wrapper scrolls sideways rather than squeezing the names. */
.screen[data-screen='home'] .lbmatrix-scroll {
  overflow-x: auto;
  background: var(--ink-1);
  border-color: var(--ink-2);
  border-radius: 8px;
}
.screen[data-screen='home'] .lbmatrix {
  min-width: 380px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.screen[data-screen='home'] .lbmatrix th,
.screen[data-screen='home'] .lbmatrix td {
  padding: 11px 2px;
}
.screen[data-screen='home'] .lbmatrix th {
  padding-top: 10px;
  padding-bottom: 10px;
}
.screen[data-screen='home'] .lbmatrix :is(th, td):first-child {
  padding-left: 12px;
}
.screen[data-screen='home'] .lbmatrix :is(th, td):last-child {
  padding-right: 12px;
}
.screen[data-screen='home'] .lbmatrix th:nth-child(1) { width: 42px; }
.screen[data-screen='home'] .lbmatrix th:nth-child(2) { width: auto; }
.screen[data-screen='home'] .lbmatrix th:nth-child(3) { width: 52px; }
.screen[data-screen='home'] .lbmatrix th:nth-child(n + 4) { width: 40px; }
.screen[data-screen='home'] .lbmatrix th:last-child { width: 50px; }
.screen[data-screen='home'] .lbmatrix thead th {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--mute);
  border-bottom: 1px solid var(--ink-2);
  white-space: nowrap;
}
.screen[data-screen='home'] .lbmatrix tbody tr + tr {
  border-top: 1px solid var(--ink-3);
}
.screen[data-screen='home'] .lbmatrix__rank {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--mute);
}
.screen[data-screen='home'] .lbmatrix__name {
  font-weight: 600;
  color: var(--paper);
}
.screen[data-screen='home'] .lbmatrix__score {
  font-weight: 700;
  color: var(--paper);
}
.screen[data-screen='home'] .lbmatrix__cat {
  color: var(--mute);
}
.screen[data-screen='home'] .lbmatrix tr.is-you {
  background: rgba(200, 255, 61, 0.07);
}
.screen[data-screen='home'] .lbmatrix tr.is-you td {
  font-weight: inherit;
}
.screen[data-screen='home'] .lbmatrix tr.is-you td:first-child {
  box-shadow: inset 2px 0 0 var(--acid);
}
.screen[data-screen='home'] .lbmatrix tr.is-you :is(.lbmatrix__name, .lbmatrix__score) {
  color: var(--paper);
}
.screen[data-screen='home'] .lbmatrix tr.is-you :is(.lbmatrix__rank, .lbmatrix__cat) {
  color: var(--mute);
}
.screen[data-screen='home'] .lbmatrix tr.is-you .lbmatrix__name { font-weight: 600; }
.screen[data-screen='home'] .lbmatrix tr.is-you .lbmatrix__score { font-weight: 700; }

/* Invite. */
.screen[data-screen='home'] [data-action='invite-friend'] {
  min-height: 48px;
}

/* ==========================================================================
   Category backdrops — game and results screens.

   startCategoryQuiz() puts the quiz's category on <body data-category>, and
   showScreen() the screen on <body data-view>. While a quiz (or its results)
   is on screen, the matching scene from .backdrop fills the viewport behind
   #app. Scenery keeps to the edges and stays low-contrast so questions and
   answers read cleanly over it; the answer cards are opaque regardless.
   Every scene is dark, so these views force the dark tokens in either theme.
   ========================================================================== */

body:is([data-view='game'], [data-view='results'])[data-category] {
  color-scheme: dark;
  --bg: #07070f;
  --bg-elevated: rgba(18, 16, 34, 0.92);
  --bg-raised: rgba(38, 32, 69, 0.9);
  --surface-border: rgba(241, 238, 251, 0.14);
  --text: #f5f0ff;
  --text-muted: #bdb3de;
  --text-faint: #8f88ad;
  --correct: #2fd48f;
  --correct-soft: rgba(47, 212, 143, 0.2);
  --wrong: #ff5c78;
  --wrong-soft: rgba(255, 92, 120, 0.2);
  --gold: #ffc857;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  animation: none;
  background-attachment: fixed;
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
body:is([data-view='game'], [data-view='results'])[data-category] .backdrop {
  display: block;
}
/* Transparent controls would sit straight on the scenery; give them a base. */
body:is([data-view='game'], [data-view='results'])[data-category] .btn--ghost {
  background: rgba(8, 8, 18, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
body:is([data-view='game'], [data-view='results'])[data-category] .linkbtn {
  text-shadow: 0 1px 6px #000, 0 0 2px #000;
}
/* A soft darkening down the reading column keeps text contrast high over any scene. */
.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 46rem 70% at 50% 42%, rgba(4, 4, 10, 0.5), transparent 75%);
}
.scene {
  display: none;
  position: absolute;
  inset: 0;
}
body[data-category='science'] .scene--science,
body[data-category='geography'] .scene--geography,
body[data-category='current-events'] .scene--current-events,
body[data-category='general-knowledge'] .scene--general-knowledge,
body[data-category='entertainment'] .scene--entertainment {
  display: block;
}

/* --- Science: the lab at night ---------------------------------------------- */

body[data-category='science'] {
  --accent: #22c3ff;
  --accent-soft: rgba(34, 195, 255, 0.16);
  --accent2: #7dff9b;
  background-color: #04111c;
  background-image:
    radial-gradient(50rem 34rem at 88% 4%, rgba(34, 195, 255, 0.22), transparent 62%),
    radial-gradient(40rem 30rem at 0% 100%, rgba(125, 255, 155, 0.12), transparent 60%),
    linear-gradient(180deg, #05182a 0%, #030c16 100%);
}
.sci-lattice {
  position: absolute;
  inset: 0;
  color: #5fd4ff;
  opacity: 0.07;
}
.sci-atom {
  position: absolute;
  top: -40px;
  right: -60px;
  width: min(420px, 70vw);
  height: min(420px, 70vw);
  opacity: 0.55;
  overflow: visible;
}
.sci-atom__spin {
  transform-box: view-box;
  transform-origin: center;
  animation: spin 90s linear infinite;
}
.sci-orbit {
  fill: none;
  stroke: #5fd4ff;
  stroke-width: 1.4;
  stroke-opacity: 0.7;
}
.sci-electron {
  fill: #b8f3ff;
  filter: drop-shadow(0 0 5px #22c3ff);
}
.sci-nucleus {
  fill: #7dff9b;
  filter: drop-shadow(0 0 14px rgba(125, 255, 155, 0.9));
  animation: pulse 4s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}
.sci-dna {
  position: absolute;
  top: 0;
  bottom: 0;
  left: max(8px, calc(50% - 460px));
  width: 90px;
  overflow: hidden;
  opacity: 0.4;
  mask-image: linear-gradient(180deg, transparent, #000 15%, #000 85%, transparent);
}
.sci-dna svg {
  display: block;
  width: 90px;
  height: 1800px;
  animation: dna-rise 40s linear infinite;
}
.sci-dna__strand {
  fill: none;
  stroke: #22c3ff;
  stroke-width: 3;
  stroke-linecap: round;
}
.sci-dna__strand--b { stroke: #7dff9b; }
.sci-dna__rungs {
  fill: none;
  stroke: #bfefff;
  stroke-opacity: 0.4;
  stroke-width: 2;
}
.sci-molecule {
  position: absolute;
  right: max(-20px, calc(50% - 520px));
  bottom: 8%;
  width: 190px;
  height: 190px;
  opacity: 0.4;
  animation: spin 120s linear infinite reverse;
}
.sci-bond {
  fill: none;
  stroke: #7dff9b;
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.sci-bond--inner { stroke-opacity: 0.5; stroke-width: 1.5; }
.sci-atomdot { fill: #22c3ff; }
.sci-atomdot--alt { fill: #ff6fb1; }
.sci-formula {
  position: absolute;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: #9fe6ff;
  opacity: 0.22;
  white-space: nowrap;
}
@keyframes dna-rise {
  to { transform: translateY(-600px); }
}
@keyframes pulse {
  from { transform: scale(0.9); }
  to { transform: scale(1.12); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Geography: Earth from orbit ---------------------------------------------- */

body[data-category='geography'] {
  --accent: #3fa8ff;
  --accent-soft: rgba(63, 168, 255, 0.16);
  --accent2: #45e3b0;
  background-color: #010208;
  background-image: radial-gradient(60rem 30rem at 50% 110%, rgba(63, 140, 255, 0.25), transparent 70%);
}
.geo-stars {
  position: absolute;
  inset: 0;
  opacity: 0.8;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 27% 8%, #cfe3ff, transparent),
    radial-gradient(1.4px 1.4px at 41% 26%, #fff, transparent),
    radial-gradient(1px 1px at 58% 12%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 73% 30%, #dbe8ff, transparent),
    radial-gradient(1px 1px at 86% 9%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 94% 38%, #fff, transparent),
    radial-gradient(1px 1px at 5% 44%, #cfe3ff, transparent),
    radial-gradient(1px 1px at 33% 47%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 66% 52%, #fff, transparent),
    radial-gradient(1px 1px at 18% 60%, #fff, transparent),
    radial-gradient(1px 1px at 80% 58%, #cfe3ff, transparent);
  background-size: 420px 420px;
}
/* A huge sphere whose upper limb curves across the lower screen — the view
   from a satellite. The surface is a strip of two texture copies, slid
   sideways on the compositor so the planet turns without repainting. */
.geo-earth {
  --d: max(150vw, 1100px);
  position: absolute;
  left: 50%;
  top: 60dvh;
  width: var(--d);
  height: var(--d);
  margin-left: calc(var(--d) / -2);
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(140, 200, 255, 0.35),
    0 0 40px 8px rgba(80, 160, 255, 0.55),
    0 0 140px 40px rgba(50, 120, 255, 0.28);
  opacity: 0.92;
}
.geo-earth__surface {
  position: absolute;
  top: -15%;
  left: 0;
  width: calc(var(--d) * 5.2);
  height: 130%;
  background: url('/img/earth-blue-marble.jpg') repeat-x 0 0 / 50% 100%;
  will-change: transform;
  animation: earth-turn 300s linear infinite;
}
.geo-earth__shade {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* Limb darkening (the surface falls away toward the edge), a faint blue
     haze of atmosphere, and dusk creeping in from both sides. */
  background:
    radial-gradient(circle closest-side, transparent 72%, rgba(10, 40, 90, 0.25) 88%, rgba(0, 8, 30, 0.7) 97%, rgba(40, 110, 220, 0.5) 100%),
    linear-gradient(90deg, rgba(0, 0, 8, 0.7) 0%, transparent 32%, transparent 68%, rgba(0, 0, 8, 0.7) 100%);
  box-shadow: inset 0 24px 50px -16px rgba(150, 210, 255, 0.6);
}
@keyframes earth-turn {
  to { transform: translateX(-50%); }
}
@media (min-width: 900px) {
  .geo-earth { top: 58dvh; }
}

/* --- Current events: on air ---------------------------------------------------- */

body[data-category='current-events'] {
  --accent: #ff4d4d;
  --accent-soft: rgba(255, 77, 77, 0.16);
  --accent2: #ffb03a;
  background-color: #0c0a10;
  background-image:
    radial-gradient(46rem 30rem at 100% 0%, rgba(255, 60, 60, 0.2), transparent 62%),
    radial-gradient(40rem 30rem at 0% 100%, rgba(255, 176, 58, 0.1), transparent 60%),
    linear-gradient(180deg, #140d14 0%, #0a080d 100%);
}
.news-columns {
  position: absolute;
  top: 12%;
  bottom: 14%;
  left: max(10px, calc(50% - 470px));
  width: 150px;
  opacity: 0.08;
  background:
    repeating-linear-gradient(180deg, #fff 0 3px, transparent 3px 11px) 0 0 / 68px 100% no-repeat,
    repeating-linear-gradient(180deg, #fff 0 3px, transparent 3px 11px) 82px 30px / 68px 100% no-repeat;
  mask-image: linear-gradient(180deg, transparent, #000 10%, #000 90%, transparent);
}
.news-globe {
  position: absolute;
  top: -70px;
  right: -70px;
  width: min(380px, 66vw);
  height: min(380px, 66vw);
  fill: none;
  stroke: #ff8a7a;
  stroke-width: 0.8;
  opacity: 0.3;
  animation: spin 200s linear infinite;
}
.news-rings {
  position: absolute;
  top: min(120px, 22vw);
  right: min(120px, 22vw);
  width: 0;
  height: 0;
}
.news-rings span {
  position: absolute;
  left: -140px;
  top: -140px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 2px solid rgba(255, 90, 90, 0.85);
  opacity: 0;
  animation: broadcast 4.5s ease-out infinite;
}
.news-rings span:nth-child(2) { animation-delay: 1.5s; }
.news-rings span:nth-child(3) { animation-delay: 3s; }
.news-live {
  position: absolute;
  left: -22px;
  top: -11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e5262f;
  color: #fff;
  font: 700 11px/18px ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-style: normal;
  letter-spacing: 0.12em;
  box-shadow: 0 0 18px rgba(255, 60, 60, 0.7);
  animation: live-blink 2s steps(1) infinite;
}
.news-ticker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  overflow: hidden;
  background: rgba(229, 38, 47, 0.16);
  border-top: 1px solid rgba(255, 77, 77, 0.35);
}
.news-ticker__track {
  display: flex;
  width: max-content;
  animation: ticker 60s linear infinite;
}
.news-ticker__track span {
  font: 600 11px/26px ui-monospace, 'SFMono-Regular', Consolas, monospace;
  letter-spacing: 0.18em;
  color: rgba(255, 210, 200, 0.55);
  white-space: nowrap;
}
@keyframes broadcast {
  from { transform: scale(0.15); opacity: 0.8; }
  to { transform: scale(1); opacity: 0; }
}
@keyframes live-blink {
  50% { opacity: 0.55; }
}
@keyframes ticker {
  to { transform: translateX(-50%); }
}

/* --- General knowledge: a library of ideas ---------------------------------- */

body[data-category='general-knowledge'] {
  --accent: #f2a93b;
  --accent-soft: rgba(242, 169, 59, 0.16);
  --accent2: #ff7a59;
  background-color: #110c08;
  background-image:
    radial-gradient(44rem 30rem at 0% 0%, rgba(242, 169, 59, 0.2), transparent 62%),
    radial-gradient(40rem 30rem at 100% 100%, rgba(255, 122, 89, 0.12), transparent 60%),
    linear-gradient(180deg, #1a120c 0%, #0d0906 100%);
}
.gk-bulb {
  position: absolute;
  top: 3%;
  left: max(4px, calc(50% - 500px));
  width: 120px;
  height: 168px;
  fill: none;
  stroke: #ffd27a;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.4;
  filter: drop-shadow(0 0 18px rgba(242, 169, 59, 0.6));
  animation: bulb-glow 5s ease-in-out infinite alternate;
}
.gk-bulb__filament { stroke: #fff1c9; }
.gk-glyphs span {
  position: absolute;
  bottom: -40px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 30px;
  font-weight: 700;
  color: #ffd27a;
  opacity: 0;
  animation: glyph-rise 36s linear infinite;
}
.gk-glyphs span:nth-child(even) {
  font-size: 22px;
  color: #ff9f80;
}
.gk-shelf {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 110px;
  opacity: 0.32;
}
.gk-books rect:nth-child(3n + 1) { fill: #8a4b2c; }
.gk-books rect:nth-child(3n + 2) { fill: #c98b3a; }
.gk-books rect:nth-child(3n) { fill: #5e3a5c; }
.gk-plank { fill: #c98b3a; }
@keyframes bulb-glow {
  from { opacity: 0.28; }
  to { opacity: 0.55; }
}
@keyframes glyph-rise {
  0% { transform: translateY(0) rotate(-8deg); opacity: 0; }
  10% { opacity: 0.3; }
  80% { opacity: 0.2; }
  100% { transform: translateY(-110vh) rotate(10deg); opacity: 0; }
}

/* --- Entertainment: premiere night ------------------------------------------ */

body[data-category='entertainment'] {
  --accent: #ff3fa0;
  --accent-soft: rgba(255, 63, 160, 0.16);
  --accent2: #ffc857;
  background-color: #0e0612;
  background-image:
    radial-gradient(50rem 30rem at 50% 120%, rgba(255, 63, 160, 0.22), transparent 65%),
    radial-gradient(40rem 26rem at 50% -10%, rgba(140, 70, 255, 0.2), transparent 60%),
    linear-gradient(180deg, #170a1d 0%, #0b050e 100%);
}
.ent-beam {
  position: absolute;
  bottom: -10vh;
  width: 30vmax;
  height: 125vh;
  transform-origin: 50% 100%;
  background: linear-gradient(0deg, rgba(255, 230, 190, 0.2), rgba(255, 230, 190, 0.06) 55%, transparent 90%);
  clip-path: polygon(47% 100%, 53% 100%, 100% 0, 0 0);
  filter: blur(14px);
  mix-blend-mode: screen;
}
.ent-beam--left {
  left: -10vmax;
  animation: beam-left 14s ease-in-out infinite alternate;
}
.ent-beam--right {
  right: -10vmax;
  animation: beam-right 17s ease-in-out infinite alternate;
}
.ent-film {
  position: absolute;
  bottom: 70px;
  left: -10%;
  width: 120%;
  height: 64px;
  transform: rotate(-6deg);
  overflow: hidden;
  opacity: 0.3;
}
.ent-film__track {
  width: calc(200% + 120px);
  height: 100%;
  background:
    /* sprocket holes, top and bottom */
    repeating-linear-gradient(90deg, transparent 0 8px, #0e0612 8px 16px, transparent 16px 24px) 0 5px / 100% 7px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 8px, #0e0612 8px 16px, transparent 16px 24px) 0 52px / 100% 7px no-repeat,
    /* frames */
    repeating-linear-gradient(90deg, rgba(255, 63, 160, 0.55) 0 76px, #0e0612 76px 84px, rgba(140, 70, 255, 0.55) 84px 160px, #0e0612 160px 168px) 0 16px / 100% 32px no-repeat,
    #2a1630;
  animation: film-roll 30s linear infinite;
}
.ent-bulbs {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 10px;
  background: radial-gradient(circle, #ffe3a3 0 3px, rgba(255, 200, 87, 0.35) 4px, transparent 5px) 0 0 / 28px 10px repeat-x;
  filter: drop-shadow(0 0 6px rgba(255, 200, 87, 0.8));
  animation: marquee 1.6s steps(2) infinite;
  opacity: 0.7;
}
.ent-sparkles {
  position: absolute;
  inset: 0;
  overflow: visible;
}
.ent-sparkle { fill: #ffe3a3; }
.ent-sparkles .tw1 { animation: twinkle 3s ease-in-out infinite alternate; }
.ent-sparkles .tw2 { animation: twinkle 4s ease-in-out -1s infinite alternate; }
.ent-sparkles .tw3 { animation: twinkle 5s ease-in-out -2s infinite alternate; }
@keyframes beam-left {
  from { transform: rotate(28deg); }
  to { transform: rotate(4deg); }
}
@keyframes beam-right {
  from { transform: rotate(-30deg); }
  to { transform: rotate(-6deg); }
}
@keyframes film-roll {
  to { transform: translateX(-168px); }
}
@keyframes marquee {
  to { background-position: 14px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop * { animation: none !important; }
}
