/* World Cup 2026 Tracker — Liquid Glass Edition
   Inspired by Apple visionOS / iOS 26 liquid-glass material,
   recolored with the FIFA World Cup identity palette (stadium-at-dusk):
   - Deep charcoal substrate (not the AI-template navy)
   - Trophy gold primary
   - Signal red accent (live/alerts)
   - Pitch green for success/active states
*/

/* ─── Design tokens ─── */
:root {
  /* Substrate — stadium charcoal with warm blood-red blob */
  --bg-base: #0d0a08;
  --bg-blob-1: #b8202c;   /* signal red */
  --bg-blob-2: #d4a017;   /* trophy amber */
  --bg-blob-3: #1a6b3a;   /* pitch green */

  /* Glass surfaces — warm white-tinted */
  --glass-bg:        rgba(255, 248, 235, 0.05);   /* slight cream tint, not pure white */
  --glass-bg-hover:  rgba(255, 248, 235, 0.09);
  --glass-bg-active: rgba(255, 248, 235, 0.13);
  --glass-border:    rgba(255, 214, 10, 0.14);    /* gold-tinted borders */
  --glass-border-strong: rgba(255, 214, 10, 0.28);
  --glass-highlight: rgba(255, 248, 235, 0.28);   /* warm cream top highlight */
  --glass-shadow:    0 8px 32px rgba(0, 0, 0, 0.55);

  /* FIFA WC 2026 palette */
  --gold: #ffd60a;          /* trophy gold */
  --gold-deep: #d4a017;     /* deeper amber for gradients */
  --gold-glow: rgba(255, 214, 10, 0.45);
  --gold-soft: rgba(255, 214, 10, 0.12);

  --live: #e63946;          /* signal red — used for live/urgent */
  --live-glow: rgba(230, 57, 70, 0.55);
  --live-soft: rgba(230, 57, 70, 0.14);

  --pitch: #06d6a0;         /* pitch green — success, active */
  --pitch-glow: rgba(6, 214, 160, 0.45);
  --pitch-soft: rgba(6, 214, 160, 0.14);

  --accent: #ffd60a;        /* gold is the primary action color now, not cyan */
  --accent-glow: rgba(255, 214, 10, 0.45);

  /* Typography — warm whites */
  --text: rgba(255, 248, 235, 0.96);
  --text-dim: rgba(255, 248, 235, 0.66);
  --text-faint: rgba(255, 248, 235, 0.42);

  /* Option text color for form controls — ensures visibility on light browser-default styling */
  --option-text: #1a1410;
  --option-bg: #fff8eb;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;

  --blur-sm: 20px;
  --blur-md: 30px;
  --blur-lg: 40px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  /* Bump base font size to industry standard (BBC, Sky, Apple, ESPN all use 17-19px).
     Old base was 16px, raised to 18px previously, now 19px for stronger readability. */
  font-size: 19px;
  -webkit-text-size-adjust: 100%;
}

html, body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  overflow-x: hidden;
  position: relative;
  font-feature-settings: 'ss01', 'cv11';
  letter-spacing: -0.01em;
}

/* ─── Animated background blobs — warm stadium floodlights ─── */
body::before {
  content: '';
  position: fixed;
  inset: -10vh -10vw;
  z-index: -2;
  background:
    radial-gradient(42vw 42vw at 18% 22%, var(--bg-blob-1) 0%, transparent 58%),
    radial-gradient(36vw 36vw at 82% 65%, var(--bg-blob-2) 0%, transparent 58%),
    radial-gradient(48vw 48vw at 50% 95%, var(--bg-blob-3) 0%, transparent 58%);
  filter: blur(50px) saturate(150%);
  opacity: 0.5;
  animation: bgDrift 32s ease-in-out infinite alternate;
}

@keyframes bgDrift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(3vw, -2vh) scale(1.06); }
  100% { transform: translate(-2vw, 3vh) scale(1.02); }
}

/* Subtle grain — kills banding, adds cinema feel */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* ─── Glass primitive ─── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

