:root {
  --night: #1a110a;
  --wood: #5a3218;
  --wood-hi: #8a5a30;
  --wood-lo: #3a2010;
  --brass: #e8c040;
  --paper: #f4ead2;
  --ink: #1e130c;
  --red: #9c3a2e;
  --green: #3d7a3a;
  --pixel: 'Silkscreen', 'Courier New', monospace;
  --type: 'VT323', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 52px),
    var(--night);
  color: var(--paper);
  font: 22px/1.25 var(--type);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 50;
  padding: 8px 12px;
  background: var(--paper);
  color: #111;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 4px;
  margin: 0 1px;
  border: 1px solid #8a6a4a;
  border-bottom-width: 3px;
  background: #2a1a0e;
  font: inherit;
  text-align: center;
}

/* ---------- bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 14px;
  background: var(--wood-lo);
  border-bottom: 4px solid var(--wood);
}
.logo {
  margin: 0;
  font: 400 24px var(--pixel);
  color: var(--brass);
  text-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}
.score {
  margin: 0;
  padding: 0 10px;
  min-width: 90px;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px var(--wood);
  font: 400 30px/1.2 var(--type);
  color: var(--brass);
  text-align: right;
}
.streak { margin: 0; }
.pips { display: flex; gap: 6px; }
.pips span {
  width: 22px;
  height: 14px;
  border: 2px solid #6a4a2a;
  border-radius: 6px 6px 2px 2px;
}
.pips span.on { background: var(--brass); border-color: var(--brass); }
.corner { display: flex; gap: 8px; margin-left: auto; }
.corner button, .quit {
  white-space: nowrap;
  padding: 3px 12px;
  border: 2px solid var(--wood-hi);
  background: var(--wood-lo);
  color: var(--paper);
  font: 400 20px var(--type);
  text-decoration: none;
  cursor: pointer;
}
.corner button[aria-pressed='false'] { opacity: 0.6; text-decoration: line-through; }
.quit { border-color: var(--red); }

/* ---------- the hall ---------- */

