/* TV display, "cut-and-paste gig zine" (see DESIGN.md). Designed at 1920x1080;
   everything is sized in --u so it scales to 1280x720 and odd laptop windows
   without scrolling. 1u = 1% of the width of the largest 16:9 box that fits.

   Paper means information (typed slips), colour blocks mean identity
   (category, player), Anton carries numbers. Depth is a hard offset shadow;
   on the ink canvas a "shadow" is a second colour block peeking out. */

:root {
  --u: min(1vw, 1.7778vh);
  /* Margin kept clear for TVs that crop the picture edges (set by tv.js). */
  --edge-x: 0px;
  --edge-y: 0px;
  --spot-s: min(calc(var(--u) * 27), 47vh); /* sleeve edge */
  --tv-stuck: calc(var(--u) * 0.25) calc(var(--u) * 0.35) 0 rgba(0, 0, 0, 0.38);
  --tv-lifted: calc(var(--u) * 0.5) calc(var(--u) * 0.8) 0 rgba(0, 0, 0, 0.4);
  /* White cut-out border for drawn stickers, scaled with the screen. */
  --tv-cutout:
    drop-shadow(calc(var(--u) * 0.16) 0 0 #fff) drop-shadow(calc(var(--u) * -0.16) 0 0 #fff)
    drop-shadow(0 calc(var(--u) * 0.16) 0 #fff) drop-shadow(0 calc(var(--u) * -0.16) 0 #fff)
    drop-shadow(calc(var(--u) * 0.3) calc(var(--u) * 0.45) 0 rgba(0, 0, 0, 0.35));
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
}

body {
  font-size: calc(var(--u) * 1.6);
  line-height: 1.2;
  color: var(--paper);
}

[hidden] { display: none !important; }

.screen {
  position: fixed;
  top: var(--edge-y);
  right: var(--edge-x);
  bottom: var(--edge-y);
  left: var(--edge-x);
}

/* Typed slips used as blocks (rotatable) rather than inline strips. */
.slip {
  display: inline-block;
  font-family: var(--font-type);
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  padding: 0.2em 0.6em;
}

.typestrip:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Stickers + doodles                                                  */
/* ------------------------------------------------------------------ */

.zs { display: block; }
.zs svg, .zs img, .deco-item > svg { display: block; width: 100%; height: auto; }
.zs.is-drawn { filter: var(--tv-cutout); }

.deco {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

.deco-item {
  position: absolute;
  display: block;
  transform: rotate(var(--r, 0deg));
}

.deco-item.d-burst > svg,
.deco-item.d-bolt > svg,
.deco-item.d-bolt2 > svg { filter: var(--tv-cutout); }

/* ------------------------------------------------------------------ */
/* Lobby                                                               */
/* ------------------------------------------------------------------ */

.lobby {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: calc(var(--u) * 3) calc(var(--u) * 6) calc(var(--u) * 3);
  overflow: hidden;
}

.lobby-brand {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: calc(var(--u) * 5.8);
  font-weight: 400;
  line-height: 1;
}

.lobby-main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
  grid-gap: calc(var(--u) * 5);
  gap: calc(var(--u) * 5);
  min-height: 0;
}

.lobby-code-block { min-width: 0; }

.lobby-kicker {
  margin: 0 0 calc(var(--u) * 1.4);
  font-size: calc(var(--u) * 2.2);
}

.lobby-kicker .typestrip {
  display: inline-block;
  transform: rotate(-2deg);
  line-height: 1.5;
}

.lobby-code {
  display: inline-flex;
  align-items: center;
  min-height: calc(var(--u) * 17);
  padding: calc(var(--u) * 0.4) calc(var(--u) * 3) 0;
  background-color: var(--lemon);
  background-image: var(--dots);
  background-size: var(--dots-size);
  color: var(--ink);
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 15.5);
  line-height: 1;
  letter-spacing: 0.04em;
  transform: rotate(-1.5deg);
  box-shadow: calc(var(--u) * 1.1) calc(var(--u) * 1.1) 0 var(--pink);
}

.lobby-code .ch {
  display: inline-block;
  animation: code-in 0.55s var(--ease-slam) both;
  animation-delay: calc(var(--i) * 80ms);
}

@keyframes code-in {
  from { opacity: 0; transform: translateY(-0.12em) scale(1.5) rotate(-10deg); }
  to { opacity: 1; transform: none; }
}

.lobby-connecting {
  font-family: var(--font-type);
  font-size: calc(var(--u) * 3.6);
  letter-spacing: 0;
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  50% { opacity: 0.45; }
}

.lobby-hint {
  margin: calc(var(--u) * 2.8) 0 0;
  max-width: calc(var(--u) * 50);
  font-size: calc(var(--u) * 2.05);
}

.lobby-hint .typestrip { line-height: 1.85; }

.lobby-hint strong {
  font-weight: 400;
  background: var(--lemon);
  padding: 0 0.2em;
  white-space: nowrap;
}

.lobby-status {
  display: inline-block;
  max-width: calc(var(--u) * 50);
  margin: calc(var(--u) * 1.6) 0 0;
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.8);
  text-wrap: balance;
}