/* ─── Header ─── */
header {
  padding: 18px 18px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 10, 8, 0.5);
  backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 4px 24px rgba(0, 0, 0, 0.4);
}
header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #fff8eb 0%, var(--gold) 50%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}
.tagline {
  /* Quiet but readable feature summary right under the title.
     Hidden on phone (≤720px) to keep the static header compact.
     Shows on tablet+ where there's room. */
  display: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.35;
  max-width: 720px;
  letter-spacing: 0.005em;
}
@media (min-width: 720px) {
  .tagline { display: block; }
}
.subtitle {
  font-size: 0.84rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.header-actions button {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  white-space: nowrap;
}
.header-actions button:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
}
.header-actions button:active { transform: scale(0.97); }
.header-actions button.active {
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.28), rgba(255, 214, 10, 0.12));
  border-color: var(--gold);
  color: var(--gold);
  box-shadow:
    0 0 16px var(--gold-glow),
    inset 0 1px 0 var(--glass-highlight);
}

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(13, 10, 8, 0.55);
  backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  position: sticky;
  top: 0;
  z-index: 99;
}
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: all 0.2s;
}
.filter-toggle:hover { background: var(--glass-bg-hover); }
.filter-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}
.filter-summary {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
  padding-left: 4px;
}

/* ─── Sync badge ─── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 7px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-start;
  user-select: none;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.sync-badge:hover {
  border-color: var(--glass-border-strong);
  background: var(--glass-bg-hover);
  color: var(--text);
}
.sync-badge:active { transform: scale(0.97); }
.sync-badge .sync-icon { font-size: 0.85rem; }
.sync-badge.ok {
  border-color: rgba(6, 214, 160, 0.4);
  color: var(--pitch);
  background: var(--pitch-soft);
}
.sync-badge.error {
  border-color: rgba(230, 57, 70, 0.4);
  color: var(--live);
  background: var(--live-soft);
}
.sync-badge.syncing {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}
.sync-badge.syncing .sync-icon {
  animation: spin 1s linear infinite;
  display: inline-block;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 16, 10, 0.75);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 24px;
  border: 1px solid var(--glass-border-strong);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-highlight),
    0 0 20px var(--gold-glow);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 14px 14px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 9px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.tab:hover { color: var(--text); background: var(--glass-bg-hover); }
.tab.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1a1410;
  border-color: transparent;
  font-weight: 700;
  box-shadow:
    0 4px 16px var(--gold-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ─── Match list ─── */
.match-list {
  padding: 8px 14px 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.date-header {
  padding: 14px 8px 6px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  margin-top: 10px;
  border-bottom: 1px solid transparent;
}
.date-header.today {
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold-glow);
}

/* ─── Match card ─── */
.match-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-highlight);
}
.match-card::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  background: var(--glass-border-strong);
  border-radius: 0 3px 3px 0;
  transition: all 0.3s;
}
.match-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
  transform: translateY(-1px);
}
.match-card:active { transform: scale(0.99); }

/* Favorite — gold trophy glow */
.match-card.favorite {
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.14), rgba(212, 160, 23, 0.04));
  border-color: rgba(255, 214, 10, 0.42);
  box-shadow:
    0 0 28px var(--gold-glow),
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-highlight);
}
.match-card.favorite::before {
  width: 4px;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold-glow);
}

/* Live — pulsing red */
.match-card.live {
  border-color: rgba(230, 57, 70, 0.5);
  animation: livePulse 2.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent, var(--glass-shadow), inset 0 1px 0 var(--glass-highlight); }
  50% { box-shadow: 0 0 28px -2px var(--live-glow), var(--glass-shadow), inset 0 1px 0 var(--glass-highlight); }
}

