/* Player screens (phones first) + join page */

body.game {
  /* Electric glow at the top, through Gagner Violet, into Midnight */
  --game-bg: radial-gradient(120% 90% at 50% 0%, var(--electric) 0%, var(--violet) 42%, var(--midnight) 100%);
  --focus: var(--volt);
  background: var(--game-bg);
  background-color: var(--midnight);
  background-attachment: fixed;
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  transition: background .4s ease;
}
/* Correct answers get the brand's "play" colour; wrong stays an unmistakable red */
body.game[data-result="correct"] { --game-bg: radial-gradient(120% 90% at 50% 0%, #dcff6e 0%, var(--volt) 55%, #9fcc16 100%); color: var(--midnight); }
body.game[data-result="wrong"]   { --game-bg: linear-gradient(160deg, #d8243f, #7d0a1c); }
body.game a:not(.btn) { color: var(--volt); }

/* ───── Join page ───── */
body.game--join {
  /* Brand tints for the floating shapes and the card ring */
  --v0: var(--volt); --v1: #8b73ff; --v2: var(--mist); --v3: #b3a4ff;
  overflow: hidden auto;
}
.join {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; padding: 24px var(--gutter);
}
.join__brand { text-decoration: none; }
.join__brand .logo { font-size: clamp(1.7rem, 7vw, 2.5rem); filter: drop-shadow(0 6px 28px rgb(198 244 50 / .28)); animation: join-bob 5s ease-in-out infinite; }
/* Stage pops in and carries a spinning answer-colour ring + glow behind the card */
.join__stage { position: relative; width: 100%; max-width: 400px; animation: join-pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.join__card { position: relative; width: 100%; max-width: 400px; color: var(--text); }
.join__stage::before, .join__stage::after {
  content: ""; position: absolute; inset: -3px; z-index: -1; border-radius: calc(var(--radius) + 3px);
  background: conic-gradient(from var(--spin), var(--volt), var(--electric), var(--mist), var(--electric), var(--volt));
  animation: join-spin 6s linear infinite;
}
.join__stage::after { inset: 0; filter: blur(22px); opacity: .6; }

@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes join-spin { to { --spin: 360deg; } }
@keyframes join-pop { from { opacity: 0; transform: translateY(24px) scale(.94); } }
@keyframes join-bob { 50% { transform: translateY(-6px); } }

/* ───── Animated backdrop (backdrop_html) ───── */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; contain: strict; }
.bg > * { position: absolute; }

.bg__aurora { inset: 0; translate: calc(var(--px, 0) * -10px) calc(var(--py, 0) * -10px); transition: translate .8s ease-out; }
.bg__aurora i {
  position: absolute; width: 65vmax; height: 65vmax; border-radius: 50%;
  filter: blur(70px); opacity: .5; mix-blend-mode: screen; will-change: transform;
  animation: bg-float 20s ease-in-out infinite alternate;
}
.bg__aurora i:nth-child(1) { background: var(--electric); top: -25vmax; left: -20vmax; }
.bg__aurora i:nth-child(2) { background: #7b5cff; bottom: -30vmax; right: -25vmax; animation-duration: 26s; animation-delay: -8s; opacity: .4; }
.bg__aurora i:nth-child(3) { background: var(--volt); top: 30%; left: 40%; width: 40vmax; height: 40vmax; animation-duration: 17s; animation-delay: -4s; opacity: .12; }
@keyframes bg-float {
  33% { transform: translate(8vmax, 6vmax) scale(1.1); }
  66% { transform: translate(-6vmax, 10vmax) scale(.9); }
  100% { transform: translate(4vmax, -6vmax) scale(1.05); }
}

.bg__stars { inset: 0; }
.bg__stars::before, .bg__stars::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 38% 72%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 64% 34%, #fff, transparent),
    radial-gradient(1px 1px at 86% 58%, #fff, transparent),
    radial-gradient(2px 2px at 52% 8%, var(--volt), transparent);
  background-size: 320px 320px;
  animation: bg-twinkle 4s ease-in-out infinite alternate;
}
.bg__stars::after { background-size: 460px 460px; background-position: 130px 90px; animation-delay: -2s; }
@keyframes bg-twinkle { from { opacity: .15; } to { opacity: .7; } }

/* Synthwave floor */
.bg__grid {
  left: -50%; right: -50%; bottom: 0; height: 45%; perspective: 320px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 45%);
  mask-image: linear-gradient(to bottom, transparent, #000 45%);
}
.bg__grid::before {
  content: ""; position: absolute; inset: -150% 0 -60px;
  background-image:
    linear-gradient(rgb(170 150 255 / .3) 2px, transparent 2px),
    linear-gradient(90deg, rgb(170 150 255 / .3) 2px, transparent 2px);
  background-size: 60px 60px;
  transform-origin: 50% 100%;
  animation: bg-grid 2.4s linear infinite;
}
.bg__grid::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--volt), transparent); opacity: .5; }
@keyframes bg-grid {
  from { transform: rotateX(70deg) translateY(0); }
  to { transform: rotateX(70deg) translateY(60px); }
}

/* Floating answer shapes: d0 far + blurred, d1 outlined, d2 near + glowing */
.bg__shapes { inset: 0; }
.bg__shape {
  position: absolute; top: 0; left: var(--x); width: var(--s); height: var(--s);
  animation: bg-rise var(--d) linear var(--delay) infinite; will-change: transform;
  translate: calc(var(--px, 0) * var(--depth)) calc(var(--py, 0) * var(--depth));
  transition: translate .6s ease-out;
}
.bg__shape svg { display: block; width: 100%; height: 100%; overflow: visible; fill: var(--c); animation: bg-turn var(--d) linear var(--delay) infinite; }
.bg__shape--c0 { --c: var(--v0); }
.bg__shape--c1 { --c: var(--v1); }
.bg__shape--c2 { --c: var(--v2); }
.bg__shape--c3 { --c: var(--v3); }
.bg__shape--d0 { --depth: 6px; }
.bg__shape--d0 svg { opacity: .3; filter: blur(1.5px); }
.bg__shape--d1 { --depth: 14px; }
.bg__shape--d1 svg { opacity: .7; fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; }
.bg__shape--d2 { --depth: 28px; }
.bg__shape--d2 svg { opacity: .85; filter: drop-shadow(0 0 14px var(--c)); }
@keyframes bg-rise {
  0% { transform: translate3d(0, 105vh, 0); opacity: 0; }
  8%, 88% { opacity: 1; }
  100% { transform: translate3d(var(--drift), calc(-1 * var(--s) - 5vh), 0); opacity: 0; }
}
@keyframes bg-turn { to { transform: rotate(var(--turn)); } }

@media (prefers-reduced-motion: reduce) {
  .bg *, .bg *::before, .bg *::after, .join__stage, .join__stage::before, .join__stage::after, .join__brand .logo { animation: none !important; }
  .bg__shapes { display: none; }
}
.join__title { font-size: 1.25rem; text-align: center; margin-bottom: 16px; }
.join__game { text-align: center; font-weight: 700; color: var(--text-muted); margin-bottom: 12px; overflow-wrap: anywhere; }
.join__rejoin { display: grid; gap: 12px; text-align: center; }
.join__rejoin-text { margin: 0; }
/* "Install app" chip, top-right of the join page */
.install-chip {
  position: fixed; z-index: 5; top: calc(14px + var(--safe-top)); right: calc(14px + var(--safe-right));
  display: inline-flex; align-items: center; gap: .45em; min-height: 40px; padding: 0 16px; border-radius: 999px;
  font: inherit; font-size: .92rem; font-weight: 700; color: #fff; cursor: pointer;
  background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .22);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background .2s ease, transform .2s ease;
}
.install-chip:hover { background: rgb(255 255 255 / .18); transform: translateY(-1px); }
.install-chip:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.install-chip__icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Frosted pill under the card: prompt text + Volt call-to-action */
.join__footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  margin: 0; padding: 6px 6px 6px 18px; border-radius: 999px;
  font-size: .95rem; color: rgb(255 255 255 / .8);
  background: rgb(255 255 255 / .08); border: 1px solid rgb(255 255 255 / .16);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgb(0 0 0 / .25);
}
body.game a.pill-link {
  display: inline-flex; align-items: center; gap: .45em; min-height: 40px; padding: .45em 1.1em;
  border-radius: 999px; font-weight: 700; color: var(--midnight); text-decoration: none;
  background: var(--volt);
  box-shadow: 0 4px 18px rgb(198 244 50 / .3), inset 0 -2px 0 rgb(20 8 63 / .14);
  transition: transform .2s ease, box-shadow .2s ease;
}
body.game a.pill-link:hover { transform: translateY(-1px); box-shadow: 0 6px 26px rgb(198 244 50 / .5), inset 0 -2px 0 rgb(20 8 63 / .14); }
body.game a.pill-link:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 999px; }
@media (max-width: 380px) { .join__footer { padding: 12px; border-radius: 20px; } }

