/* WhatsTheYardage.com: black, flat, number-first. Color only where it carries meaning. */
:root {
  --bg: #000;
  --fill: #1c1c1e;      /* buttons, current-hole cell */
  --fill-2: #2c2c2e;
  --line: #2c2c2e;
  --text: #fff;
  --dim: #8e8e93;
  --faint: #48484a;
  --green: #32d74b;
  --yellow: #ffd60a;
  --red: #ff453a;
  --dock-h: 76px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
svg { display: block; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px);
}

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.course { display: grid; text-align: left; min-width: 0; }
.course__name { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course__loc { font-size: .8rem; color: var(--dim); }
.course__loc:empty { display: none; }
.gps {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: .85rem; font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums;
}
.gps__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.gps--good .gps__dot { background: var(--green); }
.gps--ok   .gps__dot { background: var(--yellow); }
.gps--poor .gps__dot { background: var(--red); }
.gps--fixed .gps__dot { background: var(--text); }

/* ---------- scorecard hole strip ---------- */
.holes {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px;
  margin: 12px 0 4px;
}
.holes:empty { display: none; }
.holes button {
  height: 34px; border-radius: 6px; font-size: .9rem; font-weight: 600;
  color: var(--dim); font-variant-numeric: tabular-nums;
}
.holes button:active { background: var(--fill); }
.holes button.is-current { background: var(--text); color: #000; }

/* ---------- current hole ---------- */
.hole { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; margin-top: 10px; }
.step {
  width: 52px; height: 52px; border-radius: 50%; background: var(--fill);
  display: grid; place-items: center;
}
.step svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.step:not(:disabled):active { background: var(--fill-2); }
.hole__mid { text-align: center; }
.hole__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.hole__sub { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: .85rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.auto {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 4px; border: 1px solid var(--faint); color: var(--dim);
}
.auto.is-on { border-color: var(--green); color: var(--green); }

/* ---------- yardages ---------- */
.yards {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 12px 0; font-variant-numeric: tabular-nums;
}
.yards .n { display: block; font-weight: 700; line-height: .9; }
.yards .l { display: block; font-size: .8rem; color: var(--dim); margin-top: 6px; }
.yards__center { text-align: center; }
.yards__center .n { font-size: clamp(7rem, 40vw, 11rem); letter-spacing: -.045em; }
.yards__edges {
  display: grid; grid-template-columns: 1fr 1fr; margin-top: 22px;
  border-top: 1px solid var(--line); padding-top: 18px;
}
.edge { text-align: center; }
.edge + .edge { border-left: 1px solid var(--line); }
.edge .n { font-size: clamp(2.75rem, 15vw, 4rem); font-weight: 600; letter-spacing: -.03em; }
.yards.is-long .yards__center .n { font-size: clamp(5rem, 28vw, 8rem); }
.yards.is-long .edge .n { font-size: clamp(2.25rem, 11vw, 3rem); }
.yards.stale .n, .yards.is-far .n { color: var(--faint); }

/* ---------- messages ---------- */
.msgs { display: grid; gap: 6px; }
.msg { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0; font-size: .875rem; color: var(--dim); text-align: center; }
.msg[hidden], .msg:empty { display: none; }
.msg--warn { color: var(--yellow); }
.msg--note { color: var(--text); }
.msg.is-error { color: var(--red); }
.link { color: var(--text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link[hidden] { display: none; }

/* ---------- bottom dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  max-width: 480px; margin: 0 auto;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--line);
}
.shot { flex: 1; display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; min-width: 0; }
.shot .l { font-size: .8rem; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.shot .n { font-size: 1.5rem; font-weight: 700; white-space: nowrap; }
.btn { height: 44px; padding: 0 18px; border-radius: 22px; background: var(--fill); font-weight: 600; }
.btn--primary { background: var(--text); color: #000; }
.btn[hidden] { display: none; }
.icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.icon svg { width: 22px; height: 22px; fill: var(--text); }
.icon:active, .btn:not(:disabled):active { opacity: .7; }

/* ---------- settings sheet ---------- */
.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 8px 16px max(20px, env(safe-area-inset-bottom));
  border: 0; border-radius: 14px 14px 0 0; background: var(--fill); color: var(--text);
  max-height: 85vh; overflow: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet__head { display: flex; justify-content: space-between; align-items: center; height: 48px; }
.sheet h2 { font-size: 1.05rem; margin: 0; }
.sheet h3 { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); margin: 16px 0 6px; }
.list, .row { background: var(--fill-2); border-radius: 10px; }
.list button {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--faint);
}
.list button:last-child { border-bottom: 0; }
.list .d { color: var(--dim); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list button.is-current { color: var(--green); }
.list button.is-current .d::before { content: "✓  "; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; margin-bottom: 8px; }
.row[hidden] { display: none; }
.switch {
  appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; margin: 0;
  background: var(--faint); position: relative; cursor: pointer; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.fine { font-size: .75rem; color: var(--dim); text-align: center; margin: 18px 0 0; }

.noscript { position: fixed; inset: auto 0 0 0; padding: 14px; background: var(--red); color: #fff; text-align: center; }

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