:root {
  --night: #160f12;
  --night-2: #241a1e;
  --cream: #fbf1d9;
  --cherry: #d62839;
  --cherry-deep: #8e1424;
  --teal: #37c0bd;
  --teal-deep: #0f5960;
  --mustard: #f2b33d;
  --pink: #ff5fa2;
  --chrome: #c9d1d5;
  --chalk: #f3f1ea;
  --board: #24302b;
  --sign: 'Bungee', 'Arial Black', sans-serif;
  --script: 'Pacifico', cursive;
  --body: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--cream);
  font-family: var(--body);
  font-size: 17px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 95, 162, 0.18), transparent 55%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 60px),
    linear-gradient(var(--night), #0d0809);
}

.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;
}

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

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

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--body);
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- marquee ---------- */

.marquee {
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas: 'logo score callout' 'logo score ticket';
  align-items: center;
  gap: 2px 22px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 150px 8px 16px;
}
.logo {
  grid-area: logo;
  margin: 0;
  font-family: var(--script);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.1;
  color: #ffe3f0;
  text-shadow: 0 0 6px var(--pink), 0 0 18px var(--pink), 0 0 36px rgba(255, 95, 162, 0.6);
  white-space: nowrap;
}
.scoreboard {
  grid-area: score;
  min-width: 170px;
  padding: 4px 14px 6px;
  border: 2px solid var(--chrome);
  border-radius: 10px;
  background: #0b0708;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.9), 0 0 0 4px #3a2c31;
  text-align: right;
}
.score {
  margin: 0;
  font-family: var(--sign);
  font-size: 30px;
  line-height: 1.1;
  color: var(--mustard);
  text-shadow: 0 0 10px rgba(242, 179, 61, 0.55);
  font-variant-numeric: tabular-nums;
}
.ballno {
  margin: 0;
  font-family: var(--sign);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--teal);
}
.callout {
  grid-area: callout;
  margin: 0;
  min-height: 1.3em;
  font-family: var(--sign);
  font-size: 18px;
  line-height: 1.25;
  color: var(--cream);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
}
.callout.big { color: var(--mustard); }
.callout.rush { color: var(--pink); text-shadow: 0 0 10px var(--pink); }
.callout.order { color: #9ff3ee; }
.callout.night { color: #7dff9c; text-shadow: 0 0 10px rgba(125, 255, 156, 0.7); }
.callout.jukebox { color: #ffc2de; }

.ticket {
  grid-area: ticket;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  justify-self: start;
  max-width: 100%;
  padding: 4px 10px 6px;
  background: #fffbe9;
  color: #2a2220;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  position: relative;
}
.ticket[hidden] { display: none; }
.ticket-name {
  margin: 0;
  font-weight: 700;
  font-size: 17px;
}
.ticket-no {
  font-family: var(--sign);
  font-size: 11px;
  color: var(--cherry);
}
.ticket-items {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-weight: 600;
}
.ticket-items li::before { content: '\2610\00a0'; }
.ticket-items li.done { color: #6b625e; text-decoration: line-through; }
.ticket-items li.done::before { content: '\2611\00a0'; color: var(--cherry); }
.ticket-items li.next { color: var(--cherry-deep); }
.ticket-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
}
.ticket-timer span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--cherry);
  transform-origin: left;
}

/* ---------- floor ---------- */

.floor {
  display: grid;
  grid-template-columns: minmax(200px, 270px) auto minmax(200px, 270px);
  grid-template-areas: 'menu cabinet board';
  justify-content: center;
  align-items: start;
  gap: 22px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 4px 16px 24px;
}

.cabinet {
  grid-area: cabinet;
  position: relative;
  outline: none;
}
.glass {
  position: relative;
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(90deg, #8a949a, #eef2f3 18%, #9aa4aa 50%, #eef2f3 82%, #8a949a);
  box-shadow: 0 0 0 3px #2a1d21, 0 18px 40px rgba(0, 0, 0, 0.6), 0 0 60px rgba(255, 95, 162, 0.15);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#table {
  display: block;
  border-radius: 8px;
  background: #2a1712;
}

.overlay {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 8px;
  background: rgba(14, 8, 10, 0.55);
}
.overlay[hidden] { display: none; }
.card {
  width: min(320px, 100%);
  padding: 20px 18px 18px;
  border: 3px solid var(--chrome);
  border-radius: 16px;
  background: var(--cherry-deep);
  background: linear-gradient(180deg, var(--cherry), var(--cherry-deep));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 0 3px rgba(255, 255, 255, 0.15);
  text-align: center;
}
.card-script {
  margin: 0;
  font-family: var(--script);
  font-size: 42px;
  line-height: 1.2;
  color: #fff3f8;
  text-shadow: 0 0 8px var(--pink), 0 0 20px var(--pink);
}
.card-sub, .card-hint {
  margin: 4px 0 14px;
  font-size: 17px;
}
.card-hint { margin: 14px 0 0; font-size: 15px; line-height: 1.5; }
.card-title {
  margin: 0 0 8px;
  font-family: var(--sign);
  font-size: 22px;
}
.final {
  margin: 0 0 14px;
  font-family: var(--sign);
  font-size: 34px;
  color: var(--mustard);
}
button, .quit {
  font: inherit;
  cursor: pointer;
}
.big {
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--cherry-deep);
  font-family: var(--sign);
  font-size: 16px;
  box-shadow: 0 4px 0 #5c0d17;
}
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #5c0d17; }

#initials-form label { display: block; margin-bottom: 8px; font-size: 17px; }
.initials-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 6px; }
#initials {
  width: 4.2em;
  padding: 6px 8px;
  border: 3px solid var(--chrome);
  border-radius: 8px;
  background: var(--board);
  color: var(--chalk);
  font-family: var(--sign);
  font-size: 24px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.form-msg { min-height: 1.3em; margin: 0 0 10px; font-size: 15px; }