.lobby-status:empty { display: none; }

.lobby-status.ok {
  padding: 0.3em 0.8em;
  background: var(--mint);
  color: var(--ink);
  transform: rotate(1deg);
  box-shadow: calc(var(--u) * 0.4) calc(var(--u) * 0.4) 0 var(--paper);
}

.lobby-status.ok::before {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.55em;
  border-radius: 50%;
  background: var(--ink);
  vertical-align: 0.05em;
}

.lobby-qr-block {
  position: relative;
  display: grid;
  place-items: center;
}

.qr-backing,
.lobby-qr {
  grid-area: 1 / 1;
  width: min(calc(var(--u) * 29), 54vh);
  aspect-ratio: 1;
}

.qr-backing {
  background-color: var(--violet);
  background-image: var(--dots);
  background-size: var(--dots-size);
  transform: translate(calc(var(--u) * 1.8), calc(var(--u) * 1.4)) rotate(5deg);
}

.lobby-qr {
  position: relative;
  padding: calc(var(--u) * 1.5);
  background: var(--paper);
  transform: rotate(-2.5deg);
  font-size: calc(var(--u) * 2.4); /* sizes the tape */
}

.lobby-qr:empty { background: var(--ink-3); }
.lobby-qr:empty::before { display: none; }

.lobby-qr img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Lobby collage: around the edges and behind the scraps, never over them. */
#lobby-deco .d-hands { left: 57%; top: 67%; width: calc(var(--u) * 15); --r: -12deg; }
#lobby-deco .d-headphones { right: calc(var(--u) * 2.5); top: calc(var(--u) * 1.6); width: calc(var(--u) * 10); --r: 14deg; }
#lobby-deco .d-boombox { right: calc(var(--u) * 1.6); bottom: calc(var(--u) * 1.2); width: calc(var(--u) * 12); --r: -7deg; }
#lobby-deco .d-cassette { left: calc(var(--u) * 68); top: calc(var(--u) * 2); width: calc(var(--u) * 8); --r: -14deg; }
#lobby-deco .d-burst { left: calc(var(--u) * 44); top: 25%; width: calc(var(--u) * 10); --r: 10deg; }
#lobby-deco .d-bolt { left: calc(var(--u) * 55); top: 34%; width: calc(var(--u) * 4.6); --r: 14deg; }
#lobby-deco .d-bolt2 { left: calc(var(--u) * 1.4); bottom: calc(var(--u) * 2.2); width: calc(var(--u) * 3.6); --r: -16deg; }
#lobby-deco .d-notes { left: calc(var(--u) * 71); bottom: calc(var(--u) * 0.6); width: calc(var(--u) * 6); --r: 8deg; }
#lobby-deco .d-sparkle { left: calc(var(--u) * 1.4); top: calc(var(--u) * 1.6); width: calc(var(--u) * 3.6); }

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

.game {
  display: grid;
  grid-template-columns: minmax(0, 70fr) minmax(0, 30fr);
  grid-gap: calc(var(--u) * 2.2);
  gap: calc(var(--u) * 2.2);
  padding: calc(var(--u) * 1.6) calc(var(--u) * 2.2) calc(var(--u) * 2.2);
}

.board-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.board-head {
  display: flex;
  align-items: center;
  grid-gap: calc(var(--u) * 2);
  gap: calc(var(--u) * 2);
  min-height: calc(var(--u) * 3.4);
  margin-bottom: calc(var(--u) * 1.2);
  padding: 0 calc(var(--u) * 0.4);
  transition: opacity 0.4s;
}

.quiz-title {
  margin: 0;
  max-width: 72%;
  padding: 0.18em 0.6em;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.9);
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: rotate(-1deg);
}

.quiz-title:empty { display: none; }

.cards-left {
  margin: 0 0 0 auto;
  padding: 0.2em 0.6em;
  background: var(--lemon);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.7);
  line-height: 1.2;
  white-space: nowrap;
  transform: rotate(1.4deg);
}

.cards-left:empty { display: none; }

.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ------------------------------------------------------------------ */
/* Board: a colour-blocked zine grid, one colour per category column,   */
/* thin ink gutters (the canvas shows through the gaps).                */
/* ------------------------------------------------------------------ */

.board {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  grid-template-rows: auto repeat(5, minmax(0, 1fr));
  grid-gap: calc(var(--u) * 0.45);
  gap: calc(var(--u) * 0.45);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.board.is-dim {
  opacity: 0.25;
  transform: scale(0.985);
}

.cat-name {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--u) * 6.6);
  padding: calc(var(--u) * 0.9) calc(var(--u) * 0.7);
  background: var(--cc);
  border-radius: var(--r-block);
}

