:root {
  --bg: #111827; --panel: #1f2937; --text: #f9fafb; --muted: #9ca3af;
  --green: #16a34a; --blue: #2563eb; --red: #dc2626; --amber: #d97706; --gray: #4b5563;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.3 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); }
#hdr-title { font-weight: 700; }
#hdr-race { flex: 1; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { padding: 12px 14px 40px; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
button { font: inherit; color: var(--text); border: 0; border-radius: 12px; padding: 14px; cursor: pointer; }
button:active { filter: brightness(1.25); }
button.icon { background: transparent; font-size: 22px; padding: 4px 8px; }
button.mode { display: block; width: 100%; text-align: left; background: var(--panel); margin-bottom: 12px; font-size: 22px; padding: 18px; }
button.mode small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
button.big { display: block; width: 100%; font-size: 40px; font-weight: 800; padding: 46px 0; margin: 10px 0; }
button.big small { display: block; font-size: 16px; font-weight: 400; opacity: .8; margin-top: 6px; }
button.start { background: var(--green); }
button.lap { background: var(--blue); }
button.primary { background: var(--blue); }
button.secondary { background: var(--gray); }
button.danger { background: var(--red); }
button.warn { background: var(--amber); }
button.small { font-size: 14px; padding: 10px; }
.row { display: flex; gap: 10px; margin: 8px 0; }
.row > * { flex: 1; min-width: 0; }
#clock { font-size: 56px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; padding: 6px 0; }
.list { margin: 12px 0 0; padding: 0; list-style: none; }
.list li { display: flex; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--panel); font-variant-numeric: tabular-nums; }
.list li:first-child { background: var(--panel); border-radius: 8px; font-weight: 700; }
.list li .pos { color: var(--muted); width: 3em; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.bib { min-width: 0; padding: 0; aspect-ratio: 1.6; font-size: 28px; font-weight: 800; background: var(--panel); border: 2px solid var(--gray); font-variant-numeric: tabular-nums; }
.bib.unknown { color: var(--amber); }
input, textarea { width: 100%; font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--gray); background: var(--panel); color: var(--text); user-select: text; -webkit-user-select: text; }
input[type=tel] { font-size: 22px; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
label input, label textarea { margin-top: 4px; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #000; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; max-width: 90vw; z-index: 9; }
#toast.err { background: var(--red); }
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 20px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--panel); }
th { color: var(--muted); font-weight: 600; }
h3 { margin: 16px 0 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; background: var(--gray); }
.badge.bad { background: var(--red); }
.badge.ok { background: var(--green); }
button.armed { background: var(--red) !important; }
button:disabled { opacity: .4; }
#btn-back { font-size: 17px; color: #93c5fd; }
select { width: 100%; font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--gray); background: var(--panel); color: var(--text); margin-top: 4px; }
#edit { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 8; }
#edit .sheet { background: var(--panel); width: 100%; padding: 16px 16px 30px; border-radius: 16px 16px 0 0; }
#edit input { font-size: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.flag { color: #fbbf24; }
.list li.flagged { border-left: 4px solid var(--amber); }

.ro td input { padding: 6px 8px; font-size: 15px; }
.ro td.bad input { border-color: var(--red); }
.ro .x { background: transparent; color: var(--muted); padding: 4px 8px; font-size: 18px; }
a { color: #93c5fd; }
.ro td.ro-bib { width: 3.5em; font-variant-numeric: tabular-nums; }
code { background: var(--panel); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
ul.formats { margin: 6px 0; padding-left: 20px; } ul.formats li { margin: 3px 0; }
.why { display: block; font-size: 12px; margin-top: 2px; } .why:empty { display: none; }
.linkrow { display: flex; gap: 8px; align-items: center; margin: 8px 0; } .linkrow b { width: 6em; } .linkrow input { flex: 1; font-size: 13px; color: var(--muted); } .linkrow button { padding: 10px 12px; }
#timer-shared { text-align: center; margin: -2px 0 8px; min-height: 1.2em; }
