/* Design notes: the screen is projected in a lit classroom, so the interface
   stays near monochrome and every colour belongs to a team. The board is the
   only dark object on the page, framed like a monitor set into a panel, and it
   stays dark in both themes because it is a screen inside the screen. */

:root {
  --ground: #e4e7eb;
  --panel: #f6f7f9;
  --panel-sunk: #eceff2;
  --line: #cbd2da;
  --line-soft: #dde2e8;
  --ink: #16202e;
  --ink-soft: #5a6675;
  --ink-faint: #8b95a2;
  --alert: #c0392b;
  --alert-wash: #f3dedb;
  --live: #2e7d5b;
  --board-bg: #121a24;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c1219;
    --panel: #141c25;
    --panel-sunk: #101821;
    --line: #33424f;
    --line-soft: #1d2833;
    --ink: #e4e9ee;
    --ink-soft: #93a0ae;
    --ink-faint: #6a7684;
    --alert: #e4705f;
    --alert-wash: #35201d;
    --live: #4fb287;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* An element with an explicit display wins over the user-agent rule for
   [hidden], and every panel here sets one. Toggling .hidden in JS would work
   too, but this keeps the attribute meaningful. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace; }

.screen {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding-block: 10px;
  padding-inline: 16px;
  max-width: 1800px;
  margin-inline: auto;
}

/* ---- header ---- */
.bar {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.wordmark {
  font-size: clamp(20px, 1.9vw, 30px);
  font-weight: 700;
  font-stretch: 88%;
  letter-spacing: -0.015em;
  margin: 0;
}
.wordmark a { color: inherit; text-decoration: none; }
.round { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bar .spacer { flex: 1 1 auto; }
.clock { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.clock .turn { font-size: clamp(20px, 1.9vw, 30px); font-weight: 600; }
.clock .of { color: var(--ink-faint); }

.chip {
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: var(--panel-sunk);
  font-size: 13px;
  color: var(--ink-soft);
}
.chip b { color: var(--ink); font-weight: 600; }
.chip.imminent { border-color: var(--alert); background: var(--alert-wash); color: var(--alert); }
.chip.imminent b { color: var(--alert); }
.chip.offline { border-color: var(--alert); color: var(--alert); }

/* ---- stage ---- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 400px);
  gap: 10px;
  min-height: 0;
}
.board-col { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; min-height: 0; }
.board-wrap {
  background: var(--board-bg);
  border: 1px solid var(--line);
  min-height: 0;
  overflow: hidden;
  position: relative;
}
#board { display: block; width: 100%; height: 100%; }

.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #8895a4;
  padding: 24px;
}
.waiting h2 { color: #e4e9ee; font-size: clamp(20px, 2.4vw, 32px); margin: 0 0 8px; font-stretch: 85%; }
.waiting p { margin: 0; max-width: 46ch; }
.waiting code { color: #f2a03d; }

/* the rules live on screen: nobody should have to remember them */
.rules-strip {
  display: flex;
  gap: clamp(14px, 2.5vw, 40px);
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: clamp(12px, 1vw, 14px);
  color: var(--ink-soft);
}
.rules-strip > div { display: flex; align-items: center; gap: 9px; }
.rules-strip b { color: var(--ink); font-weight: 600; }
.glyph { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.dot { width: 13px; height: 13px; border-radius: 50%; background: #f2a03d; }
.dot.b { background: #2fb8c6; }
.zone-glyph { width: 9px; height: 22px; border: 1.5px dashed var(--alert); }

/* ---- side ---- */
.side { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; min-height: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel > h2 {
  margin: 0;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.panel > h2 span { font-weight: 400; color: var(--ink-faint); }

table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  text-align: right;
  padding: 6px 14px 4px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
tbody td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
tbody tr:last-child td { border-bottom: 0; }
td.rank { color: var(--ink-faint); text-align: left; width: 1%; }
td.team { text-align: left; }
.team-cell { display: flex; align-items: center; gap: 8px; }
.pip {
  width: 19px; height: 19px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #101820;
  flex: 0 0 auto;
}
.team-name { font-weight: 500; font-stretch: 88%; }
.ver { font-size: 12px; color: var(--ink-soft); padding: 1px 5px; transition: background-color .6s; }
.ver.bump { background: var(--live); color: #fff; }
.score { font-weight: 600; font-size: 16px; }
.alive { color: var(--ink-soft); }
.alive.none { color: var(--alert); }
.up { font-size: 13px; color: var(--ink-soft); }
.up.hurt { color: var(--alert); font-weight: 600; }
tr.offline .team-name { color: var(--ink-faint); text-decoration: line-through; }
tr.offline .pip { opacity: .35; }

.feed { overflow: hidden; }
.feed ol { margin: 0; padding: 6px 0; list-style: none; overflow-y: auto; flex: 1; font-size: 13px; }
.feed li { display: grid; grid-template-columns: 42px 1fr; gap: 10px; padding: 3px 14px; align-items: baseline; }
.feed .at { color: var(--ink-faint); font-size: 12px; }
.feed .what strong { font-weight: 600; font-stretch: 88%; }
.feed li.ev-alert .what { color: var(--alert); }
.feed li.ev-ship .what strong { color: var(--live); }
.feed li.ev-rule .what { font-weight: 600; }

.empty { padding: 14px; color: var(--ink-faint); font-size: 13px; }

/* ---- footer ---- */
.footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--panel-sunk);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink-faint);
}
.footer .spacer { flex: 1 1 auto; }
.footer a { color: var(--ink-soft); }

/* ---- controls (admin) ---- */
button, .btn {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--ink-soft); }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
.group { display: inline-flex; }
.group button + button { margin-left: -1px; }

/* ---- mutation banner ---- */
.mutation[hidden] { display: none; }
.mutation {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 18, 25, .62);
  z-index: 10;
  animation: fade .25s ease-out;
}
.mutation .card {
  background: var(--alert);
  color: #fff;
  padding: 26px clamp(24px, 5vw, 64px);
  max-width: min(92vw, 760px);
  animation: slam .32s cubic-bezier(.2, .9, .3, 1);
}
.mutation .kicker { font-size: 14px; opacity: .85; }
.mutation h3 {
  margin: 4px 0 8px;
  font-size: clamp(30px, 5vw, 58px);
  font-weight: 700;
  font-stretch: 82%;
  letter-spacing: -0.02em;
  line-height: 1;
  text-wrap: balance;
}
.mutation p { margin: 0; font-size: clamp(15px, 1.5vw, 19px); max-width: 52ch; }
@keyframes fade { from { opacity: 0; } }
@keyframes slam { from { transform: scale(.94); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .mutation, .mutation .card { animation: none; }
  .ver { transition: none; }
}

@media (max-width: 900px) {
  .screen { height: auto; min-height: 100%; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .board-wrap { aspect-ratio: 13 / 8; max-width: 100%; }
  .rules-strip { flex-direction: column; gap: 8px; }
  .side { grid-template-rows: auto auto; }
  .feed ol { max-height: 230px; }
}