.cat-slip {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  padding: 0.22em 0.5em;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.95);
  line-height: 1.12;
  text-align: center;
  overflow-wrap: anywhere;
  transform: rotate(var(--tilt, 0deg));
  box-shadow: var(--tv-stuck);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border-radius: var(--r-block);
  background-color: var(--cc);
  background-image: var(--dots);
  background-size: var(--dots-size);
  color: var(--cc-ink);
  overflow: hidden;
}

.card .pts {
  position: relative;
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 5.6);
  line-height: 1;
  letter-spacing: 0.01em;
}

.card .pts-num { position: relative; }

.card .scrib {
  display: none;
  position: absolute;
  left: -18%;
  top: 18%;
  width: 136%;
  height: auto;
  pointer-events: none;
}

.card .who {
  display: none;
  max-width: 90%;
  margin-top: calc(var(--u) * 0.5);
}

.card .who-name {
  display: block;
  padding: 0.06em 0.4em 0.02em;
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 2.2);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--tv-stuck);
}

.card .who.nobody .who-name {
  padding: 0;
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.9);
  color: var(--ink);
  box-shadow: none;
}

.card .bonus-mark {
  display: none;
  position: absolute;
  top: calc(var(--u) * 0.45);
  right: calc(var(--u) * 0.45);
  width: calc(var(--u) * 3.3);
  place-items: center;
  aspect-ratio: 1;
  clip-path: var(--burst);
  background: var(--red);
  font-size: calc(var(--u) * 1.45);
  line-height: 1;
  transform: rotate(12deg);
}

/* Spent card: a scrap of newsprint glued over the slot. Points small,
   winner as a small block in their colour (or "nobody", points crossed out). */
.card[data-status='done'] {
  background-color: var(--paper);
  background-image: none;
  color: var(--ink);
  clip-path: var(--torn);
  transform: rotate(var(--tilt, 0deg));
}

.card[data-status='done']::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: var(--grain);
  opacity: 0.14;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.card[data-status='done'] .pts {
  font-size: calc(var(--u) * 2.2);
  color: var(--paper-mute);
}

.card[data-status='done'] .who { display: block; }
.card[data-status='done'].is-nobody .scrib { display: block; }
.card[data-status='done'][data-bonus='1'] .bonus-mark { display: grid; }

/* Active: the slot the card left. An empty ink slot outlined in its colour. */
.card[data-status='active'] {
  background-color: var(--ink);
  background-image: none;
  color: var(--cc);
  outline: calc(var(--u) * 0.3) dashed var(--cc);
  outline-offset: calc(var(--u) * -0.7);
}

.card[data-status='active']::after {
  content: 'now playing';
  margin-top: calc(var(--u) * 0.3);
  padding: 0.1em 0.45em;
  background: var(--cc);
  color: var(--cc-ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.3);
}

.card[data-status='active'] .pts { font-size: calc(var(--u) * 3.6); }

.board.dealing .card,
.board.dealing .cat-name {
  animation: deal 0.55s var(--ease-out) both;
  animation-delay: calc(var(--d, 0) * 1ms);
}

@keyframes deal {
  from { opacity: 0; transform: translateY(calc(var(--u) * -2.4)) rotate(-5deg) scale(1.05); }
  to { opacity: 1; }
}

/* A freshly spent scrap gets pressed down. */
.card.flash { animation: stick 0.6s var(--ease-slam); }

@keyframes stick {
  from { transform: scale(1.12) rotate(-4deg); }
}

/* ------------------------------------------------------------------ */
/* Spotlight: card in play. The category colour floods the board area. */
/* ------------------------------------------------------------------ */

.spot {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--r-block);
  background-color: var(--cc, var(--lemon));
  background-image: var(--dots);
  background-size: var(--dots-size);
  color: var(--cc-ink, var(--ink));
}

.spot::before { /* newsprint grain over the flood */
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: var(--grain);
  opacity: 0.12;
  mix-blend-mode: multiply;
}

.scene {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  grid-gap: calc(var(--u) * 1.6);
  gap: calc(var(--u) * 1.6);
  width: 100%;
}

.stage {
  position: relative;
  width: calc(var(--spot-s) * 1.62);
  height: var(--spot-s);
  flex: none;
}

