/* ============================================================
   CLV Tracker - Premium Light UI
   Fonts: Outfit (headings) + Inter (body)
   Theme: World Cup Gold
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@600;700;800&display=swap');

:root {
  /* Surface & background */
  --bg: #F4F2EE;
  --bg-warm: #FAF9F7;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;

  /* Borders */
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);

  /* Text */
  --text: #1A1A2E;
  --text-secondary: #4A4A68;
  --muted: #8888A4;

  /* Accent - World Cup Gold */
  --accent: #C8911E;
  --accent-light: #E6A817;
  --accent-glow: rgba(200, 145, 30, 0.15);
  --accent-surface: rgba(200, 145, 30, 0.06);
  --gold: #E6A817;
  --gold-light: #F5CD5A;

  /* Status */
  --green: #16A34A;
  --green-bg: rgba(22, 163, 74, 0.08);
  --green-fg: #15803D;
  --red: #DC2626;
  --red-bg: rgba(220, 38, 38, 0.06);
  --red-fg: #B91C1C;
  --grey-bg: rgba(0, 0, 0, 0.03);
  --grey-fg: #6B7280;

  /* Mono */
  --mono: 'SF Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 0 3px var(--accent-glow);

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(200, 145, 30, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(230, 168, 23, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 100% 80% at 50% 0%, rgba(255, 255, 255, 0.6) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

body>* {
  position: relative;
  z-index: 1;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.muted {
  color: var(--muted);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, #A67413 0%, var(--accent) 40%, var(--gold-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  animation: fadeUp 0.5s var(--ease-out) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Tagline ---------- */
.tagline {
  margin: 6px 0 20px;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.info {
  color: var(--accent);
  cursor: help;
  border-bottom: 1px dotted var(--accent);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--panel-solid);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s var(--ease-out);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0px) scale(0.98);
}

/* ---------- Stats grid ---------- */
.grid4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

@media (max-width: 560px) {
  .grid4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.stat .num {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------- Panel (glass card) ---------- */
.panel {
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.panel:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text);
}

/* ---------- Leaderboard table ---------- */
table.lb {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.lb td,
.lb th {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}

.lb th {
  color: var(--muted);
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lb td:first-child,
.lb th:first-child {
  text-align: left;
  font-family: 'Inter', sans-serif;
}

.lb tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.lb tbody tr:hover {
  background: var(--accent-surface);
}

/* ---------- Match cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--panel-solid);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.card .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card .match {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
}

.card .mv {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Badges ---------- */
.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.b-short-sig {
  background: var(--green-bg);
  color: var(--green-fg);
}

.b-drift-sig {
  background: var(--red-bg);
  color: var(--red-fg);
}

.b-minor {
  background: var(--grey-bg);
  color: var(--grey-fg);
}

/* ---------- CLV colors ---------- */
.pos {
  color: var(--green-fg);
  font-weight: 600;
}

.neg {
  color: var(--red-fg);
  font-weight: 600;
}

/* ---------- Modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 640px;
  max-width: 96vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.3s var(--ease-spring) both;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  margin: 0 0 6px;
}

.close-x {
  float: right;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  transition: color 0.15s ease;
}

.close-x:hover {
  color: var(--text);
}

.hidden {
  display: none;
}

/* ---------- CLV detail table ---------- */
.clv-tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
  font-variant-numeric: tabular-nums;
}

.clv-tbl td,
.clv-tbl th {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
}

.clv-tbl td:first-child,
.clv-tbl th:first-child {
  text-align: left;
  font-family: 'Inter', sans-serif;
}

.clv-tbl th {
  color: var(--muted);
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Narrative block ---------- */
.narrative {
  white-space: pre-line;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  margin: 12px 0;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-glow);
  color: var(--accent);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .wrap {
    padding: 20px 14px 64px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .panel {
    padding: 16px;
  }
}