.match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.match-phase {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 4px 10px;
  border-radius: 6px;
}
.match-card.favorite .match-phase {
  color: var(--gold);
  background: var(--gold-soft);
  border-color: rgba(255, 214, 10, 0.32);
}
.match-time {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.team {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.team:last-child { justify-content: flex-end; text-align: right; }
.team .flag-svg {
  flex-shrink: 0;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}
.flag-placeholder {
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.team-name {
  font-size: 0.94rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.team.is-favorite .team-name {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold-glow);
}
.team.is-favorite .team-name::before {
  content: '★ ';
  font-size: 0.78em;
  margin-right: 1px;
}
.vs {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-faint);
  flex-shrink: 0;
  padding: 0 6px;
  letter-spacing: 0.5px;
}
.match-card.favorite .vs { color: var(--gold); }

.match-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
  gap: 8px;
  flex-wrap: wrap;
}
.match-venue, .match-broadcast {
  font-size: 0.82rem;
  color: var(--text-dim);
}
.match-broadcast { font-weight: 600; }
.match-countdown {
  font-size: 0.86rem;
  color: var(--text-dim);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.match-countdown.live { color: var(--live); font-weight: 800; text-shadow: 0 0 10px var(--live-glow); }
.match-countdown.finished { color: var(--text-faint); }

.timer-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--gold-soft);
  color: var(--gold);
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 214, 10, 0.32);
}

/* ─── Modals (heavy glass) ─── */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal.hidden { display: none; }
.hidden { display: none !important; }

/* ─── Sync modal ─── */
.sync-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.sync-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.sync-action:hover {
  background: var(--glass-bg-hover);
  border-color: var(--gold);
  transform: translateY(-1px);
}
.sync-action:active { transform: scale(0.99); }
.sync-action-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 2.4rem;
  text-align: center;
}
.sync-action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.sync-action-text strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}
.sync-action-text span {
  font-size: 0.76rem;
  color: var(--text-dim);
  line-height: 1.35;
}
.sync-section {
  margin-bottom: 14px;
}
.sync-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.sync-section textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.78rem;
  resize: vertical;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.sync-section textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

