/* Soccer Scanner — phone-first, dark, big targets. No framework. */

:root {
  --bg: #0b0d10;
  --card: #14181d;
  --card-2: #1b2027;
  --line: #262d36;
  --text: #eef2f6;
  --muted: #8f9bab;
  --accent: #22c55e;
  --accent-press: #16a34a;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.screen { min-height: 100vh; min-height: 100dvh; }

/* .drill and .done set display, which outranks the UA's [hidden]{display:none}.
   Without this the drill overlay sits on top of the setup screen permanently. */
[hidden] { display: none !important; }

#setup { max-width: 620px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- masthead ---------- */
.masthead { text-align: center; padding: 18px 0 22px; }
.masthead h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.ball { filter: grayscale(1) brightness(2); }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 20px;
}

.row { margin: 0; padding: 16px 0 0; }
.row + .row { border-top: 1px solid var(--line); margin-top: 16px; }

.legend {
  padding: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.legend output { color: var(--text); font-variant-numeric: tabular-nums; }
.hint { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: 0.7; }

/* ---------- segmented control ---------- */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  /* Never shrink below the label. `min-width: max-content` plus flex-wrap means
     a row that cannot fit four across wraps instead of clipping — which is what
     happens to "Numbers" on a 375px phone, and worse with iOS larger-text. */
  flex: 1 1 auto;
  min-width: max-content;
  min-height: 48px;
  padding: 12px 10px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
/* Radio-style rows use aria-checked; the multi-select All row uses aria-pressed.
   Both must light up, or a selected control reads as unselected. */
.seg-btn[aria-checked="true"],
.seg-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #05210f;
}

/* ---------- slider ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 36px; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--card-2); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--card-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; margin-top: -12px;
  border-radius: 50%; background: var(--accent); border: 0;
}
input[type="range"]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); border: 0; }
.scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.78rem; }

/* ---------- color chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  position: relative;
  opacity: 0.5;
  transform: scale(0.88);
  transition: opacity 0.12s, transform 0.12s, border-color 0.12s;
}
.chip[aria-pressed="true"] {
  opacity: 1;
  transform: scale(1);
  border-color: var(--text);
}
/* A tick, not just brightness — brightness alone is ambiguous outdoors and unusable
   for anyone who cannot separate the dimmed shade from the lit one. */
.arrow-chips .chip {
  background: var(--card-2);
  border-color: var(--line);
  display: flex; align-items: center; justify-content: center;
}
.arrow-chips .chip svg { width: 26px; height: 26px; fill: var(--muted); }
.arrow-chips .chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
.arrow-chips .chip[aria-pressed="true"] svg { fill: #05210f; }
/* The colour chips mark selection with a tick; the arrow chips already carry a
   glyph there, so they use fill + ring instead and must not draw one. */
.arrow-chips .chip[aria-pressed="true"]::after { content: none; }

.chip[aria-pressed="true"]::after {
  content: "";
  position: absolute; left: 50%; top: 46%;
  width: 9px; height: 16px;
  border: solid var(--chip-fg, #000);
  border-width: 0 3px 3px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}
.chip:active { transform: scale(0.93); }

/* ---------- number range (dual-handle slider) ---------- */
.range-slider { position: relative; height: 36px; }
.range-slider .rs-track {
  position: absolute; left: 0; right: 0; top: 15px; height: 6px;
  border-radius: 3px; background: var(--card-2);
}
.range-slider .rs-fill {
  position: absolute; top: 0; bottom: 0;
  border-radius: 3px; background: var(--accent);
}
/* Both inputs sit on the same track. The track itself must not eat taps, or the
   upper input would block the lower one everywhere except its thumb. */
.range-slider input[type="range"] {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 36px; margin: 0;
  background: none; pointer-events: none;
}
.range-slider input[type="range"]::-webkit-slider-runnable-track { background: none; }
.range-slider input[type="range"]::-moz-range-track { background: none; }
.range-slider input[type="range"]::-webkit-slider-thumb { pointer-events: auto; }
.range-slider input[type="range"]::-moz-range-thumb { pointer-events: auto; }
#rangeMin { z-index: 4; }
#rangeMax { z-index: 3; }

.row-note { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }

/* ---------- switch ---------- */
.switch {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; cursor: pointer; padding-top: 18px; font-weight: 500;
}
.switch.tight { padding-top: 14px; font-size: 0.95rem; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track {
  flex: none; width: 52px; height: 32px; border-radius: 16px;
  background: var(--card-2); border: 1px solid var(--line); position: relative;
  transition: background 0.15s;
}
.track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked ~ .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked ~ .track::after { transform: translateX(20px); background: #05210f; }
.switch input:focus-visible ~ .track { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- buttons ---------- */
.big-start {
  display: block; width: 100%;
  margin-top: 22px; padding: 20px;
  background: var(--accent); color: #05210f;
  border: 0; border-radius: 12px;
  font: inherit; font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
}
.big-start:active { background: var(--accent-press); }
.ghost {
  display: block; width: 100%; margin-top: 10px; padding: 14px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.microcopy { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 0.82rem; }

/* ---------- guide ---------- */
.guide { margin-top: 40px; }
.guide h2 { margin: 34px 0 10px; font-size: 1.22rem; letter-spacing: -0.01em; }
.guide h3 { margin: 22px 0 6px; font-size: 1rem; }
.guide p { margin: 0 0 12px; color: #c6cfda; }
.guide ul { margin: 0 0 12px; padding-left: 20px; color: #c6cfda; }
.guide li { margin-bottom: 8px; }
.guide strong { color: var(--text); }

/* ---------- ads / footer ---------- */
.ad-slot { margin: 32px 0 0; min-height: 0; }
.footer { margin-top: 36px; text-align: center; border-top: 1px solid var(--line); padding-top: 24px; }
.tip {
  display: inline-block; padding: 13px 22px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.tip:active { background: var(--line); }
.fine { color: var(--muted); font-size: 0.8rem; margin: 16px 0 0; }

/* ---------- drill ---------- */
.drill {
  position: fixed; inset: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.cue {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
.cue #cueArrow {
  width: 62vmin; height: 62vmin;
  color: #fff;                 /* overridden per-cue via --cue-fg */
}
.cue span {
  font-size: 58vmin;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.drill-hud {
  position: absolute; left: 0; right: 0; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none;
  color: var(--cue-fg, #fff);
}
.clock { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: 0.85; }
.tap-hint { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.5; }
.progress {
  position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: rgba(128,128,128,0.25);
}
#progressBar { height: 100%; width: 0; background: var(--cue-fg, #fff); opacity: 0.55; }

/* ---------- done ---------- */
.done { display: flex; align-items: center; justify-content: center; padding: 20px; }
.done-card { max-width: 420px; width: 100%; text-align: center; padding: 32px 24px 28px; }
.done-card h2 { margin: 0 0 6px; font-size: 1.5rem; }
.stats { color: var(--muted); margin: 0; }
.stats strong { color: var(--text); font-variant-numeric: tabular-nums; }
.done-card .tip { margin-top: 22px; }

@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(0.94); } 100% { transform: scale(1); } }
.seg-btn.pulse { animation: pulse 0.22s ease-out; }

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