/* ==========================================================================
   GOLFPULSE v4 — THE TRUE MASTER PAINT JOB (style.css)
   ========================================================================== */

/* 1. CORE RESET & NORMALIZE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-size-adjust: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth; }

/* 2. DESIGN TOKENS */
:root {
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --bg: #0a0d0a; --bg-card: #111611; --bg-card-hover: #161b16; --bg-surface: #0e120e;
  --border: #1e261e; --border-bright: #2a352a;
  --text: #e8ece8; --text-muted: #7a8a7a; --text-faint: #4a5a4a;
  --green: #22c55e; --green-dim: #166534; --green-bg: rgba(34, 197, 94, 0.08);
  --red: #ef4444; --red-dim: #991b1b; --red-bg: rgba(239, 68, 68, 0.08);
  --yellow: #eab308; --yellow-dim: #854d0e; --white: #ffffff;
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem;
  --text-xs: 0.6875rem; --text-sm: 0.75rem; --text-base: 0.8125rem; --text-md: 0.875rem; --text-lg: 1rem; --text-xl: 1.25rem;
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px;
  --ease: 180ms cubic-bezier(0.16, 1, 0.3, 1); --tab-h: 56px; --header-h: 52px;
}

/* 3. BASE LAYOUT */
body { min-height: 100dvh; font-family: var(--font-mono); font-size: var(--text-base); color: var(--text); background: var(--bg); line-height: 1.5; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding-top: var(--header-h); overflow-x: hidden; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
::selection { background: rgba(34, 197, 94, 0.25); color: var(--text); }
a { color: var(--green); text-decoration: none; } a:hover { text-decoration: underline; }

/* 4. NAVIGATION */
.header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: var(--header-h); background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s4); }
.brand { display: flex; flex-direction: column; gap: 0; }
.brand-name { font-size: var(--text-lg); font-weight: 700; color: var(--green); letter-spacing: -0.02em; line-height: 1.1; }
.brand-tagline { font-size: var(--text-xs); color: var(--text-faint); font-style: italic; line-height: 1.2; }
.header-meta { display: flex; align-items: center; gap: var(--s3); }
.refresh-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: var(--s1) var(--s2); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: var(--text-xs); cursor: pointer; transition: all var(--ease); display: flex; align-items: center; gap: var(--s1); }
.refresh-btn:hover, .refresh-btn:active { border-color: var(--green); color: var(--green); }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); border-top: 1px solid var(--border); display: flex; align-items: stretch; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: none; color: var(--text-faint); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; cursor: pointer; position: relative; transition: color var(--ease); -webkit-tap-highlight-color: transparent; padding: var(--s1) 0; }
.tab-btn:active { background: rgba(34, 197, 94, 0.05); }
.tab-btn.active { color: var(--green); }
.tab-btn.active::after { content: ''; position: absolute; top: 0; left: 20%; right: 20%; height: 2px; background: var(--green); border-radius: 0 0 2px 2px; }
.tab-btn svg { width: 20px; height: 20px; stroke-width: 1.5; }
.tab-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }

