/* ── Reset & Tokens ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: dark;
  --bg:        #0d0f14;
  --bg-card:   #141820;
  --bg-input:  #1a1f2e;
  --bg-hover:  #1e2435;
  --border:    #252c3f;
  --border-hi: #3a4460;

  --ink:       #eef1f8;
  --ink-2:     #9aa3ba;
  --ink-3:     #6b7491;

  /* High-contrast, colourblind-safe accents (Okabe–Ito) */
  --accent:    #4f9ae0;
  --accent-2:  #56b4e9;
  --accent-glow: rgba(79,154,224,.28);

  --green:     #2ecc8f;
  --yellow:    #f0e442;
  --red:       #ff6b4a;
  --orange:    #e69f00;

  --bg-2:      #1a1f2e;   /* alias for bg-input; widely used in inline styles */
  --surface:   #141820;   /* alias for bg-card; used in scoresheet sticky cells */
  --ink-1:     #cdd3e6;   /* mid tone between --ink and --ink-2 */

  /* Scoresheet selection colours — Correct=green, Error=red, Bonus=blue. */
  --c-correct:    #2ecc71;  --c-correct-bg: rgba(46,204,113,.16);
  --c-error:      #f05252;  --c-error-bg:   rgba(240,82,82,.15);
  --c-bonus:      #4f8ef0;  --c-bonus-bg:   rgba(79,142,240,.16);
  --rookie:       #22d3ee;  --rookie-bg:    rgba(34,211,238,.16);

  --r:         10px;
  --r-sm:      6px;
  --shadow:    0 2px 20px rgba(0,0,0,.5);

  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}

/* ── Theme: Light ─────────────────────────────────────────────────────────── */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f5f7fb;
  --bg-card:   #ffffff;
  --bg-input:  #eef1f7;
  --bg-hover:  #e6eaf3;
  --bg-2:      #eef1f7;
  --border:    #dce1ec;
  --border-hi: #c2cad9;
  --ink:       #1b2130;
  --ink-2:     #515a70;
  --ink-3:     #858ea6;
  --accent:    #3a66d0;
  --accent-2:  #6b4ce0;
  --accent-glow: rgba(58,102,208,.15);
  --green:     #1f9d61;
  --yellow:    #b8860b;
  --red:       #d83a3a;
  --orange:    #cf6f1a;
  --shadow:    0 2px 18px rgba(20,30,60,.10);
  --surface:   #ffffff;
  --ink-1:     #3d4660;
  --c-correct: #15803d;  --c-correct-bg: rgba(22,163,74,.16);
  --c-error:   #c62828;  --c-error-bg:   rgba(198,40,40,.13);
  --c-bonus:   #1d4ed8;  --c-bonus-bg:   rgba(29,78,216,.12);
  --rookie:    #0e7490;  --rookie-bg:    rgba(14,116,144,.13);
}

/* ── Theme: Brown / Beige ─────────────────────────────────────────────────── */
:root[data-theme="beige"] {
  color-scheme: light;
  --bg:        #e9ddc7;
  --bg-card:   #f4ecd9;
  --bg-input:  #e0d2b6;
  --bg-hover:  #d8c8a6;
  --bg-2:      #e0d2b6;
  --border:    #cdb897;
  --border-hi: #b09a72;
  --ink:       #3b2f20;
  --ink-2:     #6a5942;
  --ink-3:     #9a876a;
  --accent:    #9c5b2b;
  --accent-2:  #c08540;
  --accent-glow: rgba(156,91,43,.18);
  --green:     #5f7d3a;
  --yellow:    #b07d12;
  --red:       #a8452f;
  --orange:    #c0701f;
  --shadow:    0 2px 18px rgba(80,55,25,.15);
  --surface:   #f4ecd9;
  --ink-1:     #5a4835;
  --c-correct: #4d7a26;  --c-correct-bg: rgba(77,122,38,.18);
  --c-error:   #b0342a;  --c-error-bg:   rgba(176,52,42,.16);
  --c-bonus:   #2a5db0;  --c-bonus-bg:   rgba(42,93,176,.16);
  --rookie:    #155e6b;  --rookie-bg:    rgba(21,94,107,.18);
}

