/* Dart Checkout Trainer — styles
   Palette from the board itself: painted sisal black, cream beds,
   wire red & green, brass barrels. */

:root {
  --ink: #17130e;        /* page background, warm board black */
  --ink-2: #211b12;      /* panels */
  --ink-3: #2b2417;      /* raised elements */
  --sisal: #e8dec3;      /* cream beds / primary text */
  --sisal-dim: #b3a88c;
  --chalk: #f4edda;
  --red: #c8403a;
  --red-hot: #e0574e;
  --green: #2e7d4f;
  --green-hot: #47a26c;
  --brass: #c9a24b;
  --brass-hot: #eccf7e;
  --line: rgba(232, 222, 195, 0.14);
  --disp: "Big Shoulders", "Arial Narrow", sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--sisal);
  background: radial-gradient(1200px 800px at 50% -10%, #2a2214, var(--ink) 62%) fixed;
}

::selection { background: var(--brass); color: var(--ink); }
a { color: var(--brass-hot); }
h2 { font-family: var(--disp); font-weight: 700; font-size: 30px; letter-spacing: 0.5px; margin: 0 0 10px; color: var(--chalk); }

:focus-visible { outline: 2px solid var(--brass-hot); outline-offset: 2px; border-radius: 4px; }

/* ============================ header ============================ */

.site-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  max-width: 1100px; margin: 0 auto; padding: 18px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dart svg { width: 22px; height: 22px; fill: var(--brass); display: block; }
.brand-name {
  font-family: var(--disp); font-weight: 700; font-size: 26px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--chalk);
}
.brand-name b { color: var(--brass); font-weight: 800; }

.tabs { display: flex; gap: 4px; }
.tab {
  font-family: var(--mono); font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--sisal-dim); background: none; border: none; cursor: pointer;
  padding: 10px 14px 12px; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--chalk); }
.tab.is-active { color: var(--chalk); border-bottom-color: var(--brass); }

/* ============================ layout ============================ */

main { max-width: 1100px; margin: 0 auto; padding: 10px 20px 60px; }
.mode { display: none; }
.mode.is-active { display: block; }

.hud {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; padding: 18px 0 14px;
}

/* Score plate — the signature element */
.score-plate { display: grid; justify-items: start; }
.plate-label {
  font-family: var(--mono); font-size: 12px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--brass);
}
.plate-number {
  font-family: var(--disp); font-weight: 800; font-optical-sizing: auto;
  font-size: clamp(72px, 18vw, 110px); line-height: 0.9;
  color: var(--chalk); letter-spacing: 1px;
  padding-bottom: 6px; border-bottom: 3px solid var(--brass);
  min-width: 2.1ch; font-variant-numeric: tabular-nums;
}
.pips { display: inline-flex; gap: 8px; margin-top: 10px; }
.pip svg { width: 22px; height: 22px; fill: var(--brass); display: block; transition: opacity 0.2s; }
.pip.used svg { opacity: 0.22; }

.hud-side { display: grid; gap: 10px; justify-items: start; }

