:root {
  --bg: #070b09;
  --bg-2: #0d1410;
  --panel: rgba(16, 24, 20, 0.92);
  --panel-solid: #121a16;
  --card: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f1e8;
  --muted: #aebbb0;
  --gold: #e0b84a;
  --gold-2: #c9a227;
  --green: #3dcf8a;
  --water: #4db2e0;
  --warm: #e08a4a;
  --red: #e0644a;
  --pin: #1a1408;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --top: env(safe-area-inset-top, 0px);
  --bot: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  font-size: 16px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Noto Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }

#app {
  height: 100dvh;
  position: relative;
  overflow: hidden;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- top bar ---------- */

.topbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 20;
  padding: calc(10px + var(--top)) 14px 10px;
  background: linear-gradient(180deg, rgba(7, 11, 9, 0.97), rgba(7, 11, 9, 0.9));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 650;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 12px;
  z-index: 40;
  min-width: 230px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.menu button {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.menu button:last-of-type { border-bottom: 0; }
.menu-status {
  padding: 10px 16px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  user-select: text;
}

/* ---------- main scroll view ---------- */

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(74px + var(--top)) 14px calc(var(--nav-h) + var(--bot) + 20px);
}

.section-title {
  margin: 22px 2px 10px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- bottom nav ---------- */

.bottomnav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--bot));
  padding-bottom: var(--bot);
  background: rgba(10, 14, 12, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.bottomnav button {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  min-height: var(--nav-h);
}
.bottomnav button svg { width: 22px; height: 22px; }
.bottomnav button[aria-current="true"] { color: var(--gold); }

/* ---------- cards, tiles, rows ---------- */

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

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
}
.tile strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tile span { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.tile strong.good { color: var(--green); }
.tile strong.bad { color: var(--warm); }

.list-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row strong { display: block; font-size: 0.98rem; }
.list-row .sub {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row .num {
  font-size: 1.3rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.list-row .num small { display: block; font-size: 0.7rem; font-weight: 650; color: var(--muted); }
.num.under { color: var(--green); }
.num.over { color: var(--text); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}
.badge.gold { color: var(--gold); background: rgba(224, 184, 74, 0.12); }

/* ---------- chips & buttons ---------- */

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  margin: 8px 0;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 650;
  font-size: 0.86rem;
}
.chip[aria-pressed="true"] {
  background: var(--gold);
  color: var(--pin);
  border-color: var(--gold);
}
.chip-gold { border-color: rgba(224, 184, 74, 0.45); color: var(--gold); }

.btn {
  display: block;
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  margin: 8px 0;
}
.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--pin);
}
.btn.danger {
  border-color: rgba(224, 100, 74, 0.5);
  color: var(--red);
  background: rgba(224, 100, 74, 0.07);
}
.btn.quiet { border: 0; background: transparent; color: var(--muted); min-height: 42px; }
.btn:disabled { opacity: 0.45; }

.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- forms ---------- */

