/* Laugh or Lame: a TV panel show shot in a writers' room.
   The set is studio blue; the only bright light comes from the judges' signs. */

:root {
  --set: #0E2537;          /* the studio, page background */
  --backdrop: #14344C;     /* panels, the judges' desk */
  --backdrop-edge: #1D4562;
  --bulb: #FFC94A;         /* LAUGH, lit */
  --bulb-deep: #F2A922;
  --bulb-ink: #4A2E00;
  --tube: #BFD6E4;         /* LAME, lit */
  --tube-ink: #2C4659;
  --unlit: #1A3B54;        /* a sign with the power off */
  --unlit-ink: #2E5573;
  --card: #FDFBF4;         /* index card */
  --card-rule: #C9DCEB;
  --card-margin: #E8A0A0;
  --pencil: #C8372D;       /* red pencil: cut */
  --ink: #1F2633;          /* typed text on cards */
  --ink-soft: #5B6577;
  --text: #E8EEF3;         /* text on the set */
  --text-soft: #A3B8C8;
  --focus: #FFC94A;

  --type: "Courier Prime", "Courier New", monospace;
  --sign: "Bungee", "Arial Black", sans-serif;

  /* Type scale: a perfect fourth from a 17px base */
  --s-1: 0.8125rem;
  --s0: 1.0625rem;
  --s1: 1.4167rem;
  --s2: 1.889rem;
  --s3: 2.519rem;
  --s4: 3.358rem;

  --line: 1.6;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1180px;
}

* { box-sizing: border-box; }

html { background: var(--set); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 201, 74, 0.07), transparent 70%),
    var(--set);
  color: var(--text);
  font-family: var(--type);
  font-size: var(--s0);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:hover { color: var(--bulb); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--bulb);
  color: var(--bulb-ink);
  padding: 8px 12px;
  z-index: 10;
}
.skip:focus { left: 8px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 20px var(--gutter);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--sign);
  font-size: var(--s1);
  line-height: 1;
}
.logo-laugh, .logo-lame {
  padding: 8px 10px 6px;
  border-radius: 4px;
}
.logo-laugh {
  background: var(--bulb);
  color: var(--bulb-ink);
  box-shadow: 0 0 18px rgba(255, 201, 74, 0.45);
}
.logo-lame {
  background: var(--unlit);
  color: var(--unlit-ink);
}
.logo-or {
  font-family: var(--type);
  font-style: italic;
  font-size: var(--s0);
  color: var(--text-soft);
}
.logo:hover .logo-lame { color: var(--tube-ink); background: var(--tube); }

.nav { display: flex; gap: 8px 24px; flex-wrap: wrap; }
.nav a {
  text-decoration: none;
  color: var(--text-soft);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--bulb); }
.nav a:hover { color: var(--text); }

main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px var(--gutter) 64px;
}
main:focus { outline: none; }

.footer {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  color: var(--text-soft);
  font-size: var(--s-1);
  border-top: 1px solid var(--backdrop-edge);
}
.footer p { margin: 0; max-width: 70ch; }

h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: var(--s3); }
h2 { font-size: var(--s1); }
p { max-width: 68ch; }

/* ---------- The judges' signs ---------- */