/* Record: a halftone vinyl (zine.js drawn('vinyl')) in a round wrap */
.disc-wrap {
  position: absolute;
  top: calc(var(--spot-s) * 0.03);
  left: calc(var(--spot-s) * 0.03);
  width: calc(var(--spot-s) * 0.94);
  height: calc(var(--spot-s) * 0.94);
  border-radius: 50%;
  box-shadow: var(--tv-lifted);
  transition: transform 1s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.stage.out .disc-wrap { transform: translateX(calc(var(--spot-s) * 0.65)); }

.disc {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 50%;
}

.disc > svg {
  display: block;
  width: 100%;
  height: 100%;
}

.disc.spinning { animation: spin 4.5s linear infinite; }

/* The light on the record: doesn't turn with it. */
.disc-glint {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

.disc-glint > svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes spin { to { transform: rotate(360deg); } }

.label {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36%;
  height: 36%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  color: var(--cc-ink, var(--ink));
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}

.label-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  /* Kept well inside the round label: near its top edge the circle is too
     narrow, which cut the category name off. Category above the spindle
     hole, points below it. */
  width: 66%;
  height: 62%;
}

.label-cat {
  font-family: var(--font-type);
  font-size: calc(var(--spot-s) * 0.03);
  line-height: 1.05;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.label-pts {
  font-family: var(--font-poster);
  font-size: calc(var(--spot-s) * 0.07);
  line-height: 1;
}

/* Sleeve: an ink record sleeve with a colour block and huge points */
.sleeve {
  position: absolute;
  top: 0;
  right: auto;
  bottom: auto;
  left: 0;
  width: var(--spot-s);
  height: var(--spot-s);
  transform-origin: 0 0;
}

.sleeve-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.face-front {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  grid-gap: calc(var(--spot-s) * 0.05);
  gap: calc(var(--spot-s) * 0.05);
  padding: calc(var(--spot-s) * 0.06);
  border-radius: var(--r-block);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--tv-lifted);
  overflow: hidden;
}

.sleeve-cat {
  position: relative;
  z-index: 1;
  font-size: calc(var(--spot-s) * 0.07);
  line-height: 1;
  transform: rotate(-2deg);
  transform-origin: 0 50%;
  overflow-wrap: anywhere;
}

.sleeve-cat .typestrip { line-height: 1.6; }

.sleeve-block {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  min-height: 0;
  padding: 0 calc(var(--spot-s) * 0.045);
  background-color: var(--cc, var(--lemon));
  background-image: var(--dots);
  background-size: var(--dots-size);
  color: var(--cc-ink, var(--ink));
  overflow: hidden;
}

/* A record printed half out of the sleeve's colour block. */
.sleeve-block::before {
  content: '';
  position: absolute;
  right: -24%;
  top: -30%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  /* hard-edged label + spindle hole, not a fade */
  background: radial-gradient(circle, var(--ink) 0 4%, var(--paper) 4.5% 24%, var(--ink) 24.5%);
}

.sleeve-pts {
  position: relative;
  font-family: var(--font-poster);
  font-size: calc(var(--spot-s) * 0.4);
  line-height: 0.95;
  letter-spacing: 0.01em;
}

/* Album cover at the reveal: a photo print with a white border, taped on. */
.art-photo {
  position: absolute;
  left: 2%;
  top: 2%;
  width: 96%;
  height: 96%;
  padding: 4%;
  z-index: 2;
  background: #fff;
  box-shadow: var(--tv-lifted);
  font-size: calc(var(--spot-s) * 0.075); /* sizes the tape */
  opacity: 0;
  transform: rotate(-9deg) scale(1.12);
  transition: opacity 0.35s var(--ease-out), transform 0.7s var(--ease-slam);
}

.sleeve.show-art .art-photo { opacity: 1; transform: rotate(-3deg); }

.sleeve-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Bonus: a starburst slapped onto the sleeve (slam animated from tv.js). */
.bonus-burst {
  display: none;
  position: absolute;
  /* Slapped over the lower part of the sleeve: the category slip on top stays
     readable (the burst's "Worth double: N" covers the points). */
  left: -10%;
  top: 14%;
  width: 112%;
  height: 112%;
  z-index: 3;
  transition: transform 0.7s var(--ease-out);
}

.sleeve.bonus-on .bonus-burst { display: block; }

.burst-tilt {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  transform: rotate(-6deg);
}

.burst-tilt > svg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(calc(var(--u) * 0.5) calc(var(--u) * 0.8) 0 rgba(0, 0, 0, 0.35));
}

.burst-body {
  position: relative;
  width: 80%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--ink);
}

.bonus-emoji {
  font-size: calc(var(--spot-s) * 0.16);
  line-height: 1.05;
}

.bonus-title {
  margin-top: calc(var(--spot-s) * 0.01);
  font-family: var(--font-poster);
  font-size: calc(var(--spot-s) * 0.13);
  line-height: 0.95;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  transition: opacity 0.3s;
}

.bonus-text {
  margin: calc(var(--spot-s) * 0.035) 0 0;
  font-size: calc(var(--spot-s) * 0.062);
  line-height: 1.7;
  transition: opacity 0.3s;
}

.bonus-text .typestrip { line-height: 1.7; }

.bonus-double {
  margin: calc(var(--spot-s) * 0.03) 0 0;
  font-size: calc(var(--spot-s) * 0.066);
  transition: opacity 0.3s;
}

.bonus-double .typestrip { padding: 0.25em 0.6em; line-height: 1.8; }

.bonus-double b {
  font-family: var(--font-poster);
  font-weight: 400;
  font-size: 1.1em;
  line-height: 1;
  color: var(--lemon);
}

/* Once the card is resolved (or the album cover is up), the burst shrinks to a
   badge on the sleeve's corner so the answer and the winner have the room. */
