:root {
  --green-50: #eaf6f2;
  --green-100: #9fe1cb;
  --green-600: #0f6e56;
  --green-700: #0f6e56;
  --green-800: #0a5a46;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --amber-400: #fbbf24;
  /* Score-vs-par tiers — matched to the palette used across PGA Tour,
     Masters.com, DP World Tour, ESPN, Golf Channel, ~2026 (Johan's
     research). Bogey/double keep dark text instead of the white text
     those sites use — better contrast on tan/light-blue at our size. */
  --eagle-bg: #003d7c;  --eagle-text: #ffffff;
  --birdie-bg: #d32f2c; --birdie-text: #ffffff;
  --bogey-bg: #c8a96e;  --bogey-text: #2c2c2a;
  --double-bg: #7cb5d4; --double-text: #2c2c2a;
  --triple-bg: #2c2c2c; --triple-text: #ffffff;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #2c2c2a;
  --white: #ffffff;
  --shadow: 0 1px 3px rgb(0 0 0/.1), 0 1px 2px rgb(0 0 0/.06);
  --shadow-md: 0 4px 6px rgb(0 0 0/.07), 0 2px 4px rgb(0 0 0/.06);
  --shadow-lg: 0 10px 15px rgb(0 0 0/.1), 0 4px 6px rgb(0 0 0/.05);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "Open Sans", Arial, sans-serif;
  background: var(--green-50);
  color: var(--slate-900);
  min-height: 100vh;
  padding-bottom: var(--nav-h);
  max-width: 480px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: calc(100vh - var(--nav-h)); }

/* ── HEADER ── */
.header {
  background: var(--green-700);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header h1 { font-size: 17px; font-weight: 700; font-family: "Montserrat", Arial, sans-serif; display: flex; align-items: center; gap: 8px; }
.header-logo { height: 24px; width: auto; display: block; }
.header-btn {
  background: rgba(255,255,255,.18);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--nav-h);
  background: white; border-top: 1px solid var(--slate-200);
  display: flex; z-index: 100;
  box-shadow: 0 -2px 12px rgb(0 0 0/.08);
}
.nav-btn {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer;
  color: var(--slate-400); transition: color .15s; padding: 8px 0;
}
.nav-btn.active { color: var(--green-600); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .02em; }

/* ── CARDS ── */
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin: 12px 14px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; font-family: "Montserrat", Arial, sans-serif; }

/* ── BUTTONS ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 24px; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; border: none; cursor: pointer;
  transition: all .15s; width: 100%;
}
.btn-primary { background: var(--green-600); color: white; }
.btn-primary:active { background: var(--green-700); }
.btn-secondary { background: var(--slate-100); color: var(--slate-800); }
.btn-secondary:active { background: var(--slate-200); }
.btn-danger { background: var(--red-100); color: var(--red-500); }
.btn-sm { padding: 9px 18px; font-size: 14px; width: auto; border-radius: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── FORM ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--slate-500); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .06em;
}
.form-select, .form-input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm); font-size: 16px; color: var(--slate-900);
  background: white; outline: none; transition: border-color .2s;
  appearance: none;
}
.form-select:focus, .form-input:focus { border-color: var(--green-600); }

/* ── SCORING HEADER ── */
.score-header {
  background: var(--green-700); color: white;
  padding: 16px 16px 20px;
}
.score-header-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px;
}
.score-player-name { font-size: 16px; font-weight: 700; }
.score-course-name { font-size: 12px; opacity: .7; margin-top: 2px; }
.score-hi-badge {
  background: rgba(255,255,255,.2); border-radius: 20px;
  padding: 4px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.hole-stats-row {
  display: flex; justify-content: space-around;
  background: rgba(0,0,0,.15); border-radius: var(--radius-sm);
  padding: 12px 8px;
}
.hole-stat { text-align: center; }
.hole-stat-label { font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .06em; }
.hole-stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stroke-badge {
  display: inline-block; background: var(--amber-400); color: var(--slate-900);
  font-size: 11px; font-weight: 700; padding: 2px 10px;
  border-radius: 20px; margin-top: 4px;
}

/* ── PROGRESS BAR ── */
.progress-bar {
  display: flex; gap: 3px; padding: 10px 14px; background: white;
  border-bottom: 1px solid var(--slate-100);
}
.progress-dot {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--slate-200); transition: background .3s;
}
.progress-dot.done { background: var(--green-600); }
.progress-dot.current { background: var(--amber-400); }

