.hover-reveal {
    opacity: 0;
}
.cursor-pointer:hover .hover-reveal {
    opacity: 1;
}

/* =========================================================
   FPL Edge - Design System
   Complete theme: Light & Dark with CSS custom properties
   ========================================================= */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ---------- Design Tokens: Light Mode ---------- */
:root {
  /* Core Surfaces */
  --bg-base:      #f1f5f9;
  --bg-surface:   #ffffff;
  --bg-elevated:  #f8fafc;
  --bg-muted:     #e2e8f0;

  /* Borders */
  --border-base:  #e2e8f0;
  --border-muted: #cbd5e1;
  --border-focus: #7c3aed;

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverted:  #ffffff;

  /* Brand */
  --brand:        #7c3aed;
  --brand-light:  #ede9fe;
  --brand-hover:  #6d28d9;
  --brand-glow:   rgba(124, 58, 237, 0.25);

  /* Accent */
  --accent-cyan:  #0ea5e9;
  --accent-pink:  #ec4899;
  --accent-amber: #f59e0b;

  /* Status */
  --green:  #16a34a;
  --red:    #dc2626;
  --yellow: #d97706;
  --blue:   #2563eb;

  /* Scrollbar */
  --scrollbar-track: #e2e8f0;
  --scrollbar-thumb: #94a3b8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.10), 0 6px 12px rgba(0,0,0,0.06);
  --shadow-brand: 0 0 0 3px var(--brand-glow);

  /* Nav glass - light */
  --glass-bg:     rgba(255,255,255,0.85);
  --glass-border: rgba(0,0,0,0.06);

  /* Pitch */
  --pitch-bg:     #e7f5e7;
  --pitch-lines:  rgba(0,80,0,0.12);

  /* Nav heights (for main padding) */
  --nav-height-mobile: 120px;
  --nav-height-desktop: 96px;
}

/* ---------- Design Tokens: Dark Mode ---------- */
.dark {
  --bg-base:      #0a0f1e;
  --bg-surface:   #111827;
  --bg-elevated:  #1e293b;
  --bg-muted:     #1a2340;

  --border-base:  #1e293b;
  --border-muted: #2d3f5e;
  --border-focus: #8b5cf6;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --text-inverted:  #0f172a;

  --brand:        #8b5cf6;
  --brand-light:  #1e1b4b;
  --brand-hover:  #7c3aed;
  --brand-glow:   rgba(139, 92, 246, 0.3);

  --accent-cyan:  #22d3ee;
  --accent-pink:  #f472b6;
  --accent-amber: #fbbf24;

  --green:  #4ade80;
  --red:    #f87171;
  --yellow: #fbbf24;
  --blue:   #60a5fa;

  --scrollbar-track: #1e293b;
  --scrollbar-thumb: #334155;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.6);
  --shadow-brand: 0 0 0 3px var(--brand-glow);

  --glass-bg:     rgba(17,24,39,0.85);
  --glass-border: rgba(255,255,255,0.06);

  --pitch-bg:     #0d2a1a;
  --pitch-lines:  rgba(255,255,255,0.06);
}

/* ---------- Base Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ---------- Typography ---------- */
.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
}

/* ---------- Fluid Typography ---------- */
/* Hero headlines scale smoothly from mobile → desktop */
.text-fluid-hero {
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 1.1;
}
.text-fluid-section {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.2;
}
.text-fluid-sub {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
}

/* ---------- Glassmorphism Nav ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-color: var(--glass-border);
}

/* ---------- Surface Cards ---------- */
.surface {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.surface:hover {
  box-shadow: var(--shadow-md);
}

/* ---------- Card Hover Lift ---------- */
.card-hover {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ---------- Brand Colors (legacy + themed) ---------- */
.gradient-text {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Nav Tab Active State ---------- */
.tab-active {
  border-bottom: 2px solid var(--brand);
  color: var(--brand);
  font-weight: 600;
}

/* ---------- Price / Value Colors ---------- */
.price-up   { color: var(--green); }
.price-down { color: var(--red); }

/* ---------- Fixture Difficulty Badges ---------- */
.difficulty-1 { background: #14532d; color: #bbf7d0; border-radius: 6px; }
.difficulty-2 { background: #166534; color: #bbf7d0; border-radius: 6px; }
.difficulty-3 { background: #374151; color: #e5e7eb; border-radius: 6px; }
.difficulty-4 { background: #7f1d1d; color: #fecaca; border-radius: 6px; }
.difficulty-5 { background: #450a0a; color: #fca5a5; border-radius: 6px; }

/* ---------- Pitch Background ---------- */
.pitch-bg {
  background: var(--pitch-bg);
  position: relative;
  overflow: hidden;
}
.pitch-lines {
  position: absolute;
  inset: 0;
  border: 2px solid var(--pitch-lines);
  border-radius: 8px;
}
.pitch-lines::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--pitch-lines);
}
.pitch-lines::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  border: 2px solid var(--pitch-lines);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ---------- Scrollbars ---------- */
.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--brand); }

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ---------- Horizontal scroll fade indicators on nav tabs ---------- */
.nav-tabs-wrapper {
  position: relative;
}
.nav-tabs-wrapper::after {
  content: '';
  pointer-events: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  background: linear-gradient(to right, transparent, var(--glass-bg));
  z-index: 2;
  border-radius: 0 8px 8px 0;
}

/* ---------- Loading Pulse ---------- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.loading { animation: pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-elevated) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Inputs & Selects ---------- */
input, select, textarea {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-brand);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ---------- Themed Input (for rivals input) ---------- */
.themed-input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}
.themed-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-brand);
}

/* ---------- Buttons ---------- */
.btn-brand {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.btn-brand:hover {
  background: var(--brand-hover);
  box-shadow: 0 6px 20px var(--brand-glow);
  transform: translateY(-1px);
}
.btn-brand:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-base);
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border-muted);
}

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  letter-spacing: 0.04em;
}
.badge-brand  { background: var(--brand-light); color: var(--brand); }
.badge-green  { background: rgba(22,163,74,0.15); color: var(--green); }
.badge-red    { background: rgba(220,38,38,0.15); color: var(--red); }
.badge-yellow { background: rgba(217,119,6,0.15); color: var(--yellow); }