.arrow-icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
a:hover > .arrow-icon { transform: translateX(3px); }
.input--xl { font-size: 1.5rem; font-weight: 800; text-align: center; letter-spacing: .06em; min-height: 60px; }
.input--xl::placeholder { font-weight: 600; letter-spacing: normal; opacity: .55; }

/* ───── Player top bar ───── */
.pbar {
  display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 8px;
  min-height: 52px; padding: 6px 12px; background: rgb(20 8 63 / .35);
  border-bottom: 4px solid var(--team, transparent); font-weight: 700;
}
.pbar__q { font-size: .9rem; opacity: .9; }
.pbar__name { text-align: center; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar__score { justify-self: end; background: rgb(255 255 255 / .16); font-family: var(--font-display); padding: .15em .7em; border-radius: 999px; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: center; }
.pbar__score:empty { visibility: hidden; }
.pbar__mute { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .12); color: inherit; cursor: pointer; font-size: 1.1rem; }
.pbar__mute:hover { background: rgb(255 255 255 / .22); }

.offline {
  background: #ffb800; color: var(--midnight); text-align: center; font-weight: 700; padding: 6px;
  position: sticky; top: 0; z-index: 10;
}

/* ───── Screens ───── */
.pscreens { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pscreen { flex: 1; display: flex; flex-direction: column; padding: 16px; animation: screen-in .25s ease; }
.pscreen--center { align-items: center; justify-content: center; text-align: center; gap: 12px; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

.pbig { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 3.2rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 0; overflow-wrap: anywhere; }
.pmid { font-size: 1.2rem; margin: 8px 0; }
.pmsg { font-size: clamp(1rem, 4.2vw, 1.25rem); margin: 0; max-width: 32ch; }
.pmsg--soft { opacity: .8; }
.btn--quiet { --btn-bg: transparent; --btn-fg: #fff; border-color: rgb(255 255 255 / .5); margin-top: 16px; }
.btn--quiet:hover { background: rgb(255 255 255 / .12); filter: none; }
.pquestion { font-family: var(--font-display); font-size: clamp(1.5rem, 6.5vw, 2.5rem); font-weight: 800; letter-spacing: -.015em; line-height: 1.15; max-width: 26ch; overflow-wrap: anywhere; }

.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 6px solid rgb(255 255 255 / .2); border-top-color: var(--volt);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Team picker */
.team-pick { width: 100%; max-width: 480px; }
.team-pick__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.team-btn {
  display: grid; gap: 2px; padding: 14px 12px; min-height: 64px; border-radius: var(--radius);
  background: var(--c); color: #fff; border: 3px solid transparent; cursor: pointer; font-weight: 800;
  box-shadow: 0 4px 0 rgb(0 0 0 / .25); touch-action: manipulation; text-align: center;
}
.team-btn[aria-checked="true"] { border-color: #fff; outline: 3px solid rgb(255 255 255 / .45); outline-offset: 2px; }
.team-btn[aria-checked="true"] .team-btn__name::before {
  content: ""; display: inline-block; width: 1em; height: 1em; margin-right: .3em; vertical-align: -.12em;
  background: currentColor; -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat;
}
.team-btn__count { font-weight: 600; font-size: .85rem; opacity: .9; }

/* Intro "get ready" bar */
.ready-bar { width: min(80vw, 420px); height: 10px; border-radius: 99px; background: rgb(255 255 255 / .2); overflow: hidden; }
.ready-bar span { display: block; height: 100%; background: var(--volt); transform-origin: left; transform: scaleX(0); }

/* ───── Question screen ───── */
.pscreen--question { padding: 10px; gap: 10px; }
.qhead { display: grid; gap: 8px; }
.qhead__text { font-size: clamp(1.1rem, 4.6vw, 1.5rem); margin: 0; text-align: center; overflow-wrap: anywhere; }
.timer { position: relative; height: 30px; border-radius: 99px; background: rgb(20 8 63 / .45); overflow: hidden; }
.timer__bar { position: absolute; inset: 0; background: var(--volt); transform-origin: left; }
.timer--urgent .timer__bar { background: #ff5a6a; }
.timer__num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgb(20 8 63 / .8); font-variant-numeric: tabular-nums; }

.pimg { display: block; align-self: center; max-width: 100%; max-height: 28vh; object-fit: contain; border-radius: 12px; flex: none; }
.pimg[hidden] { display: none; }
.pimg--intro { max-height: 36vh; }
.answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 10px; min-height: 0; }
.answers--2 { grid-template-columns: 1fr; }
.answers--tf { grid-template-columns: 1fr 1fr; }
.answer {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 96px; padding: 12px; border: 0; border-radius: var(--radius); color: #fff; cursor: pointer;
  font-size: clamp(1.05rem, 4.5vw, 1.5rem); font-weight: 800; text-align: center; overflow-wrap: anywhere;
  box-shadow: inset 0 -6px 0 rgb(0 0 0 / .25);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
  transition: transform .06s ease, filter .12s ease;
}
.answer .shape { width: clamp(36px, 12vw, 64px); height: clamp(36px, 12vw, 64px); filter: drop-shadow(0 2px 0 rgb(0 0 0 / .25)); }
.answer:active { transform: scale(.97); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .25); }
.answer:hover { filter: brightness(1.08); }
.answer--0, .chip--0 { background: var(--a0); }
.answer--1, .chip--1 { background: var(--a1); }
.answer--2, .chip--2 { background: var(--a2); }
.answer--3, .chip--3 { background: var(--a3); }

/* Landscape phones & tablets: one row of answers */
@media (orientation: landscape) and (max-height: 560px) {
  .answers { grid-template-columns: repeat(4, 1fr); }
  .answers--2, .answers--tf, .answers--3 { grid-template-columns: repeat(var(--n, 2), 1fr); }
  .answers--3 { --n: 3; }
  .pscreen--question { padding-top: 6px; }
  .pimg { max-height: 22vh; }
}
@media (min-width: 900px) {
  .pscreen--question { max-width: 1000px; width: 100%; margin: 0 auto; }
}

.chip { display: inline-flex; align-items: center; gap: .5em; padding: .4em .9em; border-radius: 999px; font-weight: 700; margin-top: 8px; }
.chip .shape { width: 1.1em; height: 1.1em; }

/* ───── Result ───── */
.result-icon {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: rgb(255 255 255 / .18); animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.result-icon svg.icon { width: 56px; height: 56px; stroke-width: 3; }
.pmsg svg.icon--flame { color: var(--volt); }
body.game[data-result="correct"] .pmsg svg.icon--flame { color: var(--midnight); }
.points-pill { background: rgb(0 0 0 / .25); padding: .3em 1.1em; border-radius: 999px; font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; margin: 0; }
body.game[data-result="correct"] .result-icon,
body.game[data-result="correct"] .points-pill { background: var(--midnight); color: var(--volt); }
body.game[data-result="correct"] .pbar { background: rgb(20 8 63 / .12); }
body.game[data-result="correct"] .pbar__score { background: rgb(20 8 63 / .12); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }

.medal { font-size: 5rem; line-height: 1; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