/* ── Theme: Retro (Super-Nintendo grey) ───────────────────────────────────── */
:root[data-theme="retro"] {
  color-scheme: light;
  --bg:        #cfcfd6;
  --bg-card:   #e3e3e9;
  --bg-input:  #c6c6cf;
  --bg-hover:  #bdbdc8;
  --bg-2:      #c6c6cf;
  --border:    #a8a8b4;
  --border-hi: #84848f;
  --ink:       #2b2b34;
  --ink-2:     #54545f;
  --ink-3:     #797985;
  --accent:    #6c5ca8;   /* SNES purple */
  --accent-2:  #9b8ec9;   /* lavender */
  --accent-glow: rgba(108,92,168,.22);
  --green:     #4f9a4a;
  --yellow:    #b8860b;
  --red:       #b8443f;
  --orange:    #c0701f;
  --shadow:    0 2px 16px rgba(60,55,80,.18);
  --surface:   #e3e3e9;
  --ink-1:     #3d3d4a;
  --c-correct: #3f7d3a;  --c-correct-bg: rgba(63,125,58,.16);
  --c-error:   #b8443f;  --c-error-bg:   rgba(184,68,63,.16);
  --c-bonus:   #2f5db0;  --c-bonus-bg:   rgba(47,93,176,.16);
  --rookie:    #245f6e;  --rookie-bg:    rgba(36,95,110,.18);
}
/* Retro flair: techy mono headings */
:root[data-theme="retro"] .brand h1,
:root[data-theme="retro"] .meet-title,
:root[data-theme="retro"] .nav-brand {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -.5px;
}

/* ── Text size scale (scales rem-based UI proportionally) ─────────────────── */
:root[data-font="sm"] { font-size: 15px; }  /* Small  (base) */
:root[data-font="md"] { font-size: 18px; }  /* Medium (between) */
:root[data-font="lg"] { font-size: 21px; }  /* Large  (biggest) */
:root[data-font="xl"] { font-size: 21px; }  /* legacy alias → Large */

/* ── Appearance control (floating theme + text-size picker) ───────────────── */
#appearance-fab {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 950;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
#appearance-fab:hover { transform: scale(1.08); background: var(--bg-hover); }

#appearance-panel {
  position: fixed;
  right: 16px; bottom: 66px;
  z-index: 951;
  width: min(260px, calc(100vw - 32px));
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px;
}
#appearance-panel.hidden { display: none; }
.appr-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin-bottom: 8px; font-weight: 700;
}
.appr-themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.appr-theme {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--ink-2); cursor: pointer; font-size: .78rem; font-weight: 500;
  transition: border-color .12s, color .12s;
}
.appr-theme:hover { color: var(--ink); }
.appr-theme.active { border-color: var(--accent); color: var(--ink); }
.appr-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(128,128,128,.45); flex-shrink: 0; }
.appr-sizes { display: flex; gap: 6px; }
.appr-size {
  flex: 1; padding: 6px 0; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--ink-2); cursor: pointer; font-weight: 700; line-height: 1;
  transition: border-color .12s, color .12s, background .12s;
}
.appr-size:hover { color: var(--ink); }
.appr-size.active { border-color: var(--accent); color: var(--ink); background: var(--bg-hover); }