.sign {
  --w: 100%;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--w);
  aspect-ratio: 2.6 / 1;
  border-radius: 8px;
  background: var(--unlit);
  color: var(--unlit-ink);
  font-family: var(--sign);
  font-size: clamp(1.4rem, 4.2vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 3px #0B1E2D, inset 0 2px 10px rgba(0, 0, 0, 0.5);
  transition: background-color 120ms ease, color 120ms ease, box-shadow 200ms ease;
  user-select: none;
}
/* Bulbs around the frame: dark until the sign lights */
.sign::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 5px;
  background:
    radial-gradient(circle, currentColor 1.6px, transparent 2.4px) top left / 14px 100% repeat-y,
    radial-gradient(circle, currentColor 1.6px, transparent 2.4px) top right / 14px 100% repeat-y;
  background-size: 14px 14px;
  opacity: 0.25;
  pointer-events: none;
}
.sign[data-state="laugh"] {
  background: radial-gradient(ellipse at 50% 40%, #FFE08A, var(--bulb) 55%, var(--bulb-deep));
  color: var(--bulb-ink);
  box-shadow: inset 0 0 0 3px #B87A0B, 0 0 28px 4px rgba(255, 201, 74, 0.45), 0 0 80px rgba(255, 201, 74, 0.2);
}
.sign[data-state="laugh"]::before { opacity: 0.6; color: #FFF6D8; }
.sign[data-state="lame"] {
  background: linear-gradient(180deg, #D3E4EE, var(--tube));
  color: var(--tube-ink);
  box-shadow: inset 0 0 0 3px #7F9CB0, 0 0 22px rgba(191, 214, 228, 0.25);
}
.sign[data-state="lame"]::before { opacity: 0; }
.sign.flicker[data-state="lame"] { animation: tube-flicker 700ms steps(1) 1; }
.sign.pop[data-state="laugh"] { animation: bulb-pop 420ms ease-out 1; }

@keyframes tube-flicker {
  0% { opacity: 0.2; } 12% { opacity: 1; } 18% { opacity: 0.3; } 30% { opacity: 1; }
  38% { opacity: 0.55; } 46% { opacity: 1; } 100% { opacity: 1; }
}
@keyframes bulb-pop {
  0% { filter: brightness(1.6); transform: scale(1.04); }
  100% { filter: brightness(1); transform: scale(1); }
}

.judge {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}
.judge-name {
  font-weight: 700;
  font-size: var(--s0);
  color: var(--text);
}
.judge-detail {
  font-size: var(--s-1);
  color: var(--text-soft);
  min-height: 3.2em;
  max-width: 24ch;
}

/* Small signs: on cards and scorecards */
.lamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--s-1);
  color: var(--ink-soft);
  white-space: nowrap;
}
.lamp b {
  font-family: var(--sign);
  font-weight: 400;
  font-size: 0.75rem;
  line-height: 1;
  padding: 4px 6px 3px;
  border-radius: 3px;
  background: #DCE3EA;
  color: #9AA8B6;
}
.lamp[data-state="laugh"] b { background: var(--bulb); color: var(--bulb-ink); box-shadow: 0 0 8px rgba(242, 169, 34, 0.6); }
.lamp[data-state="lame"] b { background: var(--tube); color: var(--tube-ink); }

/* ---------- Index cards ---------- */

/* Card geometry is in a fixed unit (--u) so the typed lines sit on the rules at any font size. */
.card {
  --u: 1.0625rem;
  --rule-gap: calc(var(--u) * 1.6);
  --rule-top: calc(var(--u) * 2.4);
  position: relative;
  background-color: var(--card);
  background-image:
    linear-gradient(var(--card-margin), var(--card-margin)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--rule-gap) - 1px), var(--card-rule) calc(var(--rule-gap) - 1px), var(--card-rule) var(--rule-gap));
  background-size: 100% 2px, 100% 100%;
  background-position: 0 var(--rule-top), 0 var(--rule-top);
  background-repeat: no-repeat, no-repeat;
  color: var(--ink);
  padding: calc(var(--u) * 0.5) 16px calc(var(--u) * 0.6);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.28);
  line-height: var(--rule-gap);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  height: calc(var(--u) * 1.9);
  line-height: calc(var(--u) * 1.3);
  overflow: hidden;
  font-size: var(--s-1);
  color: var(--ink-soft);
}
.card-text {
  margin: 0;
  font-size: var(--s0);
  line-height: var(--rule-gap);
  min-height: calc(var(--rule-gap) * 2);
  overflow-wrap: anywhere;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  min-height: var(--rule-gap);
  line-height: 1;
}
.card-quip {
  margin: 0;
  line-height: var(--rule-gap);
  font-size: var(--s-1);
  font-style: italic;
  color: var(--ink-soft);
}

/* Being typed: Jev hasn't cleared it yet */
.card.typing .card-text::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: -0.15em;
  background: var(--ink);
  animation: caret 900ms steps(1) infinite;
}
.typing-dots { color: var(--ink-soft); letter-spacing: 0.2em; }
@keyframes caret { 50% { opacity: 0; } }

