/* ─────────────────────────────────────────────────────────────────────────
   JORD Golf Tournament System — Design System
   v1.0.0
   Tune the :root block below to re-skin the entire app.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand — Cream editorial (Vessel/Malbon-inspired) — matches landing page */
  --jord-cream:        #F5F2EB;   /* warm cream — page background */
  --jord-cream-2:      #ECE7DB;   /* deeper cream — surface variant / hover */
  --jord-paper:        #FBF9F4;   /* lightest cream — cards */
  --jord-ink:          #1A1A1A;   /* near-black body text */
  --jord-ink-2:        #5C5852;   /* muted secondary */
  --jord-ink-3:        #8A8479;   /* tertiary / meta labels */
  --jord-saffron:      #B8884D;   /* warm earth-tone accent */
  --jord-saffron-2:    #9A6E3A;   /* darker saffron for hover/gradient */
  --jord-flag-red:     #B33A3A;   /* danger / alerts on cream */
  /* legacy aliases (kept so existing inline styles still resolve) */
  --jord-fairway:      #F5F2EB;
  --jord-fairway-2:    #ECE7DB;
  --jord-charcoal:     #1A1A1A;
  --jord-charcoal-2:   #5C5852;
  --jord-gold:         #B8884D;
  --jord-gold-2:       #9A6E3A;
  --jord-sand:         #ECE7DB;
  --jord-sky:          #5C5852;

  /* Semantic */
  --bg:           #F5F2EB;
  --surface:      #FBF9F4;
  --surface-2:    #ECE7DB;
  --ink:          #1A1A1A;
  --ink-2:        #5C5852;
  --ink-3:        #8A8479;
  --primary:      #1A1A1A;          /* primary CTA = dark on cream */
  --primary-hover:#2A2A2A;
  --primary-ink:  #FBF9F4;          /* cream text on dark CTAs */
  --accent:       #B8884D;          /* saffron — highlights, leader rows */
  --accent-2:     #9A6E3A;
  --danger:       #B33A3A;
  --border:       rgba(26, 26, 26, 0.10);
  --border-2:     rgba(26, 26, 26, 0.18);
  --shadow-sm:    0 1px 2px rgba(26,26,26,0.04), 0 1px 3px rgba(26,26,26,0.06);
  --shadow-md:    0 6px 18px rgba(26,26,26,0.06), 0 2px 6px rgba(26,26,26,0.05);
  --shadow-lg:    0 18px 42px rgba(26,26,26,0.10), 0 6px 14px rgba(26,26,26,0.06);

  /* Type */
  --font-display: 'Playfair Display', 'Georgia', 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Radii */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
  --t-med:  240ms cubic-bezier(.4,0,.2,1);
  --t-slow: 480ms cubic-bezier(.4,0,.2,1);
}

/* Optional dark mode (used for TV-mode leaderboard) — editorial near-black */
.theme-dark {
  --bg:        #141312;
  --surface:   #1E1C1A;
  --surface-2: #2A2724;
  --ink:       #F5F2EB;
  --ink-2:     #B8B3A8;
  --ink-3:     #8A8479;
  --primary:   #F5F2EB;
  --primary-hover: #ECE7DB;
  --primary-ink: #1A1A1A;
  --accent:    #C99A5E;       /* slightly brighter saffron on dark */
  --accent-2:  #B8884D;
  --border:    rgba(245, 242, 235, 0.10);
  --border-2:  rgba(245, 242, 235, 0.20);
}

