:root {
  color-scheme: light;
  --muted: #5a3467;
  --line: #ddc4dd;
}

html, body { height: auto; min-height: 100%; overflow: visible; }
.clouds-layer { position: fixed; }
main { position: relative; }
@media (prefers-reduced-motion: reduce) {
  .cloud { animation: none; }
}
html:has(#challenge[open]), body:has(#challenge[open]) { overflow: hidden; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--purple-dark); outline-offset: 4px; }

main {
  max-width: 1140px;
  margin: auto;
  padding: 70px 28px calc(28px + var(--am-consent-h));
}
main:has(:is(.setup-menu, .victory-screen, .room-screen):not([hidden])) {
  display: grid;
  min-height: 100dvh;
  align-items: center;
}
h1, h2, p { margin: 0; }
h2 { font-size: 1.6rem; font-weight: normal; line-height: 1.15; }

.board { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(0, 1fr); gap: 22px; }
.side { display: grid; align-content: start; gap: 18px; }
.wheel-card, .turn-card, .collection {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 4px 0 #2f1c4710;
}
.wheel-card {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  background-color: #e8f5f5;
  background-image: radial-gradient(#b0d7dd 1px, transparent 1px);
  background-size: 18px 18px;
}
.turn-card, .collection { background: #fffefd; }
.board[hidden] { display: none; }
.setup-menu { width: min(100%, 440px); margin-inline: auto; gap: 15px; }
.setup-menu .mascot { height: auto; }
.setup-menu .start-hint, .room-screen .start-hint {
  margin-top: -6px;
  max-width: 34ch;
  font-size: clamp(15px, 3.6vw, 19px);
  line-height: 1.25;
  color: var(--purple-dark);
  opacity: .9;
}
.setup-menu #start:disabled { cursor: default; }
.mode-choices, .player-names {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.player-names label { display: grid; gap: 5px; text-align: left; font-weight: 700; color: var(--key-text); }
.player-names input, .room-name input {
  min-width: 0;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--purple);
  border-radius: 10px;
  background: #fffefd;
  color: var(--ink);
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
}
.collections { display: grid; gap: 12px; }
.collections:has(.collection + .collection) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.collection.active { border-color: var(--purple-dark); box-shadow: inset 0 0 0 2px var(--purple-dark); }
.collection h2 { overflow-wrap: break-word; hyphens: auto; }
.collections:has(.collection + .collection) .pie-plate { width: min(100%, 130px); }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.collections:has(.collection + .collection) .card-heading { flex-direction: column; text-align: center; }
.score, #round {
  color: var(--purple-dark);
  background: #f6e8f2;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 800;
  font-size: .9rem;
  white-space: nowrap;
}
#round:empty { display: none; }
.wheel-frame {
  position: relative;
  display: block;
  padding: 0;
  color: var(--ink);
  background: #fffdf8;
  width: min(89%, 374px);
  aspect-ratio: 1;
  margin: 25px auto 18px;
  border: 8px solid #fffdf8;
  border-radius: 50%;
  box-shadow: 0 9px 0 #78b0bd, 0 17px 25px #366b7d30;
}
.wheel-frame:not(:disabled) { cursor: pointer; }
.wheel-frame:not(:disabled):hover .hub { background: var(--purple-dark); }
.wheel-frame:not(:disabled):active .hub { scale: .93; }
#wheel { position: absolute; inset: 0; border-radius: 50%; }
#wheel.spinning, #wheel.spinning .wheel-symbol { transition: transform 1500ms cubic-bezier(.12, .67, .15, 1), rotate 1500ms cubic-bezier(.12, .67, .15, 1); }
.wheel-symbol {
  position: absolute;
  translate: -50% -50%;
  rotate: var(--wheel-turn, 0deg);
  font-size: clamp(1rem, 3.3vw, 2rem);
  font-weight: 900;
  letter-spacing: -.055em;
}
.pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  translate: -50%;
  width: 34px;
  height: 39px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: 2;
}
.hub {
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: 23%;
  aspect-ratio: 1;
  background: var(--ink);
  color: white;
  border: 5px solid #fffdf8;
  border-radius: 50%;
  font-size: clamp(.7rem, 2.2vw, 1.7rem);
  box-shadow: 0 4px 10px #1b153b29;
}
.turn-card { min-width: 0; block-size: 176px; overflow: auto; }
.turn-player {
  width: fit-content;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 5px 12px;
  border: 1px solid var(--purple-dark);
  border-radius: 8px;
  background: #f6e8f2;
  color: var(--purple-dark);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: bold;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
#turn-actions:not(:empty) { margin-top: 12px; }
.ages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; border: 0; padding: 0; margin: 0; width: 100%; min-width: 0; }
.ages legend { padding: 0 0 7px; font-weight: 700; color: var(--key-text); }
.age {
  position: relative;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  gap: 2px;
  place-items: center;
  padding: 9px 2px;
  background: #fcf4f8;
  border: 1px solid #ead5e3;
  border-radius: 12px;
  cursor: pointer;
}
.age small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.setup-menu .tut-trigger {
  background: var(--green);
  color: #17371c;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 7px 4px;
  min-height: 43px;
}
.setup-menu .tut-trigger:hover { background: #56c562; }
.setup-menu .tut-trigger:has(:checked) {
  background: #247535;
  color: white;
}
.setup-menu .tut-trigger small { color: inherit; }
.age:has(:focus-visible) { outline: 3px solid var(--purple-dark); outline-offset: 2px; }
.secondary, .answer { cursor: pointer; font-weight: 800; }
.primary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 49px;
  padding: 10px 15px;
  font-size: 1.2rem;
}
.primary:hover:not(:disabled) { background: #ce3e54; }
.primary:disabled { color: var(--key-text); background: #f2dce8; box-shadow: none; cursor: default; transform: none; }
.secondary { padding: 10px 0 0; border: 0; background: transparent; color: var(--purple-dark); text-decoration: underline; }
.turn-copy { margin: 9px 0 14px; color: var(--muted); }
.pie-plate {
  width: clamp(110px, 17vw, 196px);
  margin: 9px auto 0;
}
.pie-plate svg { display: block; width: 100%; height: auto; }
.pie-wedge { stroke: #fffefd; stroke-width: 4px; stroke-linejoin: round; }
.flying-slice {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 134px;
  height: 134px;
  pointer-events: none;
  transform-origin: top left;
  filter: drop-shadow(0 5px 5px #33313f55);
}
.category-tag { display: inline-block; padding: 4px 10px; margin-bottom: 9px; border-radius: 6px; font-size: .84rem; font-weight: 800; }
.expression { margin-top: 7px; font-size: clamp(1.4rem, 3.2vw, 2.1rem); font-weight: 850; letter-spacing: -.025em; }
.answers { display: grid; grid-template-columns: repeat(var(--choices, 3), minmax(0, 1fr)); gap: 7px; margin: 13px 0 5px; }
.answer { min-width: 0; min-height: 46px; border: 1px solid #ead5e3; border-radius: 10px; background: var(--key); color: var(--key-text); padding: 7px 4px; }
.answer:hover:not(:disabled) { border-color: var(--purple-dark); background: #f5d4e7; }
.answer:disabled { cursor: default; }
.feedback { margin: 9px 0; color: #873931; font-weight: 720; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 720px) {
  main { padding: 70px 14px calc(28px + var(--am-consent-h)); }
  .board { grid-template-columns: 1fr; gap: 12px; }
  .side { gap: 12px; }
  .wheel-card, .turn-card, .collection { padding: 14px; border-radius: 18px; }
  .wheel-frame { width: min(72%, 256px); margin: 14px auto 9px; border-width: 5px; }
  .pointer { width: 24px; height: 27px; top: -9px; }
}

#challenge {
  width: 88vw;
  height: 88dvh;
  max-width: none;
  max-height: none;
  margin: auto;
  overflow: clip;
  background: #fffdf9;
  border: 3px solid #d5b3d6;
  border-radius: 26px;
  box-shadow: 0 12px 0 #7a43802e, 0 18px 30px #0004;
  color: var(--ink);
  padding: 0;
  text-align: center;
}
#challenge::backdrop { background: #14121a9c; }
#challenge > .tut-x {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  height: 30px;
  z-index: 2;
}
#challenge-viewport {
  position: absolute;
  inset: 27px clamp(5px, 1.25vw, 18px) 7px;
}
#challenge-content {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-bottom: 6px;
  transform: translate(-50%, -50%) scale(var(--challenge-scale, 1));
}
#challenge h2 { max-width: 28ch; font-size: clamp(1.6rem, 5vw, 3rem); color: var(--purple-dark); }
#challenge .expression { margin-top: 10px; }
#challenge .answers { width: min(100%, 440px); }
.category-tag.light-ink, .wheel-symbol.light-ink { color: white; }

#challenge-content.embedded {
  justify-content: flex-start;
  gap: 4px;
}
#challenge-content.embedded h2 { font-size: clamp(1.2rem, 3.6vw, 2rem); }
.site-game-shell {
  position: relative;
  flex: 1 1 0;
  min-height: 100px;
  width: 100%;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sky);
}
.site-game {
  position: absolute;
  inset: 0 auto auto 0;
  display: block;
  border: 0;
  transform: scale(var(--site-scale, 1));
  transform-origin: top left;
}
#challenge-content.embedded > :not(.site-game-shell) { flex: none; }

.result-panel .primary { width: min(100%, 230px); }

.site-game-footer {
  display: grid;
  place-items: center;
  block-size: 54px;
  width: 100%;
}
.site-game-footer .solution-review {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, auto);
  gap: 8px;
  padding: 0;
  align-items: center;
}
.site-game-footer .solution-review .primary {
  width: auto;
  min-height: 38px;
  padding: 5px 12px;
  gap: 7px;
  font-size: 1rem;
}
.victory-screen { gap: 12px; margin-inline: auto; }
.victory-screen .title {
  font-size: clamp(2.2rem, 6vw, 3.75rem);
  color: var(--purple-dark);
  overflow-wrap: anywhere;
  text-shadow: 2px 2px 0 white;
}
.victory-screen .mascot { width: min(115px, 29vw); height: auto; }
.victory-message { font-size: clamp(1.2rem, 3vw, 1.6rem); color: var(--purple-dark); }
.victory-screen .pie-plate { width: clamp(105px, 18vw, 146px); margin: 0; }