/* Red pencil through a card that got cut */
.card.cut .card-text { position: relative; color: var(--ink-soft); }
.card.cut .card-text::after {
  content: "";
  position: absolute;
  left: -6px; right: -6px; top: 50%;
  height: 3px;
  background: var(--pencil);
  border-radius: 2px;
  transform: rotate(-4deg);
  opacity: 0.85;
}
.cut-note {
  font-size: var(--s-1);
  color: var(--pencil);
  font-weight: 700;
}
.card.withheld .card-text {
  color: transparent;
  background: repeating-linear-gradient(90deg, #E2DED2 0 10px, transparent 10px 14px);
  border-radius: 2px;
}
.card.survivor { box-shadow: 0 0 0 2px var(--bulb), 0 6px 18px rgba(0, 0, 0, 0.3); }

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 0;
  border-radius: 6px;
  font: 700 var(--s0) / 1 var(--type);
  cursor: pointer;
  text-decoration: none;
  background: var(--bulb);
  color: var(--bulb-ink);
  box-shadow: 0 3px 0 #B87A0B;
}
.button:hover { color: var(--bulb-ink); filter: brightness(1.06); }
.button:active { transform: translateY(2px); box-shadow: 0 1px 0 #B87A0B; }
.button:disabled { opacity: 0.55; cursor: progress; }
.button.quiet {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--backdrop-edge);
}
.button.quiet:hover { color: var(--text); box-shadow: inset 0 0 0 2px var(--text-soft); }

/* Paddles: the viewer's vote */
.paddles { display: flex; gap: 10px; }
.paddle {
  flex: 1;
  min-height: 52px;
  border: 0;
  border-radius: 6px;
  font: 400 1.05rem / 1 var(--sign);
  cursor: pointer;
  background: #E7ECF0;
  color: #6F7F8E;
  box-shadow: inset 0 0 0 2px #CBD5DD;
}
.paddle:hover { color: var(--ink); }
.paddle[data-verdict="laugh"][aria-pressed="true"] { background: var(--bulb); color: var(--bulb-ink); box-shadow: 0 0 16px rgba(242, 169, 34, 0.55); }
.paddle[data-verdict="lame"][aria-pressed="true"] { background: var(--tube); color: var(--tube-ink); box-shadow: inset 0 0 0 2px #7F9CB0; }
.tally { margin: 8px 0 0; font-size: var(--s-1); color: var(--ink-soft); min-height: 1.6em; }

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

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  align-items: center;
  padding: clamp(24px, 5vw, 56px) 0 clamp(24px, 4vw, 40px);
}
.stage-copy { text-align: center; }
.stage-copy h1 {
  font-size: clamp(var(--s2), 3.6vw, var(--s3));
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.stage-copy p {
  margin: 16px auto 0;
  color: var(--text-soft);
  text-wrap: pretty;
  max-width: 44ch;
}

.pitch {
  display: grid;
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
  gap: 14px;
}
.pitch label { font-weight: 700; }
.pitch .card { padding-bottom: 16px; }
.pitch textarea {
  display: block;
  width: 100%;
  min-height: calc(var(--rule-gap) * 3);
  margin: 0;
  padding: 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: var(--s0) / var(--rule-gap) var(--type);
}
.pitch textarea:focus { outline: none; }
.pitch .card:focus-within { box-shadow: 0 0 0 3px var(--focus), 0 6px 18px rgba(0, 0, 0, 0.28); }
.pitch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}
.count { font-size: var(--s-1); color: var(--text-soft); }
.form-error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 4px;
  background: rgba(200, 55, 45, 0.15);
  border-left: 4px solid var(--pencil);
  color: #FFD9D4;
}
.seeds { display: flex; flex-wrap: wrap; gap: 10px; }
.seed {
  border: 0;
  border-radius: 2px;
  padding: 6px 12px;
  background: var(--card);
  color: var(--ink);
  font: var(--s-1) / 1.4 var(--type);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: rotate(var(--tilt, -1deg));
}
.seed:nth-child(2n) { --tilt: 1.2deg; }
.seed:nth-child(3n) { --tilt: -0.4deg; }
.seed:hover { transform: rotate(0) translateY(-2px); }