.hall {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 20px;
  outline: none;
}
.stage {
  position: relative;
  width: min(100%, calc((100dvh - 290px) * 16 / 9), 1200px);
  min-width: min(100%, 360px);
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 0 4px var(--wood), 0 0 0 8px var(--wood-lo), 0 16px 30px rgba(0, 0, 0, 0.6);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.callout {
  position: absolute;
  left: 50%;
  top: 8%;
  margin: 0;
  padding: 2px 12px;
  transform: translateX(-50%);
  background: rgba(30, 19, 12, 0.85);
  color: var(--brass);
  font: 400 clamp(16px, 2.6vw, 26px) var(--pixel);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.callout.show { opacity: 1; }

.tray {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px 18px;
  width: min(100%, 1200px);
}
.hat-buttons {
  display: grid;
  grid-template-columns: repeat(6, 54px);
  gap: 6px;
}
.hat-buttons button {
  position: relative;
  width: 54px;
  height: 46px;
  padding: 0;
  border: 2px solid var(--wood-hi);
  background: #6a3c1c;
  cursor: pointer;
}
.hat-buttons button canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hat-buttons button[aria-pressed='true'] { border-color: var(--brass); background: #8a5a30; box-shadow: 0 0 0 2px var(--brass); }
.hat-buttons button:disabled { opacity: 0.25; cursor: default; }
.hat-buttons button .key {
  position: absolute;
  left: 2px;
  top: 0;
  font: 400 14px var(--type);
  color: var(--paper);
}
.hat-card {
  min-height: 92px;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.hat-name { margin: 0; font: 400 18px var(--pixel); color: var(--red); }
.hat-note { margin: 2px 0 4px; font-size: 22px; }
.hat-link { color: #3a5a6a; font-size: 19px; }
.aim { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 280px; }
.aim-help, .aim-read { margin: 0; font-size: 18px; text-align: right; color: #d8c6a4; }
.aim-read { color: var(--brass); min-height: 1.2em; }

.big {
  padding: 8px 18px;
  border: 0;
  background: var(--brass);
  color: var(--ink);
  font: 400 18px var(--pixel);
  box-shadow: 0 4px 0 #8a6a1a;
  cursor: pointer;
}
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6a1a; }
.big:disabled { opacity: 0.4; cursor: default; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(26, 17, 10, 0.7);
}
.overlay[hidden] { display: none; }
.card {
  width: min(480px, 100%);
  margin: auto;
  padding: 18px 20px 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 4px var(--wood), 8px 8px 0 4px var(--ink);
  text-align: center;
}
.card-title { margin: 0 0 6px; font: 400 30px var(--pixel); color: var(--red); }
.card-sub { margin: 0 0 10px; }
.points {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  text-align: left;
}
.points li { display: flex; justify-content: space-between; border-bottom: 1px dotted #b9a27a; }
.pork { margin: 0 0 10px; color: #6a3c1c; }
.final { margin: 0; font: 400 40px var(--pixel); color: var(--ink); }
.over-line { margin: 0 0 8px; }
.board {
  margin-top: 14px;
  padding: 8px 12px 10px;
  background: var(--wood-lo);
  color: var(--paper);
  text-align: left;
}
.board h2 { margin: 0 0 6px; font: 400 18px var(--pixel); color: var(--brass); text-align: center; }
.board-tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.board-tabs button {
  flex: 1;
  padding: 2px 6px;
  border: 2px solid var(--wood-hi);
  background: transparent;
  color: var(--paper);
  font: 400 19px var(--type);
  cursor: pointer;
}
.board-tabs button[aria-selected='true'] { background: var(--wood-hi); }
.board-list { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.board-list li { display: flex; gap: 8px; border-bottom: 1px dashed rgba(244, 234, 210, 0.2); counter-increment: rank; }
.board-list li::before { content: counter(rank) '.'; width: 1.6em; opacity: 0.6; }
.board-list .who { flex: 1; letter-spacing: 0.15em; }
.board-list li.you { color: var(--brass); }
.board-list li.empty { justify-content: center; opacity: 0.75; }
.board-list li.empty::before { content: none; }
.fine-print { margin: 12px 0 0; font-size: 18px; color: #6a5a48; }
.fine-print a { color: #6a3c1c; }
#initials-form label { display: block; margin-bottom: 6px; }
.initials-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
#initials {
  width: 4.4em;
  padding: 4px 6px;
  border: 3px solid var(--wood);
  background: var(--ink);
  color: var(--brass);
  font: 400 24px var(--pixel);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.form-msg { min-height: 1.2em; margin: 0 0 8px; }

.noscript { padding: 40px; text-align: center; }

/* The share card: just the hall, edge to edge */
.share-card .bar, .share-card .tray { display: none; }
.share-card .hall { padding: 0; height: 100vh; overflow: hidden; }
.share-card .stage { width: 100vw; min-width: 0; margin-top: calc(100vh - 100vw * 9 / 16); box-shadow: none; }

@media (max-width: 900px) {
  .tray { grid-template-columns: 1fr; justify-items: center; }
  .aim { align-items: center; max-width: none; }
  .aim-help, .aim-read { text-align: center; }
}
@media (max-width: 560px) {
  body { font-size: 20px; }
  .bar { flex-wrap: wrap; gap: 6px 10px; padding: 6px 10px; }
  .logo { font-size: 18px; }
  .score { min-width: 70px; font-size: 24px; }
  .pips span { width: 16px; height: 11px; }
  .corner button, .quit { padding: 2px 8px; font-size: 18px; }
  .hat-buttons { grid-template-columns: repeat(6, 48px); }
  .hat-buttons button { width: 48px; height: 42px; }
  .points { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .big:active { transform: none; }
  .callout { transition: none; }
}