.result-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  align-content: center;
  width: min(100%, 540px);
  min-height: min(55dvh, 390px);
  padding: 20px 12px;
  border-radius: 22px;
  background: #f8e4df;
}
.result-panel.correct { background: #e1f4df; }
.result-panel .feedback { margin: 0 0 8px; }
.result-panel.correct .feedback { color: #28613e; }
.result-stamp {
  display: grid;
  place-items: center;
  width: clamp(80px, 18dvh, 146px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: #fff;
  background: #b4484a;
  font-size: clamp(2.8rem, 11dvh, 5rem);
  font-weight: 900;
  line-height: 1;
}
.result-slice {
  width: clamp(80px, 18dvh, 146px);
  height: clamp(80px, 18dvh, 146px);
  filter: drop-shadow(0 5px 3px #33313f40);
}
@media (prefers-reduced-motion: no-preference) {
  :is(.result-stamp, .result-slice) { animation: reward-pop .38s cubic-bezier(.22, .84, .29, 1.3) both; }
}
@keyframes reward-pop {
  from { scale: .35; opacity: 0; rotate: -20deg; }
  to { scale: 1; opacity: 1; rotate: 0deg; }
}

@media (max-width: 720px) {
  .board { grid-template-columns: minmax(0, 1fr) minmax(105px, .56fr); }
  .side { display: contents; }
  .wheel-card { grid-area: 2 / 1; }
  .collections { grid-area: 2 / 2; align-content: center; }
  .collections:has(.collection + .collection) { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .collections:has(.collection + .collection) .collection { padding: 6px; }
  .collections:has(.collection + .collection) .pie-plate { width: min(100%, 62px); margin-top: 3px; }
  .turn-card { grid-area: 1 / 1 / auto / -1; }
  .wheel-card .card-heading { flex-wrap: wrap; }
  .collection .card-heading { flex-direction: column; text-align: center; gap: 5px; }
  .collection h2, .wheel-card h2 { font-size: 1.35rem; }
  .collection h2 { font-size: 1.1rem; }
  .pie-plate { width: min(100%, 160px); }
  .wheel-frame { width: min(92%, 210px); }
}
@media (max-width: 500px) {
  #challenge { width: 94vw; height: 94dvh; border-radius: 17px; }
}

.solution-review {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 16px;
  width: 100%;
  padding: 4px 0;
}
.solution-review .primary { width: min(100%, 200px); }
.solution-label { color: #226034; font-weight: bold; }
.answer.solution-answer {
  color: #184525;
  background: #d5efd8;
  border: 2px solid #34804a;
}
.answer.missed-answer {
  color: #78352d;
  background: #f6e4df;
}

@media (max-height: 480px) {
  #challenge { width: 96vw; height: 96dvh; border-radius: 15px; }
  #challenge-content.embedded h2 { font-size: 1.15rem; }
  #challenge-content.embedded .category-tag { margin-bottom: 0; }
}

/* Session stopwatch, next to the spin counter. */
.wheel-card .card-heading { flex-wrap: wrap; }
.wheel-card .hud-time { margin-left: auto; }

/* End screen: same results block and buttons as every other game. */
.victory-screen .results { display: grid; gap: 4px; color: var(--purple-dark); font-size: 1.15rem; }
.victory-screen .end-actions .big-button { text-decoration: none; }
.link-button { border: 0; background: none; color: var(--purple-dark); text-decoration: underline; cursor: pointer; font: inherit; }

/* A class (?code=): join, wait, the end; the pool line on the board. */
.room-screen { width: min(100%, 440px); margin-inline: auto; gap: 14px; }
.room-screen[hidden] { display: none; }
.room-screen .mascot { height: auto; }
.room-code { font-size: 1.2rem; color: var(--purple-dark); }
.room-code b { letter-spacing: .12em; }
.room-name { display: grid; gap: 6px; width: 100%; text-align: left; font-weight: 700; color: var(--key-text); }
.room-name input { font-size: 1.3rem; }
.room-status { color: #873931; font-weight: 700; }
.room-end-mine { color: var(--purple-dark); font-size: 1.15rem; }
.class-pool {
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  background: #fff8ea;
  color: var(--purple-dark);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  text-align: center;
  box-shadow: 0 3px 0 #0b142a22;
}
.class-pool[hidden] { display: none; }
@media (max-width: 720px) {
  .class-pool { grid-area: 3 / 1 / auto / -1; }
}