/* 5. COMPONENT: LIVE TAB */
.tab-content { display: none; padding: var(--s4); padding-bottom: var(--s8); max-width: 600px; margin: 0 auto; animation: fadeIn 200ms ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.event-banner { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s3) var(--s4); margin-bottom: var(--s4); display: flex; align-items: center; justify-content: space-between; }
.event-name { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.event-round { font-size: var(--text-xs); color: var(--text-muted); }
.event-update { font-size: var(--text-xs); color: var(--text-faint); }
.stat-pill { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: var(--r-sm); font-size: 10px; font-weight: 700; min-width: 32px; }
.stat-pill.under { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-dim); }
.stat-pill.over { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-dim); }
.stat-pill.even { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }
.pairing-selector { margin-bottom: var(--s4); }
.pairing-selector label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; display: block; margin-bottom: var(--s2); }
.pairing-select { width: 100%; padding: var(--s3) var(--s4); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); font-family: var(--font-mono); font-size: var(--text-sm); cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%237a8a7a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.pairing-select:focus { outline: none; border-color: var(--green); }
.pairing-select option { background: var(--bg-card); color: var(--text); }
.pinned-card { background: linear-gradient(135deg, rgba(34,197,94,0.06) 0%, rgba(34,197,94,0.02) 100%); border: 1px solid var(--green-dim); border-radius: var(--r-lg); padding: var(--s4); margin-bottom: var(--s4); }
.pinned-header { font-size: var(--text-xs); color: var(--green); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: var(--s3); display: flex; align-items: center; gap: var(--s2); }
.pinned-header svg { width: 12px; height: 12px; }
.pinned-players { display: flex; flex-direction: column; gap: var(--s3); }
.pinned-player { display: flex; align-items: center; justify-content: space-between; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.pinned-player:last-child { border-bottom: none; }
.pinned-player-name { font-weight: 600; font-size: var(--text-md); color: var(--white); }
.pinned-player-stats { display: flex; align-items: center; gap: var(--s4); font-size: var(--text-sm); }
.pinned-pos { color: var(--text-muted); min-width: 32px; text-align: right; }
.pinned-score { font-weight: 700; min-width: 36px; text-align: right; }
.pinned-thru { color: var(--text-muted); font-size: var(--text-xs); min-width: 36px; text-align: right; }
.leaderboard-header { display: flex; align-items: center; padding: var(--s2) var(--s3); font-size: var(--text-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; gap: var(--s3); }
.leaderboard-header .lh-pos { width: 32px; flex-shrink: 0; }
.leaderboard-header .lh-player { flex: 1; }
.leaderboard-header .lh-today { min-width: 32px; text-align: right; }
.leaderboard-header .lh-thru { min-width: 28px; text-align: right; }
.leaderboard-header .lh-total { min-width: 36px; text-align: right; }
.lb-row { display: flex; align-items: center; padding: var(--s3); border-bottom: 1px solid var(--border); transition: background var(--ease); }
.lb-row:active { background: var(--bg-card-hover); }
.lb-pos { width: 32px; font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.lb-player { flex: 1; min-width: 0; }
.lb-name { font-size: var(--text-sm); font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-country { font-size: var(--text-xs); color: var(--text-faint); }
.lb-scores { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; }
.lb-thru { font-size: var(--text-xs); color: var(--text-faint); min-width: 28px; text-align: right; }
.lb-total { font-weight: 700; font-size: var(--text-md); min-width: 36px; text-align: right; }
.score-under { color: var(--green) !important; }
.score-over { color: var(--red) !important; }
.score-even { color: var(--text); }
.score-cut { color: var(--text-faint) !important; }

/* 6. COMPONENT: PRE-TOURNAMENT VIEW */
.field-group { margin-bottom: var(--s6); }
.field-time-header { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: var(--s2) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--s2); }
.field-row { display: flex; align-items: center; justify-content: space-between; padding: var(--s2) 0; }
.field-name { font-size: var(--text-sm); color: var(--text); }
.field-rank { font-size: var(--text-xs); color: var(--text-faint); }
.pretourney-banner { background: linear-gradient(135deg, rgba(34,197,94,0.08) 0%, rgba(34,197,94,0.02) 100%); border: 1px solid var(--green-dim); border-radius: var(--r-lg); padding: var(--s3) var(--s4); margin-bottom: var(--s4); text-align: center; }
.pretourney-banner .banner-title { font-size: var(--text-sm); font-weight: 700; color: var(--green); margin-bottom: var(--s1); }
.pretourney-banner .banner-sub { font-size: var(--text-xs); color: var(--text-muted); }

/* 7. COMPONENT: COURSE TAB (Orbital View) */
.course-map-wrapper { width: 100%; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); margin-bottom: var(--s4); background: var(--bg-card); position: relative; }
.course-map-placeholder { padding: var(--s8) var(--s4); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-faint); font-size: var(--text-xs); text-align: center; gap: var(--s2); }
.course-map-placeholder svg { width: 32px; height: 32px; margin-bottom: var(--s2); }
.map-sub { font-style: italic; font-size: 9px; }
.course-map-img { width: 100%; height: auto; display: block; }
.course-yardage-banner { display: flex; justify-content: space-around; background: linear-gradient(to right, rgba(34,197,94,0.06), transparent); border: 1px solid var(--green-dim); border-radius: var(--r-md); padding: var(--s3); margin-bottom: var(--s6); }
.cy-stat { text-align: center; font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.cy-val { font-size: var(--text-md); font-weight: 700; color: var(--white); margin-top: 2px; }
.hole-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: var(--s2); }
.hole-card.compact { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); align-items: center; text-align: center; }
.hole-num-wrap { background: var(--bg-surface); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-bright); margin-bottom: var(--s1); }
.hole-card.compact .hole-num { font-size: var(--text-md); font-weight: 700; color: var(--white); }
.hole-card.compact .hole-meta { display: flex; flex-direction: column; gap: 2px; font-size: var(--text-sm); }
.hole-card.compact .hole-par { color: var(--text); font-weight: 600; }
.hole-card.compact .hole-yds { color: var(--text-muted); font-size: 10px; }

