/* Layout: night apron. One centred 1080px column; a runway-lit hero with a
   split-flap board, then the ballot on one raised panel that overlaps it.
   A deliberately dark look throughout (an airfield after sunset). */
:root {
  color-scheme: dark;
  --ground: #0a111c;
  --ground-raise: #0d1624;
  --panel: #121a27;
  --panel-2: #172235;
  --panel-3: #1d2a40;
  --line: #24324a;
  --line-strong: #36496a;
  --ink: #eef2f8;
  --ink-2: #a9b5c8;
  --ink-3: #7d8ba1;
  --red: #d81f40;          /* Jet Bridge red for fills and buttons */
  --red-hover: #ea2b4d;
  --red-text: #ff6b80;     /* Jet Bridge red as text on the dark ground */
  --red-wash: rgba(216, 31, 64, 0.16);
  --on-red: #ffffff;
  --green: #3ddc84;        /* threshold-light green */
  --amber: #ffc24a;
  --amber-wash: rgba(255, 194, 74, 0.08);
  --flap: #151b24;
  --flap-top: #1a212c;
  --flap-edge: #05080c;
  --flap-ink: #f3eee0;
  --series-jb: #eb6263;    /* chart colour for Jet Bridge */
  --series-mak: #338ced;   /* chart colour for MAK Airways */
  --shadow: rgba(0, 0, 0, 0.55);
  --amber-line: rgba(255, 194, 74, 0.4);
  --pass-edge: transparent;

  /* The night scene (runway, departure board, header band) is a picture:
     it keeps these colours in both themes. */
  --scene-bg: #0a111c;
  --scene-glow: #142640;
  --scene-ink: #eef2f8;
  --scene-ink-2: #a9b5c8;
  --scene-ink-3: #7d8ba1;
  --scene-green: #3ddc84;
  --scene-amber: #ffc24a;
  /* Numbers inside heatmap cells, by how dark the cell is. */
  --cell-ink-on-dark: #ffffff;
  --cell-ink-on-light: #0b1220;

  /* Readex Pro everywhere (the organisers' choice); the three roles differ
     only in weight, size and spacing. */
  --font-display: "Readex Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Readex Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Readex Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --wrap: 1080px;
}

/* Light theme: the apron by day. Follows the device unless the viewer
   picks one with the toggle (data-theme on <html>). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ground: #eef1f6;
    --ground-raise: #f7f9fc;
    --panel: #ffffff;
    --panel-2: #f3f6fa;
    --panel-3: #e6ebf2;
    --line: #dde3ec;
    --line-strong: #c2ccda;
    --ink: #0e1726;
    --ink-2: #43516a;
    --ink-3: #616f86;
    --red-hover: #bf1838;
    --red-text: #c4153a;
    --red-wash: rgba(216, 31, 64, 0.08);
    --green: #0a7f44;
    --amber: #9a5800;
    --amber-wash: rgba(154, 88, 0, 0.08);
    --amber-line: rgba(154, 88, 0, 0.35);
    --series-jb: #ec4647;
    --series-mak: #257de0;
    --shadow: rgba(16, 24, 40, 0.14);
    --pass-edge: #d3dbe6;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #eef1f6;
  --ground-raise: #f7f9fc;
  --panel: #ffffff;
  --panel-2: #f3f6fa;
  --panel-3: #e6ebf2;
  --line: #dde3ec;
  --line-strong: #c2ccda;
  --ink: #0e1726;
  --ink-2: #43516a;
  --ink-3: #616f86;
  --red-hover: #bf1838;
  --red-text: #c4153a;
  --red-wash: rgba(216, 31, 64, 0.08);
  --green: #0a7f44;
  --amber: #9a5800;
  --amber-wash: rgba(154, 88, 0, 0.08);
  --amber-line: rgba(154, 88, 0, 0.35);
  --series-jb: #ec4647;
  --series-mak: #257de0;
  --shadow: rgba(16, 24, 40, 0.14);
  --pass-edge: #d3dbe6;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red-text); outline-offset: 3px; }
h1, h2, h3 { text-wrap: balance; }

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Sky: masthead + hero over the runway ---------- */