/* ── SCORE ENTRY ── */
.score-entry { padding: 20px 16px 8px; text-align: center; }
.score-entry-label {
  font-size: 12px; font-weight: 700; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 18px;
}
.score-controls {
  display: flex; align-items: center;
  justify-content: center; gap: 20px; margin-bottom: 14px;
}
.score-btn {
  width: 76px; height: 76px; border-radius: 50%; border: none;
  font-size: 38px; font-weight: 300; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s; box-shadow: var(--shadow-md);
}
.score-btn:active { transform: scale(.92); }
.score-btn-minus { background: var(--slate-100); color: var(--slate-700); }
.score-btn-plus  { background: var(--green-600); color: white; }
.score-display { width: 110px; text-align: center; }
.score-value { font-size: 80px; font-weight: 800; line-height: 1; }
.score-label {
  font-size: 15px; font-weight: 600; margin-top: 2px;
  padding: 3px 12px; border-radius: 20px; display: inline-block;
}
.s-eagle  { color: var(--eagle-text);  background: var(--eagle-bg); }
.s-birdie { color: var(--birdie-text); background: var(--birdie-bg); }
.s-par    { color: var(--slate-600);   background: var(--slate-100); }
.s-bogey  { color: var(--bogey-text);  background: var(--bogey-bg); }
.s-double { color: var(--double-text); background: var(--double-bg); }
.s-worse  { color: var(--triple-text); background: var(--triple-bg); }

.net-box {
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm); padding: 10px 16px;
  margin: 0 14px 10px; text-align: center;
}
.net-box-label { font-size: 12px; color: var(--slate-500); }
.net-box-value { font-size: 20px; font-weight: 700; color: var(--slate-800); }

/* ── MINI SCORECARD ── */
.scorecard-wrap {
  margin: 0 14px 12px; background: white;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); overflow-x: auto;
}
.scorecard-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; min-width: 360px;
}
.scorecard-table th {
  background: var(--slate-800); color: white;
  padding: 6px 3px; text-align: center;
  font-size: 11px; font-weight: 600; min-width: 28px;
}
.scorecard-table td {
  padding: 6px 3px; text-align: center;
  border-bottom: 1px solid var(--slate-100);
}
.scorecard-table tr:last-child td { border-bottom: none; }
.sc-cur { background: var(--green-50) !important; font-weight: 700; }
.sc-eagle, .sc-birdie, .sc-bogey, .sc-double, .sc-triple {
  font-weight: 700; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; width: 24px; height: 24px;
}
.sc-eagle  { background: var(--eagle-bg);  color: var(--eagle-text); }
.sc-birdie { background: var(--birdie-bg); color: var(--birdie-text); }
.sc-par    { font-weight: 500; }
.sc-bogey  { background: var(--bogey-bg);  color: var(--bogey-text); }
.sc-double { background: var(--double-bg); color: var(--double-text); }
.sc-triple { background: var(--triple-bg); color: var(--triple-text); }

.save-wrap { padding: 8px 14px 20px; }

/* ── ROUND COMPLETE ── */
.complete-banner {
  background: var(--green-700); color: white;
  padding: 32px 20px; text-align: center;
}
.complete-icon { font-size: 56px; margin-bottom: 8px; }
.complete-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; font-family: "Montserrat", Arial, sans-serif; }
.complete-sub { font-size: 14px; opacity: .8; }
.complete-scores {
  display: flex; justify-content: center; gap: 40px; margin-top: 20px;
}
.complete-score-item { text-align: center; }
.complete-score-label { font-size: 11px; opacity: .7; text-transform: uppercase; }
.complete-score-val { font-size: 36px; font-weight: 800; }