.sleeve.bonus-on:not(.flipped) .bonus-burst,
.spot.resolved .sleeve.bonus-on .bonus-burst { transform: translate(-50%, 6%) scale(0.34); }
/* Take the title/text out of the layout (not just invisible), so the emoji sits
   in the middle of the shrunken badge instead of being pushed up and sideways. */
.sleeve.bonus-on:not(.flipped) .burst-body > :not(.bonus-emoji),
.spot.resolved .sleeve.bonus-on .burst-body > :not(.bonus-emoji) { display: none; }
.sleeve.bonus-on:not(.flipped) .burst-body,
.spot.resolved .sleeve.bonus-on .burst-body { width: auto; }
.sleeve.bonus-on:not(.flipped) .bonus-emoji,
.spot.resolved .sleeve.bonus-on .bonus-emoji { font-size: calc(var(--spot-s) * 0.3); }

/* Under the record: hint while playing, answer + result once resolved */
.result {
  position: relative;
  width: 100%;
  height: calc(var(--u) * 15.5);
  display: grid;
  place-items: center;
  text-align: center;
}

.result > * { grid-area: 1 / 1; }

.hint {
  display: flex;
  align-items: center;
  grid-gap: calc(var(--u) * 1.4);
  gap: calc(var(--u) * 1.4);
  font-size: calc(var(--u) * 2.7);
  transition: opacity 0.4s;
}

.hint .typestrip {
  display: inline-block;
  padding: 0.25em 0.7em;
  line-height: 1.3;
  transform: rotate(-1.2deg);
  box-shadow: var(--tv-stuck);
}

.hint .zs {
  flex: none;
  width: calc(var(--u) * 6.4);
  transform: rotate(-10deg);
}

.spot.resolved .hint { opacity: 0; }

.resolved-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  grid-gap: calc(var(--u) * 1.2);
  gap: calc(var(--u) * 1.2);
  max-width: 94%;
  opacity: 0;
}

.spot.resolved .resolved-box { opacity: 1; }

.answer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  grid-gap: calc(var(--u) * 0.6) calc(var(--u) * 1.2);
  gap: calc(var(--u) * 0.6) calc(var(--u) * 1.2);
  max-width: 100%;
}

.answer:not(.show-song) { display: none; }

.answer .typestrip {
  display: inline-block;
  max-width: 100%;
  padding: 0.15em 0.55em;
  line-height: 1.25;
  box-shadow: var(--tv-stuck);
}

.ans-title { font-size: calc(var(--u) * 2.9); transform: rotate(-1.2deg); }
.ans-artist { font-size: calc(var(--u) * 2.2); background: var(--ink); color: var(--paper); transform: rotate(1deg); }

.outcome {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-gap: calc(var(--u) * 1.6);
  gap: calc(var(--u) * 1.6);
  max-width: 100%;
}

.outcome .zs {
  flex: none;
  width: calc(var(--u) * 7.5);
  transform: rotate(-8deg);
}

.outcome-name {
  min-width: 0;
  padding: 0.04em 0.35em 0;
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 5.8);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: rotate(-1.5deg);
  /* ink edge + hard shadow: reads even when the winner's colour is the flood colour */
  box-shadow: 0 0 0 calc(var(--u) * 0.3) var(--ink), calc(var(--u) * 0.7) calc(var(--u) * 0.9) 0 var(--ink);
}

.outcome-pts {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--u) * 10.5);
  height: calc(var(--u) * 10.5);
  transform: rotate(9deg);
}

.outcome-pts > svg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(calc(var(--u) * 0.4) calc(var(--u) * 0.6) 0 rgba(0, 0, 0, 0.35));
}

.outcome-pts-num {
  position: relative;
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 3.1);
  line-height: 1;
  color: var(--ink);
}

/* Nobody: calmer, just a typed slip. */
.outcome.nobody .zs { display: none; }

.outcome.nobody .outcome-name {
  padding: 0.25em 0.8em;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 3.2);
  line-height: 1.2;
  transform: rotate(-1deg);
  box-shadow: var(--tv-stuck);
}

.spot.pop .outcome { animation: slam-in 0.6s var(--ease-slam) both; }
.spot.pop .outcome.nobody { animation: fade-up 0.8s var(--ease-out) both; }
.spot.pop .answer { animation: fade-up 0.5s var(--ease-out) both; }

@keyframes slam-in {
  from { opacity: 0; transform: scale(1.7) rotate(-5deg); }
  40% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(calc(var(--u) * 1)); }
  to { opacity: 1; transform: none; }
}

/* A hard ring that leaves the record in the winner's colour */
.ring {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 50%;
  border: calc(var(--u) * 0.7) solid var(--ring, var(--paper));
  opacity: 0;
  pointer-events: none;
}

.ring.go { animation: ring 1.2s var(--ease-out) forwards; }

@keyframes ring {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* ------------------------------------------------------------------ */
/* Leaderboard: each player a block in their colour                    */
/* ------------------------------------------------------------------ */

.lb-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding-top: calc(var(--u) * 0.2);
}

