:root {
  --green: #0f5132;
  --green-2: #1b7a4b;
  --green-soft: #e3f0e8;
  --gold: #c99500;
  --gold-soft: #fff4d1;
  --red: #b42318;
  --red-soft: #fde8e7;
  --bg: #f5f7f4;
  --card: #ffffff;
  --text: #17211b;
  --muted: #5d6b62;
  --line: #dde3de;
  --focus: #1f6feb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 14px rgba(16, 24, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #4cc38a;
    --green-2: #6fd6a2;
    --green-soft: #183326;
    --gold: #f2c94c;
    --gold-soft: #3a3115;
    --red: #ff8a80;
    --red-soft: #3d1c1a;
    --bg: #0f1411;
    --card: #18201b;
    --text: #e8efe9;
    --muted: #9fb0a5;
    --line: #2a352e;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--green); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 1.4em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--green); color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0b2b1d; } }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 1.15rem; }
.brand img { border-radius: 8px; }
.topnav { display: none; margin-left: auto; gap: 4px; flex-wrap: wrap; }
.topnav a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.topnav a[aria-current="page"], .topnav a:hover { background: rgba(255, 255, 255, .16); }

main { max-width: 1040px; margin: 0 auto; padding: 16px; outline: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px; min-height: 56px;
  color: var(--muted); text-decoration: none; font-size: .72rem;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--green); font-weight: 600; }
@media (min-width: 860px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 24px; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.hero {
  background: linear-gradient(135deg, var(--green), var(--green-2)); color: #fff; border: 0;
}
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #0b2b1d, #145234); } }
.hero h1, .hero a { color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .85); }
.grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: rgba(255, 255, 255, .14); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }

.stage {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  text-decoration: none; color: inherit;
}
.stage .date { text-align: center; background: var(--green-soft); border-radius: 10px; padding: 6px 0; line-height: 1.15; }
.stage .date b { display: block; font-size: 1.4rem; color: var(--green); }
.stage .date span { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.stage h3 { margin: 0; }
.stage.cancelled h3 { text-decoration: line-through; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--green-soft); color: var(--green); white-space: nowrap;
}
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.grey { background: var(--line); color: var(--muted); }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--green); background: var(--green); color: #fff; font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
@media (prefers-color-scheme: dark) { .btn, button { color: #08140d; } }
.btn.secondary, button.secondary { background: transparent; color: var(--green); }
.btn.danger, button.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.small, button.small { min-height: 36px; padding: 0 12px; font-size: .875rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit;
}
textarea { min-height: 100px; }
.form-grid { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.error { color: var(--red); font-weight: 600; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: .92rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.finalist td:first-child { box-shadow: inset 4px 0 var(--gold); }
td input { min-height: 36px; padding: 4px 8px; width: 80px; }
td select { min-height: 36px; padding: 4px 8px; width: auto; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--text);
  white-space: nowrap; background: var(--card);
}
.tabs a[aria-current="page"] { background: var(--green); color: #fff; border-color: var(--green); }
@media (prefers-color-scheme: dark) { .tabs a[aria-current="page"] { color: #08140d; } }

.prize { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prize:last-child { border-bottom: 0; }
.sponsor-tier { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sponsor { text-align: center; padding: 18px 10px; font-weight: 600; }
.sponsor.main { grid-column: 1 / -1; font-size: 1.3rem; }
.flight { break-inside: avoid; }
.flight header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.flight ul { margin: 0; padding-left: 18px; }
.flights { display: grid; gap: 12px; }
@media (min-width: 640px) { .flights { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .flights { grid-template-columns: repeat(3, 1fr); } }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 20;
}
#toast.show { opacity: 1; }
.notice { background: var(--gold-soft); border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 8px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

@media print {
  .topbar, .tabbar, .actions, .tabs, .no-print, #toast { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; }
  .flights { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