.sky {
  position: relative;
  overflow: hidden;
  color: var(--scene-ink);
  background:
    radial-gradient(120% 70% at 70% 46%, var(--scene-glow) 0%, rgba(10, 17, 28, 0) 62%),
    var(--scene-bg);
}
.approach { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(10, 17, 28, 0.94) 0%, rgba(10, 17, 28, 0.6) 40%, rgba(10, 17, 28, 0) 68%),
    linear-gradient(0deg, var(--scene-bg) 0%, rgba(10, 17, 28, 0) 22%);
}
.masthead, .hero { position: relative; z-index: 1; }
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 22px;
}
.logo { height: 36px; width: auto; display: block; }
.masthead-tag, .eyebrow, .board-head, .steps li, label, legend, .pass-label, .note-mono {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.masthead-tag { font-size: 0.72rem; color: var(--scene-ink-3); }
.masthead-right { display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(169, 181, 200, 0.35);
  background: rgba(10, 17, 28, 0.4);
  color: var(--scene-ink);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--scene-ink-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle[data-mode="light"] .icon-sun { display: none; }
.theme-toggle[data-mode="light"] .icon-moon { display: block; }

.hero-inner {
  display: grid;
  gap: 22px;
  justify-items: start;
  padding-block: clamp(28px, 6vw, 72px) clamp(72px, 10vw, 128px);
}
.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.74rem;
  color: var(--scene-ink-2);
}
.eyebrow-sep { color: var(--scene-ink-3); }
.lamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--scene-green);
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.16), 0 0 14px rgba(61, 220, 132, 0.8);
  animation: lamp 2.4s ease-in-out infinite;
}
.lamp.is-closed { background: var(--scene-amber); box-shadow: 0 0 0 3px rgba(255, 194, 74, 0.16); animation: none; }
@keyframes lamp { 50% { opacity: 0.45; } }

h1 {
  margin: 0;
  max-width: 15ch;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 6vw, 4.1rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}
.lede {
  margin: 0;
  max-width: 34rem;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--scene-ink-2);
}