/* "Scores" on the left, the room code on the right: up here the TV buttons
   (bottom right) can never cover the code. */
.lb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Room for the leader's crown, which pokes up above the first row. */
  margin: 0 0 calc(var(--u) * 2.4);
}

.lb-title {
  margin: 0;
  font-size: calc(var(--u) * 1.9);
  font-weight: 400;
  line-height: 1;
}

.lb-title .typestrip {
  display: inline-block;
  padding: 0.2em 0.6em;
  line-height: 1.2;
  transform: rotate(-1.5deg);
}

.lb {
  --row: calc(var(--u) * 6.4); /* tv.js sets this from the measured height and player count */
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  grid-gap: calc(var(--u) * 0.7);
  gap: calc(var(--u) * 0.7);
}

.lb-row {
  position: relative;
  display: grid;
  grid-template-columns: 1.4em minmax(0, 1fr) auto;
  align-items: center;
  grid-gap: calc(var(--u) * 0.9);
  gap: calc(var(--u) * 0.9);
  height: var(--row);
  flex: none;
  padding: 0 calc(var(--u) * 1.3) 0 calc(var(--u) * 0.9);
  border-radius: var(--r-block);
  background: var(--pc, var(--paper));
  color: var(--pc-ink, var(--ink));
  font-family: var(--font-poster);
  /* min(3u, half the row), worked out in tv.js: CSS min() is Chromium 79+. */
  font-size: var(--lb-fs, calc(var(--u) * 3));
  line-height: 1.1;
}

.lb-rank {
  text-align: center;
  font-size: 0.78em;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.lb-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.lb-score {
  font-size: 1.12em;
  font-variant-numeric: tabular-nums;
}

.lb-crown {
  display: none;
  position: absolute;
  right: calc(var(--u) * -1.2);
  top: calc(var(--lb-fs, calc(var(--u) * 3)) * -0.7);
  width: var(--lb-crown, calc(var(--u) * 4));
  transform: rotate(18deg);
  filter: var(--tv-cutout);
  pointer-events: none;
}

.lb-crown svg { display: block; width: 100%; height: auto; }
.lb-row[data-lead] .lb-crown { display: block; }

.lb-row.pulse { animation: row-pulse 1.4s var(--ease-out); }

@keyframes row-pulse {
  0% { transform: translateX(calc(var(--u) * -1)) scale(1.05); box-shadow: calc(var(--u) * 0.7) calc(var(--u) * 0.7) 0 var(--paper); }
  100% { transform: none; box-shadow: 0 0 0 transparent; }
}

.lb-empty {
  align-self: flex-start;
  padding: 0.2em 0.6em;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.8);
}

.room-tag {
  margin: 0 0 0 calc(var(--u) * 1);
  white-space: nowrap;
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.5);
  color: var(--paper-dim);
}

.room-code-small {
  display: inline-block;
  margin-left: 0.3em;
  padding: 0.08em 0.4em 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-poster);
  font-size: 1.2em;
  letter-spacing: 0.08em;
  transform: rotate(-2deg);
}

.room-code-small:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Final results                                                       */
/* ------------------------------------------------------------------ */

.final {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--u) * 2.6) calc(var(--u) * 4) calc(var(--u) * 2.4);
  overflow: hidden;
}

.final > :not(.deco) { position: relative; z-index: 2; }

.final-title {
  margin: 0;
  max-width: calc(var(--u) * 60);
  padding: 0.18em 0.7em;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 2);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: rotate(-1.5deg);
}

.final-title:empty { display: none; }

.final-headline {
  margin-top: calc(var(--u) * 1.4);
  max-width: calc(var(--u) * 80);
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 5.6);
  text-wrap: balance;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: var(--paper);
}

.final.celebrate .final-headline {
  animation: slam-in 0.7s var(--ease-slam) both;
  animation-delay: 1.5s;
}

.podium {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: calc(var(--u) * 74);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  grid-gap: calc(var(--u) * 1.4);
  gap: calc(var(--u) * 1.4);
  margin-top: calc(var(--u) * 1.2);
}

.step {
  flex: 0 1 calc(var(--u) * 24);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  height: 100%;
}

.step-people {
  display: flex;
  flex-direction: column;
  align-items: center;
  grid-gap: calc(var(--u) * 1.6);
  gap: calc(var(--u) * 1.6);
  padding-bottom: calc(var(--u) * 1.6);
}

.step-person {
  display: flex;
  align-items: center;
  grid-gap: calc(var(--u) * 1);
  gap: calc(var(--u) * 1);
  max-width: 100%;
  padding: calc(var(--u) * 0.7) calc(var(--u) * 1.1) calc(var(--u) * 0.5);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(var(--u) * 1.5); /* sizes the tape */
  transform: rotate(var(--tilt, 0deg));
  box-shadow: calc(var(--u) * 0.45) calc(var(--u) * 0.45) 0 var(--pc, var(--paper-dim));
}

.step-name {
  min-width: 0;
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 3.4);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step[data-rank='1'] .step-name { font-size: calc(var(--u) * 4.4); }

