/* ============================================================
   Disc Golf Tracker — Dark, minimal, premium UI
   ============================================================ */

:root {
  --bg: #0a0b0d;
  --surface: #15171b;
  --surface-2: #1d2024;
  --border: #2a2e34;
  --text: #e8eaed;
  --text-dim: #8b9098;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

#app { min-height: 100vh; }

/* ── Auth screens ──────────────────────────────────── */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-card p.subtitle {
  color: var(--text-dim);
  margin-bottom: 28px;
  font-size: 0.9rem;
}

/* ── Forms ────────────────────────────────────────── */

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border 0.2s;
  margin-bottom: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  text-decoration: none;
  width: 100%;
}

button.primary, .btn.primary {
  background: var(--accent);
  color: #0a0b0d;
}

button.primary:hover, .btn.primary:hover {
  opacity: 0.9;
}

button.secondary, .btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover, .btn.secondary:hover {
  background: var(--border);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  font-size: 0.8rem;
  width: auto;
}

button.small {
  padding: 8px 14px;
  font-size: 0.85rem;
  width: auto;
}

/* ── Alerts ───────────────────────────────────────── */

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert.success {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: #86efac;
}

/* ── Layout ───────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar .logo {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 8px 12px 20px;
  letter-spacing: -0.02em;
}

.sidebar .logo span { color: var(--accent); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--surface-2);
  color: var(--accent);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 40px 48px;
  max-width: 960px;
}

/* ── Header ───────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Stats grid ───────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .value.good { color: var(--accent); }
.stat-card .value.bad { color: var(--danger); }
.stat-card .value.neutral { color: var(--text); }

.stat-card .sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Chart ────────────────────────────────────────── */

.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}

.chart-section h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  font-weight: 600;
}

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart-svg {
  display: block;
  margin: 0 auto;
}

/* ── Tables ───────────────────────────────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.88rem;
}

th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr { border-bottom: 1px solid var(--border); }
tr:last-child { border-bottom: none; }
tr:hover { background: var(--surface-2); }

td .score-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
}

.score-pill.under { background: rgba(74, 222, 128, 0.15); color: var(--accent); }
.score-pill.over { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.score-pill.even { background: rgba(139, 144, 152, 0.15); color: var(--text-dim); }

/* ── Friends list ─────────────────────────────────── */

.friend-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}