/* The departure board */
.board {
  --fw: clamp(21px, 6.9vw, 46px);
  display: grid;
  gap: 10px;
  max-width: 100%;
  padding: 12px clamp(10px, 2vw, 16px) clamp(12px, 2vw, 16px);
  background: linear-gradient(#0f151e, #090d13);
  border: 1px solid #1f2a3a;
  border-radius: 12px;
  box-shadow: 0 24px 60px -24px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.board-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.68rem;
  color: var(--scene-ink-3);
}
.board-count { font-variant-numeric: tabular-nums; color: var(--scene-amber); }
.flaps { display: flex; gap: clamp(2px, 0.5vw, 5px); }
.flap {
  position: relative;
  flex: none;
  width: var(--fw);
  height: calc(var(--fw) * 1.4);
  perspective: 320px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: calc(var(--fw) * 0.72);
  color: var(--flap-ink);
}
.flap::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: calc(50% - 0.5px);
  height: 1px;
  background: var(--flap-edge);
  z-index: 3;
}
.flap-half, .flap-leaf {
  position: absolute;
  left: 0; right: 0;
  height: 50%;
  overflow: hidden;
  backface-visibility: hidden;
}
.flap-half.top, .flap-leaf.top {
  top: 0;
  border-radius: 4px 4px 0 0;
  background: var(--flap-top);
  transform-origin: 50% 100%;
}
.flap-half.bottom, .flap-leaf.bottom {
  bottom: 0;
  border-radius: 0 0 4px 4px;
  background: var(--flap);
  transform-origin: 50% 0%;
}
.flap-leaf { z-index: 2; }
.flap-leaf.bottom { transform: rotateX(90deg); }
.flap-ch {
  position: absolute;
  left: 0; right: 0;
  height: calc(var(--fw) * 1.4);
  line-height: calc(var(--fw) * 1.4);
  text-align: center;
}
.top .flap-ch { top: 0; }
.bottom .flap-ch { bottom: 0; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.02rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s, color 0.15s;
}
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.08rem; }
.btn-primary { background: var(--red); color: var(--on-red); }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--panel-3); color: var(--ink-3); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-text {
  background: none;
  border: 0;
  padding: 6px 4px;
  color: var(--ink-2);
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-text:hover { color: var(--ink); }

/* ---------- Ballot panel ---------- */

.ballot { position: relative; z-index: 2; margin-top: -56px; padding-bottom: 56px; scroll-margin-top: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(18px, 4vw, 36px);
  box-shadow: 0 40px 90px -50px var(--shadow);
}

.steps {
  display: flex;
  gap: 8px;
  margin: 0 0 clamp(20px, 3vw, 28px);
  padding: 0;
  list-style: none;
}
.steps li {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 10px;
  border-top: 3px solid var(--line);
  font-size: 0.7rem;
  color: var(--ink-3);
}
.steps-n { font-weight: 600; }
.steps li.is-done { color: var(--ink-2); border-top-color: rgba(216, 31, 64, 0.55); }
.steps li[aria-current="step"] { color: var(--ink); border-top-color: var(--red); }

.step-head { display: grid; gap: 6px; margin-bottom: 22px; }
.step-head h2, .closed h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.45rem, 3.4vw, 1.95rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.step-head h2:focus { outline: none; }
.step-head p, .closed p { margin: 0; max-width: 62ch; color: var(--ink-2); }
.prompt strong { color: var(--red-text); font-weight: 600; }

/* Fields */
.fields { display: grid; gap: 18px; }
@media (min-width: 720px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .field-company { grid-column: 1 / -1; }
}
.field { display: grid; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
label, legend { font-size: 0.72rem; color: var(--ink-2); padding: 0; }
legend { margin-bottom: 7px; }
.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--ground-raise);
  color: var(--ink);
  font-size: 1.06rem;
  font-weight: 500;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--red-text); box-shadow: 0 0 0 3px var(--red-wash); }
.input[aria-invalid="true"] { border-color: var(--amber); }
.field-error { margin: 0; color: var(--amber); font-size: 0.92rem; }