.closed {
  text-align: center;
  padding: 24px;
  border-radius: 8px;
  background: var(--backdrop);
}

/* ---------- The show ---------- */

.show-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
  padding: 16px 0 24px;
}
.premise-label { margin: 0 0 4px; color: var(--text-soft); font-size: var(--s-1); }
.premise {
  font-size: clamp(var(--s1), 3vw, var(--s2));
  max-width: 34ch;
  text-wrap: balance;
}
.rounds { display: flex; align-items: center; gap: 10px; font-size: var(--s-1); color: var(--text-soft); }
.round-lights { display: flex; gap: 6px; }
.round-lights span {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--unlit);
  box-shadow: inset 0 0 0 2px #0B1E2D;
}
.round-lights span.on { background: var(--bulb); box-shadow: 0 0 8px rgba(255, 201, 74, 0.7); }

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(14px, 3vw, 36px);
  align-items: start;
  padding: clamp(18px, 3vw, 32px);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--backdrop), #102C41);
  box-shadow: inset 0 1px 0 var(--backdrop-edge), 0 18px 40px rgba(0, 0, 0, 0.35);
}
.desk-card { align-self: center; }
.desk-card .card { transform: rotate(-0.6deg); }
.desk-empty { color: var(--text-soft); text-align: center; margin: 0 auto; }

.status-line { margin: 18px 0 0; color: var(--text-soft); min-height: 1.6em; }

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  margin-top: 40px;
}
.round { margin-bottom: 32px; }
.round h2 { font-size: var(--s0); margin-bottom: 14px; color: var(--text-soft); font-weight: 400; }
.round h2 b { color: var(--text); }
.pile {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.pile .card:nth-child(3n + 1) { transform: rotate(-0.5deg); }
.pile .card:nth-child(3n + 2) { transform: rotate(0.4deg); }

.board {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 18px;
  border-radius: 8px;
  background: #A9824F;
  background-image: radial-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 1.4px);
  background-size: 7px 7px;
  box-shadow: inset 0 0 0 6px #6D4F2C, 0 10px 24px rgba(0, 0, 0, 0.35);
  color: #2B1D0D;
}
.board h2 { font-size: var(--s0); margin-bottom: 12px; }
.board ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.board .card { font-size: var(--s-1); padding: 0.4em 12px 10px; }
.board .card-text { font-size: var(--s-1); min-height: 0; }
.board .pin {
  position: absolute;
  top: -5px; left: 50%;
  width: 12px; height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #F07A6F, var(--pencil));
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.4);
}
.board-empty { margin: 0; font-size: var(--s-1); }

.finale {
  margin-top: 16px;
  padding: clamp(20px, 4vw, 40px);
  border-radius: 10px;
  background: radial-gradient(ellipse 70% 60% at 50% 0%, rgba(255, 201, 74, 0.16), transparent 70%), var(--backdrop);
  scroll-margin-top: 16px;
}
.finale > h2 { font-size: var(--s2); text-align: center; }
.finale > p { margin: 8px auto 28px; text-align: center; color: var(--text-soft); }
.finalists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.finalist .card { padding-bottom: 16px; }
.finalist .card-text { font-size: 1.2rem; }
.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.verdicts .sign { font-size: 1.1rem; aspect-ratio: 3 / 1; }
.verdicts figcaption { margin-top: 4px; font-size: var(--s-1); color: var(--ink-soft); text-align: center; }
.verdicts figure { margin: 0; }
.your-vote { margin: 12px 0 8px; font-weight: 700; }
.share { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 32px; }

/* ---------- Hall of fame ---------- */