.step-score {
  flex: none;
  padding: 0.06em 0.35em 0;
  background: var(--pc, var(--lemon));
  color: var(--pc-ink, var(--ink));
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 2.5);
  line-height: 1.15;
}

.step-people.multi {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  grid-gap: calc(var(--u) * 1.6) calc(var(--u) * 1.2);
  gap: calc(var(--u) * 1.6) calc(var(--u) * 1.2);
}

.step-people.multi .step-name,
.step[data-rank='1'] .step-people.multi .step-name { font-size: calc(var(--u) * 3); }
.step-people.many .step-name,
.step[data-rank='1'] .step-people.many .step-name { font-size: calc(var(--u) * 2.4); }
.step-people.many .step-score { font-size: calc(var(--u) * 1.9); }

.step-block {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: calc(var(--u) * 0.6);
  border-radius: var(--r-block) var(--r-block) 0 0;
  background-color: var(--sb);
  background-image: var(--dots);
  background-size: var(--dots-size);
  color: var(--ink);
  box-shadow: calc(var(--u) * 0.8) calc(var(--u) * -0.8) 0 var(--sb2);
  transform-origin: bottom;
}

.step[data-rank='1'] .step-block { height: 58%; --sb: var(--lemon); --sb2: var(--pink); }
.step[data-rank='2'] .step-block { height: 42%; --sb: var(--sky); --sb2: var(--violet); }
.step[data-rank='3'] .step-block { height: 30%; --sb: var(--tangerine); --sb2: var(--lilac); }

.step-rank {
  font-family: var(--font-poster);
  font-size: calc(var(--u) * 7);
  line-height: 1;
}

.step[data-rank='1'] .step-rank { font-size: calc(var(--u) * 9.5); }

.final.celebrate .step-block {
  animation: rise 0.8s var(--ease-out) both;
  animation-delay: calc(var(--d) * 1ms);
}

.final.celebrate .step-people {
  animation: slam-in 0.6s var(--ease-slam) both;
  animation-delay: calc(var(--d) * 1ms + 650ms);
}

.final.celebrate .final-rest li {
  animation: fade-up 0.6s var(--ease-out) both;
  animation-delay: calc(var(--d) * 1ms);
}

@keyframes rise {
  from { transform: scaleY(0); }
  to { transform: none; }
}

.final-rest {
  list-style: none;
  margin: calc(var(--u) * 1.8) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  grid-gap: calc(var(--u) * 1) calc(var(--u) * 1.4);
  gap: calc(var(--u) * 1) calc(var(--u) * 1.4);
  max-width: calc(var(--u) * 74);
}

.final-rest:empty { display: none; }

.final-rest li {
  display: flex;
  align-items: stretch;
  grid-gap: calc(var(--u) * 0.9);
  gap: calc(var(--u) * 0.9);
  padding-right: calc(var(--u) * 1.2);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(var(--u) * 2.1);
  line-height: 1.5;
  transform: rotate(var(--tilt, 0deg));
}

.final-rest .r {
  display: grid;
  place-items: center;
  min-width: 1.8em;
  background: var(--pc);
  color: var(--pc-ink);
  font-family: var(--font-poster);
}

.final-rest .n { font-family: var(--font-type); align-self: center; }
.final-rest .s { font-family: var(--font-poster); align-self: center; }

/* Final collage: corners only, clear of the podium and the names. */
#final-deco .d-trophy { left: calc(var(--u) * 3); top: calc(var(--u) * 9); width: calc(var(--u) * 11); --r: -9deg; }
#final-deco .d-disco { right: calc(var(--u) * 3); top: calc(var(--u) * 2.5); width: calc(var(--u) * 11); --r: 8deg; }
#final-deco .d-rock { left: calc(var(--u) * 2.5); bottom: calc(var(--u) * 2.5); width: calc(var(--u) * 10); --r: 12deg; }
#final-deco .d-sparkle { right: calc(var(--u) * 7); bottom: calc(var(--u) * 17); width: calc(var(--u) * 4); }
#final-deco .d-sparkle2 { left: calc(var(--u) * 16); top: calc(var(--u) * 3); width: calc(var(--u) * 3); }
#final-deco .d-burst { right: calc(var(--u) * 3); bottom: calc(var(--u) * 3); width: calc(var(--u) * 8); --r: -8deg; }

/* ------------------------------------------------------------------ */
/* Connection indicator: a typed slip                                  */
/* ------------------------------------------------------------------ */

.net {
  position: fixed;
  top: calc(var(--edge-y) + var(--u) * 1.2);
  left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  z-index: 10;
  display: flex;
  align-items: center;
  grid-gap: calc(var(--u) * 0.7);
  gap: calc(var(--u) * 0.7);
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.2);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.6);
  box-shadow: calc(var(--u) * 0.35) calc(var(--u) * 0.45) 0 var(--red);
}

