html {
    scrollbar-gutter: stable;
    max-width: 100%;
    overflow-x: clip;
}

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

:root {
    color-scheme: light;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-hover: #f1f5f9;
    --surface-card: #ffffff;
    --surface-card-muted: #f8fafc;
    --surface-elevated: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --text-inverse: #ffffff;
    --border-color: #e5e7eb;
    --border-subtle: #f0f0f0;
    --shadow-card: 0 3px 8px rgba(15, 23, 42, 0.08);
    --skeleton-base: #f0f0f0;
    --skeleton-highlight: #e0e0e0;
    --score-text: #1a1d23;
    --muted-score: #999999;
    --accent-green: #22c55e;
    --accent-yellow: #facc15;
    --accent-blue: #1e3a8a;
}

.dark-mode {
    color-scheme: dark;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #263449;
    --surface-card: #162033;
    --surface-card-muted: #1e293b;
    --surface-elevated: #263449;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-inverse: #0f172a;
    --border-color: #475569;
    --border-subtle: rgba(148, 163, 184, 0.22);
    --shadow-card: 0 10px 26px rgba(0, 0, 0, 0.28);
    --skeleton-base: #1e293b;
    --skeleton-highlight: #334155;
    --score-text: #f8fafc;
    --muted-score: #94a3b8;
    --accent-green: #10b981;
    --accent-yellow: #fbbf24;
    --accent-blue: #3b82f6;
}

body {
    margin: 0;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: clip;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.25s ease, color 0.25s ease;
}


/* =========================================
   GLOBAL TOOLTIP ENGINE
   Position: fixed on viewport — escapes all parent overflow
   ========================================= */

#gl-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
  background: #0b1a28;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre;
  text-align: left;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.15s ease;

  /* Hidden by default — JS drives visibility */
  visibility: hidden;
}

#gl-tooltip.gl-tip-visible {
  visibility: visible;
  opacity: 1;
}

/* Tooltip Arrow */
#gl-tooltip::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  /* Dynamically follows the badge center */
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
}

/* Tooltip below element (Arrow points UP) */
#gl-tooltip.gl-bottom::after {
  top: -6px;
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent #0b1a28 transparent;
}

/* Tooltip above element (Arrow points DOWN) */
#gl-tooltip.gl-top::after {
  bottom: -6px;
  border-width: 6px 6px 0 6px;
  border-color: #0b1a28 transparent transparent transparent;
}

/* Cursor hint on all tooltip triggers */
[data-tooltip] {
  cursor: pointer;
}

/* Ensure form rows never clip their children */
.form-indicators,
.pc-form-row,
.team-form-row {
  overflow: visible !important;
}

/* Make anchor links reset their styling when acting as form dots */
a.form-dot,
a.form-badge {
  text-decoration: none !important;
  color: #fff !important;
}

/* Kickoff time shown on NS cards — always dark, never red */
.pc-ns-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--score-text);
  text-align: center;
  line-height: 1;
}

/* ==============================================
   GLOBAL SCORE STATE CLASSES
   Applied by Django template on page load, and
   by match_state.js for live/real-time updates.
   ============================================== */

/* Winner's score — bold dark black */
.score-strong {
  color: var(--score-text) !important;
  font-weight: 700 !important;
}

/* Loser/Draw score — muted grey */
.score-faded {
  color: var(--muted-score) !important;
  font-weight: 500 !important;
}

/* Live match score — red pulse */
.score-live {
  color: #e11d48 !important;
  font-weight: 700 !important;
}

/* Not-started hidden score */
.score-hidden {
  visibility: hidden !important;
}

/* Status label beneath score */
.pc-minute-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-score);
  text-align: center;
  margin-top: 2px;
  line-height: 1.2;
}

/* Finished label */
.pc-minute-label.label-finished {
  color: var(--text-tertiary);
}