.field { margin: 0 0 12px; }
.field label {
  display: block;
  margin: 0 2px 6px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.field textarea { min-height: 80px; resize: vertical; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23aebbb0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

input[type="number"] { font-variant-numeric: tabular-nums; }

/* ---------- steppers & segmented controls ---------- */

.stepper {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
}
.stepper button {
  height: 56px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.5rem;
  font-weight: 700;
}
.stepper .val {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stepper .val-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  height: auto;
}
.stepper .val small {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stepper .val .rel { font-size: 0.95rem; font-weight: 750; margin-left: 6px; }
.rel.under { color: var(--green); }
.rel.over { color: var(--warm); }

.stepper.small { grid-template-columns: 44px 1fr 44px; margin: 4px 0 10px; }
.stepper.small button { height: 44px; font-size: 1.2rem; }
.stepper.small .val { font-size: 1.3rem; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  margin: 6px 0 12px;
}
.seg button {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 650;
  font-size: 0.85rem;
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--pin);
}
/* auto-suggested (from score − putts) but not yet confirmed */
.seg button.suggested {
  border-style: dashed;
  border-color: rgba(224, 184, 74, 0.55);
  color: var(--text);
}

.subhead {
  margin: 14px 2px 4px;
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- live hole screen ---------- */

.hole-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 8px;
}
.hole-head h2 { margin: 0; font-size: 1.6rem; letter-spacing: -0.03em; }
.hole-head .facts { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.hole-head .facts b { color: var(--text); }
.hole-head .facts b.par-3 { color: var(--water); }
.hole-head .facts b.par-4 { color: var(--gold); }
.hole-head .facts b.par-5 { color: var(--green); }

.run-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.run-strip div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
}
.run-strip strong { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.run-strip span { color: var(--muted); font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; }

.book-note {
  background: rgba(224, 184, 74, 0.09);
  border: 1px solid rgba(224, 184, 74, 0.26);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  user-select: text;
}
.book-note .subhead { margin-top: 0; color: var(--gold); }
.book-note p { margin: 0; }

.hist-line { color: var(--muted); font-size: 0.85rem; margin: 0 2px 12px; }
.hist-line b { color: var(--text); }

.caddie {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0 12px;
}
.caddie .gps-btn { font-size: 1.1rem; }
.caddie .gps-btn[aria-pressed="true"] {
  background: rgba(77, 178, 224, 0.16);
  box-shadow: inset 0 0 0 1px rgba(77, 178, 224, 0.55);
}
.caddie input {
  width: 110px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.caddie .say { flex: 1; font-size: 0.92rem; color: var(--muted); }
.caddie .say b { color: var(--gold); font-size: 1.02rem; }

.hole-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.hole-nav .btn { margin: 0; }

/* ---------- scorecard table ---------- */

.card-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
.scorecard { border-collapse: collapse; min-width: 100%; font-variant-numeric: tabular-nums; }
.scorecard th, .scorecard td {
  padding: 6px 7px;
  text-align: center;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.scorecard th {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.scorecard td:first-child, .scorecard th:first-child {
  text-align: left;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.scorecard .tot { font-weight: 750; color: var(--gold); }
.sc-birdie { color: var(--green); font-weight: 750; }
.sc-eagle { color: var(--water); font-weight: 750; }
.sc-bogey { color: var(--warm); }
.sc-double { color: var(--red); }

/* hole-by-hole quick grid (post-round card entry) */
.grid-entry {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  gap: 6px 8px;
  align-items: center;
}
.grid-entry .gh { color: var(--muted); font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.grid-entry input {
  width: 100%;
  min-height: 44px;
  text-align: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.grid-entry .ghead {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

/* ---------- charts ---------- */

.chart-card { padding: 14px 8px 6px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-title { margin: 0 8px 6px; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.axis-label { fill: var(--muted); font-size: 10px; }
.gridline { stroke: rgba(255, 255, 255, 0.07); }

/* ---------- sheet & backdrop ---------- */

.backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.45);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  max-height: min(90dvh, 800px);
  background: var(--panel-solid);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(110%);
  transition: transform 0.38s var(--ease);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--bot);
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 100%;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
}
.sheet-handle::after {
  content: "";
  width: 48px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
}

.sheet-body {
  overflow: auto;
  padding: 4px 18px 20px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet-body p, .sheet-body .fine, .sheet-body .callout { user-select: text; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet-head h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.03em; }
.sheet-kicker {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.close-x {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.3rem;
  line-height: 1;
  flex: none;
}

.callout {
  background: rgba(224, 184, 74, 0.1);
  border: 1px solid rgba(224, 184, 74, 0.28);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
  line-height: 1.45;
  font-size: 0.9rem;
}

.muted { color: var(--muted); }
.fine { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.fine a { color: var(--water); }

/* ---------- install bar ---------- */

.install-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + var(--bot) + 12px);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border-radius: 16px;
  background: var(--panel-solid);
  border: 1px solid rgba(224, 184, 74, 0.3);
  box-shadow: var(--shadow);
}
.install-bar div { flex: 1; }
.install-bar strong { display: block; font-size: 0.9rem; }
.install-bar span { font-size: 0.75rem; color: var(--muted); }
.install-bar .chip { min-height: 38px; }

/* ---------- empty states ---------- */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .big { font-size: 2rem; margin-bottom: 8px; }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }
.empty p { margin: 0 0 14px; font-size: 0.9rem; line-height: 1.5; }

.noscript { padding: 24px; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .backdrop { transition: none; }
}