.company-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.company {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--ground-raise);
  cursor: pointer;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  transition: border-color 0.15s, background-color 0.15s;
}
.company input { position: absolute; opacity: 0; pointer-events: none; }
.company:hover { border-color: var(--ink-3); }
.company:has(input:focus-visible) { outline: 2px solid var(--red-text); outline-offset: 3px; }
.company:has(input:checked) { border-color: var(--red); background: var(--red-wash); }
.dot { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.dot-jb { background: var(--series-jb); }
.dot-mak { background: var(--series-mak); }
.company-name {
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.02rem, 3vw, 1.2rem);
  line-height: 1.15;
  color: var(--ink);
}
@media (max-width: 480px) {
  .company-choices { grid-template-columns: minmax(0, 1fr); }
  .company { min-height: 60px; }
}
.tick {
  flex: none;
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.company:has(input:checked) .tick {
  border-color: var(--red);
  background: var(--red) radial-gradient(circle, var(--on-red) 0 3.5px, transparent 4px);
}
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
}
.actions-left { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Step 2: the picker ---------- */

.picker { display: grid; gap: 22px; }
@media (min-width: 860px) {
  .picker { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; gap: 28px; }
  .tray-wrap { position: sticky; top: 16px; }
}
.name-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.name-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 66px;
  padding: 10px 10px 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background-color 0.15s, opacity 0.2s;
}
.name-card-label {
  min-width: 0;
  overflow-wrap: break-word;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.98rem, 3.2vw, 1.28rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.name-card .mark {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
}
.name-card:hover:not(:disabled) { border-color: var(--red); background: var(--panel-3); transform: translateY(-2px); }
.name-card:hover:not(:disabled) .mark { border-style: solid; border-color: var(--red); color: var(--red-text); }
.name-card:disabled { cursor: not-allowed; }
.name-card.is-picked { background: var(--ground-raise); color: var(--ink-3); border-style: dashed; }
.name-card.is-picked .mark { border: 0; background: var(--red); color: var(--on-red); }
.name-card:disabled:not(.is-picked) { opacity: 0.4; }

.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tray-head h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
}
.tray { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.slot {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--line-strong);
}
.slot-ord { display: grid; font-family: var(--font-mono); font-weight: 600; font-size: 0.86rem; color: var(--ink-3); line-height: 1.2; }
.slot-pts { font-size: 0.66rem; font-weight: 500; color: var(--ink-3); letter-spacing: 0.04em; }
.slot-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.15;
  color: var(--ink-3);
}
.slot-remove {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.slot-remove:hover { border-color: var(--red); color: var(--red-text); }
.slot.is-filled { border-style: solid; border-color: var(--line); background: var(--panel-2); }
.slot.is-filled .slot-name { color: var(--ink); }
.slot.is-filled .slot-ord > span:first-child { color: var(--red-text); }
.slot.is-next { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-wash); animation: next 1.6s ease-in-out infinite; }
.slot.is-next .slot-name { color: var(--ink-2); font-weight: 500; }
@keyframes next { 50% { box-shadow: 0 0 0 6px rgba(216, 31, 64, 0.05); } }
.slot.just-landed { animation: land 0.6s cubic-bezier(.2, .8, .2, 1); }
@keyframes land {
  0% { transform: scale(0.97); background: var(--red-wash); }
  60% { transform: scale(1.015); }
  100% { transform: scale(1); }
}
.note { margin: 12px 0 0; font-size: 0.88rem; color: var(--ink-3); }

.fly {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--red);
  color: var(--on-red);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  white-space: nowrap;
  box-shadow: 0 12px 30px -10px rgba(216, 31, 64, 0.8);
}

/* ---------- Step 3: the boarding pass ---------- */

.pass {
  --paper: #eef2f7;
  --paper-stub: #e2e8f0;
  --paper-ink: #0f1a2b;
  --paper-ink-2: #4d5b70;
  --paper-line: #c3cedc;
  --paper-red: #b3122f;
  --stamp: #0b7f45;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid var(--pass-edge);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 60px -30px var(--shadow);
}
.pass-band {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 20px;
  background: var(--red);
  color: var(--on-red);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.pass-body { display: grid; gap: 18px; padding: 18px 20px 22px; }
.pass-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.pf-wide { grid-column: 1 / -1; }
.pf { min-width: 0; margin: 0; }
.pf dt, .pass-label {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--paper-ink-2);
}
.pf dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.pass-picks { margin: 4px 0 0; padding: 0; list-style: none; }
.pass-picks li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--paper-line);
}
.pass-picks li:last-child { border-bottom: 0; }
.pp-ord { font-family: var(--font-mono); font-weight: 600; font-size: 0.85rem; color: var(--paper-red); }
.pp-name { font-family: var(--font-display); font-weight: 600; font-size: 1.18rem; line-height: 1.15; overflow-wrap: break-word; }
.pp-pts { font-family: var(--font-mono); font-size: 0.74rem; color: var(--paper-ink-2); font-variant-numeric: tabular-nums; }
.pass-stub {
  position: relative;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  background: var(--paper-stub);
  border-left: 2px dashed var(--paper-line);
}
.pass-stub::before, .pass-stub::after {
  content: "";
  position: absolute;
  left: -12px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--panel);
}
.pass-stub::before { top: -11px; }
.pass-stub::after { bottom: -11px; }
.barcode {
  height: 56px;
  margin-top: 4px;
  background: repeating-linear-gradient(90deg,
    var(--paper-ink) 0 2px, transparent 2px 4px,
    var(--paper-ink) 4px 5px, transparent 5px 8px,
    var(--paper-ink) 8px 11px, transparent 11px 12px,
    var(--paper-ink) 12px 13px, transparent 13px 16px);
  opacity: 0.85;
}
.pass.is-recorded #pass-status { color: var(--stamp); }
.stamp {
  position: absolute;
  right: 224px;
  top: 64px;
  padding: 6px 14px;
  border: 3px solid var(--stamp);
  border-radius: 8px;
  color: var(--stamp);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transform: rotate(-9deg);
  opacity: 0.9;
  animation: stamp 0.45s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes stamp {
  0% { transform: rotate(-9deg) scale(2.2); opacity: 0; }
  100% { transform: rotate(-9deg) scale(1); opacity: 0.9; }
}
@media (max-width: 640px) {
  .pass { grid-template-columns: 1fr; }
  .pass-stub {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-left: 0;
    border-top: 2px dashed var(--paper-line);
  }
  .pass-stub::before, .pass-stub::after { top: -12px; bottom: auto; }
  .pass-stub::before { left: -11px; }
  .pass-stub::after { left: auto; right: -11px; }
  .barcode { grid-column: 1 / -1; height: 40px; }
  .stamp { right: 14px; top: 56px; font-size: 0.9rem; }
}

.alert {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--amber);
  border-radius: var(--r-sm);
  background: var(--amber-wash);
  color: var(--ink);
}
.done { margin-top: 20px; display: grid; gap: 4px; }
.done-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; color: var(--green); }
.done-text { margin: 0; color: var(--ink-2); max-width: 62ch; }

