:root {
  --bg: #0e1a13;
  --surface: #16261c;
  --surface-2: #1e3326;
  --border: #2c4535;
  --text: #f2f5f1;
  --text-dim: #9fb3a6;
  --accent: #3fae67;
  --accent-strong: #57d382;
  --danger: #d95c5c;
  --warn: #e0b04a;
  --radius: 14px;
  --tap: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  gap: 16px;
  overflow-y: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.btn {
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06180f;
}

.btn-primary:active { background: var(--accent-strong); }

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-block { width: 100%; }

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

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2 > * { min-width: 0; }

.compact-stepper-card { padding: 14px 10px; }
.compact-stepper { gap: 6px; min-width: 0; }
.compact-stepper .stepper-btn.compact-stepper-btn {
  width: 40px; height: 40px; font-size: 1.2rem;
  flex: 0 0 auto;
}
.compact-stepper .value.compact-stepper-value {
  font-size: 1.6rem;
  min-width: 0;
  flex: 1 1 auto;
  text-align: center;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

select, input[type="text"], input[type="date"], textarea {
  min-height: var(--tap);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
}

textarea { min-height: 72px; resize: vertical; }

/* --- Hole entry --- */

.hole-header {
  text-align: center;
}

.hole-header .hole-num {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}

.hole-header .hole-meta {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 4px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.progress-dots .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.progress-dots .dot.done { background: var(--accent); }
.progress-dots .dot.current { background: var(--warn); }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.stepper .value {
  font-size: 3rem;
  font-weight: 800;
  min-width: 84px;
  text-align: center;
}

.stepper-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:active { background: var(--accent); color: #06180f; }

.stepper-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.par-pick {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.par-pick button {
  flex: 1;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 1.1rem;
}

.par-pick button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #06180f;
}

.toggle-row {
  display: flex;
  gap: 10px;
}

.toggle {
  flex: 1;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
}

.toggle.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06180f;
}

.toggle.na { opacity: 0.4; pointer-events: none; }

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

details.more summary {
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
  cursor: pointer;
}

details.more summary::-webkit-details-marker { display: none; }

details.more .more-body {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

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

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item .meta { color: var(--text-dim); font-size: 0.85rem; }
.list-item .score { font-size: 1.4rem; font-weight: 800; }

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

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.banner.warn { border-color: var(--warn); color: var(--warn); }

table.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.score-table th, table.score-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

table.score-table th { color: var(--text-dim); font-weight: 600; }

.sg-row {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.sg-label { color: var(--text-dim); }

.sg-track {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.sg-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: var(--text-dim);
  border-radius: 999px;
}

.sg-fill.positive { background: var(--accent); }
.sg-fill.negative { background: var(--danger); }

.sg-value { text-align: right; font-weight: 700; }
.sg-value.positive { color: var(--accent-strong); }
.sg-value.negative { color: var(--danger); }

.trend-chart { width: 100%; height: auto; display: block; }
