/* Double Top: page layout, the TV-style scoreboard, the title and result screens. Warm dark glass
   with a brass hairline over a fire-lit pub. */
:root {
  --ink: #110b07;
  --cream: #f5e8cc;
  --muted: rgba(245, 232, 204, 0.66);
  --brass: #d6a65a;
  --brass-deep: #9b6d2c;
  --red: #d8432f;
  --green: #3aa56a;
  --glass: rgba(16, 10, 7, 0.74);
  --line: rgba(214, 166, 90, 0.42);
  --ui: var(--kit-grotesk);
  --display: var(--kit-serif);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.defs { position: absolute; }

html, body {
  margin: 0;
  height: 100%;
  background: #0c0806;
  color: var(--cream);
  font: 500 15px/1.35 var(--ui);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; }
#game { position: absolute; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; cursor: none; }
.screen-title:not([hidden]) ~ #game canvas, .is-capturing #game canvas { cursor: default; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* The scoreboard, top left: a broadcast caption in brass and glass. */
.hud {
  position: absolute;
  top: max(2.4vh, env(safe-area-inset-top));
  left: max(2vw, 18px);
  right: max(2vw, 18px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-size: clamp(13px, 1.12vw, 20px);
}
.cards {
  display: grid;
  min-width: 17em;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 0.7em;
  box-shadow: 0 0.6em 2em rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.card {
  display: grid;
  grid-template-columns: 0.9em 1fr auto auto;
  grid-template-areas: "dot name pips left" ". out out out";
  align-items: center;
  column-gap: 0.7em;
  padding: 0.55em 0.95em 0.55em 0.7em;
  position: relative;
}
.card + .card { border-top: 1px solid rgba(214, 166, 90, 0.18); }
.card::before {
  content: "";
  grid-area: dot;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: rgba(245, 232, 204, 0.15);
}
.card.active { background: linear-gradient(90deg, rgba(214, 166, 90, 0.2), rgba(214, 166, 90, 0)); }
.card.active::before { background: var(--brass); box-shadow: 0 0 0.6em var(--brass); }
.card .name { grid-area: name; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78em; color: var(--muted); }
.card.active .name { color: var(--cream); }
.card .left { grid-area: left; font-weight: 750; font-size: 1.85em; line-height: 1; min-width: 2.2em; text-align: right; letter-spacing: -0.02em; }
.card .pips { grid-area: pips; display: inline-flex; gap: 0.18em; color: var(--brass); }
.card .pips svg { width: 0.42em; height: 1.4em; }
.card .pips svg.used { opacity: 0.18; }
.card[data-player="1"] .pips { color: #e0654c; }
.card .out { grid-area: out; font-size: 0.74em; letter-spacing: 0.08em; color: var(--brass); font-weight: 600; text-transform: uppercase; }
.card .out:empty { display: none; }
.card .out b { color: var(--cream); font-weight: 700; letter-spacing: 0.04em; margin-left: 0.4em; }

.leg { display: flex; flex-direction: column; align-items: flex-end; gap: 0.45em; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  height: 2.1em;
  padding: 0 1em;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  font-weight: 650;
  font-size: 0.82em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.chip b { font-weight: 600; color: var(--muted); }
.chip.visit .num { font-size: 1.3em; letter-spacing: 0; color: var(--cream); font-weight: 750; }

/* The aim: a fine ring that breathes with the hand. */
.reticle {
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 246, 228, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 220, 160, 0.35);
  pointer-events: none;
  will-change: transform;
}
.reticle i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fff6e4; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.reticle.grip { border-color: var(--brass); width: 22px; height: 22px; margin: -11px 0 0 -11px; transition: width 0.25s, height 0.25s, margin 0.25s; }

/* What a dart scored, beside it. */
.pop {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(22px, -50%);
  padding: 0.35em 0.8em 0.4em;
  border-radius: 0.5em;
  font: 750 clamp(15px, 1.35vw, 24px)/1 var(--ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(16, 10, 7, 0.82);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
}
.pop small { display: block; font-size: 0.62em; letter-spacing: 0.18em; color: var(--muted); margin-top: 0.3em; font-weight: 600; }
.pop.treble { background: rgba(150, 30, 20, 0.88); border-color: rgba(255, 140, 110, 0.6); }
.pop.double { background: rgba(20, 100, 55, 0.88); border-color: rgba(140, 240, 180, 0.55); }
.pop.bull { background: rgba(150, 105, 30, 0.9); border-color: rgba(255, 220, 150, 0.7); }
.pop.on { animation: pop 1.25s cubic-bezier(0.2, 0.9, 0.2, 1) forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(10px, -50%) scale(0.7); }
  12% { opacity: 1; transform: translate(26px, -50%) scale(1.06); }
  24% { transform: translate(24px, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(24px, -95%) scale(1); }
}

/* A caller's shout across the room. */
.call {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font: 700 clamp(34px, 4.6vw, 86px)/1.05 var(--display);
  font-style: italic;
  text-align: center;
  color: #fff3dc;
  text-shadow: 0 0.04em 0 var(--brass-deep), 0 0 0.6em rgba(255, 190, 100, 0.55), 0 0.15em 0.6em rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.call.bust { color: #ffd9cf; text-shadow: 0 0.04em 0 #7a1d12, 0 0 0.6em rgba(255, 80, 50, 0.6), 0 0.15em 0.6em rgba(0, 0, 0, 0.6); font-style: normal; letter-spacing: 0.12em; text-transform: uppercase; }
.call.on { animation: call 1.6s cubic-bezier(0.2, 0.9, 0.2, 1) forwards; }
@keyframes call {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  26% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.3vh;
  padding: 24px;
  text-align: center;
}
.screen p { margin: 0; }
.screen-title {
  background:
    radial-gradient(ellipse 58% 56% at 50% 48%, rgba(10, 6, 4, 0.72), rgba(10, 6, 4, 0.25) 70%, rgba(10, 6, 4, 0.05) 100%);
}
.kicker { font-size: clamp(12px, 1.02vw, 17px); letter-spacing: 0.32em; text-transform: uppercase; color: var(--brass); font-weight: 650; }
.screen-title h1 {
  margin: 0.1em 0 0.15em;
  font: 700 clamp(58px, 8.6vw, 156px)/1.08 var(--display);
  letter-spacing: -0.01em;
  color: #fff4dc;
  text-shadow: 0 0.03em 0 var(--brass-deep), 0 0.2em 0.7em rgba(0, 0, 0, 0.7), 0 0 1.2em rgba(255, 170, 80, 0.3);
}
.tagline { font-size: clamp(15px, 1.35vw, 22px); max-width: 32em; color: rgba(245, 232, 204, 0.9); }
.keys { color: var(--muted); font-size: clamp(12px, 0.92vw, 15px); max-width: 52em; }
.meta { color: var(--brass); font-size: clamp(12px, 0.88vw, 14px); letter-spacing: 0.1em; text-transform: uppercase; }
.meta span + span::before { content: "· "; color: var(--muted); }
.meta span:empty, .meta span:empty + span::before { display: none; }
.facts { color: rgba(245, 232, 204, 0.45); font-size: clamp(11px, 0.8vw, 13px); letter-spacing: 0.04em; margin-top: 1vh !important; }
.loading { font-size: 17px; letter-spacing: 0.08em; color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

#app > .panel {
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: min(460px, 88vw);
  padding: 34px 44px 32px;
  border-radius: 18px;
  background: linear-gradient(to bottom, rgba(30, 20, 13, 0.86), rgba(14, 9, 6, 0.9));
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.panel h2 { margin: 0 0 6px; font: 700 clamp(28px, 3vw, 48px)/1.1 var(--display); font-style: italic; }
.big { font-size: clamp(19px, 1.8vw, 28px); font-weight: 700; color: var(--brass); }

.cta {
  margin-top: 1.6vh;
  font: inherit;
  font-size: clamp(14px, 1.1vw, 18px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: linear-gradient(to bottom, #f3d293, #c9954a);
  border: 0;
  border-radius: 999px;
  padding: 0.85em 2.1em;
  cursor: pointer;
  box-shadow: 0 0.25em 0 #7d5422, 0 0.8em 2em rgba(0, 0, 0, 0.5), 0 0 1.4em rgba(255, 190, 100, 0.25);
}
.cta:focus-visible { outline: 3px solid var(--cream); outline-offset: 5px; }

.status {
  position: absolute;
  left: 50%;
  bottom: max(2.2vh, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 0.5em 1.3em;
  max-width: calc(100% - 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  font-size: clamp(12px, 0.92vw, 15px);
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  pointer-events: none;
}
.is-capturing .status, .status:empty { display: none; }

.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 210, 140, 0) 45%, rgba(255, 190, 110, 0.35)); }
.flash.on { animation: flash 0.6s ease-out; }
.flash.red { background: radial-gradient(ellipse at center, rgba(200, 40, 20, 0) 40%, rgba(200, 40, 20, 0.45)); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.touch-pause { position: absolute; right: 16px; bottom: 16px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--cream); font: 700 13px var(--ui); }
@media (pointer: coarse) { .touch-pause[hidden] { display: block !important; } }
.is-capturing .touch-pause { display: none !important; }

@media (prefers-reduced-motion: reduce) { .loading { animation: none; } }