/* Live blinking tick on the apostrophe after elapsed minute (e.g 57') */
@keyframes live-tick-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.live-tick {
  display: inline-block;
  animation: live-tick-blink 1.4s ease-in-out infinite;
  font-weight: inherit;
  color: inherit;
}

/* Live label for Half Time */
.pc-minute-label.label-live {
  color: #e11d48;
}

/* Disrupted label (Postponed, Cancelled, Suspended) */
.pc-minute-label.label-status-disrupted {
  color: #f59e0b;
}

/* ==============================================
   FULL TIME SCORE (EXTRA TIME SUB-SCORE)
   ============================================== */
.pc-ft-score {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 2px;
  margin-bottom: 2px;
  line-height: 1;
}

/* ==============================================
   INJURY TIME BADGE
   ============================================== */
.pc-score-block {
    position: relative;
}

.injury-time-container {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fee2e2;
    color: #e11d48;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(225, 29, 72, 0.4);
    animation: injury-pulse 2s infinite ease-in-out;
    z-index: 10;
}

@keyframes injury-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); transform: translateX(-50%) scale(1); }
    50%  { box-shadow: 0 0 0 6px rgba(225, 29, 72, 0); transform: translateX(-50%) scale(1.05); }
    100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); transform: translateX(-50%) scale(1); }
}

/* ==============================================
   NS SCORE DASH
   Shown when match has no goals yet (future)
   ============================================== */
.pc-score-dash {
  font-size: 22px;
  font-weight: 850;
  color: var(--score-text);
  line-height: 1;
}