/* ─── Region selector ─── */
.region-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass-bg);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.region-list::-webkit-scrollbar { width: 6px; }
.region-list::-webkit-scrollbar-thumb { background: var(--glass-border-strong); border-radius: 3px; }
.region-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.region-row:last-child { border-bottom: none; }
.region-row:hover { background: var(--glass-bg-hover); }
.region-row:active { background: var(--glass-bg-active); }
.region-row.selected {
  background: linear-gradient(135deg, var(--gold-soft), rgba(255,214,10,0.04));
  border-left: 3px solid var(--gold);
  padding-left: 11px;
}
.region-row .flag-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 1.8rem;
  text-align: center;
}
.region-row .region-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.region-row .region-tz {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.region-current {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 10px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.region-current strong { color: var(--gold); font-weight: 700; }
#region-search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.modal-content {
  position: relative;
  width: 100%;
  max-height: 88vh;
  background: rgba(20, 16, 10, 0.82);
  backdrop-filter: blur(var(--blur-lg)) saturate(200%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(200%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--glass-border-strong);
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  padding: 22px 22px 30px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow:
    0 -20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 var(--glass-highlight);
  animation: slideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.close-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: all 0.2s;
}
.close-btn:hover { background: var(--glass-bg-hover); }
.close-btn:active { transform: scale(0.95); }

.modal-hint, .setting-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ─── Settings sections ─── */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--glass-border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.setting-row label {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}

/* ─── Form controls ───
   Critical: on desktop browsers, <select> renders with the OS's native chrome.
   Without explicit colors, the OS picks white-on-white. We force dark-on-cream
   using color-scheme + explicit text/background. */
.setting-row select,
.setting-row input[type="date"] {
  padding: 9px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 60%;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color-scheme: dark;
}
.setting-row select:focus,
.setting-row input[type="date"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

/* The option list (dropdown menu) — desktop browsers show this with native
   chrome. Force dark scheme + dark text on dark background. */
.setting-row select option {
  background: #1a1410;
  color: var(--text);
  padding: 8px;
}

/* ─── Toggle switch ─── */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: linear-gradient(180deg, #fff8eb 0%, #d4cdb8 100%);
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.toggle-switch.on {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  box-shadow: 0 0 14px var(--gold-glow), inset 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch.on::after {
  left: 24px;
  background: linear-gradient(180deg, #fff8eb 0%, #f0e8d0 100%);
}

/* ─── Calendar (date picker) ─── */
.calendar {
  margin-top: 12px;
  padding: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.calendar-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.calendar-nav {
  display: flex;
  gap: 6px;
}
.calendar-nav button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-bg);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.calendar-nav button:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
}
.calendar-nav button:active { transform: scale(0.94); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-dow {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  color: var(--text-dim);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.calendar-day:hover {
  background: var(--glass-bg-hover);
  color: var(--text);
}
.calendar-day.has-match {
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
}
.calendar-day.has-match::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 4px var(--gold-glow);
}
.calendar-day.selected {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1a1410;
  border-color: transparent;
  font-weight: 800;
  box-shadow:
    0 0 18px var(--gold-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.calendar-day.today {
  border-color: var(--live);
  color: var(--live);
}
.calendar-day.empty { visibility: hidden; cursor: default; }
.calendar-day.has-match.selected::after {
  background: #1a1410;
  box-shadow: none;
}

.calendar-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.calendar-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.calendar-btn:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-strong); }
.calendar-btn:active { transform: scale(0.97); }
.calendar-btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  color: #1a1410;
  font-weight: 700;
  box-shadow: 0 4px 14px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.calendar-meta {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.calendar-meta strong { color: var(--gold); font-weight: 700; }

/* ─── Match detail modal ─── */
.match-modal-content { padding-bottom: 30px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
  gap: 12px;
}
.detail-row:last-of-type { border-bottom: none; }
.detail-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 700;
  flex-shrink: 0;
}
.detail-value {
  font-size: 0.92rem;
  color: var(--text);
  text-align: right;
  font-weight: 500;
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.detail-value .flag-svg {
  vertical-align: middle;
}

.timer-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}
.timer-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.timer-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.timer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.timer-option {
  padding: 11px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.timer-option:hover { background: var(--glass-bg-hover); }
.timer-option:active { transform: scale(0.97); }
.timer-option.selected {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1a1410;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 4px 16px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.timer-actions {
  display: flex;
  gap: 8px;
}
.timer-btn {
  flex: 1;
  padding: 11px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.timer-btn:hover { background: var(--glass-bg-hover); }
.timer-btn:active { transform: scale(0.97); }
.timer-btn.default {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  color: #1a1410;
  font-weight: 700;
  box-shadow: 0 4px 14px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.timer-btn.clear {
  background: transparent;
  color: var(--live);
  border-color: rgba(230, 57, 70, 0.4);
}

/* ─── Favorites grid ─── */
.favorites-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.fav-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.fav-team:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
}
.fav-team:active { transform: scale(0.97); }
.fav-team.selected {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: 0 0 14px var(--gold-glow), inset 0 1px 0 var(--glass-highlight);
}
.fav-team .flag-svg {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.fav-team .name {
  font-size: 0.66rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  color: var(--text-dim);
}
.fav-team.selected .name { color: var(--gold); }

/* ─── Empty state ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  color: var(--text-dim);
  text-align: center;
}
.empty-state p {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ─── Responsive ─── */
@media (min-width: 720px) {
  .modal-content {
    max-width: 520px;
    margin: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border-strong);
  }
  .modal {
    align-items: center;
  }
  .favorites-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ─── Tablet & desktop: cap width, center the list ─── */
@media (min-width: 720px) {
  .match-list {
    max-width: 680px;
    margin: 0 auto;
  }
  /* Cap the team-vs-team gap so it never feels stretched on wider cards */
  .match-teams {
    max-width: 480px;
    margin: 0 auto;
  }
  .header-actions {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ─── Desktop: two-column card grid ─── */
@media (min-width: 1100px) {
  .match-list {
    max-width: 1180px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 8px 14px 100px;
  }
  /* Each card spans its grid cell; team row keeps its sensible gap */
  .match-card {
    margin: 0;
  }
  .match-teams {
    max-width: none;  /* let it stretch within the card column */
  }
  /* Date headers should span both columns so the timeline reads left-to-right */
  .date-header {
    grid-column: 1 / -1;
    margin-top: 16px;
    padding-left: 4px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 8px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.02));
  }
}

/* ─── Wide desktop: three-column card grid ─── */
@media (min-width: 1600px) {
  .match-list {
    max-width: 1680px;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}