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

:root {
  --green-dark:  #1b5e20;
  --green:       #2e7d32;
  --green-mid:   #43a047;
  --green-pale:  #e8f5e9;
  --green-bg:    #f1f8f0;
  --orange:      #f57f17;
  --red:         #c62828;
  --red-pale:    #ffebee;
  --text:        #1a1a1a;
  --muted:       #616161;
  --border:      #e0e0e0;
  --white:       #ffffff;
  --shadow:      0 2px 8px rgba(0,0,0,0.09);
  --radius:      12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--green-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

body {
  max-width: 480px;
  margin: 0 auto;
}

#app { min-height: 100vh; }

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

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: 16px;
  padding-bottom: 36px;
}

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

.header {
  background: var(--green-dark);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.header--home .header-title { font-size: 22px; }

.header-icon { font-size: 26px; line-height: 1; }

.back-btn {
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 2px 8px 2px 0;
  line-height: 1;
  flex-shrink: 0;
}

.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  line-height: 1;
  flex-shrink: 0;
}

.icon-btn:active { background: rgba(255,255,255,0.3); }

/* Game header layout */
.header--game { gap: 8px; }

.hole-badge {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.hole-num { font-size: 24px; font-weight: 800; }
.hole-of-18 { font-size: 14px; opacity: 0.75; }

.hole-par-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Progress Bar ─────────────────────────── */

.progress-bar {
  height: 5px;
  background: rgba(46,125,50,0.2);
}

.progress-fill {
  height: 100%;
  background: var(--green-mid);
  transition: width 0.3s ease;
  min-width: 4px;
}

/* ── Buttons ──────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
}

.btn:active:not(:disabled) {
  opacity: 0.72;
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.btn--primary   { background: var(--green);     color: var(--white); }
.btn--secondary { background: var(--green-pale); color: var(--green-dark); }
.btn--ghost     { background: transparent;       color: var(--green); border: 2px solid var(--green); }
.btn--finish    { background: var(--orange);     color: var(--white); }
.btn--danger    { background: var(--red-pale);   color: var(--red); }

.btn--full { width: 100%; }
.btn--lg   { padding: 16px 20px; font-size: 17px; border-radius: 12px; }
.btn--sm   { padding: 8px 12px; font-size: 14px; }
.btn--nav  { flex: 1; }

/* ── Cards ────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card--highlight { border-left: 4px solid var(--green); }

.card--clickable { cursor: pointer; transition: box-shadow 0.15s; }
.card--clickable:active { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.card-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--green);
  margin-bottom: 4px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.card-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ── Player score chips (history cards) ───── */

.player-scores-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.player-score-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-bg);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 14px;
}

.psc-name { color: var(--muted); }
.psc-score { font-weight: 700; color: var(--green-dark); }

/* ── Utility ──────────────────────────────── */

.mt-12 { margin-top: 12px; }

.section { margin-bottom: 24px; }

.section-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 10px;
}

.empty-hint {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  padding: 8px 0;
}

/* ── Setup: Add player row ────────────────── */

.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.text-input {
  flex: 1;
  height: 46px;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus { border-color: var(--green); }

/* ── Setup: Player chips ──────────────────── */

.player-chip-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-radius: 10px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
}

.player-chip-name { font-weight: 600; font-size: 15px; }

.chip-remove {
  background: var(--red-pale);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  color: var(--red);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.chip-remove:active { opacity: 0.7; }

/* ── Setup: Par grid ──────────────────────── */

.par-preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.par-preset-label { font-size: 14px; color: var(--muted); }

.par-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.par-cell {
  background: var(--white);
  border-radius: 10px;
  padding: 10px 6px 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.par-cell-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ── Score Controls ───────────────────────── */

.score-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.sc-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--green-pale);
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  font-family: inherit;
}

.sc-btn:active { background: var(--green-mid); color: white; transform: scale(0.92); }

.sc-val {
  min-width: 22px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--green-dark);
}

/* Large variants for game screen */
.score-ctrl--lg { gap: 10px; }

.sc-btn--lg {
  width: 52px;
  height: 52px;
  font-size: 26px;
  border-radius: 50%;
}

.sc-val--lg {
  min-width: 44px;
  font-size: 32px;
  font-weight: 800;
}

.sc-val--empty {
  color: var(--border);
}

/* ── Game: Player rows ────────────────────── */

.player-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.player-row {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-row-info {
  flex: 1;
  min-width: 0;
}

.player-row-name {
  display: block;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-row-total {
  font-size: 13px;
  color: var(--muted);
}

/* ── Game: Hole nav ───────────────────────── */

.hole-nav {
  display: flex;
  gap: 8px;
}

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

.sc-date {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.sc-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sc-section { margin-bottom: 20px; }

.sc-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.sc-table {
  width: 100%;
  min-width: 380px;
  border-collapse: collapse;
  background: var(--white);
  font-size: 13px;
}

.sc-table th,
.sc-table td {
  text-align: center;
  padding: 8px 5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sc-table thead th {
  background: var(--green-dark);
  color: var(--white);
  font-weight: 700;
  font-size: 12px;
  border-bottom: none;
}

.sc-table tbody .par-row {
  background: var(--green-pale);
  font-weight: 700;
}

.sc-table tbody tr:last-child td {
  border-bottom: none;
}

.sc-name-col {
  min-width: 72px;
  text-align: left !important;
  padding-left: 10px !important;
}

.sc-name {
  text-align: left !important;
  padding-left: 10px !important;
  font-weight: 600;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-sub-col { background: var(--green-pale) !important; }
.sc-tot-col { background: var(--green-dark) !important; color: var(--white) !important; }

td.sc-sub { background: var(--green-pale); font-weight: 700; }
td.sc-tot { background: var(--green-dark); color: var(--white); font-weight: 700; }
th.sc-sub { background: var(--green) !important; }
th.sc-tot { background: var(--green-dark) !important; font-weight: 700; }

.s-empty { color: var(--border); }
.s-over  { color: var(--red); }
.s-under { color: var(--green-dark); font-weight: 700; }

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.action-row .btn { flex: 1; }