/* Base PPG Prediction Card Badge Colors */
.ppg-badge-green  { background: #16a34a !important; color: white !important; }
.ppg-badge-lime   { background: #91BC80 !important; color: white !important; }
.ppg-badge-amber  { background: #d97706 !important; color: white !important; }
.ppg-badge-orange { background: #ea580c !important; color: white !important; }
.ppg-badge-red    { background: #dc2626 !important; color: white !important; }

/* ==============================================
   MY TEAMS / FAVORITES SYSTEM
   ============================================== */

/* Sidebar "Add a Team" Button */
.add-team-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    background: #1d4ed8; /* Professional Blue */
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-team-btn:hover {
    background: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

.add-team-btn:active {
    transform: translateY(0);
}

/* Sidebar Favorite Items */
#pinnedTeamsList li:hover {
    background: rgba(255, 255, 255, 0.05);
}

.team-pin {
    opacity: 0.4;
    transition: all 0.2s ease;
}

#pinnedTeamsList li:hover .team-pin,
.team-pin.active {
    opacity: 1;
}

.team-pin.active {
    color: #fbbf24 !important; /* Gold */
}

/* Search Result Star */
.search-team-star {
    padding: 8px;
    margin-left: 10px;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.search-team-star:hover {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    transform: scale(1.2);
}

.search-team-star.active {
    color: #fbbf24;
}

.search-team-star i {
    font-size: 16px;
}

/* Search League Pin */
.league-pin {
    opacity: 0.3;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-45deg); /* Professional unpinned look */
    color: #9ca3af;
}

.league-pin.active {
    opacity: 1;
    color: #22c55e !important;
    transform: rotate(0deg); /* Straightened when pinned */
}

.search-league-pin {
    padding: 8px;
    margin-left: 10px;
}

.search-league-pin:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    transform: scale(1.15) rotate(0deg);
    opacity: 0.9;
}

.search-league-pin.active {
    color: #3b82f6 !important; /* Blue for active search pins */
}

/* Suggested Results Section Labels */
.search-section-label {
    padding: 12px 14px 6px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dark-mode .search-section-label {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Dark Mode Overrides for Sidebar items */
.dark-mode #pinnedTeamsList li:hover {
    background: rgba(255, 255, 255, 0.08);
}


/* ==========================================================================
   UNIFIED FORM BADGE DESIGN SYSTEM (TEAM PERFORMANCE SYSTEM STYLE)
   This applies to all form indicator badge sequences (.form-dot) globally
   (prediction cards, match preview page, and team details page form row).
   ========================================================================== */
.form-indicators {
  display: flex !important;
  flex-direction: row !important;
  gap: 3px !important;
  align-items: center !important;
}

/* Base shape and styling (matching .form-badge from Team Performance block) */
.form-indicators .form-dot {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 16px !important;
  height: 16px !important;
  border-radius: 4px !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  color: white !important;
  margin: 0 1px !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  text-decoration: none !important;
  text-transform: uppercase !important;
  line-height: 1 !important;
  border: none !important;
  transition: transform 0.15s ease, filter 0.15s ease !important;
}

/* Hover micro-interactions */
.form-indicators .form-dot:hover {
  transform: scale(1.18) !important;
  filter: brightness(1.08) !important;
  z-index: 10 !important;
}

/* Colors matching the exact spec from stats.css .badge-* rules */
.form-indicators .form-dot.w {
  background: #16a34a !important; /* Win Green */
  color: white !important;
}

.form-indicators .form-dot.d {
  background: #e7c57d !important; /* Draw Yellow/Beige */
  color: #92400e !important;       /* Dark Amber Text */
}

.form-indicators .form-dot.l {
  background: #c0152a !important; /* Loss Red */
  color: white !important;
}

/* Remove the native blue/grey touch flash from every clickable surface.
   Keep a visible outline only for genuine keyboard navigation. */
html {
  -webkit-tap-highlight-color: transparent;
}

*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Shared premium notice used by tool actions. */
.tool-save-crown {
  color: #f59e0b;
  filter: drop-shadow(0 1px 2px rgba(245, 158, 11, 0.24));
}

.tool-date-limit {
  margin-left: 5px;
  color: #d97706;
  font-size: 8px;
  font-weight: 800;
  text-transform: none;
}

.tool-premium-modal[hidden] {
  display: none !important;
}

.tool-premium-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(5px);
}

.tool-premium-dialog {
  position: relative;
  width: min(460px, 100%);
  overflow: hidden;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 8px;
  background: var(--surface-card, #fff);
  box-shadow: 0 26px 80px rgba(2, 6, 23, 0.34);
  padding: 28px;
  text-align: center;
}

.dark-mode .tool-premium-dialog {
  background: #111827;
  border-color: rgba(251, 191, 36, 0.32);
}

.tool-premium-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.tool-premium-close:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #0f172a;
}

.dark-mode .tool-premium-close:hover {
  color: #f8fafc;
}

.tool-premium-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  font-size: 24px;
}

.tool-premium-kicker {
  color: #d97706;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.tool-premium-dialog h2 {
  margin: 6px 0 9px;
  color: var(--text-primary, #0f172a);
  font-size: 20px;
  font-weight: 850;
  letter-spacing: 0;
}

.dark-mode .tool-premium-dialog h2 {
  color: #f8fafc;
}

.tool-premium-dialog p {
  max-width: 390px;
  margin: 0 auto;
  color: var(--text-secondary, #64748b);
  font-size: 12px;
  line-height: 1.6;
}

.dark-mode .tool-premium-dialog p {
  color: #94a3b8;
}

.tool-premium-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.tool-premium-cancel,
.tool-premium-upgrade {
  min-height: 40px;
  padding: 9px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.tool-premium-cancel {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
}

.dark-mode .tool-premium-cancel {
  border-color: #334155;
  background: #1e293b;
  color: #cbd5e1;
}

.tool-premium-upgrade {
  border: 1px solid #d97706;
  background: #f59e0b;
  color: #111827;
}

.tool-premium-upgrade:hover {
  background: #fbbf24;
}

@media (max-width: 640px) {
  .tool-premium-modal {
    align-items: center;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px
      calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .tool-premium-dialog {
    padding: 26px 18px 20px;
  }

  .tool-premium-actions {
    flex-direction: column-reverse;
  }

  .tool-premium-cancel,
  .tool-premium-upgrade {
    width: 100%;
  }
}
