@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* Same palette and type as samuelwiseman.com and Spendly */
:root {
  --bg: #f2f3f5;
  --surface: #fff;
  --field: #f7f8f9;
  --line: #e3e5e9;
  --line-strong: #d2d5db;
  --text: #17181a;
  --muted: #62656c;
  --faint: #7b7e85;
  --dark: #141517;
  --critical: #c42b2b;
  --hover: rgba(20, 21, 23, .05);

  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono, .fig {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 2px solid var(--dark); outline-offset: 3px; border-radius: 8px; }

.col { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 16px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
[hidden] { display: none !important; }

.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.title {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 6px 0 6px;
  overflow-wrap: anywhere;
}

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

/* ---- pills and buttons ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .55);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}
a.pill:hover { background: var(--surface); }
.pill.brand { font-weight: 500; padding-left: 14px; }
.pill.brand img { width: 17px; height: 24px; object-fit: contain; }
.back-label { overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .5);
  color: var(--text);
  border-radius: 13px;
  cursor: pointer;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-primary:hover { background: #000; }

.btn-danger { color: var(--critical); border-color: #ecc4c4; }
.btn-danger:hover { background: #fdf3f3; }

.btn-ghost { border-color: transparent; background: transparent; font-weight: 400; }
.btn-ghost:hover { background: var(--hover); }
.btn-ghost.btn-danger:hover { background: #fdf3f3; }

.btn-small { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 11px; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  border: 0; background: transparent; color: var(--faint);
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- page furniture ---- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 40px; }
.top-links { display: flex; gap: 8px; flex: none; }
.page-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.section { margin-top: 40px; }
.quiet-actions { margin-top: 40px; }
.lead { margin-bottom: 24px; }
.block { margin: 32px 0 40px; }
.page-title { font-size: 22px; font-weight: 500; margin-bottom: 8px; }
.section-title { font-size: 17px; font-weight: 500; margin-bottom: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.text-input {
  height: 42px; font: inherit; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 12px;
}
.form-error { color: var(--critical); font-size: 14px; margin: 14px 0; }
.form-note { font-size: 13px; margin-top: 10px; }
.saved-note { color: var(--muted); font-size: 14px; margin-left: 8px; }

.group-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 4px 10px; font-size: 15px; font-weight: 500;
}
.group-sum { font-size: 13px; font-weight: 400; color: var(--muted); text-align: right; }

.title + .list, .title + .empty, .form-error + .list { margin-top: 20px; }
.empty { color: var(--muted); padding: 40px 24px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.empty p + p { margin-top: 6px; }
.page-actions + .section, .title + .muted + .page-actions { margin-top: 24px; }

/* ---- login ---- */
.login { min-height: calc(100dvh - 90px); display: grid; place-content: center; justify-items: center; text-align: center; }
.login .crest { width: 110px; height: auto; margin-bottom: 20px; }
.login .label + .page-title { margin-top: 6px; }
.login-title { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.login .muted { margin: 10px 0 28px; max-width: 34ch; }
.login .form-error { margin: -12px 0 16px; }
.center-actions { display: flex; gap: 10px; justify-content: center; }

/* ---- lists of rows (groups, games, members, courses) ---- */
.list { list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 6px; }
.list > li + li { border-top: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  text-decoration: none;
  transition: background 0.15s;
}
a.row:hover { background: var(--field); }
.row.static { grid-template-columns: auto minmax(0, 1fr) auto; border-radius: 0; }

.tile {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600; font-size: 15px; color: var(--muted);
}
.tile.mono { font-size: 13px; font-weight: 500; }
.date-tile { line-height: 1.05; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; align-content: center; gap: 1px; }
.date-tile b { font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--text); font-family: var(--mono); }

.row-text { display: grid; gap: 1px; min-width: 0; }
.row-name { font-weight: 500; overflow-wrap: anywhere; }
.row-meta { font-size: 13px; color: var(--muted); }
.row-fig { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); text-align: right; }
.row-fig b { color: var(--text); font-weight: 500; margin-left: 4px; }
.row-lead { display: grid; justify-items: end; line-height: 1.2; }
.row-lead span { font-size: 12px; color: var(--muted); }
.row-lead b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 500; }
.chev { color: var(--faint); font-size: 20px; line-height: 1; margin-left: -4px; }

/* ---- forms ---- */
.stack .card + .group-title, .stack .form-note + .group-title { margin-top: 28px; }
.form-card { padding: 18px 18px 6px; }

.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.field-row label { min-width: 0; }