.closed { display: grid; gap: 8px; padding-block: 8px; }

/* ---------- Footer ---------- */

.footer { padding-block: 8px 40px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 4px 24px; color: var(--ink-3); font-size: 0.88rem; }
.footer-inner p { margin: 0; }

/* ---------- Results page ---------- */

.sky-slim {
  background:
    radial-gradient(80% 140% at 85% 0%, var(--scene-glow) 0%, rgba(10, 17, 28, 0) 62%),
    var(--scene-bg);
}
.sky-slim::after { display: none; }
.results-head {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  padding-block: 8px 36px;
}
.results-title { display: grid; gap: 10px; }
.results-title h1 { max-width: none; font-size: clamp(2rem, 5vw, 3.1rem); }
.board-leader { --fw: clamp(21px, 6.9vw, 40px); }
.results-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-bottom: 56px; }
.gate { max-width: 520px; }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 0.92rem; }
.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.chart-panel, .tiles, .chips { min-width: 0; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.updated { margin: 0; font-size: 0.9rem; color: var(--ink-3); }
.dash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 16px 18px; border-radius: var(--r-md); background: var(--panel); border: 1px solid var(--line); }
.tile-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
}
.tile-label .dot { width: 9px; height: 9px; }
.tile-value { margin: 8px 0 0; font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; line-height: 1; letter-spacing: -0.02em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
}
.chip .dot { width: 9px; height: 9px; }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-checked="true"] { background: var(--panel-3); border-color: var(--ink-3); color: var(--ink); }
.chip-n { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.chart-panel { padding: clamp(16px, 3vw, 28px); }
.chart-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.chart-head h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; line-height: 1.15; letter-spacing: -0.01em; }
.chart-sub { margin: 4px 0 0; max-width: 60ch; font-size: 0.92rem; color: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 0.9rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 10px; border-radius: 2px; }
.swatch-jb { background: var(--series-jb); }
.swatch-mak { background: var(--series-mak); }
.legend-ramp { gap: 8px; font-size: 0.8rem; color: var(--ink-3); }
.ramp { display: flex; gap: 2px; }
.ramp span { width: 12px; height: 10px; border-radius: 2px; }