/* Send-a-request form inside the appearance panel */
.appr-divider {
  height: 1px; background: var(--border); margin: 14px 0;
}
.appr-request-msg, .appr-request-contact {
  width: 100%; box-sizing: border-box;
  background: var(--bg-input); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 9px; font-size: .82rem; font-family: inherit;
  margin-bottom: 8px; resize: vertical;
}
.appr-request-msg:focus, .appr-request-contact:focus {
  outline: none; border-color: var(--accent);
}
.appr-request-send {
  width: 100%; padding: 8px 0; border-radius: var(--r-sm);
  border: 1px solid var(--accent); background: var(--accent);
  color: #fff; cursor: pointer; font-weight: 700; font-size: .82rem;
  transition: opacity .12s;
}
.appr-request-send:hover { opacity: .9; }
.appr-request-send:disabled { opacity: .55; cursor: default; }
.appr-request-status {
  font-size: .74rem; margin-top: 7px; min-height: 1em; line-height: 1.35;
}
.appr-request-status.ok  { color: var(--green, #2e9e57); }
.appr-request-status.err { color: var(--red, #d4543a); }

/* Sidebar copy of the appearance controls */
.appr-side {
  padding: 12px 0;
  margin-bottom: 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.appr-side .appr-themes { margin-bottom: 0; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.view   { display: none; }
.view.active { display: flex; }

/* ── Sign-in view ────────────────────────────────────────────────────────── */
#view-signin {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(79,126,255,.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 75% 70%, rgba(124,92,252,.06) 0%, transparent 70%);
}

.signin-wrap {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 32px;
  animation: fadeUp .5s ease both;
}

.brand { text-align: center; }

.brand-icon {
  font-size: 48px;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  display: block;
}

.brand h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: -.5px;
}

.brand h1 em {
  font-style: italic;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: .875rem;
}

.signin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.signin-note {
  font-size: .8rem;
  color: var(--ink-3);
  text-align: center;
  margin-top: 18px;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
#view-app {
  min-height: 100vh;
  flex-direction: row;
}

/* ── Viewer shell ─────────────────────────────────────────────────────────── */
#view-viewer {
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}
#view-viewer .viewer-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
#view-viewer .viewer-body {
  flex: 1;
  padding: 24px;
  overflow-x: auto;
  overflow-y: auto;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-top {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 8px;
}

.nav-user {
  font-size: .78rem;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-list {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
  color: var(--ink-2);
  transition: all .15s;
}

.nav-item:hover { background: var(--bg-hover); color: var(--ink); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
/* Fixed-size icon box so every label starts at the same x-position,
   regardless of emoji glyph width. */
.nav-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.sidebar-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ── Main content ─────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  padding: 32px 36px;
  max-width: none;
}

.tab-section { display: none; }
.tab-section.active { display: block; }

.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.page-header p { color: var(--ink-2); font-size: .9rem; }

/* ── Mode Toggle ─────────────────────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--r);
  width: fit-content;
  margin-bottom: 24px;
}

.mode-btn {
  padding: 8px 24px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  font-size: .875rem;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 20px;
}

.card h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  margin-bottom: 18px;
  color: var(--ink);
}

.card-note {
  font-size: .82rem;
  color: var(--ink-2);
  margin-bottom: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.setup-cols {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
}
.setup-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Setup tab explicit column placement — resets to auto on mobile so cards flow in source order */
.setup-col-l { grid-column: 1; }
.setup-col-r { grid-column: 2; }
@media (max-width: 700px) {
  .setup-col-l, .setup-col-r { grid-column: auto; }
}

/* ── Fields ───────────────────────────────────────────────────────────────── */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.field-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 130px;
}

.field-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  padding: 8px 12px;
  transition: border-color .15s;
  outline: none;
  width: 100%;
}

.field-input.sm { width: 90px; }
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

select.field-input { cursor: pointer; }

.field-hint {
  font-size: .78rem;
  color: var(--ink-3);
}

.roster-area {
  width: 100%;
  min-height: 240px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: .83rem;
  padding: 12px;
  resize: vertical;
  outline: none;
  line-height: 1.7;
}

.roster-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 10px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.btn-primary:hover { opacity: .85; }
.btn-primary:active { transform: scale(.97); }
.btn-primary.small { padding: 7px 16px; font-size: .82rem; }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 8px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.btn-secondary:hover { background: var(--accent-glow); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.btn-ghost:hover { color: var(--ink); border-color: var(--border-hi); }
.btn-ghost.small { padding: 6px 12px; font-size: .8rem; }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(240,82,82,.1); }

/* ── Info bubbles ─────────────────────────────────────────────────────────── */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  background: transparent;
  color: var(--ink-3);
  font-size: .65rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}
.info-btn:hover  { color: var(--accent); border-color: var(--accent); }
.info-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

.info-popover {
  position: fixed;
  top: 0; left: 0; /* JS overrides before unhiding; defaults prevent flash at 0,0 */
  z-index: 4000;
  min-width: 160px;
  max-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  padding: 14px 32px 14px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  font-size: .85rem;
  line-height: 1.6;
  color: var(--ink);
}
.info-popover.hidden { display: none; }
/* Preserve newlines in tooltip text so numbered lists show one item per line */
#info-popover-text { white-space: pre-line; }

.info-popover-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: .8rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.info-popover-close:hover { color: var(--ink); }

.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.status-msg {
  font-size: .82rem;
  color: var(--green);
}

/* ── Changes list ─────────────────────────────────────────────────────────── */
.changes-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.change-pill, .team-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: .82rem;
}