/* ─── Reset ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--border-2); transition: color var(--t-fast), border-color var(--t-fast); }
a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
a.plain, .topbar a, .nav a, .brand, .btn { border-bottom: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: -0.018em; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: clamp(22px, 3vw, 30px); }
h3 { font-size: 20px; }
h4 { font-size: 16px; }
p  { margin: 0 0 var(--s-3); }
small, .small { font-size: 13px; color: var(--ink-2); }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-sm); }

/* ─── Layout primitives ──────────────────────────────────────────────── */
.container       { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--s-4); }
.container-sm    { max-width: 720px; }
.container-md    { max-width: 920px; }
.row             { display: flex; gap: var(--s-4); }
.row-wrap        { flex-wrap: wrap; }
.row-between     { justify-content: space-between; align-items: center; }
.row-end         { justify-content: flex-end; align-items: center; }
.col             { display: flex; flex-direction: column; gap: var(--s-3); }
.grow            { flex: 1; }
.center          { display: flex; align-items: center; justify-content: center; }
.gap-1{gap:var(--s-1)}.gap-2{gap:var(--s-2)}.gap-3{gap:var(--s-3)}
.gap-4{gap:var(--s-4)}.gap-5{gap:var(--s-5)}.gap-6{gap:var(--s-6)}
.mt-1{margin-top:var(--s-1)}.mt-2{margin-top:var(--s-2)}.mt-3{margin-top:var(--s-3)}
.mt-4{margin-top:var(--s-4)}.mt-5{margin-top:var(--s-5)}.mt-6{margin-top:var(--s-6)}
.mb-1{margin-bottom:var(--s-1)}.mb-2{margin-bottom:var(--s-2)}.mb-3{margin-bottom:var(--s-3)}
.mb-4{margin-bottom:var(--s-4)}.mb-5{margin-bottom:var(--s-5)}.mb-6{margin-bottom:var(--s-6)}
.hidden          { display: none !important; }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.text-mono       { font-family: var(--font-mono); }
.text-muted      { color: var(--ink-2); }
.text-accent     { color: var(--accent); }
.text-danger     { color: var(--danger); }
.full-bleed      { width: 100vw; margin-left: 50%; transform: translateX(-50%); }