/* 8. COMPONENT: CAVEMAN TAB */
.caveman-intro { font-size: var(--text-xs); color: var(--text-faint); font-style: italic; margin-bottom: var(--s4); text-align: center; }
.caveman-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4); margin-bottom: var(--s3); }
.caveman-name { font-size: var(--text-md); font-weight: 700; color: var(--white); margin-bottom: var(--s2); }
.caveman-odds { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--s3); }
.caveman-odds strong { color: var(--green); font-weight: 600; }
.caveman-verdict { font-size: var(--text-sm); font-weight: 700; padding: var(--s2) var(--s3); border-radius: var(--r-sm); display: inline-block; margin-bottom: var(--s3); letter-spacing: 0.03em; }
.verdict-likes { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-dim); }
.verdict-fair { background: rgba(255,255,255,0.03); color: var(--text); border: 1px solid var(--border); }
.verdict-overpay { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-dim); }
.caveman-meta { display: flex; flex-wrap: wrap; gap: var(--s2); font-size: var(--text-xs); }
.caveman-tag { padding: var(--s1) var(--s2); background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text-muted); }
.caveman-chance { font-weight: 600; }
.chance-likely { color: var(--green); }
.chance-good { color: var(--green); }
.chance-possible { color: var(--yellow); }
.chance-longshot { color: var(--text-muted); }
.caveman-skills { display: flex; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.skill-tag { font-size: var(--text-xs); padding: var(--s1) var(--s2); border-radius: var(--r-sm); background: rgba(255,255,255,0.03); border: 1px solid var(--border); }
.skill-elite { color: var(--green); border-color: var(--green-dim); }
.skill-strong { color: #86efac; }
.skill-avg { color: var(--text-muted); }
.skill-weak { color: var(--red); border-color: var(--red-dim); }

/* 9. COMPONENT: NERD TAB (Mobile-First Card List) */
.nerd-controls { margin-bottom: var(--s4); display: flex; align-items: center; justify-content: space-between; }
.nerd-count { font-size: var(--text-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.nerd-sort-select { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); font-family: var(--font-mono); font-size: var(--text-xs); padding: var(--s1) var(--s4) var(--s1) var(--s2); border-radius: var(--r-sm); appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%237a8a7a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; cursor: pointer; }
.nerd-list { display: flex; flex-direction: column; gap: var(--s3); }
.nerd-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4); }
.nc-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--border); }
.nc-name { font-size: var(--text-md); font-weight: 700; color: var(--white); }
.nc-ranks { font-size: var(--text-xs); color: var(--text-faint); }
.nc-row { display: flex; justify-content: space-between; margin-bottom: var(--s3); flex-wrap: wrap; gap: var(--s3); }
.nc-block { display: flex; flex-direction: column; gap: 2px; }
.nc-label { font-size: 9px; text-transform: uppercase; color: var(--text-faint); letter-spacing: 0.05em; }
.nc-val { font-size: var(--text-sm); font-weight: 600; color: var(--text); display: flex; align-items: baseline; gap: 4px; }
.nc-val.highlight { color: var(--green); }
.nc-sub { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.nc-finishes { display: flex; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; }
.nc-tag { padding: 2px 6px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--text-xs); color: var(--text-muted); }
.nc-sg-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3); }
.nc-sg-title { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: var(--s3); display: block; }
.nc-sg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s4); }
.nc-sg-row { display: flex; align-items: center; justify-content: space-between; }
.nc-sg-row.tot { grid-column: 1 / -1; padding-bottom: var(--s2); border-bottom: 1px dashed var(--border); margin-bottom: var(--s1); }
.nc-sg-label { font-size: 10px; font-weight: 600; color: var(--text-muted); width: 32px; }
.nc-sg-grid .sg-visual { min-width: auto; flex: 1; justify-content: flex-end; }