.team-pool-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.change-pill .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-add    { background: rgba(61,214,140,.15); color: var(--green); }
.badge-remove { background: rgba(240,82,82,.15);  color: var(--red); }

/* ── Meets container ──────────────────────────────────────────────────────── */
.meets-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.meet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}

.meet-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  transform: translateY(-2px);
}

.meet-card.pending { opacity: .78; }
.meet-card.ready   { border-color: var(--accent); }
.meet-card.locked  { border-color: var(--green); }

.meet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.meet-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
}

.meet-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.meet-badge.pending  { background: rgba(90,98,120,.2); color: var(--ink-2); }
.meet-badge.ready    { background: rgba(79,126,255,.15); color: var(--accent); }
.meet-badge.locked   { background: rgba(61,214,140,.15); color: var(--green); }
.meet-badge.complete { background: rgba(61,214,140,.15); color: var(--green); }
.meet-card.complete  { border-left: 4px solid var(--green); }

.meet-card-body { padding: 16px 20px; }
.meet-meta { font-size: .8rem; color: var(--ink-2); margin-bottom: 14px; line-height: 1.6; }

.meet-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Schedule grid (inside meet detail) ──────────────────────────────────── */
.sched-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  margin-top: 12px;
}

.sched-grid th {
  background: var(--bg-input);
  color: var(--ink-2);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .05em;
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-hi);
}

.sched-grid td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-hi);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
}

.sched-grid tr:last-child td { border-bottom: none; }
.sched-grid tr:hover td { background: var(--bg-hover); }

.sched-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.sched-grid.transposed {
  margin-top: 0;
  table-layout: fixed;
  min-width: 800px; /* Ensure enough room for columns */
}