/* Points by name: one grid per row so rows can restack on phones */
.lb { display: grid; gap: 2px; }
.lb-row {
  display: grid;
  grid-template-columns: 26px minmax(96px, 170px) minmax(0, 1fr) 64px;
  grid-template-areas: "rank who track value";
  align-items: center;
  column-gap: 14px;
}
.lb-rank { grid-area: rank; text-align: right; font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem; color: var(--ink-3); }
.lb-who { grid-area: who; display: grid; min-width: 0; }
.lb-name { font-family: var(--font-display); font-weight: 600; font-size: 1.04rem; line-height: 1.15; overflow-wrap: break-word; }
.lb-meta { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-3); }
.lb-track {
  grid-area: track;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  background-image: linear-gradient(90deg, var(--line) 0 1px, transparent 1px);
  background-size: var(--grid, 25%) 100%;
  background-repeat: repeat-x;
  box-shadow: inset 1px 0 0 var(--line-strong);
}
.lb-seg { position: relative; flex: none; height: 18px; min-width: 3px; }
.lb-seg-jb { background: var(--series-jb); }
.lb-seg-mak { background: var(--series-mak); }
.lb-seg.is-end { border-radius: 0 4px 4px 0; }
.lb-seg-label {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--on-red);
  white-space: nowrap;
}
.lb-value { grid-area: value; text-align: right; font-family: var(--font-mono); font-weight: 600; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.lb-axis { height: 22px; }
.lb-ticks { grid-area: track; position: relative; height: 100%; }
.lb-tick {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .lb-row {
    grid-template-columns: 22px minmax(0, 1fr) 60px;
    grid-template-areas: "rank who value" "rank track track";
    column-gap: 10px;
    padding-top: 6px;
  }
  .lb-track { height: 30px; }
  .lb-axis { padding-top: 0; }
}

/* Where each name was ranked */
.hm-scroll { overflow-x: auto; }
.hm { display: grid; grid-template-columns: minmax(84px, 170px) repeat(5, minmax(40px, 1fr)); gap: 3px; }
.hm-col {
  padding-bottom: 4px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.hm-name { align-self: center; padding-right: 8px; font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; overflow-wrap: break-word; }
.hm-cell {
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.hm-cell.on-dark { color: var(--cell-ink-on-dark); }
.hm-cell.on-light { color: var(--cell-ink-on-light); }
.hm-cell.is-zero { background: var(--panel-2); color: var(--ink-3); }

/* Every vote */
.table-scroll { overflow-x: auto; }
.votes { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.votes th {
  padding: 0 14px 10px 0;
  border-bottom: 1px solid var(--line-strong);
  text-align: left;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}
.votes td { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: top; }
.votes td.strong { color: var(--ink); font-weight: 600; white-space: nowrap; }
.votes .num { text-align: right; font-variant-numeric: tabular-nums; }
.votes .dot { display: inline-block; width: 9px; height: 9px; vertical-align: middle; }
.nowrap { white-space: nowrap; }
.badge {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--amber-line);
  background: var(--amber-wash);
  color: var(--amber);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.empty, .empty-cell { color: var(--ink-3); }
.empty { margin: 0; }
.tip {
  position: fixed;
  z-index: 60;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--ground);
  font-size: 0.86rem;
  font-weight: 500;
  pointer-events: none;
  box-shadow: 0 10px 30px -10px var(--shadow);
}

/* Narrow phones: the place badge sits under the name so names never wrap. */
@media (max-width: 480px) {
  .name-card { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; min-height: 76px; padding: 10px 12px; }
  .name-card-label { font-size: 1.02rem; }
  .name-card .mark { min-width: 26px; height: 22px; padding: 0 7px; font-size: 0.72rem; }
}

@media (max-width: 719px) {
  .sky::after {
    background:
      linear-gradient(180deg, rgba(10, 17, 28, 0.9) 0%, rgba(10, 17, 28, 0.62) 50%, rgba(10, 17, 28, 0.2) 75%, var(--scene-bg) 100%);
  }
  .masthead-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