/* toggles */
.switch {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font-family: var(--mono); font-size: 13px; color: var(--sisal);
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .knob {
  width: 36px; height: 20px; border-radius: 20px; flex: none;
  background: var(--ink-3); border: 1px solid var(--line); position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--sisal-dim); transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .knob { background: #4a3c1c; border-color: var(--brass); }
.switch input:checked + .knob::after { transform: translateX(16px); background: var(--brass-hot); }
.switch input:focus-visible + .knob { outline: 2px solid var(--brass-hot); outline-offset: 2px; }

/* buttons */
.btn-primary, .btn-ghost {
  font-family: var(--mono); font-size: 14px; letter-spacing: 1px; text-transform: uppercase;
  border-radius: 8px; cursor: pointer; padding: 12px 22px;
}
.btn-primary {
  background: var(--brass); color: var(--ink); border: 1px solid var(--brass);
  font-weight: 600;
}
.btn-primary:hover { background: var(--brass-hot); border-color: var(--brass-hot); }
.btn-ghost {
  background: none; color: var(--sisal); border: 1px solid var(--line);
  padding: 8px 14px; font-size: 12px;
}
.btn-ghost:hover { border-color: var(--brass); color: var(--chalk); }

/* stage — single column by default (HUD, board, side info stacked);
   the desktop breakpoint below turns this into a 3-column row. */
.stage {
  display: grid; grid-template-columns: 1fr;
  gap: 24px; align-items: start;
}
.stage-solo { justify-items: center; }

.board-wrap { position: relative; max-width: 580px; margin: 0 auto; width: 100%; }

/* ========================== dartboard ========================== */

.dartboard { width: 100%; height: auto; display: block; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.55)); }
.dartboard .seg { stroke: #0b0906; stroke-width: 1.4; cursor: pointer; transition: filter 0.12s; }
.dartboard .surround { fill: #0f0c08; }
.dartboard .s-dark { fill: #262016; }
.dartboard .s-light { fill: var(--sisal); }
.dartboard .r-red { fill: var(--red); }
.dartboard .r-green { fill: var(--green); }
.dartboard .board-num {
  fill: var(--sisal); font-family: var(--disp); font-weight: 700; font-size: 27px;
  pointer-events: none; user-select: none;
}
.dartboard .seg:hover { filter: brightness(1.25); }
.dartboard .surround:hover { filter: brightness(1.6); }
.dartboard.is-disabled .seg { pointer-events: none; }
.dartboard.is-disabled { opacity: 0.92; }

/* helper target — a subtle brighter/richer shade of the segment's own
   color, pulsating in place. No outline, so it never bleeds into
   neighboring segments. */
.dartboard .is-target {
  animation: target-pulse 1.8s ease-in-out infinite;
}
@keyframes target-pulse {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.45) saturate(1.3); }
}

/* thrown-dart markers — where each dart this turn actually landed */
.dartboard .dart-marks { pointer-events: none; }
.dartboard .dart-mark {
  fill: var(--brass-hot); stroke: var(--ink); stroke-width: 1.5;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
  transform-box: fill-box; transform-origin: center;
  animation: mark-pop 0.2s ease-out;
}
@keyframes mark-pop {
  0% { transform: scale(2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* result stamp */
.stamp {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column;
  pointer-events: none; text-align: center;
}
.stamp.is-shown { display: flex; }
.stamp-title {
  font-family: var(--disp); font-weight: 800; font-size: clamp(44px, 9vw, 72px);
  letter-spacing: 2px; text-transform: uppercase; line-height: 1;
  padding: 10px 26px 14px; border: 3px solid currentColor; border-radius: 10px;
  background: rgba(23, 19, 14, 0.86); transform: rotate(-5deg);
  animation: stamp-pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.stamp.ok .stamp-title { color: var(--green-hot); }
.stamp.fail .stamp-title { color: var(--red-hot); }
.stamp-sub {
  margin-top: 12px; font-family: var(--mono); font-size: 14px; color: var(--chalk);
  background: rgba(23, 19, 14, 0.86); padding: 4px 12px; border-radius: 6px;
}
@keyframes stamp-pop {
  0% { transform: rotate(-5deg) scale(1.25); opacity: 0; }
  100% { transform: rotate(-5deg) scale(1); opacity: 1; }
}

/* ========================= side panel ========================= */

.side { display: grid; gap: 18px; max-width: 580px; margin: 0 auto; width: 100%; }

.advice {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px;
}
.advice-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--brass);
}
.advice-field { margin: 10px 0 6px; }
.advice-field .chip { font-size: 20px; padding: 6px 14px; }
.advice-why { margin: 6px 0 10px; color: var(--chalk); }
.advice-route {
  margin: 0; font-family: var(--mono); font-size: 12px; color: var(--sisal-dim);
  border-top: 1px solid var(--line); padding-top: 10px;
}

.thrown-wrap { display: grid; gap: 8px; }
.thrown-under { margin-top: 18px; justify-items: center; }
.thrown-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--sisal-dim);
}
.thrown { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; }

/* chips */
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--ink-3); color: var(--sisal); white-space: nowrap;
}
.chip em { font-style: normal; font-size: 11px; opacity: 0.65; }
.chip.c-red { border-color: rgba(224, 87, 78, 0.5); color: #f0968f; background: rgba(200, 64, 58, 0.13); }
.chip.c-green { border-color: rgba(71, 162, 108, 0.5); color: #8ed0a9; background: rgba(46, 125, 79, 0.14); }
.chip.c-single { color: var(--sisal); }
.chip.c-miss { color: var(--sisal-dim); border-style: dashed; }

.pref-star { color: var(--brass-hot); }

/* ========================== game mode ========================== */

.game-start, .summary {
  max-width: 620px; margin: 60px auto; text-align: center;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px 34px;
}
.game-start p { color: var(--sisal-dim); margin: 0 0 26px; }

.game-stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gstat {
  font-family: var(--mono); font-size: 13px; color: var(--sisal);
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; white-space: pre;
}
.gstat-clock {
  font-size: 20px; font-weight: 600; color: var(--brass-hot);
  min-width: 92px; text-align: center; font-variant-numeric: tabular-nums;
}

.summary h2 { margin-bottom: 22px; }
.sum-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px;
}
.stat { background: var(--ink-3); border-radius: 10px; padding: 14px 8px 12px; display: grid; gap: 2px; }
.stat-v { font-family: var(--disp); font-weight: 700; font-size: 30px; color: var(--chalk); line-height: 1; }
.stat-l { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sisal-dim); }