.sched-grid.transposed th {
  text-align: center;
  border-right: 1px solid var(--border-hi);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sched-grid.transposed th:last-child {
  border-right: none;
}

.sched-grid.transposed td {
  text-align: center;
  border-right: 1px solid var(--border-hi);
  vertical-align: middle;
  padding: 8px 8px;
  position: relative;
}

.sched-grid.transposed td:last-child {
  border-right: none;
}

.sched-grid.transposed tr.slot-group-end td {
  border-bottom: 2px solid var(--border-hi);
}

.empty-cell {
  color: var(--ink-3) !important;
  font-style: italic;
}

.pos-a { color: #4f7eff; }
.pos-b { color: #a78bfa; }
.pos-c { color: #38bdf8; }

/* ── Viewer team cells ──────────────────────────────────────────────────────── */
.viewer-team {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.viewer-highlight {
  background: #fff176;
  color: #1a1a1a !important;
  font-weight: 600;
  border-radius: 4px;
}
.viewer-dim {
  opacity: .35;
  transition: opacity .15s;
}
.viewer-quiz-cell {
  cursor: pointer;
  transition: background .12s;
}
.viewer-quiz-cell:hover {
  background: var(--bg-hover) !important;
}

/* ── Meet detail modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  width: min(820px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}

.modal-header h3 { font-family: 'DM Serif Display', serif; font-size: 1.3rem; }
.modal-close { background: none; border: none; color: var(--ink-2); font-size: 1.4rem; cursor: pointer; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 24px 28px; }

/* ── Scoresheet sticky name column ───────────────────────────────────────── */
.ss-q-name {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-card);
  box-shadow: 3px 0 8px -2px rgba(0,0,0,.45);
}
.ss-drag-handle {
  cursor: grab;
  color: var(--ink-3);
  font-size: .85rem;
  opacity: .4;
  flex-shrink: 0;
  user-select: none;
  padding: 0 1px;
  transition: opacity .12s;
}
.ss-drag-handle:hover { opacity: .85; }
.ss-drag-handle:active { cursor: grabbing; }
.ss-q-name.ss-drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: rgba(71,119,224,.1) !important;
}
.ss-q-name.ss-drag-source { opacity: .45; }

/* ── Cross-ref table ──────────────────────────────────────────────────────── */
.cross-table-wrap { overflow-x: auto; margin-top: 16px; }

.cross-table {
  border-collapse: collapse;
  font-size: .72rem;
  white-space: nowrap;
}

.cross-table th, .cross-table td {
  border: 1px solid var(--border-hi);
  padding: 4px 7px;
  text-align: center;
}

.cross-table th {
  background: var(--bg-input);
  color: var(--ink-2);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .62rem;
}

.cross-table td.row-head {
  background: var(--bg-input);
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
}

.cross-table td.diag   { background: var(--bg-hover); }
.cross-table td.cnt-0  { color: var(--ink-3); }
.cross-table td.cnt-1  { background: rgba(61,214,140,.12); color: var(--green); font-weight: 600; }
.cross-table td.cnt-2  { background: rgba(245,200,66,.12); color: var(--yellow); font-weight: 600; }
.cross-table td.cnt-hi { background: rgba(240,82,82,.15);  color: var(--red);    font-weight: 700; }

.sum-col { background: rgba(79,126,255,.08) !important; color: var(--accent) !important; font-weight: 700; }

/* ── Day schedule table (editor + read-only view) ─────────────────────────── */
.day-table {
  border-collapse: collapse;
  width: auto;
  min-width: 320px;
  max-width: 100%;
  font-size: .9rem;
}
.day-table th, .day-table td {
  border: 1px solid var(--border-hi);
  vertical-align: middle;
}
.day-table th { background: var(--bg-input); text-align: center; }
.day-table td { padding: 0; text-align: center; } /* editor inputs carry their own padding */
.day-table input { font-family: inherit; text-align: center; }
.day-table input::placeholder { color: var(--ink-3); }
.day-table .day-del {
  background: none; border: none; color: var(--ink-3);
  cursor: pointer; font-size: .8rem; line-height: 1;
  padding: 3px 5px; border-radius: 4px; flex-shrink: 0;
}
.day-table .day-del:hover { color: var(--red); background: var(--bg-hover); }
.ds-drag-handle {
  width: 24px; text-align: center; color: var(--ink-3);
  cursor: grab; font-size: 1rem; user-select: none; padding: 0 3px;
}
.ds-drag-handle:active { cursor: grabbing; }
/* Read-only (viewer) variant: comfortable cell padding, zebra rows */
.day-table-view th, .day-table-view td { padding: 9px 16px; }
.day-table-view th {
  color: var(--ink-2); font-weight: 700;
  font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
}
.day-table-view tbody tr:nth-child(even) td { background: var(--bg-2); }
/* Currently-active row highlight (viewer) */
.day-table-view .ds-active-row td {
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
  font-weight: 600;
}
.day-table-view .ds-active-row td:first-child {
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
/* Section-header rows (span all columns) */
.day-table .ds-span-row td,
.day-table-view .ds-span-row td {
  background: var(--bg-2);
  border-top: 2px solid var(--border-hi);
  border-bottom: 2px solid var(--border-hi);
  text-align: center;
  color: var(--ink-2);
}
.day-table .ds-span-row td { padding: 4px 8px; }
.day-table-view .ds-span-row td {
  font-weight: 700; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 6px 16px;
}

/* ── Gen status bar ───────────────────────────────────────────────────────── */
.gen-status-bar {
  margin-top: 16px;
  font-size: .85rem;
  color: var(--ink-2);
  min-height: 20px;
}

/* ── Spinner overlay ──────────────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}

.spinner-box {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  padding: 40px 56px;
  text-align: center;
}

.spinner-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

#spinner-msg   { font-weight: 600; font-size: 1rem; }
.spinner-sub   { font-size: .82rem; color: var(--ink-2); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 30px;
  padding: 10px 22px;
  font-size: .875rem;
  box-shadow: var(--shadow);
  z-index: 3000;
  animation: fadeUp .2s ease;
}

.toast.error  { border-color: var(--red);   color: var(--red); }
.toast.success{ border-color: var(--green); color: var(--green); }

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px) } to { opacity: 1; transform: none } }
@keyframes spin    { to { transform: rotate(360deg) } }

/* ── Requirement toggle switches ─────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track-ui {
  display: flex;
  align-items: center;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  transition: background .2s;
  padding: 0 3px;
}
.toggle-switch input:checked + .toggle-track-ui { background: var(--accent); }
.toggle-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track-ui .toggle-thumb { transform: translateX(18px); }
.req-status {
  font-size: .78rem;
  font-weight: 600;
  min-width: 28px;
}
.req-status.on  { color: var(--green, #2e7d32); }
.req-status.off { color: var(--ink-3); }

/* ── Viewer tab bar ───────────────────────────────────────────────────────── */
.viewer-tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  padding: 3px;
}
.viewer-tab-btn {
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: .82rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: calc(var(--r-sm) - 2px);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.viewer-tab-btn.active {
  background: var(--bg-card);
  color: var(--ink);
}
.viewer-tab-btn:hover:not(.active) { color: var(--ink); }

/* ── Live bracket card action buttons ────────────────────────────────────── */
.btn-enter-result {
  width: 100%;
  margin-top: 10px;
  font-size: .78rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity .15s;
}
.btn-enter-result:hover { opacity: .85; }
.btn-clear-result {
  width: 100%;
  margin-top: 4px;
  font-size: .72rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-clear-result:hover { border-color: var(--red); color: var(--red); }

/* ── Mobile top bar (hidden on desktop) ──────────────────────────────────── */
#mobile-topbar {
  display: none;
}
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 98;
}

/* ── Responsive — mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Show mobile top bar */
  #mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 99;
    flex-shrink: 0;
  }

  /* Hamburger button */
  #hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
  }
  #hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
  }

  /* Sidebar becomes a slide-in drawer */
  #view-app { flex-direction: column; }
  #sidebar {
    position: fixed;
    top: 0; left: -260px;
    width: 240px !important;
    height: 100vh;
    z-index: 100;
    transition: left .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  #sidebar.open { left: 0; }
  #sidebar.open ~ #sidebar-overlay,
  .sidebar-open #sidebar-overlay { display: block; }

  #main-content {
    padding: 16px 12px;
    width: 100%;
    min-width: 0;
  }

  /* Cards stack vertically */
  .card-grid, .two-col { grid-template-columns: 1fr !important; }
  .setup-cols { flex-direction: column; }

  /* Schedule modal full-screen */
  .modal { width: 100vw !important; max-width: 100vw; max-height: 100vh; border-radius: 0; margin: 0; }
  .modal-overlay { align-items: flex-end; }

  /* Viewer top bar wraps gracefully */
  .viewer-topbar { gap: 8px; padding: 10px 14px; }
  #viewer-find-row { margin-left: 0 !important; width: 100%; order: 10; }
  #viewer-find-row select { flex: 1; }

  /* Viewer body horizontal scroll hint */
  .viewer-body { padding: 12px; }
  .viewer-body table { font-size: .78rem; }

  /* ── Forms: stack label / input / hint vertically ────────────────── */
  .field-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .field-label { min-width: 0; }
  .field-input.sm { width: 100%; }

  /* ── Cards ───────────────────────────────────────────────────────── */
  .card { padding: 14px; }

  /* ── Page headers ────────────────────────────────────────────────── */
  .page-header h2 { font-size: 1.4rem; }
  .page-header { margin-bottom: 16px; padding-bottom: 14px; }

  /* ── Modals ──────────────────────────────────────────────────────── */
  .modal-header { padding: 14px 16px; }
  .modal-body   { padding: 14px 16px; }

  /* ── Action rows ─────────────────────────────────────────────────── */
  .action-row { flex-wrap: wrap; }
  .action-row > button { flex: 1 1 auto; min-width: 110px; }

  /* ── Mode toggle stretches full width ────────────────────────────── */
  .mode-toggle { width: 100%; }
  .mode-btn { flex: 1; padding: 8px 10px; }

  /* ── Meets container: single column on narrow screens ───────────── */
  .meets-container { grid-template-columns: 1fr; }

  /* ── Transfer form grids: collapse to one column ─────────────────── */
  .transfer-form-grid,
  .group-assign-form-grid { grid-template-columns: 1fr !important; }

  /* ── Viewer tab bar: scroll horizontally if tabs overflow ────────── */
  .viewer-tab-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  .viewer-tab-btn { flex-shrink: 0; }
}