/* ---------- Stat Cards (dashboard numbers) ---------- */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--brand-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}
.stat-card:hover::before {
  opacity: 1;
}

/* ---------- Table Reset ---------- */
table { border-collapse: collapse; width: 100%; }
th {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 16px;
  white-space: nowrap;
}
td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-base);
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--bg-elevated); }

/* ---------- Modal Overlay ---------- */
.modal-overlay {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}

/* ---------- Theme Transition ---------- */
*, *::before, *::after {
  transition-property: background-color, border-color, color;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}
/* Prevent transition flickering on animations/transforms */
.card-hover, .btn-brand, .btn-ghost, .stat-card::before {
  transition-property: background-color, border-color, color, transform, box-shadow, opacity;
}

/* ── Themed Utility Helpers (from theme_upgrade.js refactor) ─────────────── */
/* These replace the old "light-class dark:dark-class" Tailwind pairs */

.themed-surface       { background: var(--bg-surface) !important; }
.themed-base          { background: var(--bg-base) !important; }
.themed-surface-alt   { background: var(--bg-elevated) !important; }
.themed-elevated      { background: var(--bg-elevated) !important; }
.themed-muted         { background: var(--bg-muted) !important; }

.themed-text-primary  { color: var(--text-primary) !important; }
.themed-text-secondary{ color: var(--text-secondary) !important; }
.themed-text-muted    { color: var(--text-muted) !important; }
.themed-text-hint     { color: var(--text-muted) !important; }

.themed-border  { border-color: var(--border-base) !important; }
.themed-border-muted { border-color: var(--border-muted) !important; }

.themed-green  { color: var(--green) !important; }
.themed-red    { color: var(--red) !important; }
.themed-blue   { color: var(--blue) !important; }
.themed-yellow { color: var(--yellow) !important; }
.themed-orange { color: var(--accent-amber) !important; }
.themed-brand  { color: var(--brand) !important; }
.themed-indigo { color: var(--brand) !important; }

/* ── Responsive Fixes ──────────────────────────────────────────────────── */

/* Ensure main content never causes horizontal scroll */
main { overflow-x: hidden; }

/* Better responsive table behavior */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Mobile-first improvements ---------- */

/* Main padding accounts for fixed nav height (mobile = taller) */
@media (max-width: 767px) {
  /* Nav height estimation for mobile: ~120px total */
  main.pt-\[140px\] {
    padding-top: 130px !important;
  }

  /* Reduce section padding on mobile */
  .py-16 { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
  .py-20 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

  /* Reduce horizontal padding on very small screens */
  .px-4 { padding-left: 1rem; padding-right: 1rem; }

  /* Tables: allow horizontal scroll, prevent breaking layout */
  td, th { font-size: 12px; padding: 8px 10px; }

  /* Hero section - reduce bottom heaviness */
  #landing > div:first-child {
    min-height: auto !important;
  }

  /* Feature cards - slightly less padding on mobile */
  .glass.rounded-2xl.p-7 {
    padding: 1.25rem !important;
  }

  /* Modals - full width on mobile */
  .modal-card {
    border-radius: 16px;
  }

  /* Stat numbers slightly smaller on very small screens */
  .text-5xl { font-size: 2.5rem !important; }
  .text-4xl { font-size: 2rem !important; }
  .text-3xl { font-size: 1.75rem !important; }

  /* Footer grid: single column */
  footer .grid { gap: 1.5rem; }
}