/* ─── Top bar ────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 242, 235, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.theme-dark .topbar { background: rgba(20,19,18,0.92); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4); gap: var(--s-4);
}
.brand {
  display: flex; align-items: center; gap: var(--s-3);
  text-decoration: none; color: var(--ink); border-bottom: 0;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 600; font-size: 18px; letter-spacing: 0.5px;
}
.brand-name {
  font-family: var(--font-display); font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.20em;
  color: var(--ink-3); margin-top: -2px; font-weight: 600;
}
.topbar-right { display: flex; align-items: center; gap: var(--s-3); }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 11px 18px; border-radius: var(--r-md);
  font-weight: 600; font-size: 14px; line-height: 1;
  border: 1px solid transparent; transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap; user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary    { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover  { background: var(--primary-hover, #2A2A2A); color: var(--primary-ink); }
.btn-accent     { background: var(--accent); color: #FBF9F4; }
.btn-accent:hover   { background: var(--accent-2); color: #FBF9F4; }
.btn-ghost      { background: transparent; color: var(--ink); border-color: var(--border-2); }
.btn-ghost:hover{ background: var(--surface-2); border-color: var(--ink); }
.btn-danger     { background: var(--danger); color: #FBF9F4; }
.btn-danger:hover{ background: #8C2A2A; }
.btn-lg         { padding: 16px 24px; font-size: 16px; border-radius: var(--r-lg); }
.btn-xl         { padding: 22px 28px; font-size: 18px; border-radius: var(--r-lg); }
.btn-block      { display: flex; width: 100%; }
.btn[disabled]  { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-icon       { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

/* ─── Cards & surfaces ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-5);
  box-shadow: var(--shadow-sm);
}
.card-tight  { padding: var(--s-4); }
.card-flat   { box-shadow: none; }
.card-accent { border-left: 4px solid var(--accent); }
.card-title  { font-family: var(--font-display); font-size: 22px; margin-bottom: var(--s-2); }
.card-sub    { color: var(--ink-2); font-size: 14px; margin-bottom: var(--s-4); }

.divider {
  height: 1px; background: var(--border); border: 0; margin: var(--s-4) 0;
}

/* Hero / page header */
.hero {
  padding: var(--s-7) 0 var(--s-6);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.hero-eyebrow {
  text-transform: uppercase; letter-spacing: 0.20em; font-size: 11px;
  color: var(--ink-3); font-weight: 600;
}
.hero-title { font-size: clamp(34px, 5vw, 54px); margin-top: var(--s-2); }
.hero-title em { font-style: italic; color: var(--accent); font-weight: 500; }
.hero-sub   { color: var(--ink-2); font-size: 17px; max-width: 620px; margin-top: var(--s-3); }

/* Reusable eyebrow label (matches landing) */
.eyebrow {
  display: inline-block;
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  letter-spacing: 0.20em; text-transform: uppercase;
  color: var(--ink-3);
}

/* ─── Forms ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-3); }
.field label { font-weight: 600; font-size: 13px; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-2);
  font-size: 15px; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 136, 77, 0.18);
}
.input-lg { padding: 16px 18px; font-size: 18px; border-radius: var(--r-lg); }
.input-code {
  text-transform: uppercase; letter-spacing: 0.25em; text-align: center;
  font-family: var(--font-mono); font-size: 24px; font-weight: 700;
}
.checkbox, .radio {
  display: flex; align-items: center; gap: var(--s-2);
  cursor: pointer; user-select: none; padding: 8px 0;
}
.checkbox input, .radio input { width: 18px; height: 18px; accent-color: var(--primary); }
.field-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { display: none; }
.switch-track {
  width: 44px; height: 26px; background: var(--border-2); border-radius: var(--r-pill);
  position: relative; transition: background var(--t-fast);
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: white;
  transition: left var(--t-fast); box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { left: 21px; }
.switch-label { font-size: 14px; font-weight: 600; }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td {
  text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-2); font-weight: 700; background: var(--surface-2);
}
.table tr:hover td { background: rgba(26,26,26,0.03); }
.table tr:last-child td { border-bottom: none; }

/* ─── Badges & chips ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.10em;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border);
}
.badge-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.badge-accent  { background: var(--accent); color: #FBF9F4; border-color: var(--accent); }
.badge-danger  { background: var(--danger); color: #FBF9F4; border-color: var(--danger); }
.badge-success { background: #4A7A53; color: #FBF9F4; border-color: #4A7A53; }
.badge-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

.kbd {
  font-family: var(--font-mono); font-size: 12px;
  padding: 2px 6px; border-radius: 4px; background: var(--surface-2);
  border: 1px solid var(--border-2); color: var(--ink-2);
}

/* ─── Stats / KPI cards ──────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-4);
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-4);
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-2); font-weight: 700; }
.stat-value { font-family: var(--font-display); font-size: 36px; font-weight: 700; line-height: 1; margin-top: var(--s-2); }
.stat-trend { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* ─── Leaderboard rows ───────────────────────────────────────────────── */
.lb-row {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: var(--s-3);
  transition: transform var(--t-med), box-shadow var(--t-med), background var(--t-med);
  cursor: pointer;
}
.lb-row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.lb-row.is-leader {
  background: linear-gradient(95deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #FBF9F4; border-color: var(--accent-2);
}
.lb-row.is-leader .lb-rank,
.lb-row.is-leader .lb-meta { color: #FBF9F4; }
.lb-rank {
  font-family: var(--font-display); font-size: 36px; font-weight: 700;
  text-align: center; color: var(--ink-2); line-height: 1;
}
.lb-team { display: flex; flex-direction: column; gap: 2px; }
.lb-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.lb-meta { font-size: 12px; color: var(--ink-2); }
.lb-score { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.lb-score-unit { font-size: 13px; color: var(--ink-2); margin-left: 4px; }
.lb-balls {
  grid-column: 1 / -1; margin-top: var(--s-3);
  border-top: 1px solid var(--border); padding-top: var(--s-3);
  display: none;
}
.lb-row.is-open .lb-balls { display: block; }
.lb-ball {
  display: grid; grid-template-columns: 30px 1fr 80px 80px;
  align-items: center; gap: var(--s-3);
  padding: 8px 0; font-size: 14px;
  border-bottom: 1px dashed var(--border);
}
.lb-ball:last-child { border: 0; }
.lb-ball-name { font-weight: 600; }
.lb-ball-loc { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.lb-ball-score { font-family: var(--font-mono); font-weight: 700; text-align: right; }

/* TV mode (full screen) */
.theme-dark .lb-row { background: var(--surface); border-color: var(--border-2); }
.theme-dark .lb-row.is-leader { background: linear-gradient(95deg, var(--accent), var(--accent-2)); color: #FBF9F4; border-color: var(--accent-2); }
.theme-dark .lb-row.is-leader .lb-rank,
.theme-dark .lb-row.is-leader .lb-meta { color: #FBF9F4; }
.tv-mode .lb-row { padding: var(--s-5); margin-bottom: var(--s-4); }
.tv-mode .lb-rank  { font-size: 56px; }
.tv-mode .lb-name  { font-size: 32px; }
.tv-mode .lb-score { font-size: 44px; }

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,26,26,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: var(--s-4); animation: fade var(--t-med);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  width: 100%; max-width: 520px; max-height: 90vh;
  /* Flex column so the body scrolls independently — header and footer
   * stay pinned. Without this the entire modal scrolls as one block on
   * mobile and the footer (e.g. "Save changes") drifts off-screen. */
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop var(--t-med);
}
.modal-lg { max-width: 800px; }
.modal-header, .modal-footer {
  flex: 0 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); gap: var(--s-3); }
.modal-body   { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--s-5); }
.modal-title  { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.modal-close  { font-size: 24px; line-height: 1; color: var(--ink-2); padding: 4px 8px; border-radius: var(--r-sm); }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }

/* ─── Toasts ─────────────────────────────────────────────────────────── */
#toast-stack {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: var(--s-2);
  max-width: 360px;
}
.toast {
  padding: 12px 16px; border-radius: var(--r-md); background: var(--surface);
  border-left: 4px solid var(--primary); box-shadow: var(--shadow-md);
  font-size: 14px; animation: slide var(--t-med);
}
.toast-success { border-left-color: #4A7A53; }
.toast-error   { border-left-color: var(--danger); }
.toast-warn    { border-left-color: var(--accent); }
.toast { color: var(--ink); border: 1px solid var(--border); border-left-width: 4px; }

/* ─── Tabs ───────────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex; background: var(--surface-2); padding: 4px;
  border-radius: var(--r-pill); border: 1px solid var(--border);
}
.tab {
  padding: 8px 16px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.tab.is-active { background: var(--primary); color: var(--primary-ink); }
.tab:hover:not(.is-active) { color: var(--ink); }

/* ─── Map ────────────────────────────────────────────────────────────── */
.map-container {
  width: 100%; height: 480px; border-radius: var(--r-lg);
  border: 1px solid var(--border-2); overflow: hidden; background: #1a1a1a;
}
.map-controls {
  display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-3);
  background: var(--surface); border-bottom: 1px solid var(--border);
}

/* ─── QR scanner ─────────────────────────────────────────────────────── */
.qr-wrap {
  position: relative; width: 100%; max-width: 380px; margin: 0 auto;
  aspect-ratio: 1; border-radius: var(--r-lg); overflow: hidden;
  background: #000; border: 1px solid var(--border-2);
}
.qr-wrap video { width: 100%; height: 100%; object-fit: cover; }
.qr-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(transparent 60px, rgba(0,0,0,0.5) 60px, rgba(0,0,0,0.5) calc(100% - 60px), transparent calc(100% - 60px)),
    linear-gradient(90deg, rgba(0,0,0,0.5) 60px, transparent 60px, transparent calc(100% - 60px), rgba(0,0,0,0.5) calc(100% - 60px));
}
.qr-frame {
  position: absolute; top: 60px; left: 60px; right: 60px; bottom: 60px;
  border: 3px solid var(--accent); border-radius: var(--r-md);
}

/* ─── Loaders ────────────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border-2);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .9s linear infinite;
}
.spinner-lg { width: 38px; height: 38px; border-width: 4px; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

/* ─── Empty state ────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: var(--s-7) var(--s-4);
  color: var(--ink-2);
}
.empty-icon { font-size: 48px; opacity: 0.6; margin-bottom: var(--s-3); }
.empty-title { font-family: var(--font-display); font-size: 22px; color: var(--ink); margin-bottom: var(--s-2); }

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop   { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse { 0%,100%{ transform:scale(1); opacity:1 } 50%{ transform:scale(1.04); opacity:.85 } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ─── Prevent horizontal overflow site-wide ─────────────────────────────── */
html { overflow-x: hidden; }
body { overflow-x: hidden; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .hide-mobile { display: none !important; }

  /* Leaderboard rows */
  .lb-row { grid-template-columns: 44px 1fr auto; }
  .lb-rank { font-size: 26px; }
  .lb-name { font-size: 18px; }
  .lb-score { font-size: 22px; }
  .lb-ball { grid-template-columns: 26px 1fr 70px; font-size: 13px; }

  /* Topbar */
  .topbar-inner { padding: var(--s-2) var(--s-3); gap: var(--s-2); flex-wrap: wrap; }
  .brand-name { font-size: 18px; }
  /* "JORD Super Admin · Super" caption hidden on narrow screens — it
   * was wrapping to 4 lines and pushing the Sign-out button off-screen.
   * Caller can re-show via the topbar dropdown if they want it back. */
  #topbar-user { display: none; }
  /* Shrink the brand-sub ("TOURNAMENT ADMIN") so the bar fits on phones */
  .brand-sub { padding-left: 8px !important; margin-left: 2px !important; font-size: 9px; }

  /* Hero */
  .hero { padding: var(--s-5) 0 var(--s-4); }

  /* Buttons — 44px minimum touch target */
  .btn { min-height: 44px; }

  /* Forms */
  .field-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 28px; }

  /* Container padding */
  .container { padding: 0 var(--s-3); }

  /* Tables — horizontal scroll */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
  .table { min-width: 480px; }
  .table th, .table td { padding: 10px; font-size: 13px; }

  /* Toast — full-width at bottom on mobile */
  #toast-stack { top: auto; bottom: 12px; left: 12px; right: 12px; max-width: none; }

  /* Modals — bottom sheet (iOS Safari: dvh respects the dynamic toolbar, env() respects the home-indicator safe area) */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 85dvh;
  }
  .modal-footer {
    /* Keep action buttons visible at the bottom; respect iOS home indicator */
    position: sticky; bottom: 0;
    background: var(--surface);
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom));
  }

  /* Map */
  .map-container { height: 300px; border-radius: var(--r-md); }
}