:is(dialog, .form-card) label:not(.check) { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
:is(dialog, .form-card) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  display: block; width: 100%; min-width: 0; margin-top: 6px;
  font: inherit; line-height: 24px; color: var(--text);
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
:is(dialog, .form-card) :is(input, select, textarea):focus { background: var(--surface); border-color: var(--line-strong); }
/* iOS Safari draws date inputs natively (own width, height and centring) unless
   appearance is reset; after that it sizes like any other field. */
:is(dialog, .form-card) input[type="date"] { -webkit-appearance: none; appearance: none; height: 46px; text-align: left; }
:is(dialog, .form-card) input[type="date"]::-webkit-date-and-time-value { text-align: left; }
:is(dialog, .form-card) select {
  -webkit-appearance: none; appearance: none; height: 46px; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2362656c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.narrow { max-width: 180px; }
/* Fields show focus with their own border, not the page-wide outline ring. */
:is(dialog, .form-card) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus-visible { outline: none; border-color: var(--dark); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; min-width: 0; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; flex: none; accent-color: var(--dark); }
.code-input { text-transform: uppercase; letter-spacing: 0.2em; font-family: var(--mono) !important; }

.rounds { list-style: none; display: grid; gap: 10px; margin-bottom: 14px; }
.round-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.round-row select { margin-top: 0 !important; }
.round-num { color: var(--muted); font-size: 13px; }
.rounds .round-row:only-child [data-remove-round] { visibility: hidden; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 4px 0 12px; }
.list + .row-actions { margin: 12px 0 0; }
.faint-link { color: var(--muted); font-size: 14px; text-underline-offset: 3px; }

.players { list-style: none; }
.player-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 12px; align-items: center; padding: 8px 0; }
.players .player-row + .player-row { border-top: 1px solid var(--line); }
.player-row input { margin-top: 0 !important; }
.hi-input { text-align: right; font-family: var(--mono) !important; }
.sub-label { font-size: 13px; color: var(--muted); margin: 14px 0 2px; padding-top: 12px; border-top: 1px solid var(--line); }

.segmented { border: 0; display: flex; align-items: center; gap: 18px; margin: 2px 0 6px; }
.segmented legend { float: left; margin-right: 6px; font-size: 13px; color: var(--muted); }
.segmented label { display: inline-flex !important; align-items: center; gap: 8px; margin: 0 !important; font-size: 15px !important; color: var(--text) !important; cursor: pointer; }

.holes-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding-bottom: 16px; }
.holes-table { width: 100%; border-collapse: collapse; }
.holes-table th { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--faint); text-align: center; padding: 0 0 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.holes-table tbody th { font-size: 13px; color: var(--muted); width: 34px; }
.holes-table td { padding: 3px; }
.holes-table input { margin-top: 0 !important; height: 40px; padding: 0 !important; text-align: center; font-family: var(--mono) !important; }