/* ---------- Tablet (768px - 1023px) ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Reduce over-generous padding */
  .py-16 { padding-top: 3rem; padding-bottom: 3rem; }
}

/* ---------- Touch targets: minimum 44px for interactive elements ---------- */
@media (max-width: 767px) {
  .nav-tab {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Buttons: ensure minimum touch size */
  button, [role="button"] {
    min-height: 36px;
  }

  /* Gameweek select: readable on mobile */
  #gameweek-select {
    max-width: 110px;
    font-size: 12px;
  }
}

/* ---------- Player cards on field view — responsive sizing ---------- */
.player-card-on-field {
  min-width: 56px;
  max-width: 80px;
}
@media (max-width: 480px) {
  .player-card-on-field {
    min-width: 44px;
    font-size: 10px;
  }
}

/* ---------- Dashboard: mobile-friendly stat row ---------- */
@media (max-width: 640px) {
  /* Stack My Team widget stats vertically */
  #my-team-widget .flex-wrap {
    gap: 0.75rem;
  }
  /* Smaller captain block */
  #my-team-widget .text-3xl {
    font-size: 1.5rem;
  }
}

/* ---------- Container max-width safety net ---------- */
.max-w-7xl {
  width: 100%;
}

/* ---------- Smooth tab transitions ---------- */
.tab-content {
  animation: tabFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
  will-change: opacity, transform;
}
@keyframes tabFadeIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Nav tab scroll indicator gradient ---------- */
#nav-tabs-container {
  -webkit-mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
}

/* ---------- Improved focus styles for accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Landing Hero responsive tweaks ---------- */
@media (max-width: 640px) {
  /* Shrink huge hero text */
  #landing h1 {
    font-size: clamp(1.85rem, 9vw, 3rem) !important;
    line-height: 1.15;
  }
  /* Shrink section headings */
  #landing h2 {
    font-size: clamp(1.35rem, 7vw, 2.25rem) !important;
  }
  /* Less vertical padding in hero */
  #landing .py-20 {
    padding-top: 2.5rem !important;
    padding-bottom: 2rem !important;
  }
  /* Smaller stat chips  */
  #landing .text-2xl, #landing .text-3xl {
    font-size: 1.5rem !important;
  }
  /* Live stats bar: tighten up */
  #landing .glass.border-y .grid {
    gap: 0.75rem;
  }
}

/* ---------- H2H Compare: responsive grid ---------- */
@media (max-width: 640px) {
  #h2h-results .grid-cols-3 {
    grid-template-columns: 1fr auto 1fr;
    gap: 0.25rem;
    font-size: 0.8rem;
  }
}

/* ---------- Fix league/manager input row on mobile ---------- */
@media (max-width: 480px) {
  #manager .flex.gap-4,
  #leagues .flex.gap-4 {
    flex-direction: column;
  }
  #leagues #league-type {
    width: 100%;
  }
}

/* ---------- Fixture filters responsive ---------- */
@media (max-width: 640px) {
  #fixtures .flex-col.sm\:flex-row.gap-3 {
    gap: 0.5rem;
  }
  #fixture-gw-filter,
  #fixture-team-filter,
  #fixture-status-filter {
    width: 100%;
    font-size: 13px;
  }
}

/* ---------- Best team pitch: smaller gap on mobile ---------- */
@media (max-width: 640px) {
  #best-team-fwd,
  #best-team-mid,
  #best-team-def,
  #best-team-gkp {
    gap: 0.5rem !important;
  }
}

/* ---------- Footer responsive ---------- */
@media (max-width: 640px) {
  footer .pt-14 { padding-top: 2rem; }
  footer .pb-8  { padding-bottom: 1.5rem; }
  footer .mb-12 { margin-bottom: 2rem; }
}

/* ---------- Comparison modal responsive ---------- */
@media (max-width: 640px) {
  #compare-modal .sm\:p-6 {
    padding: 1rem;
  }
}

/* ---------- Watchlist grid: 1 col on small, 2 on medium ---------- */
@media (max-width: 480px) {
  #watchlist-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- Auth modal: tighten on mobile ---------- */
@media (max-width: 480px) {
  #auth-modal .modal-card {
    padding: 1.5rem !important;
  }
}

/* ---------- Rivals tab: responsive layout ---------- */
@media (max-width: 640px) {
  #rival-analysis-results .grid-cols-1.md\:grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* ---------- Chip planner: 2→1 col on mobile ---------- */
@media (max-width: 480px) {
  #chip-status-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ---------- Print-friendly: hide nav on print ---------- */
@media print {
  nav, footer { display: none; }
  main { padding-top: 0 !important; }
}

/* ---------- High contrast safety ---------- */
@media (prefers-contrast: high) {
  :root {
    --border-base: #64748b;
    --text-muted:  #64748b;
  }
}