/* 10. DATA VISUALS (Bloomberg Bars) */
.sg-visual { display: flex; align-items: center; gap: var(--s2); min-width: 110px; }
.sg-val { width: 40px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.sg-track { width: 60px; height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; position: relative; }
.sg-bar { position: absolute; top: 0; height: 100%; border-radius: 3px; transition: width var(--ease); }
.sg-center-line { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,0.2); }

/* 11. PAYWALLS & LOCK STATES */
.paywall { text-align: center; padding: var(--s8) var(--s4); }
.paywall-icon { margin: 0 auto var(--s4); width: 48px; height: 48px; color: var(--text-faint); }
.paywall-title { font-size: var(--text-lg); font-weight: 700; color: var(--text); margin-bottom: var(--s2); }
.paywall-sub { font-size: var(--text-sm); color: var(--text-muted); max-width: 280px; margin: 0 auto var(--s6); line-height: 1.5; }
.paywall-cta-wrap { margin-bottom: var(--s4); }
.paywall-cta { display: inline-block; background: var(--green); color: var(--bg); font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 700; padding: var(--s3) var(--s6); border-radius: var(--r-md); text-decoration: none; transition: all var(--ease); min-width: 180px; text-align: center; }
.paywall-cta:hover { background: #16a34a; transform: translateY(-1px); }
.tab-btn.tab-locked { color: var(--text-faint); }
.tab-btn.tab-locked.active { color: var(--yellow); }
.tab-btn.tab-locked.active::after { background: var(--yellow); }

/* 12. SYSTEM INDICATORS */
.status-msg { text-align: center; padding: var(--s8) var(--s4); color: var(--text-faint); font-size: var(--text-sm); font-style: italic; }
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: var(--r-sm); height: 16px; margin-bottom: var(--s2); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-row { display: flex; gap: var(--s4); padding: var(--s3); border-bottom: 1px solid var(--border); }
.skeleton-row .skeleton { flex: 1; }
.skeleton-row .skeleton:first-child { max-width: 30px; }
.skeleton-row .skeleton:last-child { max-width: 50px; }
.update-flash { position: fixed; top: calc(var(--header-h) + var(--s2)); left: 50%; transform: translateX(-50%); background: var(--green-dim); color: var(--green); font-size: var(--text-xs); font-family: var(--font-mono); padding: var(--s1) var(--s3); border-radius: var(--r-sm); z-index: 200; opacity: 0; transition: opacity 300ms ease; }
.update-flash.visible { opacity: 1; }

/* 13. RESPONSIVENESS & ACCESSIBILITY */
.footer { text-align: center; padding: var(--s8) var(--s4) var(--s4); font-size: var(--text-xs); color: var(--text-faint); line-height: 1.6; }
.footer a { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; border: none; background: none; outline: none; }
button { cursor: pointer; }

@media (min-width: 480px) {
  :root { --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem; --text-md: 0.9375rem; --text-lg: 1.125rem; }
}
@media (min-width: 768px) {
  .tab-content { max-width: 680px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 14. BROADCAST POLISH (Hover Physics & Neon Edges) */
.caveman-card, .nerd-card, .hole-card { transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease; }
.caveman-card:hover, .nerd-card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.6); border-color: var(--border-bright); }
.nerd-card { border-left: 3px solid transparent; }
.nerd-card:hover { border-left-color: var(--green); }
.verdict-likes { box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.05); border: 1px solid var(--green); }
.lb-row:hover { background: rgba(255,255,255,0.02); }