/* Built for a volunteer holding a phone in a loud, bright arena:
   large targets, high contrast, no small text, no hover-only affordances. */

:root {
  --bg: #0b0f14;
  --panel: #141b24;
  --line: #243040;
  --fg: #e8eef6;
  --muted: #8da2ba;
  --ok: #2fbf71;
  --warn: #e8a33d;
  --bad: #e7494e;
  --accent: #3d8bfd;
}

* { box-sizing: border-box; }

/* Every interactive element gets a visible ring on keyboard focus. The
   default UA outline is easy to lose against a near-black surface, and
   nothing else in this system signals "this is where input goes next". */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

body {
  margin: 0;
  padding: 0 1rem 3rem;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.75rem 0 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

h1 { margin: 0 0 0.4rem; font-size: 1.05rem; letter-spacing: 0.02em; }
h2 { margin: 1.25rem 0 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.pills { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

.pill {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--line);
}
.pill.ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.pill.bad  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.muted { color: var(--muted); font-size: 0.72rem; }
.opt { color: var(--muted); font-weight: 400; }

label { display: block; margin: 0.9rem 0 0; font-size: 0.8rem; color: var(--muted); }

input, select {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.75rem;
  font-size: 1rem;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

button {
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button.primary   { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.secondary { background: var(--panel); }
button.ghost     {
  width: auto; margin: 0; padding: 0.5rem 0.7rem; font-size: 0.85rem; background: transparent;
  min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center;
}

.hint { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--muted); }

.hidden { display: none !important; }

.flash {
  position: sticky;
  top: 4.2rem;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.5rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border-left: 4px solid var(--line);
  background: var(--panel);
}
.flash strong { font-size: 1.05rem; }
.flash span { font-size: 0.85rem; color: var(--muted); }
.flash.ok    { border-left-color: var(--ok); }
.flash.warn  { border-left-color: var(--warn); }
.flash.error { border-left-color: var(--bad); }

/* ── scanning ─────────────────────────────────────────────────────────── */

.scanbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.station-info { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.station-info > span:first-child { font-weight: 600; font-size: 0.95rem; }

.mark { padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; }
.mark.enter { background: color-mix(in srgb, var(--ok) 22%, transparent);  color: var(--ok); }
.mark.exit  { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }

.viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
}
#video { width: 100%; height: 100%; object-fit: cover; }

.reticle {
  position: absolute;
  inset: 18% 22%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.manual { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.manual input { margin-top: 0; }
.manual button { width: auto; margin-top: 0; white-space: nowrap; }

/* Tap-to-record grid: one big button per athlete for events with no QR at all —
   a bib marker-written on an arm cannot be scanned, so this is the primary
   input there, not a fallback. Large targets on purpose: a thumb, not a
   cursor, and used while watching a runner rather than the screen. */
#tap-filter { margin-top: 0; }
.bib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr));
  gap: 0.45rem;
  margin-top: 0.6rem;
  max-height: 60vh;
  overflow-y: auto;
}
.bib-btn {
  width: auto;
  margin: 0;
  padding: 0.5rem 0.3rem;
  min-height: 3.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: transform 0.08s ease;
}
.bib-btn .num { font-size: 1.05rem; font-weight: 700; }
.bib-btn .nm {
  font-size: 0.65rem; color: var(--muted); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Recorded from THIS phone, for the current station+mark — a memory aid, not
   an authority. Another phone covering the same station has no visibility
   here, and tapping again is still allowed: a genuine re-entry is real data. */
.bib-btn.done { background: color-mix(in srgb, var(--ok) 16%, var(--panel)); border-color: var(--ok); }
.bib-btn.done .num::after { content: ' \2713'; color: var(--ok); }
/* Immediate feedback right under the thumb — the flash banner at the top of
   the screen is easy to miss while eyes are on the next runner, not the phone. */
.bib-btn.tapped { transform: scale(0.92); background: var(--accent); border-color: var(--accent); }
.bib-btn.tapped .num, .bib-btn.tapped .nm { color: var(--bg); }

/* Manual entry time control */
.timeset { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.5rem; }
.timeset .lbl { font-size: 0.78rem; color: var(--muted); margin-right: 0.15rem; }
.chip {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.6rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.timeset input[type="time"] {
  width: auto;
  margin: 0;
  padding: 0.38rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

/* Loud and persistent: a back-dated time left on by accident would silently
   corrupt every entry that follows, so it must be impossible to overlook. */
.override {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.6rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
}
.override strong { font-size: 0.95rem; color: var(--warn); }
.override span { font-size: 0.78rem; color: var(--muted); }
.override button { width: auto; align-self: flex-start; margin-top: 0.4rem; padding: 0.35rem 0.7rem; font-size: 0.78rem; }

.recent { margin: 0; padding: 0; list-style: none; }
.recent li {
  display: grid;
  grid-template-columns: 3.5rem 1fr 2.6rem 5rem 4.5rem;
  gap: 0.4rem;
  align-items: center;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.recent .bib { font-weight: 700; }
.recent .who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .mk, .recent .tm { color: var(--muted); font-variant-numeric: tabular-nums; }
.recent .st { text-align: right; font-size: 0.72rem; color: var(--muted); }
.recent li.pending  .st { color: var(--warn); }
.recent li.synced   .st { color: var(--ok); }
.recent li.rejected .st { color: var(--bad); }
.recent li.empty { display: block; color: var(--muted); }

.issues { margin-top: 1rem; padding: 0.75rem; border: 1px solid var(--bad); border-radius: 10px; }
.issues ul { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; }

footer { margin-top: 2rem; text-align: center; }
footer a { color: var(--accent); font-size: 0.85rem; text-decoration: none; }