.page-head { padding: 24px 0 28px; }
.page-head p { color: var(--text-soft); margin: 10px 0 0; }
.tabs { display: flex; gap: 8px; margin-top: 18px; }
.tabs button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: var(--s0) var(--type);
  padding: 6px 2px;
  margin-right: 16px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tabs button[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--bulb); }

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 26px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.wall .card:nth-child(odd) { transform: rotate(-0.4deg); }
.scorecard { display: grid; gap: 6px; margin-top: 10px; }
.people-bar {
  display: flex;
  height: 8px;
  gap: 2px;
  border-radius: 4px;
  overflow: hidden;
  background: #E3E8EC;
}
.people-bar i { display: block; }
.people-bar .l { background: var(--bulb-deep); }
.people-bar .m { background: #9FB9CB; }
.empty {
  padding: 32px;
  border-radius: 8px;
  background: var(--backdrop);
  text-align: center;
}
.empty p { margin: 0 auto 16px; color: var(--text-soft); }

/* ---------- Stats ---------- */

.headline-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.headline-stats div {
  padding: 18px;
  border-radius: 8px;
  background: var(--backdrop);
}
.headline-stats strong { display: block; font-family: var(--sign); font-weight: 400; font-size: var(--s3); line-height: 1.1; }
.headline-stats span { color: var(--text-soft); font-size: var(--s-1); }
.chart-wrap {
  position: relative;
  padding: 16px;
  border-radius: 8px;
  background: var(--backdrop);
}
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-wrap .axis text, .chart-wrap .label { fill: var(--text-soft); font: 12px var(--type); }
.chart-wrap .grid line { stroke: #24506F; stroke-width: 1; }
.chart-wrap .diag { stroke: #3B6788; stroke-width: 1; }
.chart-wrap .dot { fill: var(--bulb); stroke: var(--backdrop); stroke-width: 2; pointer-events: none; }
.chart-wrap .hit { fill: transparent; cursor: pointer; }
.chart-wrap .hit:hover + .dot, .chart-wrap .dot.active { fill: #FFF1C8; }
.tooltip {
  position: absolute;
  pointer-events: none;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  font-size: var(--s-1);
  line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.chart-note { color: var(--text-soft); font-size: var(--s-1); margin: 12px 0 0; }
details.table-view { margin-top: 16px; }
details.table-view summary { cursor: pointer; color: var(--text-soft); }
.data-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: var(--s-1); }
.data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--backdrop-edge); vertical-align: top; }
.data-table td.num, .data-table th.num { text-align: right; white-space: nowrap; }

/* ---------- Admin ---------- */

.queue { display: grid; gap: 20px; list-style: none; padding: 0; }
.queue li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.queue .actions { display: flex; gap: 8px; }
.admin-login { display: flex; gap: 10px; flex-wrap: wrap; max-width: 520px; }
.admin-login input {
  flex: 1;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 2px solid var(--backdrop-edge);
  background: var(--backdrop);
  color: var(--text);
  font: var(--s0) var(--type);
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr 1fr; }
  .stage-copy { grid-column: 1 / -1; order: -1; }
  .desk { grid-template-columns: 1fr 1fr; }
  .desk-card { grid-column: 1 / -1; order: -1; }
  .room { grid-template-columns: 1fr; }
  .board { position: static; order: -1; }
}

@media (max-width: 480px) {
  .masthead { padding-top: 14px; }
  .logo { font-size: 1.15rem; }
  .judge-detail { min-height: 0; }
  .queue li { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card, .seed, .pile .card, .wall .card, .desk-card .card { transform: none !important; }
}

@media (forced-colors: active) {
  .sign[data-state="laugh"], .sign[data-state="lame"], .lamp[data-state] b { forced-color-adjust: none; }
}

/* Card headers hold one line: the left label truncates, the right one never wraps. */
.card-head > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head > :last-child { flex: none; white-space: nowrap; }

/* ---------- What we learned ----------
   One structure for the whole essay: a rail on the left holding the lesson's lit verdict sign
   (sticky while you read it), and a reading column on the right. Prose that isn't a lesson sits
   in the same column, so every left edge lines up. */

.essay {
  --rail: 196px;
  --gap: clamp(28px, 4vw, 56px);
  --measure: 40rem;
  max-width: calc(var(--rail) + var(--gap) + var(--measure));
  margin: 0 auto;
  padding-bottom: 32px;
}
.essay p { max-width: none; }
.essay-head, .prose { margin-left: calc(var(--rail) + var(--gap)); }

.essay-head { padding: clamp(24px, 5vw, 56px) 0 8px; }
.essay-head h1 {
  font-size: clamp(2.6rem, 6.4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.byline { margin: 14px 0 0; color: var(--text-soft); }
.epigraph {
  margin: 36px 0 32px;
  padding: 0;
  color: var(--text-soft);
  font-style: italic;
  font-size: var(--s0);
  line-height: 1.65;
}
.epigraph p { margin: 0; }
.epigraph footer { margin-top: 8px; font-style: normal; font-size: var(--s-1); }
.epigraph footer::before { content: "- "; }

/* Typed cards get a slimmer top band than the show's cards: one line of text, not a joke with a header. */
.essay .typed-card { --rule-top: calc(var(--u) * 1.4); max-width: 36rem; transform: rotate(-0.6deg); }
.essay .typed-card .card-head { height: calc(var(--u) * 0.9); }
.essay .typed-card .card-text { font-size: 1.2rem; font-weight: 700; }
.essay-head .typed-card { transform: rotate(0.5deg); }
.essay-head .typed-card .card-text { font-weight: 400; }

.prose p, .lesson-body > p, .pattern dd {
  font-size: var(--s0);
  line-height: 1.75;
  color: var(--text);
}
.prose p { margin: 0 0 18px; }
.method { color: var(--text-soft) !important; font-size: var(--s-1) !important; line-height: 1.6 !important; }
.prose h2 { font-size: var(--s1); margin: 40px 0 14px; }

.section-title {
  margin: 88px 0 8px;
  padding-top: 26px;
  border-top: 2px solid var(--backdrop-edge);
  font-size: var(--s2);
  letter-spacing: -0.01em;
}

/* --- lessons --- */

.lesson {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--measure));
  gap: var(--gap);
  padding: 56px 0 8px;
}
.lesson + .lesson { border-top: 1px solid var(--backdrop-edge); }
.rail { position: relative; }
.lesson .rail .sign {
  position: sticky;
  top: 24px;
  font-size: 2.1rem;
}
.lesson-body h3 {
  font-size: clamp(1.45rem, 2.6vw, var(--s2));
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-bottom: 18px;
}
.lesson-body > p { margin: 0 0 16px; }
.lesson-body .typed-card { margin: 26px 0 30px; }

/* --- evidence --- */

.evidence { margin: 28px 0; }
.evidence figcaption, .evidence caption {
  margin-bottom: 14px;
  font-size: var(--s-1);
  color: var(--text-soft);
  text-align: left;
  caption-side: top;
}
.evidence .data-table { margin: 0; font-size: var(--s-1); }
.evidence th[scope="row"] { font-weight: 400; }
.evidence-note { margin: 12px 0 0; font-size: var(--s-1); color: var(--text-soft); }

.bars ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bars li {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) 3.2rem;
  gap: 14px;
  align-items: center;
  font-size: var(--s-1);
}
.bar-label { display: flex; align-items: center; gap: 8px; }
.pro-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--tube); }
.pro .bar-label { color: var(--text); font-weight: 700; }
.bar-track { height: 14px; background: var(--unlit); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--bulb); border-radius: 0 4px 4px 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

