/* Skitipp: night-blue sky, snow, and race-gate red. One narrow column, phone first. */
:root {
  --page: #eef3f8;
  --paper: #ffffff;
  --ink: #13233a;
  --muted: #5d6c80;
  --line: #d9e2ec;
  --brand: #0f2c4c;
  --brand-ink: #f4f8fc;
  --accent: #d4202f;
  --accent-ink: #ffffff;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --gold: #c9a227;
  --silver: #9aa5b1;
  --bronze: #b0733b;
  --focus: #f0b429;
  --radius: 14px;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b1420;
    --paper: #13202f;
    --ink: #e6edf5;
    --muted: #94a3b6;
    --line: #233448;
    --brand: #0a1f36;
    --brand-ink: #eef4fa;
    --accent: #f0525e;
    --ok: #4cc27f;
    --warn: #e0a548;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.5 var(--font-body); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

/* Masthead with a mountain ridge along the bottom edge. */
.masthead {
  background: var(--brand);
  color: var(--brand-ink);
  padding-top: env(safe-area-inset-top, 0px);
  position: relative;
  margin-bottom: 34px;
}
.masthead::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -18px;
  height: 19px;
  background: var(--brand);
  clip-path: polygon(0 0, 100% 0, 100% 30%, 88% 100%, 78% 40%, 66% 85%, 52% 10%, 40% 70%, 30% 30%, 18% 95%, 8% 45%, 0 80%);
}
.masthead-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-block: 12px 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand svg { width: 40px; height: 40px; flex: none; }
.brand strong { display: block; font-family: var(--font-display); font-size: 1.35rem; letter-spacing: 0.01em; }
.brand small { display: block; opacity: 0.75; font-size: 0.78rem; }
.me { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 0.85rem; }
.me form { margin: 0; }
.me .linkish { color: var(--brand-ink); opacity: 0.75; }
.nav { display: flex; gap: 4px; padding-block: 6px 10px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.nav a[aria-current="page"] { background: var(--brand-ink); color: var(--brand); font-weight: 600; }

.flash { background: color-mix(in srgb, var(--ok) 14%, var(--paper)); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.error { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); padding: 10px 14px; border-radius: 10px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }

/* Race rows */
.race { display: flex; align-items: center; gap: 12px; }
.race-badge {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  font: 700 0.95rem var(--font-display);
  background: var(--brand); color: var(--brand-ink);
}
.race-badge.W { background: #7a2e5c; }
.race-main { flex: 1; min-width: 0; }
.race-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-side { flex: none; text-align: right; font-size: 0.85rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.todo { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill.off { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.pts { font: 700 1.1rem var(--font-display); }
.month { margin: 22px 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.field + .field { margin-top: 12px; }
select, input[type=text], input[type=password], input[type=datetime-local], input[inputmode=numeric] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink);
  min-height: 44px;
}
/* Searchable athlete picker (app/static/picker.js) */
.picker { position: relative; min-width: 0; }
input.picker-input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink);
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.picker-list {
  position: absolute;
  z-index: 10;
  left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px;
  list-style: none;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.picker-list li { padding: 10px 10px; border-radius: 8px; cursor: pointer; }
.picker-list li:hover, .picker-list li.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.picker-list li[aria-selected="true"] { font-weight: 600; }
.picker-list li.picker-empty { color: var(--muted); cursor: default; }
.pick { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; }
.pick + .pick { margin-top: 10px; }
.place {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 1rem var(--font-display); color: #fff;
}
.place.p1 { background: var(--gold); }
.place.p2 { background: var(--silver); }
.place.p3 { background: var(--bronze); }
.place.aut { background: linear-gradient(#ed2939 33%, #fff 33% 66%, #ed2939 66%); color: #13233a; font-size: 0.7rem; }
button, .button {
  font: 600 1rem var(--font-body);
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); }
button.small, .button.small { padding: 6px 12px; min-height: 34px; font-size: 0.875rem; }
button.linkish { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 400; font-size: inherit; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input, .inline > select { flex: 1; min-width: 0; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 6px 8px; }
.table td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.mine td { background: color-mix(in srgb, var(--focus) 14%, transparent); }
.table .rank { width: 2.2em; font-weight: 700; color: var(--muted); }
.scroll { overflow-x: auto; }

.podium { display: grid; gap: 6px; }
.podium-row { display: flex; align-items: center; gap: 10px; }
.podium-row .place { width: 30px; height: 30px; font-size: 0.85rem; }
.hit { color: var(--ok); font-weight: 700; }
.near { color: var(--warn); font-weight: 700; }
.miss { color: var(--muted); }
.tipline { font-size: 0.9rem; line-height: 1.45; }

.rules li { margin-bottom: 6px; }
.footer { margin: 40px auto 32px; text-align: center; font-size: 0.85rem; color: var(--muted); }
.footer a { color: var(--muted); }
.admin-grid { display: grid; gap: 12px; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 10px; }