#initials-form:not([hidden]) + #btn-again { margin-top: 2px; }

/* The ticket rail over the pass (table units 404–492 × 270–374): clickable between games */
.rail-spot {
  position: absolute;
  z-index: 3;
  left: calc(8px + (100% - 16px) * 0.6733);
  top: calc(8px + (100% - 16px) * 0.2455);
  width: calc((100% - 16px) * 0.1467);
  height: calc((100% - 16px) * 0.0945);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.rail-spot:hover { background: rgba(255, 241, 217, 0.12); box-shadow: 0 0 0 2px rgba(255, 241, 217, 0.4); }
.rail-spot[hidden] { display: none; }
.rail-ticket {
  width: min(420px, calc(100vw - 32px));
  padding: 20px 20px 18px;
  border: 0;
  background: #fffbe9;
  color: #2a2220;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
  font-size: 17px;
}
.rail-ticket::backdrop { background: rgba(14, 8, 10, 0.7); }
.rail-ticket h2 { margin: 0 0 8px; font-family: var(--sign); font-weight: 400; font-size: 18px; color: var(--cherry); }
.rail-ticket p { margin: 0 0 12px; }
.pad-numbers {
  font-family: 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.6;
  word-spacing: 0.3em;
}
.rail-ticket .big { background: var(--cherry-deep); color: var(--cream); box-shadow: 0 4px 0 #5c0d17; }

.touch-hint {
  display: none;
  justify-content: space-between;
  padding: 6px 4px 0;
  font-size: 13px;
  color: rgba(251, 241, 217, 0.6);
}

/* ---------- menu card ---------- */

.menu-card {
  grid-area: menu;
  padding: 18px 18px 14px;
  border-radius: 12px;
  background: #fff8e8;
  color: #2a2220;
  box-shadow: 0 0 0 4px var(--chrome), 0 12px 26px rgba(0, 0, 0, 0.5);
  font-size: 16px;
  line-height: 1.35;
}
.menu-card h2, .menu-card h3 {
  margin: 0 0 8px;
  font-family: var(--sign);
  font-weight: 400;
  font-size: 18px;
  color: var(--cherry);
}
.menu-card h3 { margin-top: 16px; font-size: 15px; }
.keys { margin: 0; }
.keys div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dotted #c9b9a0; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; text-align: right; }
.menu-card kbd { border-color: #8d7f72; background: #fff; color: #2a2220; }
.touch-only { display: none; margin: 8px 0 0; }
.menu-list { margin: 0; padding: 0; list-style: none; }
.menu-list li { padding: 5px 0; border-bottom: 1px dotted #c9b9a0; }
.menu-list b { display: block; font-size: 17px; }
.fine-print {
  margin: 14px 0 0;
  font-size: 13px;
  color: #6b5d55;
}
.fine-print a { color: var(--cherry-deep); white-space: nowrap; }

/* ---------- chalkboard ---------- */

.chalkboard {
  grid-area: board;
  padding: 16px 18px 14px;
  border: 10px solid #6b4a2f;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.06), transparent 60%),
    var(--board);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.5);
  color: var(--chalk);
}
.chalkboard h2 {
  margin: 0 0 8px;
  font-family: var(--script);
  font-weight: 400;
  font-size: 26px;
  text-align: center;
}
.board-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.board-tabs button {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid rgba(243, 241, 234, 0.4);
  border-radius: 6px;
  background: transparent;
  color: var(--chalk);
  font-weight: 600;
}
.board-tabs button[aria-selected='true'] { background: rgba(243, 241, 234, 0.15); border-color: var(--chalk); }
.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  font-size: 19px;
}
.board-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 2px;
  border-bottom: 1px dashed rgba(243, 241, 234, 0.2);
  counter-increment: rank;
}
.board-list li::before { content: counter(rank) '.'; width: 1.6em; opacity: 0.6; }
.board-list li .who { flex: 1; font-family: var(--sign); letter-spacing: 0.12em; }
.board-list li .pts { font-variant-numeric: tabular-nums; }
.board-list li.you { color: var(--mustard); }
.board-list li.empty { justify-content: center; opacity: 0.7; }
.board-list li.empty::before { content: none; }
.best { margin: 10px 0 0; font-size: 15px; text-align: center; opacity: 0.85; }

/* ---------- corner ---------- */

.corner {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 6px;
}
.corner button, .quit {
  padding: 6px 12px;
  border: 2px solid var(--chrome);
  border-radius: 999px;
  background: rgba(22, 15, 18, 0.85);
  color: var(--cream);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.corner button[aria-pressed='false'] { opacity: 0.6; text-decoration: line-through; }
.quit { border-color: var(--cherry); }

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

/* ---------- smaller screens ---------- */

@media (max-width: 1080px) {
  .floor {
    grid-template-columns: auto minmax(220px, 280px);
    grid-template-areas: 'cabinet board' 'cabinet menu';
  }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .marquee {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'score callout' 'ticket ticket';
    gap: 4px 10px;
    padding: 8px 10px 6px;
  }
  .logo { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .scoreboard { min-width: 120px; padding: 2px 10px 4px; }
  .score { font-size: 22px; }
  .callout { font-size: 14px; }
  .ticket { padding: 3px 8px 5px; }
  .ticket-name { font-size: 15px; }
  .ticket-items { font-size: 14px; }
  .floor {
    grid-template-columns: 1fr;
    grid-template-areas: 'cabinet' 'board' 'menu';
    gap: 18px;
    padding: 0 10px 24px;
  }
  .cabinet { justify-self: center; }
  .glass { padding: 5px; }
  .overlay { inset: 5px; }
  .corner { position: static; justify-content: center; padding: 0 10px 28px; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-hint { display: flex; }
  .touch-only { display: block; }
}

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