:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --panel-2: #212b37;
  --ink: #e8edf2;
  --muted: #9aa7b4;
  --line: #2c3846;
  --brand: #ff6b35;
  --brand-2: #ffa06b;
  --accent: #35a7ff;
  --good: #34c77b;
  --bad: #ff5468;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  gap: 8px 12px;
  flex-wrap: wrap;        /* on narrow/portrait screens the nav wraps below the
                             brand instead of being clipped by a fixed height */
  padding: 6px 0;
}
/* Phones in portrait: drop the nav onto its own full-width line(s) under the
   brand so every link is reachable without rotating to landscape. */
@media (max-width: 640px) {
  .topbar .navlinks { width: 100%; justify-content: flex-start; }
}
.brand {
  font-weight: 800;
  letter-spacing: .5px;
  font-size: 20px;
  color: var(--ink);
}
.brand .dot { color: var(--brand); }
.navlinks { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.navlinks a, .navlinks .pill {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.navlinks a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }

/* Layout */
main { padding: 24px 0 64px; }
.page-title { font-size: 26px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-block;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover, .btn[disabled]:hover { border-color: var(--line); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #1a1005; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #04121f; }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 17px; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 16px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
}
textarea { min-height: 90px; resize: vertical; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 120px; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.checkrow { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkrow input[type=checkbox] { width: auto; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges / status */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.draft { color: var(--muted); }
.badge.open { color: var(--accent); border-color: var(--accent); }
.badge.live { color: var(--good); border-color: var(--good); }
.badge.closed { color: var(--muted); border-color: var(--line); }
.badge.done { color: var(--good); border-color: var(--good); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.flash.success { background: rgba(52,199,123,.12); border: 1px solid var(--good); color: var(--good); }
.flash.error { background: rgba(255,84,104,.12); border: 1px solid var(--bad); color: var(--bad); }
.flash.info { background: rgba(53,167,255,.12); border: 1px solid var(--accent); color: var(--accent); }
.flash.warning { background: rgba(255,107,53,.12); border: 1px solid var(--brand); color: var(--brand-2); }

/* Entry chips / list rows */
.entry-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; background: var(--panel-2);
}
.entry-num {
  min-width: 44px; height: 44px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px;
}
.entry-main { flex: 1; min-width: 0; }
.entry-main .owner { font-weight: 700; }
.entry-main .veh { color: var(--muted); font-size: 14px; }

.award-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; background: var(--panel-2);
}
.award-main { flex: 1; min-width: 140px; }
.award-title { font-weight: 700; }

.vendor-row {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
  justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; background: var(--panel-2);
}
.vendor-approved { border-left: 3px solid var(--accent, #3b82f6); }
.vendor-main { flex: 1; min-width: 180px; }
.vendor-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vendor-desc { margin-top: 4px; font-size: 14px; }

.vol-choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); cursor: pointer;
}
.vol-choice input { margin-top: 3px; }
.vol-full { opacity: 0.6; cursor: not-allowed; }

/* Gate fraud / duplicate-dashcard alerts */
.alert-card { border-color: var(--brand); }
.alert-title { color: var(--brand-2); margin-bottom: 4px; }
.alert-list { margin: 6px 0 0; padding-left: 18px; }
.alert-list li { margin-bottom: 4px; }
.alert-reason { font-weight: 700; }
.badge-dup { color: var(--brand-2); border-color: var(--brand); }
.badge-flag { color: var(--bad); border-color: var(--bad); margin-left: 4px; }

.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.inline-form { display: inline; }

/* Landing */
.hero { padding: 64px 0 40px; text-align: center; }
.hero h1 { font-size: 44px; margin: 0 0 14px; line-height: 1.1; }
.hero h1 .accent { color: var(--brand); }
.hero p { font-size: 19px; color: var(--muted); max-width: 620px; margin: 0 auto 26px; }
.feature-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-top: 8px; }
@media (max-width: 720px) { .feature-grid { grid-template-columns: 1fr; } .hero h1 { font-size: 32px; } }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feature h3 { margin: 0 0 6px; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 17px; }
.feature p { color: var(--muted); margin: 0; font-size: 15px; }

/* Auth */
.auth-wrap { max-width: 400px; margin: 48px auto; }

/* Leaderboard (projector) */
.board { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.board h1 { font-size: 34px; margin: 0 0 4px; }
.board .cls { margin-bottom: 28px; }
.board table { font-size: 18px; }
.board .place { font-weight: 800; color: var(--brand); width: 60px; }
.board-first td { background: rgba(255,107,53,.08); }

/* Vote page */
.vote-card {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 12px; background: var(--panel);
}
.vote-card.voted { border-color: var(--good); background: rgba(52,199,123,.08); }

/* Score entry */
.score-crit { margin-bottom: 18px; }
.score-crit .max { color: var(--muted); font-weight: 600; font-size: 14px; }

/* Responsive tables — keep wide tables inside their own scroll area
   instead of forcing the whole page to scroll sideways on a phone. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Bigger tap targets on touch devices (tablets / phones in the field). */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { padding: 10px 14px; font-size: 14px; }
  .navlinks a, .navlinks .pill { padding: 11px 12px; }
  th, td { padding: 12px 12px; }
}

/* High-visibility "Sunlight" mode — for outdoor use in direct sun.
   A screen cannot out-shine the sun, so readability comes from a bright
   white background (panels driven to max luminance) plus near-black,
   bold, high-contrast text and solid-filled status colors. Toggled and
   persisted client-side; applies to every page via <html data-theme="sun">. */
[data-theme="sun"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef1f4;
  --ink: #0a0e12;
  --muted: #33404b;
  --line: #9aa7b4;
  --brand: #c2410c;
  --brand-2: #9a3412;
  --accent: #0b57b8;
  --good: #16733a;
  --bad: #c0243a;
  --shadow: 0 1px 4px rgba(0,0,0,.18);
}
[data-theme="sun"] body { font-size: 17px; font-weight: 500; }
[data-theme="sun"] .muted, [data-theme="sun"] .page-sub, [data-theme="sun"] .help { font-weight: 600; }
[data-theme="sun"] .card { border-width: 2px; box-shadow: var(--shadow); }
[data-theme="sun"] .topbar { border-bottom-width: 2px; }
[data-theme="sun"] input, [data-theme="sun"] select, [data-theme="sun"] textarea { border-width: 2px; border-color: #55606b; }
[data-theme="sun"] th { color: #0a0e12; }
[data-theme="sun"] th, [data-theme="sun"] td { border-bottom-color: #9aa7b4; }
/* Solid-fill badges read at a glance in glare. */
[data-theme="sun"] .badge { border-width: 2px; font-weight: 800; }
[data-theme="sun"] .badge.live, [data-theme="sun"] .badge.done { background: var(--good); color: #fff; border-color: var(--good); }
[data-theme="sun"] .badge.open { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="sun"] .badge.closed, [data-theme="sun"] .badge.draft { background: #33404b; color: #fff; border-color: #33404b; }
[data-theme="sun"] .btn-primary { color: #fff; }
[data-theme="sun"] .btn-accent { color: #fff; }
[data-theme="sun"] .board-first td { background: rgba(194,65,12,.14); }

/* Floating high-visibility toggle — present on every page, hidden in print. */
.vis-toggle {
  position: fixed; right: 14px; bottom: 14px; z-index: 50;
  background: var(--brand); color: #1a1005;
  border: 2px solid #1a1005; border-radius: 999px;
  padding: 11px 18px; font-size: 14px; font-weight: 800;
  cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.35);
  min-height: 44px;
}
.vis-toggle:hover { filter: brightness(1.06); }
[data-theme="sun"] .vis-toggle { background: #111820; color: #fff; border-color: #fff; }

/* Payment badges */
.pay-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.pay-paid { background: rgba(52,199,123,.16); color: var(--good); border: 1px solid var(--good); }
.pay-unpaid { background: rgba(255,84,104,.14); color: var(--bad); border: 1px solid var(--bad); }
.pay-waived { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* Offline status pill (#363) — fixed bottom-left; the sunlight/night vis-toggle
   sits bottom-right, so they don't collide. */
.offline-pill {
  position: fixed; left: 14px; bottom: 14px; z-index: 60;
  background: var(--good); color: #04121f;
  border: 2px solid #04121f; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 800;
  box-shadow: 0 3px 12px rgba(0,0,0,.35);
  pointer-events: none; letter-spacing: .2px;
}
.offline-pill.has-queue { background: var(--brand); color: #1a1005; }
.offline-pill.is-offline { background: var(--bad); color: #fff; border-color: #fff; }

/* Queued (optimistic) check-in rows while offline. */
.entry-row.queued { outline: 2px dashed var(--brand); outline-offset: 2px; }

/* Per-event public branding (#371) */
.brand-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 4px;
}
.brand-logo {
  max-height: 56px; max-width: 180px; border-radius: 8px;
  background: #fff; padding: 4px; object-fit: contain;
}
.brand-head-text { min-width: 0; }
.brand-club { font-size: 1.4rem; font-weight: 800; line-height: 1.15; }
.brand-tagline { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.brand-social { margin-top: 4px; font-size: .85rem; }
.brand-social a { margin-right: 12px; }
.powered-by {
  display: inline-block; margin-top: 6px; font-size: .72rem;
  letter-spacing: .3px; opacity: .6; text-decoration: none; font-weight: 700;
}
.powered-by .dot { color: var(--brand); }

/* Winner share card */
.share-card { text-align: center; }
.share-ribbon { font-size: 2.6rem; line-height: 1; }
.share-place {
  font-size: 3rem; font-weight: 900; margin: 4px 0 0;
  color: var(--brand); letter-spacing: -1px;
}
.share-sub { color: var(--muted); margin: 2px 0 14px; }
.share-entry {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  text-align: left; margin: 8px auto; max-width: 380px;
}
.share-stats {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
}
.share-stats li { display: flex; flex-direction: column; }
.share-stat-num { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.share-stat-lbl { color: var(--muted); font-size: .8rem; }
.share-actions { display: grid; gap: 8px; margin-top: 16px; }

/* Dashcard (print) */
@media print {
  .topbar, .no-print, .vis-toggle, .offline-pill { display: none !important; }
  body { background: #fff; color: #000; }
}