/* ---- tabs ---- */
.tabs {
  display: flex; gap: 4px; width: max-content; max-width: 100%;
  margin: 20px 0 16px; padding: 4px;
  border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .55);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; flex: none;
  border-radius: 12px; font-size: 14px; text-decoration: none; color: var(--muted);
}
.tab:hover { color: var(--text); background: var(--hover); }
.tab.is-active { background: var(--dark); color: #fff; }

/* ---- leaderboard ---- */
.board-card { padding: 6px; }
.board { list-style: none; }
.board-head, .board-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) repeat(var(--rounds), 40px) 56px;
  align-items: center; gap: 12px; padding: 12px;
}
.board-head { padding: 10px 12px 2px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.board-row + .board-row { border-top: 1px solid var(--line); }
.board .num { text-align: right; }
.board .rcol { color: var(--muted); font-size: 14px; }
.board .total { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.rank {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--field); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15px; font-weight: 500; color: var(--muted);
}
.is-leader .rank { background: var(--dark); color: #fff; box-shadow: none; }
.rmeta { display: none; }

/* ---- scorecard: one hole at a time ---- */
.hole-card { padding: 16px 18px 18px; }
.hole-nav { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; }
.nav-btn {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--field);
  font-size: 30px; line-height: 1; text-decoration: none; color: var(--text);
}
.nav-btn:hover { background: var(--surface); border-color: var(--line-strong); }
.nav-btn[aria-disabled="true"] { opacity: .3; pointer-events: none; }
.hole-info { text-align: center; }
.hole-num { font-size: 52px; font-weight: 500; line-height: 1.05; letter-spacing: -0.04em; }
.hole-meta { font-size: 14px; color: var(--muted); }

.hole-players { list-style: none; margin-top: 14px; border-top: 1px solid var(--line); }
.hp { display: grid; grid-template-columns: minmax(0, 1fr) auto 46px; gap: 12px; align-items: center; padding: 12px 0; }
.hp + .hp { border-top: 1px solid var(--line); }
.hp-who { display: grid; min-width: 0; }
.hp-who .row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 22px; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.stepper button:hover { background: var(--field); }
.stepper button:active { transform: scale(.96); }
.stepper input {
  width: 50px; height: 50px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--field); color: var(--text);
  font-family: var(--mono); font-size: 22px; font-weight: 500; text-align: center;
  -webkit-appearance: none; appearance: none; transition: border-radius 0.15s;
}
.stepper input::placeholder { color: var(--line-strong); }
.stepper input:focus { outline: none; border-color: var(--dark); background: var(--surface); }
.stepper input.is-saving { border-style: dashed; }
.stepper input.is-error { border-color: var(--critical); }
/* Scorecard marks on the entry box itself: circles under par, squares over. */
.mk-input.birdie, .mk-input.eagle { border-radius: 50%; border-color: var(--text); }
.mk-input.eagle { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.mk-input.bogey, .mk-input.double { border-radius: 6px; border-color: var(--text); }
.mk-input.double { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }

.hp-pts { display: grid; justify-items: end; line-height: 1.1; }
.hp-pts b { font-size: 20px; font-weight: 500; }
.hp-pts small { font-size: 11px; color: var(--faint); font-family: var(--mono); }

.hole-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.save-state { font-size: 13px; color: var(--faint); }
.save-state.is-error { color: var(--critical); }

/* ---- scorecard: the whole card ---- */
.grid-card { margin-top: 16px; overflow: hidden; }
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { border-collapse: collapse; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; min-width: 100%; }
.grid th, .grid td { text-align: center; padding: 7px 1px; min-width: 28px; border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid thead th { color: var(--faint); font-weight: 400; font-size: 12px; }
.grid .par-row td, .grid .par-row th { color: var(--faint); font-size: 12px; }
.grid th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  text-align: left; padding-left: 14px; padding-right: 10px;
  font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text);
  max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid thead th:first-child, .grid .par-row th { color: var(--faint); font-weight: 400; font-size: 12px; font-family: var(--mono); }
.grid .sub { background: var(--field); font-weight: 500; color: var(--text); min-width: 34px; }
.grid thead .sub, .grid .par-row .sub { color: var(--muted); }
.grid .pts { font-weight: 600; min-width: 36px; padding-right: 10px; }
.grid .is-current { background: var(--hover); }
.grid td a { display: block; text-decoration: none; border-radius: 8px; }
.grid td a:hover { background: var(--hover); }

.mk { display: inline-grid; place-items: center; width: 24px; height: 24px; }
.mk.birdie, .mk.eagle { border: 1px solid var(--text); border-radius: 50%; }
.mk.eagle { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.mk.bogey, .mk.double { border: 1px solid var(--text); border-radius: 4px; }
.mk.double { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.legend-note { font-size: 12px; margin: 12px 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.legend-note .mk { width: 20px; height: 20px; font-family: var(--mono); font-size: 11px; color: var(--text); }

/* ---- dialog ---- */
dialog {
  margin: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 24px 60px -24px rgba(20, 21, 23, .35);
  padding: 24px; width: min(480px, 92vw);
}
dialog::backdrop { background: rgb(20 21 23 / 0.25); backdrop-filter: blur(2px); }
.dialog-title { font-size: 18px; font-weight: 500; margin-bottom: 16px; }
.dialog-lead { font-size: 14px; margin: -8px 0 16px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog-actions .btn-primary { order: 3; }
.dialog-actions [data-close] { order: 2; }
.dialog-extra { order: 1; display: flex; margin-right: auto; }
.dialog-extra .btn { border-color: transparent; background: transparent; padding: 0 10px; font-weight: 400; color: var(--muted); }
.dialog-extra .btn:hover { background: var(--field); color: var(--text); }
dialog .players { margin-top: -4px; }
.invite-code {
  font-size: 30px; font-weight: 500; letter-spacing: 0.22em; text-align: center;
  padding: 14px 0 14px 0.22em; margin-bottom: 16px;
  background: var(--field); border: 1px solid var(--line); border-radius: 16px;
}

/* ---- footer (matches samuelwiseman.com) ---- */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  margin-top: 24px; padding-top: 22px; padding-bottom: 32px;
  border-top: 1px solid var(--line);
  color: var(--faint); font-size: 13px;
}
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 561px) {
  .board-head .rcol, .board-row .rcol { display: block; }
}
@media (max-width: 560px) {
  .board-head, .board-row { grid-template-columns: 38px minmax(0, 1fr) 56px; }
  .board .rcol { display: none; }
  .rmeta { display: inline; }
  .holes-card { gap: 12px; }
}

@media (max-width: 480px) {
  .top { margin-bottom: 28px; gap: 8px; }
  .top-links { gap: 6px; }
  .pill { height: 42px; padding: 0 12px; border-radius: 14px; font-size: 14px; gap: 6px; }
  .pill.brand { padding-left: 10px; }
  .back-label { max-width: 150px; }
  .title { font-size: 28px; }
  .list, .board-card { padding: 4px; }
  .row { gap: 12px; padding: 12px 10px; }
  .chev { display: none; }
  .row.static, a.row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .board-head, .board-row { gap: 10px; padding: 12px 10px; }
  .form-card { padding: 16px 14px 4px; }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  dialog { padding: 20px; }
  .hole-card { padding: 14px 14px 16px; }
  .hp { gap: 8px; }
  .stepper { gap: 4px; }
  .stepper button { width: 38px; height: 38px; font-size: 20px; }
  .stepper input { width: 46px; height: 46px; font-size: 20px; }
  .hp-pts { width: 40px; }
  .hp { grid-template-columns: minmax(0, 1fr) auto 36px; }
}
@media (max-width: 380px) {
  .brand-tail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
