:root {
  --bg: #f4f7f4;
  --surface: #ffffff;
  --surface-2: #eaf1ec;
  --text: #17231b;
  --muted: #5b6b60;
  --line: #d6e0d9;
  --brand: #1d5e3a;
  --brand-2: #2f7d4f;
  --on-brand: #ffffff;
  --accent: #e8c547;
  --danger: #b3261e;
  --under: #b3261e;
  --over: #1a4c8b;
  --fairway: #7cc36b;
  --green: #3fae5c;
  --tee: #9ad18b;
  --bunker: #e9d8a6;
  --water: #4d9de0;
  --rough: #5f8f55;
  --path: #9e9e9e;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1511;
    --surface: #18211b;
    --surface-2: #1f2b23;
    --text: #e6eee8;
    --muted: #9aab9f;
    --line: #2c3a30;
    --brand: #2f8a55;
    --brand-2: #3fa468;
    --under: #ff8a80;
    --over: #8ab4f8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: var(--on-brand);
}
.topbar a { color: var(--on-brand); text-decoration: none; }
.brand { font-weight: 700; }
.topbar nav { display: flex; gap: 16px; font-size: 15px; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 18px 0 8px; }
h3 { font-size: 16px; margin: 12px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}

button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 12px; min-height: 48px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
button.danger { color: var(--danger); }
button.block, .btn.block { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
button.icon { min-width: 48px; padding: 0 12px; }
button.sel { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

input, select {
  font: inherit; width: 100%; padding: 12px; min-height: 48px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { color: inherit; text-decoration: none; display: block; }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: #d8f0df; color: #1d5e3a; }
.badge.warn { background: #fbecc4; color: #7a5a00; }
@media (prefers-color-scheme: dark) {
  .badge.ok { background: #1f3a28; color: #9fe0b4; }
  .badge.warn { background: #3a3218; color: #f0d27a; }
}

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.grid td.l, table.grid th.l { text-align: left; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.under { color: var(--under); font-weight: 700; }
.over { color: var(--over); }

/* ---- Round screen ---- */
.hole-head { display: flex; align-items: center; gap: 8px; }
.hole-head .title { flex: 1; text-align: center; }
.hole-head .num { font-size: 28px; font-weight: 800; line-height: 1; }
.hole-head .meta { color: var(--muted); font-size: 14px; }

.yardage { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 4px; }
.yardage .v { font-size: 34px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.yardage .center .v { font-size: 46px; color: var(--brand-2); }
.yardage .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.gps { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
.hazards { margin-top: 8px; font-size: 14px; }
.hazards li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }

.players li { display: flex; align-items: center; gap: 10px; }
.players .score {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; background: var(--surface-2);
}
.players .score.empty { color: var(--muted); font-weight: 400; }
.players .detail { font-size: 13px; color: var(--muted); }

.mic-bar {
  position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%);
}
.mic-bar button { min-height: 60px; font-size: 17px; }
.listening { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(47,125,79,.6); } 50% { box-shadow: 0 0 0 10px rgba(47,125,79,0); } }

.voice-log { font-size: 14px; min-height: 22px; text-align: center; color: var(--muted); }
.voice-log b { color: var(--text); }

.holemap { width: 100%; height: 300px; display: block; background: var(--rough); border-radius: 12px; }
@media (prefers-color-scheme: dark) { .holemap { background: #2c4a2c; } }

/* ---- Sheet editor ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 720px; margin: 0 auto; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto;
}
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .val { min-width: 44px; text-align: center; font-size: 24px; font-weight: 800; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 44px; padding: 8px; }
.field { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; font-size: 14px;
}
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; }
