/* ------------------------------------------------------------------ *
 * Host screen — the big display.
 *
 * One monospace face, hard rules, no radius, no shadow, no gradient.
 * State is shown by inversion (ink block, paper text), never by tint.
 * ------------------------------------------------------------------ */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.35 var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

h1, h2, dl, dd, dt, ol, p, figure, figcaption { margin: 0; padding: 0; }
ol { list-style: none; }

/* The whole page is one ruled grid. */
.frame {
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    'mast  mast'
    'join  stage'
    'stream stream';
  height: 100%;
  border-top: 3px solid var(--rule);
}

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

.mast {
  grid-area: mast;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gut);
  padding: 10px var(--gut);
  border-bottom: var(--rule-w) solid var(--rule);
}

.mast h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
/* Hyphens recede so the words read as one lockup. */
.mast h1 span { color: var(--ink-3); }

.readouts { display: flex; gap: 6px; }

.rd {
  padding: 2px 7px;
  font-size: 12px;
  color: var(--ink-2);
  border: var(--rule-w) solid var(--rule-2);
  text-decoration: none;
  white-space: nowrap;
}
a.rd:hover { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.rd.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.rd.alert { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* ---------------- Join column ---------------- */

.col-join {
  grid-area: join;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--gut);
  border-right: var(--rule-w) solid var(--rule);
}

/* Registration corners instead of a card: the QR sits in the page. */
.qr {
  position: relative;
  padding: 10px;
  border: var(--rule-w) solid var(--rule);
}
.qr::before,
.qr::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  border: 2px solid var(--ink);
}
.qr::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.qr::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.qr img {
  display: none;
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated; /* keep the modules crisp when upscaled */
}
.qr img.ready { display: block; }

.qr figcaption {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper-3);
}
.qr figcaption[hidden] { display: none; }

/* The room code is the one piece of this screen people read from a sofa. */
.room { margin-top: 16px; }
.room-label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
}
#roomCode {
  display: block;
  margin-top: 2px;
  color: var(--signal-red);
  font-size: clamp(42px, 4.6vw, 66px);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0.04em;
}

/* Dot leaders — a mono convention, and better than another tiny caps label. */
.spec { margin-top: 12px; }
.spec-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 2px 0;
  font-size: 12px;
}
.spec-row dt { flex: none; color: var(--ink-2); }
.spec-row .lead {
  flex: 1;
  align-self: center;
  height: 0;
  border-bottom: 1px dotted var(--ink-3);
}
.spec-row dd {
  flex: none;
  max-width: 72%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addr { color: var(--ink); }

.btn {
  width: 100%;
  margin-top: 12px;
  padding: 7px;
  font: 400 13px var(--mono);
  color: var(--ink);
  background: transparent;
  border: var(--rule-w) solid var(--rule);
  border-radius: 0;
  cursor: pointer;
}
.btn:hover { color: var(--paper); background: var(--ink); }
.btn:active { transform: translate(1px, 1px); }
.btn-sm { width: auto; margin: 0; padding: 2px 8px; font-size: 12px; }

/* ---------------- Roster ---------------- */

.players {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 18px;
  padding-top: 10px;
  border-top: var(--rule-w) solid var(--rule);
}

.players h2 {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.players .count { color: var(--ink); font-weight: 700; }

.roster { flex: 1; overflow-y: auto; min-height: 0; }

.roster li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  font-size: 14px;
  line-height: 1.5;
}
.roster li:nth-child(odd) { background: var(--paper-2); }
.roster li.off { color: var(--ink-3); }
.roster li.off .swatch { opacity: 0.35; }

.roster .tag { font-weight: 700; color: var(--ink-2); }
.roster .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.roster .ms { font-size: 12px; color: var(--ink-2); }
.roster .x {
  padding: 0 4px;
  font: 400 12px var(--mono);
  color: var(--ink-3);
  background: none;
  border: 0;
  cursor: pointer;
  visibility: hidden;
}
.roster li:hover .x { visibility: visible; }
.roster .x:hover { color: var(--paper); background: var(--ink); }

/* A press inverts the row for a beat — reads instantly from across a room. */
.roster li.hit { color: var(--paper); background: var(--ink); }
.roster li.hit .tag,
.roster li.hit .ms { color: var(--paper); }

.empty { padding: 8px 4px; font-size: 13px; color: var(--ink-2); }
.empty[hidden] { display: none; }

/* ---------------- Mode selector ---------------- */

.col-stage {
  grid-area: stage;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  min-width: 0;
}

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px var(--gut);
  border-bottom: var(--rule-w) solid var(--rule);
}

.modes button {
  padding: 4px 10px;
  font: 400 13px var(--mono);
  color: var(--ink);
  background: transparent;
  border: var(--rule-w) solid var(--rule-2);
  border-radius: 0;
  cursor: pointer;
}
.modes button:hover { border-color: var(--ink); }
.modes button.on {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 700;
}

/* ---------------- Stage ---------------- */

/* Column, so the head keeps its height and the body takes the rest. Children
   that used height:100% would otherwise overflow by the height of the head. */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--gut);
  overflow: hidden;
}
.stage > .tbl,
.stage > .meters,
.stage > .arena,
.stage > .deck,
.stage > .mix,
.stage > .wall,
.stage > .react { flex: 1; min-height: 0; }
.stage > .tbl,
.stage > .meters { flex: 0 0 auto; }