.net-dot {
  width: calc(var(--u) * 0.8);
  height: calc(var(--u) * 0.8);
  border-radius: 50%;
  background: var(--red);
  animation: breathe 1.2s ease-in-out infinite;
}

/* Screen transitions */
.screen.enter { animation: screen-in 0.5s var(--ease-out) both; }

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .disc.spinning, .lobby-connecting, .net-dot { animation: none; }
}

/* --- generated: flex gap fallback for old TV browsers (no-flexgap set by legacy-polyfills.js) --- */
.no-flexgap .board-head > * + * { margin-left: calc(var(--u) * 2); }
.no-flexgap .board-head > .cards-left { margin-left: auto; } /* keep it pushed right */
.no-flexgap .scene > * + * { margin-top: calc(var(--u) * 1.6); }
.no-flexgap .face-front > * + * { margin-top: calc(var(--spot-s) * 0.05); }
.no-flexgap .hint > * + * { margin-left: calc(var(--u) * 1.4); }
.no-flexgap .resolved-box > * + * { margin-top: calc(var(--u) * 1.2); }
.no-flexgap .answer > * + * { margin-left: calc(var(--u) * 1.2); }
.no-flexgap .answer > * { margin-bottom: calc(var(--u) * 0.6); }
.no-flexgap .outcome > * + * { margin-left: calc(var(--u) * 1.6); }
.no-flexgap .lb > * + * { margin-top: calc(var(--u) * 0.7); }
.no-flexgap .podium > * + * { margin-left: calc(var(--u) * 1.4); }
.no-flexgap .step-people > * + * { margin-top: calc(var(--u) * 1.6); }
.no-flexgap .step-people.multi > * + * { margin-top: 0; margin-left: calc(var(--u) * 1.2); }
.no-flexgap .step-people.multi > * { margin-bottom: calc(var(--u) * 1.6); }
.no-flexgap .step-person > * + * { margin-left: calc(var(--u) * 1); }
.no-flexgap .final-rest > * + * { margin-left: calc(var(--u) * 1.4); }
.no-flexgap .final-rest > * { margin-bottom: calc(var(--u) * 1); }
.no-flexgap .final-rest li > * + * { margin-left: calc(var(--u) * 0.9); }
.no-flexgap .net > * + * { margin-left: calc(var(--u) * 0.7); }

/* --- fallbacks for old TV browsers ---------------------------------------
   --u and --spot-s are also set in px from tv.js (CSS min() is Chromium 79+). */
@supports not (aspect-ratio: 1) {
  .qr-backing, .lobby-qr { height: min(calc(var(--u) * 29), 54vh); }
  .card .bonus-mark { height: calc(var(--u) * 3.3); }
  .sleeve-block::before { height: 0; padding-top: 70%; }
}
@supports not (width: min(1px, 2px)) {
  .qr-backing, .lobby-qr { width: calc(var(--u) * 29); height: calc(var(--u) * 29); }
}

/* ------------------------------------------------------------------ */
/* TV buttons (full screen / new room / exit)                          */
/* ------------------------------------------------------------------ */
.tv-tools {
  position: fixed;
  right: calc(var(--edge-x) + var(--u) * 2);
  bottom: calc(var(--edge-y) + var(--u) * 1.6);
  z-index: 50;
  display: flex;
  /* In a game, stay within the scores column: wrap onto two rows. */
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(var(--u) * 30);
  opacity: 0;
  visibility: hidden;
  transform: translateY(calc(var(--u) * 1));
  transition: opacity 0.25s, transform 0.25s var(--ease-out), visibility 0s linear 0.25s;
}
.tv-tools.is-shown {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.25s, transform 0.25s var(--ease-out), visibility 0s;
}
.tv-tool {
  margin: calc(var(--u) * 0.8) 0 0 calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.55) calc(var(--u) * 1.2);
  border: calc(var(--u) * 0.15) solid var(--ink);
  border-radius: var(--r-ctl);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-type);
  font-size: calc(var(--u) * 1.15);
  line-height: 1.2;
  box-shadow: calc(var(--u) * 0.2) calc(var(--u) * 0.3) 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.tv-tool[hidden] { display: none; }
.tv-tool:hover { background: var(--lemon); }
/* Remote focus: unmissable from the sofa. */
/* Separate rules: old TV browsers drop a whole rule with :focus-visible in it. */
.tv-tool:focus {
  outline: calc(var(--u) * 0.3) solid var(--lemon);
  outline-offset: calc(var(--u) * 0.2);
  background: var(--lemon);
}
.tv-tool:focus-visible {
  outline: calc(var(--u) * 0.3) solid var(--lemon);
  outline-offset: calc(var(--u) * 0.2);
  background: var(--lemon);
}
.tv-tool.is-armed { background: var(--red); color: var(--paper); }
/* Start screen: bottom-left is empty (stickers fill the bottom-right). */
.tv-tools.is-lobby { max-width: none; justify-content: flex-start; right: auto; left: calc(var(--edge-x) + var(--u) * 5.2); bottom: calc(var(--edge-y) + var(--u) * 2.2); }