.round-row + .round-row { margin-top: 18px; }
.round-label { margin: 0 0 6px; font-size: var(--s-1); font-weight: 700; }
.round-plot {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  height: 150px;
  border-bottom: 1px solid #2E5573;
}
.laugh-line {
  position: absolute;
  left: 0; right: 0;
  bottom: var(--line);
  border-top: 1px solid rgba(255, 201, 74, 0.55);
  pointer-events: none;
}
.laugh-line span {
  position: absolute;
  right: 0; bottom: 4px;
  font-size: 0.75rem;
  color: var(--text-soft);
}
.round-col { position: relative; }
.round-bar { position: absolute; bottom: 0; left: 21%; width: 58%; height: var(--h); border-radius: 4px 4px 0 0; }
.round-value {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--h) + 4px);
  text-align: center;
  font-size: var(--s-1);
  font-variant-numeric: tabular-nums;
}
.round-row[data-state="laugh"] .round-bar { background: var(--bulb); }
.round-row[data-state="lame"] .round-bar { background: var(--tube); }
.round-axis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-soft);
  text-align: center;
}
.round-axis span:first-child { display: none; }

/* The scorecard is an index card too: every value and label sits on its own rule. */
.scorecard {
  --rule-top: calc(var(--u) * 1.4);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  margin: 0;
  max-width: 36rem;
  padding-top: var(--rule-top);
  transform: rotate(0.4deg);
}
.scorecard div { display: flex; flex-direction: column-reverse; }
.scorecard dt, .scorecard dd { line-height: var(--rule-gap); }
.scorecard dt { font-size: var(--s-1); color: var(--ink-soft); }
.scorecard dd { margin: 0; font-size: 1.45rem; font-weight: 700; color: var(--ink); }