.stage-head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: var(--rule-w) solid var(--rule);
}
.stage-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.stage-head .note { font-size: 12px; color: var(--ink-2); }

.acts { display: flex; gap: 5px; }

.hint {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--ink-2);
  text-align: center;
  pointer-events: none;
}
.hint[hidden] { display: none; }

/* -- table, the workhorse of every stage -- */

.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  padding: 0 8px 4px 0;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-2);
  text-align: left;
  border-bottom: var(--rule-w) solid var(--rule-2);
}
.tbl td {
  padding: 6px 8px 6px 0;
  font-size: 24px;
  border-bottom: var(--rule-w) solid var(--rule-2);
  vertical-align: middle;
}
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .tag { font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.tbl .tag .swatch { margin-right: 7px; vertical-align: -1px; }
.tbl tr.lead td { font-weight: 700; }

/* -- buzzer -- */

.buzz-state {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 15px;
}
.buzz-state .lamp {
  width: 11px;
  height: 11px;
  border: 2px solid var(--ink);
  background: transparent;
}
.buzz-state.armed .lamp { background: var(--amber); border-color: var(--amber); }
.buzz-state.armed b { color: var(--amber); }
.buzz-state.locked .lamp { background: var(--ink); }

.rank { font-weight: 700; color: var(--ink-2); width: 2.5em; }
.first { color: var(--amber); font-weight: 700; }

/* -- vote meters --
   Hard-edged fills, 2px paper gap between segments, direct labels. */

.meters { display: flex; flex-direction: column; gap: 10px; }
.meter-row {
  display: grid;
  grid-template-columns: 2.2em 1fr 4.5em;
  align-items: center;
  gap: 10px;
}
.meter-key { font-size: 22px; font-weight: 700; }
.meter-track {
  position: relative;
  height: 30px;
  background: var(--paper-3);
  border: var(--rule-w) solid var(--rule-2);
}
.meter-fill {
  height: 100%;
  width: 0;
  transition: width 200ms steps(12, end); /* stepped, not eased */
}
.meter-faces {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px; /* the surface gap between adjacent fills */
  padding: 0 4px;
}
.meter-faces .swatch { width: 16px; height: 16px; }
.meter-count { font-size: 22px; font-weight: 700; text-align: right; }
.meter-total { margin-top: 12px; font-size: 12px; color: var(--ink-2); }

/* -- arena -- */

.arena { position: relative; }
.arena canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: var(--rule-w) solid var(--rule-2);
}

/* -- deck -- */

.deck { display: grid; grid-template-rows: 1fr auto; gap: 12px; }
.slide {
  display: grid;
  place-items: center;
  padding: 24px;
  border: 2px solid var(--ink);
}
.slide.black { background: var(--ink); }
.slide h4 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 46px);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  letter-spacing: -0.01em;
}
.slide.black h4 { color: var(--ink); } /* hidden on purpose */
.deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
}
.ticks { display: flex; gap: 3px; }
.ticks i { width: 16px; height: 6px; background: var(--paper-3); border: var(--rule-w) solid var(--rule-2); }
.ticks i.on { background: var(--ink); border-color: var(--ink); }

/* -- reactions -- */

.react { position: relative; }
.react-tally { display: flex; flex-wrap: wrap; gap: 18px; font-size: 26px; }
.react-tally b { font-size: 20px; margin-left: 6px; }
.floater {
  position: absolute;
  bottom: 0;
  font-size: 34px;
  pointer-events: none;
  will-change: transform, opacity;
}

/* -- mixer -- */

.mix { overflow-y: auto; }
.mix .bar { height: 18px; background: var(--paper-3); border: var(--rule-w) solid var(--rule-2); }
.mix .bar i { display: block; height: 100%; width: 0; }
.mix td { font-size: 15px; }

/* -- text wall -- */

.wall {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  align-content: start;
}
.note {
  padding: 10px 12px;
  border: var(--rule-w) solid var(--rule);
  border-left-width: 5px;
}
.note .who { font-size: 11px; color: var(--ink-2); margin-bottom: 4px; }
.note .what { font-size: 17px; word-break: break-word; }

/* ---------------- Input stream ---------------- */

.stream {
  grid-area: stream;
  display: grid;
  grid-template-rows: auto 132px;
  border-top: var(--rule-w) solid var(--rule);
}

.stream-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px var(--gut);
  border-bottom: var(--rule-w) solid var(--rule-2);
}
.stream-head h2 {
  flex: 1;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}

.log {
  overflow-y: auto;
  padding: 6px var(--gut) 10px;
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--paper-2);
}
.log div { white-space: nowrap; }
.log .t { color: var(--ink-3); }
.log .n { font-weight: 700; }
.log .c { color: var(--amber); }
.log .v { color: var(--ink-2); }

/* A live terminal has a cursor. */
.log::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--ink);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------------- Narrow ---------------- */

@media (max-width: 900px) {
  .frame {
    grid-template-columns: 1fr;
    grid-template-areas: 'mast' 'join' 'stage' 'stream';
    grid-template-rows: auto auto 1fr auto;
    overflow-y: auto;
  }
  .col-join { border-right: 0; border-bottom: var(--rule-w) solid var(--rule); }
  body { overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
