:root {
  --bg: #eef4ff;
  --card: #ffffff;
  --ink: #1d2b4f;
  --muted: #596788;
  --line: #cfdbf3;
  --green: #1b7f3b;
  --red: #c9302c;
  --focus: #2f5fe0;
  --question: var(--ink);
  --picture: none;
}

:root[data-theme="dino"] {
  --bg: #e3f0c8;
  --card: #fffbe9;
  --ink: #2f3d16;
  --muted: #55652f;
  --line: #a9bd72;
  --focus: #7a4a12;
  --question: #fffbe9; /* sits on the dark throat */
  --picture: url("images/trex.svg");
}

:root[data-theme="space"] {
  --bg: #12143a;
  --card: #262a63;
  --ink: #ffffff;
  --muted: #c0c6f2;
  --line: #5b62b5;
  --focus: #ffd84d;
  --picture: url("images/blackhole.svg");
}

:root[data-theme="baby"] {
  --bg: #fdeaf2;
  --card: #ffffff;
  --ink: #4b3566;
  --muted: #75608f;
  --line: #f2bdd5;
  --focus: #8a4fc0;
  --picture: url("images/baby.svg");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

.game {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.stats { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; }
.stat { display: flex; flex-direction: column; }
.stat:nth-child(2) { text-align: center; }
.stat:last-child { text-align: right; }
.stat-label { font-size: 1rem; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 700; }

.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

:root[data-theme="space"] .picture { inset: -12px -16px; }

.themes {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.theme .dot { display: block; width: 18px; height: 18px; margin: 0 auto; border-radius: 50%; background: #4a7dff; }
.theme[aria-pressed="true"] { border: 3px solid var(--focus); }

/* Theme picture, kept inside the question area so scores and answers stay clear. */
.picture {
  position: absolute;
  inset: 0 -8px;
  background: var(--picture) center / contain no-repeat;
  pointer-events: none;
}

.question {
  position: relative;
  color: var(--question);
  margin: 0;
  font-size: clamp(3.5rem, min(24vw, 11.5vh), 7rem);
  line-height: 1;
  white-space: nowrap;
}

.answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.answer {
  position: relative;
  min-height: 88px;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 2.25rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.answer:focus-visible, .theme:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }

.answer.right { background: var(--green); border-color: var(--green); color: #fff; }
.answer.wrong { background: var(--red); border-color: var(--red); color: #fff; }
/* Tick so the result does not depend on colour alone. No cross on the wrong
   answer: next to a number it reads as a multiplication sign. */
.answer.right::after {
  content: "✓";
  position: absolute;
  inset: auto 0 4px;
  font-size: 1.25rem;
  line-height: 1;
}

.answers.locked .answer { cursor: default; }
.answers.locked .answer:not(.right):not(.wrong) { opacity: 0.45; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Phones held sideways: question beside the answers. */
@media (orientation: landscape) and (max-height: 500px) {
  .game {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    align-items: center;
    max-width: 900px;
  }
  .stats { grid-column: 1 / -1; }
  .stage { align-self: stretch; }
  .question { font-size: clamp(3rem, 9vw, 6rem); }
}