.friend-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.friend-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.friend-username {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Pending requests ─────────────────────────────── */

.pending-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pending-card .actions {
  display: flex;
  gap: 8px;
}

/* ── Search results ───────────────────────────────── */

.search-results {
  margin-top: 12px;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 6px;
}

/* ── Forms in modal ───────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > div { flex: 1; }

/* ── Modal ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 460px;
}

.modal h3 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  font-weight: 600;
}

.modal .close-row {
  display: flex;
  justify-content: flex-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal .close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  width: auto;
}

/* ── Empty states ─────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state .title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-state .desc {
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* ── Loading ──────────────────────────────────────── */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

/* ── User menu ────────────────────────────────────── */

.user-section {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-section .username {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  color: var(--text);
}

.user-section .logout-link {
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.15s;
}

.user-section .logout-link:hover {
  color: var(--danger);
}

/* ── Per-course ───────────────────────────────────── */

.course-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.course-row:last-child { border-bottom: none; }

.course-row .course-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.course-row .course-stats {
  display: flex;
  gap: 24px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.course-row .course-stats strong {
  color: var(--text);
}

/* ── Improvement badge ────────────────────────────── */

.improvement-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.improvement-badge.up {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}

.improvement-badge.down {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.improvement-badge.flat {
  background: rgba(139, 144, 152, 0.15);
  color: var(--text-dim);
}

/* ── Mobile ───────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
  }

  .sidebar .logo { padding: 4px 12px; }
  .user-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    padding-left: 12px;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row { flex-direction: column; }
}

/* ============================================================
   Course catalog, hole maps, and scorecards
   Extends the existing token set — no new palette, one new pair of
   semantic colours for under/over par.
   ============================================================ */

:root {
  --under: #4ade80;   /* under par — reuses the accent hue deliberately */
  --over: #f87171;
  --fairway: #3f4750;
  --map-ink: #6b7280;
}

/* ── Course search ──────────────────────────────────────── */

.course-search {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.course-search input { flex: 1; }
.course-search button { width: auto; flex: 0 0 auto; white-space: nowrap; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

.course-list { display: flex; flex-direction: column; gap: 8px; }

.course-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 400;
}
.course-card:hover { background: var(--surface-2); border-color: var(--fairway); }
.course-card-name { font-weight: 600; font-size: 1rem; }
.course-card-place { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.course-card-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 4px; }

.tag {
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.tag-map { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.attribution {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 20px;
  line-height: 1.5;
}
.attribution a { color: var(--text-dim); text-decoration: underline; }
.attribution a:hover { color: var(--accent); }

/* ── Course detail ──────────────────────────────────────── */

.course-detail-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.course-detail-header button.primary { width: auto; }

.link-back,
.link-button {
  width: auto;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-back:hover, .link-button:hover { color: var(--accent); background: none; }
.link-back { margin-bottom: 6px; display: block; }

.course-place { font-size: 0.9rem; color: var(--text-dim); margin-top: 4px; }

.layout-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.layout-tab {
  width: auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.layout-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-2);
}
.layout-tab-meta { font-size: 0.72rem; color: var(--text-dim); font-weight: 400; }

.layout-summary {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.layout-summary strong { color: var(--text); font-weight: 600; }

/* ── Maps ───────────────────────────────────────────────── */

.course-map-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 24px;
}
.course-map { width: 100%; height: auto; display: block; }

/* A tee pad is a rectangle and a basket is a cylinder on a post; the markers
   are those shapes rather than generic pins. */
.hole-diagram {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg);
  border-radius: 8px;
}
.hole-diagram.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border: 1px dashed var(--border);
}

.fairway-shadow {
  fill: none;
  stroke: var(--fairway);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.35;
}
.fairway {
  fill: none;
  stroke: var(--map-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 4;
}
.tee-marker rect { fill: var(--accent); }
.basket-marker circle { fill: none; stroke: var(--text); stroke-width: 2; }
.basket-marker line { stroke: var(--text); stroke-width: 2; }

.scale-bar line { stroke: var(--text-dim); stroke-width: 1; }
.scale-bar text { fill: var(--text-dim); font-size: 9px; text-anchor: middle; }

.compass path { fill: var(--text-dim); }
.compass text { fill: var(--text-dim); font-size: 9px; text-anchor: middle; }

.course-hole { cursor: pointer; }
.course-hole .basket-dot { fill: var(--text); }
.course-hole .tee-hit { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.course-hole .hole-number {
  fill: var(--text);
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
}
.course-hole:hover .tee-hit,
.course-hole:focus-visible .tee-hit { fill: var(--accent); stroke: var(--accent); }
.course-hole:hover .hole-number,
.course-hole:focus-visible .hole-number { fill: #0a0b0d; }
.course-hole:focus { outline: none; }
.course-hole:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Hole cards ─────────────────────────────────────────── */

.hole-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.hole-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.hole-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.hole-card-number {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  min-width: 1.4em;
}
.hole-card-par { font-size: 0.8rem; color: var(--text-dim); }
.hole-card-dist { font-size: 0.8rem; color: var(--text-dim); margin-left: auto; }

.hole-card.flash { animation: holeFlash 1.1s ease-out; }
@keyframes holeFlash {
  0%, 100% { border-color: var(--border); }
  25% { border-color: var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
  .hole-card.flash { animation: none; border-color: var(--accent); }
}

/* ── Round form ─────────────────────────────────────────── */

.round-form { max-width: 560px; }

.chosen-course {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.chosen-course-name { font-weight: 600; }
.chosen-course-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

.inline-results {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.inline-results:empty { display: none; }
.inline-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-weight: 400;
  color: var(--text);
}
.inline-result:last-child { border-bottom: none; }
.inline-result:hover { background: var(--surface-2); }
.inline-result-name { font-weight: 500; }
.inline-result-meta { font-size: 0.75rem; color: var(--text-dim); }
.inline-result-empty { padding: 12px 14px; font-size: 0.85rem; color: var(--text-dim); }

.static-field {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
}
.static-field span { font-weight: 400; font-size: 0.78rem; color: var(--text-dim); }

/* ── Scorecard ──────────────────────────────────────────── */

.scorecard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.scorecard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.scorecard-head h3 { font-size: 1rem; }

.scorecard-grid { display: flex; flex-direction: column; }

.score-row {
  display: grid;
  grid-template-columns: 1fr auto 2.5rem;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.score-row:last-child { border-bottom: none; }
.score-row-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.score-row-number {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
}
.score-row-par, .score-row-dist { font-size: 0.78rem; color: var(--text-dim); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px;
  min-width: 34px;
  padding: 0;
  height: 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}
.stepper button:hover { background: var(--border); }
.stepper input {
  width: 52px;
  text-align: center;
  padding: 8px 4px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.score-row-diff {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.score-row-diff.under, .under { color: var(--under); }
.score-row-diff.over, .over { color: var(--over); }
.score-row-diff.even, .even { color: var(--text-dim); }

.scorecard-total {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.scorecard-total-score {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.scorecard-total-diff { font-size: 1rem; font-weight: 600; }
.scorecard-total-hint { font-size: 0.78rem; color: var(--text-dim); margin-left: auto; }

/* ── Stats additions ────────────────────────────────────── */

.basis-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: -8px 0 20px;
  line-height: 1.5;
  max-width: 64ch;
}
.section-note { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 14px; }
.sub-note { display: block; font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }

.outcome-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.outcome-seg { height: 100%; }
.outcome-seg.eagle,  .swatch.eagle  { background: #22d3ee; }
.outcome-seg.birdie, .swatch.birdie { background: var(--accent); }
.outcome-seg.par,    .swatch.par    { background: var(--map-ink); }
.outcome-seg.bogey,  .swatch.bogey  { background: var(--warning); }
.outcome-seg.double, .swatch.double { background: var(--danger); }

.outcome-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.outcome-key { display: inline-flex; align-items: center; gap: 6px; }
.outcome-key strong { color: var(--text); }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.by-par {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.by-par-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.by-par-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.by-par-value { font-size: 1.4rem; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.by-par-count { font-size: 0.7rem; color: var(--text-dim); }

.rank-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rank-columns .chart-section { margin-top: 0; }

.hole-rank-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.hole-rank-row:last-child { border-bottom: none; }
.hole-rank-hole { font-weight: 700; font-variant-numeric: tabular-nums; }
.hole-rank-where { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hole-rank-where .dim { opacity: 0.65; }
.hole-rank-diff { font-weight: 600; font-variant-numeric: tabular-nums; }
.hole-rank-plays { color: var(--text-dim); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.course-row .course-name .link-button { font-size: inherit; font-weight: 600; color: var(--text); }
.course-row .course-name .link-button:hover { color: var(--accent); }

@media (max-width: 768px) {
  .rank-columns { grid-template-columns: 1fr; }
  .hole-grid { grid-template-columns: 1fr; }
  .course-detail-header { align-items: flex-start; }
  .course-detail-header button.primary { width: 100%; }
  .course-search { flex-wrap: wrap; }
  .course-search input { flex: 1 1 100%; }
  .course-search button { flex: 1 1 auto; }
  .score-row { grid-template-columns: 1fr auto; grid-template-areas: "info stepper" "diff diff"; }
  .score-row-diff { grid-area: diff; text-align: left; }
}

/* ============================================================
   Round detail, history rows, and focus visibility
   ============================================================ */

/* Every interactive element is now delegated rather than inline, so focus
   styling has to be uniform instead of per-component. */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--surface-2); }

.row-link {
  width: auto;
  padding: 0;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 500;
  font-size: inherit;
  text-align: left;
}
.row-link:hover { color: var(--accent); background: none; }

.row-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.dim { color: var(--text-dim); font-size: 0.78rem; }

.round-summary {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.round-summary-score { display: flex; align-items: baseline; gap: 10px; }
.round-summary-total {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.round-summary-diff { font-size: 1.1rem; font-weight: 600; }
.round-summary-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.round-summary-meta strong { color: var(--text); }
.round-summary-meta .warn { color: var(--warning); }

.round-notes {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

/* The recorded score on a saved scorecard, above its hole diagram. */
.played-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.played-strokes {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.played-diff { font-size: 0.9rem; font-weight: 600; }

@media (max-width: 768px) {
  .round-summary { gap: 14px; }
  .round-summary-meta { gap: 12px; }
}

/* Replaces the inline styles that were scattered through the friend search. */
.search-result-name { font-weight: 600; }
.search-result-handle { font-size: 0.8rem; color: var(--text-dim); }

/* ============================================================
   Utility classes replacing former inline style attributes, so the
   Content-Security-Policy can forbid inline styles entirely.
   ============================================================ */

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.accent-link { color: var(--accent); text-decoration: none; }
.accent-link:hover { text-decoration: underline; }

.tight-header { margin-bottom: 16px; }
.loose-header { margin-bottom: 24px; }
.section-title { font-size: 1.15rem; }
.subhead { font-size: 1rem; margin-bottom: 12px; font-weight: 600; }

.chart-caption {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 12px;
}

/* Width is set through the CSSOM from data-pct; the transition makes the bar
   animate to its value on load rather than snapping. */
.outcome-seg {
  width: 0;
  transition: width 0.45s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .outcome-seg { transition: none; }
}

.friend-info { cursor: pointer; }