.live-line {
  margin: 22px 0 0;
  padding: 14px 18px;
  border-left: 3px solid var(--bulb);
  background: var(--backdrop);
  font-size: var(--s-1);
  line-height: 1.6;
  color: var(--text);
}
.live-line a { color: var(--bulb); }

/* --- notes for builders --- */

details.builders {
  margin: 26px 0 0;
  border-radius: 6px;
  background: #102C41;
  box-shadow: inset 0 0 0 1px var(--backdrop-edge);
}
details.builders summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-weight: 700;
}
details.builders summary::-webkit-details-marker { display: none; }
details.builders summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  background: var(--unlit);
  color: var(--text);
  font-weight: 700;
}
details.builders[open] summary::before { content: "−"; }
details.builders p {
  margin: 0;
  padding: 0 16px 14px 48px;
  font-size: var(--s-1);
  line-height: 1.7;
  color: var(--text-soft);
}

/* --- patterns --- */

.pattern {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--measure));
  gap: var(--gap);
  padding: 30px 0;
}
.pattern + .pattern { border-top: 1px solid var(--backdrop-edge); }
.pattern .rail h3 { font-size: var(--s1); line-height: 1.25; text-wrap: balance; }
.pattern dl { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.pattern dt { font-weight: 700; color: var(--text); line-height: 1.75; }
.pattern dd { margin: 0; }
.pattern dt:last-of-type, .pattern dt:last-of-type + dd { color: var(--text-soft); }

.closing { margin-top: 64px; }
.closing h2 { font-size: var(--s2); margin-top: 0; }
.signoff { margin-top: 28px !important; font-weight: 700; font-size: var(--s1) !important; }

@media (max-width: 760px) {
  .essay-head, .prose { margin-left: 0; }
  .lesson, .pattern { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .lesson { padding-top: 40px; }
  .lesson .rail .sign { position: static; width: 132px; font-size: 1.25rem; }
  .bars li { grid-template-columns: minmax(0, 1fr) 3rem; }
  .bar-label { grid-column: 1 / -1; }
  .pattern dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pattern dd { margin-bottom: 10px; }
  .section-title { margin-top: 64px; }
}
.essay-head + .prose { margin-top: 28px; }

/* --- how it's built: the show as a numbered run of bulbs down one line --- */

.flow { margin: 12px 0 24px calc(var(--rail) + var(--gap)); max-width: var(--measure); }
.flow ol { list-style: none; margin: 0; padding: 0; position: relative; }
/* One segment per step, from this bulb down to the next, so the line stops at the last bulb. */
.flow li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 17px; top: 36px; bottom: 0;
  width: 2px;
  background: var(--backdrop-edge);
}
.flow li {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 20px;
  padding: 0 0 26px;
}
.flow li:last-child { padding-bottom: 0; }
.flow-bulb {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bulb);
  color: var(--bulb-ink);
  font: 400 1rem / 1 var(--sign);
  box-shadow: 0 0 0 4px var(--set), 0 0 14px rgba(255, 201, 74, 0.55);
}
.flow-body h3 { font-size: var(--s1); line-height: 1.3; margin: 4px 0 6px; }
.flow-body p { margin: 0; font-size: var(--s0); line-height: 1.75; color: var(--text); }
.flow-body .flow-uses { margin-top: 6px; font-size: var(--s-1); color: var(--text-soft); }
.built-body p { margin: 0 0 14px; font-size: var(--s0); line-height: 1.75; color: var(--text); }
.built-body p:last-child { margin-bottom: 0; }

@media (max-width: 760px) {
  .flow { margin-left: 0; }
  .flow li { gap: 14px; }
}