/* ── LEADERBOARD ── */
.lb-date-bar {
  background: white; padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
  display: flex; align-items: center; gap: 10px;
}
.lb-date-bar label { font-size: 13px; font-weight: 600; color: var(--slate-600); }
.lb-date-input {
  border: 1.5px solid var(--slate-200); border-radius: 8px;
  padding: 6px 10px; font-size: 14px; outline: none;
}
.lb-date-input:focus { border-color: var(--green-600); }
.lb-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.lb-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; align-items: stretch;
}
.lb-rank-col {
  width: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--slate-50); border-right: 1px solid var(--slate-100);
  font-size: 22px; font-weight: 800; color: var(--slate-300); flex-shrink: 0;
}
.lb-rank-col.r1 { color: var(--amber-400); }
.lb-rank-col.r2 { color: #94a3b8; }
.lb-rank-col.r3 { color: #b45309; }
.lb-move { font-size: 11px; font-weight: 700; line-height: 1; }
.lb-move.up   { color: var(--green-600); }
.lb-move.down { color: var(--red-500); }
.lb-move.same { color: var(--slate-300); }
.lb-body { flex: 1; padding: 12px 14px; }
.lb-name { font-size: 16px; font-weight: 700; }
.lb-meta { font-size: 13px; color: var(--slate-500); margin-top: 3px; }
.lb-score-col {
  padding: 12px 14px; text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
}
.lb-total { font-size: 28px; font-weight: 800; }
.lb-total.under { color: var(--blue-500); }
.lb-total.over  { color: var(--red-500); }
.lb-total.even  { color: var(--slate-800); }
.lb-holes { font-size: 12px; color: var(--slate-400); }
.lb-status {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; margin-top: 4px; display: inline-block;
}
.lb-status.active { background: var(--green-100); color: var(--green-700); }
.lb-status.done   { background: var(--slate-100); color: var(--slate-500); }

/* ── PLAYERS ── */
.search-bar {
  background: white; padding: 10px 14px;
  border-bottom: 1px solid var(--slate-100);
}
.search-input {
  width: 100%; padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--slate-200); border-radius: 24px;
  font-size: 15px; background: var(--slate-50)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
  outline: none;
}
.search-input:focus { border-color: var(--green-600); }

.player-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.player-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; padding: 12px 14px; gap: 12px; cursor: pointer;
}
.player-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--green-100); color: var(--green-700);
  font-size: 15px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.player-info { flex: 1; }
.player-name { font-size: 16px; font-weight: 600; }
.player-email { font-size: 13px; color: var(--slate-400); margin-top: 1px; }
.hi-badge {
  font-size: 13px; font-weight: 700; padding: 5px 12px;
  border-radius: 20px; background: var(--green-50); color: var(--green-700);
}
.hi-badge.none { background: var(--slate-100); color: var(--slate-400); }

.fab {
  position: fixed; bottom: calc(var(--nav-h) + 14px); right: 16px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--green-600); color: white; border: none;
  font-size: 26px; box-shadow: var(--shadow-lg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s; z-index: 50;
}
.fab:active { transform: scale(.93); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; backdrop-filter: blur(2px);
}
.modal {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 201; padding: 8px 20px 24px;
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(100%); }
  to   { transform: translateX(-50%) translateY(0); }
}
.modal-handle {
  width: 36px; height: 4px; background: var(--slate-200);
  border-radius: 2px; margin: 8px auto 16px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; font-family: "Montserrat", Arial, sans-serif; }