@media (min-width: 721px) {
  .hide-desktop { display: none !important; }
}

/* Help-bubble system — small ⓘ chip next to a label that reveals a tooltip
   on hover/focus. Originally lived inline in editor.html; moved here so the
   site editor + pairings + check-in can use it without duplicating CSS. */
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-size: 11px; font-weight: 700;
  cursor: help; margin-left: 4px; position: relative; flex-shrink: 0; }
.help-icon:hover, .help-icon:focus { background: var(--accent); color: var(--primary-ink); outline: none; }
.help-icon .tooltip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 9px 11px;
  font-size: 12px; color: var(--ink); width: 240px; white-space: normal; line-height: 1.45;
  text-align: left; font-weight: 400; text-transform: none; letter-spacing: 0;
  z-index: 1000; margin-bottom: 6px; box-shadow: var(--shadow-md); pointer-events: none;
}
.help-icon:hover .tooltip, .help-icon:focus .tooltip { display: block; }
.label-with-help { display: inline-flex; align-items: center; gap: 0; }
/* On phones, hover tooltips don't fire — tap-and-hold reveals via :focus.
   Also shift left-aligned tooltips so they don't clip off-screen near the
   right edge. */
@media (max-width: 640px) {
  .help-icon .tooltip { width: 200px; left: auto; right: 0; transform: none; }
}

/* Print friendly (for export pages) */
@media print {
  .topbar, .btn { display: none; }
  body { background: white; }
}
