:root {
  --bg: #06231A;
  --bg-elev: #0E3A2A;
  --bg-elev-2: #144A36;
  --border: #1F5A40;
  --text: #F3F7F0;
  --text-dim: #A9C4B4;
  --text-faint: #6E8F7C;
  --accent: #D4AF52;
  --accent-dim: #9C8038;
  --accent-2: #7FD9C4;
  --warm: #F2B75E;
  --danger: #FF6B6B;
  --good: #52D67A;
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 16px);
  background: radial-gradient(ellipse at top, var(--bg-elev) 0%, var(--bg) 65%);
}

button { font-family: inherit; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }
.icon-xl { width: 56px; height: 56px; color: var(--text-faint); }

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: rgba(6, 20, 15, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.course-switch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}
.course-switch-btn .icon { color: var(--accent); }
.course-switch-btn span#topbar-course-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}
.course-switch-btn .caret { color: var(--text-faint); width: 18px; height: 18px; }

/* ---------- Main / views ---------- */

#app { padding: 16px; max-width: 560px; margin: 0 auto; }
.view.hidden { display: none; }
.hidden { display: none !important; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-dim);
}

/* ---------- Hole strip ---------- */

.hole-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.hole-nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.hole-nav-btn:active { background: var(--bg-elev-2); }
.hole-nav-btn:disabled { opacity: 0.35; }
.hole-strip-mid { text-align: center; flex: 1; }
.hole-strip-num { font-size: 1.3rem; font-weight: 700; }
.hole-strip-meta { color: var(--text-dim); font-size: 0.92rem; margin-top: 2px; }

/* ---------- Yardage hero (the single most prominent thing) ---------- */

.yardage-hero {
  text-align: center;
  padding: 22px 0 12px;
}
.yardage-number {
  font-size: 5.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.yardage-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-top: 6px;
}
.yardage-sub { color: var(--text-faint); font-size: 0.9rem; margin-top: 4px; min-height: 1.2em; }
.geo-status { color: var(--warm); font-size: 0.85rem; margin-top: 8px; min-height: 1.2em; }

.info-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--text-faint);
  background: none;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tooltip {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 16px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.club-card { text-align: center; }
.club-suggest-label { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.club-suggest-name { font-size: 2rem; font-weight: 800; color: var(--text); margin-top: 4px; }
.club-suggest-sub { color: var(--text-faint); font-size: 0.88rem; margin-top: 4px; }

.row-between { display: flex; align-items: center; justify-content: space-between; font-size: 1rem; }
.value-strong { font-weight: 700; font-size: 1.15rem; color: var(--accent-2); }
.source-tag { color: var(--text-faint); font-size: 0.8rem; margin-top: 4px; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 0 0;
  cursor: pointer;
}
.danger-link { color: var(--danger); }

.layout-card-title { font-weight: 700; margin-bottom: 10px; }
.hole-svg-wrap { width: 100%; aspect-ratio: 3 / 4; background: #0A2C20; border-radius: var(--radius-sm); overflow: hidden; }
.hole-svg-wrap svg { width: 100%; height: 100%; display: block; }
.layout-empty { color: var(--text-faint); font-size: 0.88rem; padding: 8px 2px 0; }

.weather-card { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; color: var(--text-dim); }

.score-card .row-between { margin-bottom: 6px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}
.stepper-value { font-size: 1.3rem; font-weight: 700; min-width: 1.6ch; text-align: center; }
.round-progress { margin-top: 10px; color: var(--good); font-weight: 600; font-size: 0.92rem; }
.no-round-msg { margin-top: 10px; }

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--accent);
  color: #14260F;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 20px;
  cursor: pointer;
  width: 100%;
}
.btn-primary:active { background: var(--accent-dim); }
.btn-primary.btn-small { width: auto; padding: 10px 18px; font-size: 0.92rem; }

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 13px 18px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}
.btn-secondary.btn-small { width: auto; padding: 9px 16px; font-size: 0.88rem; margin-bottom: 0; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:active { background: var(--bg-elev-2); }

/* ---------- Courses view ---------- */

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 13px 14px;
  font-size: 1rem;
}
.courses-status { color: var(--text-dim); font-size: 0.9rem; min-height: 1.4em; margin-bottom: 8px; }
.courses-list { list-style: none; margin: 0; padding: 0; }
.course-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.course-item:active { background: var(--bg-elev-2); }
.course-item-name { font-weight: 700; font-size: 1.02rem; }
.course-item-meta { color: var(--text-dim); font-size: 0.88rem; margin-top: 3px; }

/* ---------- Rounds view ---------- */

.stats-row { display: flex; gap: 10px; margin-bottom: 20px; }
.stat-tile {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
}
.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.stat-label { color: var(--text-dim); font-size: 0.78rem; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }

.section-title { font-size: 1.1rem; margin: 0 0 10px; }
.rounds-list { list-style: none; margin: 0; padding: 0; }
.round-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.round-item:active { background: var(--bg-elev-2); }
.round-item-name { font-weight: 700; }
.round-item-date { color: var(--text-faint); font-size: 0.82rem; margin-top: 2px; }
.round-item-score { font-weight: 800; font-size: 1.15rem; color: var(--accent-2); }
.empty-hint { color: var(--text-faint); font-size: 0.9rem; padding: 20px 0; text-align: center; }

/* ---------- Settings view ---------- */

.settings-hint { color: var(--text-dim); font-size: 0.9rem; line-height: 1.4; margin: 0 0 16px; }
.clubs-list { list-style: none; margin: 0 0 14px; padding: 0; }
.club-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.club-row input[type="text"] {
  flex: 1.3;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.98rem;
  padding: 6px 0;
}
.club-row input[type="number"] {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-2);
  font-weight: 700;
  text-align: center;
  padding: 8px 6px;
  font-size: 1rem;
}
.club-row .club-yd-label { color: var(--text-faint); font-size: 0.8rem; }
.club-row-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 2px;
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  display: flex;
  background: rgba(6, 20, 15, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 20;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.nav-btn.active { color: var(--accent); }
.nav-btn .icon { width: 22px; height: 22px; }

/* ---------- Dialogs ---------- */

dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  padding: 20px;
  width: min(420px, 92vw);
  border: 1px solid var(--border);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 14px; font-size: 1.15rem; }

.edit-dialog label {
  display: block;
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.edit-dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 1rem;
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-header h2 { margin: 0; }
.round-detail-summary { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 14px; }
.scorecard-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin-bottom: 14px; }
.scorecard-table th, .scorecard-table td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--border); }
.scorecard-table th { color: var(--text-faint); font-weight: 600; }

@media (min-width: 600px) {
  .yardage-number { font-size: 7rem; }
}