/* ── Modal header (flex: back-btn + title + close) ── */
.modal-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0 12px; border-bottom: 1px solid var(--slate-100);
  margin-bottom: 0;
}
.modal-header h2 { flex: 1; font-size: 16px; font-weight: 700; margin: 0; font-family: "Montserrat", Arial, sans-serif; }
.back-btn {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--slate-500); padding: 4px 8px; line-height: 1;
  border-radius: 6px; flex-shrink: 0;
}
.back-btn:hover { background: var(--slate-100); }
.header .back-btn { color: white; }
.header .back-btn:hover { background: rgba(255,255,255,.15); }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--slate-400); padding: 4px 8px; line-height: 1;
  border-radius: 6px; flex-shrink: 0;
}
.modal-close:hover { background: var(--slate-100); }

/* ── TOAST ── */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--slate-900); color: white;
  padding: 11px 20px; border-radius: 24px; font-size: 14px;
  font-weight: 500; z-index: 300; white-space: nowrap;
  box-shadow: var(--shadow-lg); animation: fadeInDown .25s ease;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── MISC ── */
.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: white;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--slate-500);
}
.empty-icon  { font-size: 48px; margin-bottom: 10px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--slate-700); margin-bottom: 6px; }
.empty-sub   { font-size: 14px; }
.section-label {
  padding: 14px 14px 6px;
  font-size: 12px; font-weight: 700;
  color: var(--slate-500); text-transform: uppercase; letter-spacing: .08em;
}
.divider { height: 1px; background: var(--slate-100); margin: 6px 0; }

/* ── WELCOME SCREEN ── */
.welcome-wrap {
  min-height: calc(100vh - var(--nav-h));
  background: linear-gradient(160deg, var(--green-800) 0%, var(--green-700) 55%, #0f6e56 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 28px; text-align: center; color: white;
}
.welcome-sponsor-box {
  background: white; border-radius: 16px;
  padding: 14px 28px; margin-bottom: 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
  min-width: 160px;
}
.welcome-sponsor-label {
  font-size: 10px; font-weight: 700; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px;
}
.welcome-sponsor-name {
  font-size: 17px; font-weight: 800; color: var(--slate-900);
}
.welcome-sponsor-img {
  max-height: 56px; max-width: 200px; object-fit: contain; display: block; margin: 0 auto;
}
.welcome-event-name {
  font-size: 30px; font-weight: 900; line-height: 1.15; margin-bottom: 10px;
  text-shadow: 0 2px 12px rgba(0,0,0,.25); letter-spacing: -.02em;
  font-family: "Montserrat", Arial, sans-serif;
}
.welcome-course {
  font-size: 15px; opacity: .85; margin-bottom: 4px; font-weight: 500;
}
.welcome-date {
  font-size: 13px; opacity: .65; margin-bottom: 40px;
}
.welcome-no-event {
  font-size: 38px; margin-bottom: 12px;
}
.welcome-no-title {
  font-size: 26px; font-weight: 800; margin-bottom: 8px;
  font-family: "Montserrat", Arial, sans-serif;
}
.welcome-no-sub {
  font-size: 15px; opacity: .75; margin-bottom: 40px;
}
.welcome-primary-btn {
  background: white; color: var(--green-700); border: none;
  border-radius: var(--radius-sm); padding: 17px 32px;
  font-size: 18px; font-weight: 800; cursor: pointer;
  width: 100%; max-width: 300px; display: block;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transition: transform .12s; margin-bottom: 14px;
}
.welcome-primary-btn:active { transform: scale(.97); }
.welcome-secondary-btn {
  background: rgba(255,255,255,.15); color: white;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: var(--radius-sm); padding: 13px 24px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  width: 100%; max-width: 300px; display: block;
  transition: background .15s;
}
.welcome-secondary-btn:active { background: rgba(255,255,255,.25); }

/* ── FORM SECTION LABELS ── */
.form-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--green-700); text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 0 6px; margin-bottom: 2px;
  border-bottom: 2px solid var(--green-100);
  margin-top: 8px;
}

/* ── STABLEFORD ── */
.stab-pts-big {
  font-size: 52px; font-weight: 800; line-height: 1;
  color: var(--green-600);
}
/* format badge on leaderboard / score header already uses inline color */