.sum-rounds { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 30px; }
.round-chip {
  font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--line); display: inline-flex; gap: 8px; align-items: baseline;
}
.round-chip b { font-weight: 600; }
.round-chip.ok { border-color: rgba(71, 162, 108, 0.5); color: #8ed0a9; }
.round-chip.fail { border-color: rgba(224, 87, 78, 0.45); color: #e79b95; }

/* =========================== table =========================== */

.table-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-top: 22px;
}
.filter {
  font-family: var(--mono); font-size: 14px; color: var(--chalk);
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; width: 220px;
}
.filter::placeholder { color: var(--sisal-dim); }
.filter:focus { outline: 2px solid var(--brass); outline-offset: 0; border-color: var(--brass); }

.table-note { color: var(--sisal-dim); font-size: 14px; margin: 8px 0 18px; }

.table-scroll { overflow-x: auto; }
.ct { width: 100%; border-collapse: collapse; min-width: 520px; }
.ct th {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--sisal-dim); text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--brass); position: sticky; top: 0; background: var(--ink);
}
.ct td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.path-row { cursor: pointer; }
.path-row:hover td { background: rgba(232, 222, 195, 0.045); }
.col-start b { font-family: var(--disp); font-weight: 700; font-size: 24px; color: var(--chalk); }
.alt-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--sisal-dim); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px;
}
.none { color: var(--sisal-dim); opacity: 0.5; }

.why-tr td { background: var(--ink-2); padding: 14px 16px; }
.why-row { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; }
.why-row p { margin: 0; color: var(--sisal); }
.why-n {
  font-family: var(--mono); font-size: 11px; color: var(--brass);
  border: 1px solid var(--brass); border-radius: 50%;
  width: 20px; height: 20px; flex: none; display: inline-flex;
  align-items: center; justify-content: center; align-self: center;
}

/* =========================== footer =========================== */

.site-foot { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; }
.ad-slot { margin: 20px 0; }
.gear { border-top: 1px solid var(--line); padding-top: 26px; margin-top: 10px; }
.gear h2 { font-size: 22px; }
.gear-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.gear-card {
  display: grid; gap: 4px; text-decoration: none;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px; padding: 16px;
}
.gear-card b { color: var(--chalk); }
.gear-card span { color: var(--sisal-dim); font-size: 14px; }
.gear-card:hover { border-color: var(--brass); }
.foot-line {
  border-top: 1px solid var(--line); margin-top: 30px; padding-top: 18px;
  font-family: var(--mono); font-size: 12px; color: var(--sisal-dim);
}
.foot-line a { color: var(--sisal-dim); }

/* ========================= responsive ========================= */

/* Desktop: three-column layout — checkout number on the left, board
   centered and sized to fill the viewport height, next-dart/thrown
   info on the right. Board size is driven by available height so it
   scales up on tall screens instead of staying capped at a fixed
   size, while still fitting on screen without scrolling. */
@media (min-width: 941px) and (min-aspect-ratio: 1/1) {
  .site-head { max-width: 1600px; }
  main { max-width: 1600px; padding: 12px 24px 14px; }
  .site-foot { max-width: 1600px; padding: 0 24px 14px; }
  .foot-line { margin-top: 8px; padding-top: 10px; }

  .stage {
    grid-template-columns: minmax(200px, 300px) minmax(0, 1fr) minmax(230px, 320px);
    gap: 40px; align-items: center;
    min-height: calc(100vh - 160px);
  }
  .stage-solo { grid-template-columns: minmax(200px, 300px) minmax(0, 1fr) minmax(200px, 280px); }

  .stage > .hud {
    flex-direction: column; align-items: flex-start; justify-content: center;
    gap: 26px; padding: 0;
  }
  .plate-number { font-size: clamp(64px, 6vw, 104px); }

  .board-wrap { max-width: none; width: clamp(380px, min(100%, calc(100vh - 200px)), 960px); }
  /* Game mode adds a "thrown" chip row below the board, so give it less vertical budget. */
  .stage-solo .board-wrap { width: clamp(340px, min(100%, calc(100vh - 200px)), 900px); }

  .side { max-width: none; margin: 0; align-content: center; }
  .thrown-under { margin-top: 0; justify-items: start; }
}

@media (max-width: 560px) {
  .sum-stats { grid-template-columns: repeat(2, 1fr); }
  .game-start, .summary { padding: 28px 20px; margin: 30px auto; }
  .site-head { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .dartboard .is-target, .dartboard .dart-mark, .stamp-title { animation: none; }
  * { transition: none !important; }
}