/* ── Mobile scoresheet feed — rendered by JS on screens ≤ 768 px ───────── */
.ss-mobile-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.ss-mobile-feed {
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* clear fixed score footer */
}

.ss-mobile-feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-left: 3px solid transparent;
  font-size: .83rem;
  min-height: 40px;
}

.ss-mobile-feed-row:nth-child(odd) { background: rgba(255,255,255,.02); }

.ss-mobile-feed-row.correct { border-left-color: var(--c-correct); }
.ss-mobile-feed-row.error   { border-left-color: var(--c-error); }
.ss-mobile-feed-row.bonus   { border-left-color: var(--c-bonus); }

.ss-mobile-feed-row.sub-question { padding-left: 28px; }
.ss-mobile-feed-row.sub-question .ss-mobile-q-label { opacity: .6; }

.ss-mobile-feed-row.unanswered { opacity: .4; }

.ss-mobile-q-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  color: var(--ink-3);
  width: 38px;
  flex-shrink: 0;
}

.ss-mobile-type-badge {
  font-size: .62rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  color: var(--ink-2);
  width: 36px;
  text-align: center;
  letter-spacing: .02em;
}

.ss-mobile-result {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.ss-mobile-who {
  font-weight: 600;
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.ss-mobile-outcome {
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Score footer — fixed to bottom of viewport */
.ss-mobile-score-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border-hi);
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ss-mobile-score-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  gap: 2px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.ss-mobile-score-panel:last-child { border-right: none; }

/* seat-a = Red team (left), seat-b = White team (centre), seat-c = Blue team (right).
   These are physical match colours, not quizzer positions (.pos-a/b/c). */
.ss-mobile-score-panel.seat-a {
  border-top: 2px solid rgba(220, 60, 60, .65);
  background: rgba(220, 60, 60, .08);
}

.ss-mobile-score-panel.seat-b {
  border-top: 2px solid rgba(200, 200, 200, .4);
  background: rgba(200, 200, 200, .05);
}

.ss-mobile-score-panel.seat-c {
  border-top: 2px solid rgba(71, 119, 224, .65);
  background: rgba(71, 119, 224, .08);
}

.ss-mobile-score-name {
  font-size: .62rem;
  color: var(--ink-3);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
}

.ss-mobile-score-pts {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

/* ── Offline banner ──────────────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--yellow);
  color: var(--bg);
  text-align: center;
  padding: 10px 16px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

/* ── Smooth scroll ───────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

/* ── Custom scrollbars (WebKit + Firefox) ────────────────────────────────── */
::-webkit-scrollbar             { width: 6px; height: 6px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-corner      { background: transparent; }
*                               { scrollbar-width: thin; scrollbar-color: var(--border-hi) transparent; }

/* ── Remove number-input spinners ────────────────────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── Tabular numbers on all data tables ──────────────────────────────────── */
.standings-table,
.cross-table,
.sched-grid,
.ss-table { font-variant-numeric: tabular-nums; }

/* ── Page-header accent underline ────────────────────────────────────────── */
.page-header h2 {
  position: relative;
  padding-bottom: 14px;
  margin-bottom: 0; /* was 4px; visual gap now comes from padding */
}
.page-header h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  gap: 10px;
}
.empty-state-icon  { font-size: 2.2rem; opacity: .45; line-height: 1; }
.empty-state-title { font-size: .95rem; font-weight: 600; color: var(--ink-2); }
.empty-state-sub   { font-size: .82rem; color: var(--ink-3); max-width: 280px; line-height: 1.55; }

/* ── Tab-switch fade ─────────────────────────────────────────────────────── */
.tab-section.active { animation: fadeIn .2s ease both; }

/* ── Custom select arrow ─────────────────────────────────────────────────── */
select.field-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6278' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Content-sized dropdowns: grow to fit the selected option (so larger text
   sizes don't clip the value) but cap the width so a long option can't make
   the box huge. Overrides any inline fixed width on these selects. */
select.sel-fit {
  width: auto !important;
  min-width: 80px;
  max-width: min(240px, 100%);
}

/* ── Sidebar program name ────────────────────────────────────────────────── */
.nav-program {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Skeleton loading rows ───────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row {
  height: 44px;
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
  margin-bottom: 4px;
}

/* ── Card section-heading divider ────────────────────────────────────────── */
.card h3 { margin-bottom: 6px; } /* spacing now split across ::after */
.card h3::after {
  content: '';
  display: block;
  height: 1px;
  background: var(--border);
  margin-top: 12px;
  margin-bottom: 16px;
}

/* ── Sticky table headers ─────────────────────────────────────────────────── */
/* Bound long data tables so their (already sticky) headers actually freeze. */
div:has(> table.standings-table),
div:has(> table.cross-table:not(.bracket-grid-table)) {
  max-height: 72vh;
  overflow: auto;
}
.cross-table:not(.bracket-grid-table) thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-input);
}

/* ── Print stylesheet ─────────────────────────────────────────────────────── */
@media print {
  /* Force a clean light palette regardless of the active theme */
  :root, :root[data-theme] {
    --bg:#fff; --bg-card:#fff; --bg-input:#fff; --bg-hover:#fff; --bg-2:#fff;
    --border:#bbb; --border-hi:#999;
    --ink:#000; --ink-2:#222; --ink-3:#555;
    --shadow:none;
    --c-correct:#157a37; --c-correct-bg:#eaf5ee;
    --c-error:#b42020;   --c-error-bg:#fbecec;
    --c-bonus:#1b50c0;   --c-bonus-bg:#eaf0fb;
  }
  html, body { background:#fff !important; color:#000 !important; }

  /* Hide app chrome — keep only the content */
  #sidebar, #mobile-topbar, #sidebar-overlay,
  #appearance-fab, #appearance-panel,
  #toast, #info-popover, #offline-banner,
  .viewer-topbar, .meet-actions, .action-row,
  .gen-status-bar, .skeleton-row {
    display: none !important;
  }

  #main-content { padding: 0 !important; width: 100% !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }

  /* Let tables print in full (no internal scroll) and avoid splitting rows */
  div:has(> table.standings-table),
  div:has(> table.cross-table) { max-height: none !important; overflow: visible !important; }
  table { border-collapse: collapse; }
  thead { display: table-header-group; }   /* repeat headers on each page */
  tr, .meet-card, .ss-team-block { break-inside: avoid; }
  a { color: #000 !important; text-decoration: none; }
}
