/*
  Fairway Ledger styles.

  The page is a paper scorecard sitting on a green felt table.
  Mobile comes first: big tap targets, a 9-column grid, and type
  that stays at least 16px so phones don't zoom in on focus.

  Fonts are self-hosted in fonts/ so the service worker can store them
  and the card still looks right with no signal. Same families as before:
  - Special Elite: typewriter labels, like a printed card
  - Libre Baskerville: readable sentences and the big total
  - Architects Daughter: handwriting for the course name and the win of the day, set in capitals
  If a file is missing, the card falls back to Courier, Palatino, and a print font.
  Licenses are in fonts/NOTICE.txt.
*/

@font-face {
  font-family: "Architects Daughter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/architects-daughter-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Architects Daughter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/architects-daughter-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville-400-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville-400-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-baskerville-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/libre-baskerville-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Libre Baskerville";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/libre-baskerville-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Special Elite";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/special-elite-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Special Elite";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/special-elite-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f3ecdc;
  --paper-deep: #e6dcc6;
  --ink: #2a261f;
  --pencil: #5e574c;
  --olive: #3f5124;
  --olive-deep: #2c3b18;
  --olive-soft: #e4ecd2;
  --line: rgba(63, 81, 36, 0.38);
  --felt: #1e331c;
  --danger: #6b3a2f;
  --type: "Special Elite", "Courier New", Courier, monospace;
  --serif: "Libre Baskerville", Palatino, "Palatino Linotype", serif;
  --hand: "Architects Daughter", "Segoe Print", cursive;
}

* { box-sizing: border-box; }

html {
  background: var(--felt);
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.45;
  background-color: var(--felt);
  background-image:
    radial-gradient(ellipse at 18% 0%, rgba(255, 255, 255, 0.06), transparent 46%),
    radial-gradient(ellipse at 90% 100%, rgba(0, 0, 0, 0.28), transparent 42%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 3px);
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
  opacity: 0.4;
}

.tap:disabled {
  opacity: 1;
  color: rgba(63, 81, 36, 0.55);
  border-color: rgba(63, 81, 36, 0.45);
  background: rgba(255, 255, 255, 0.35);
}

:focus-visible {
  outline: 2px solid var(--olive-deep);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-140%);
  background: var(--paper);
  color: var(--olive);
  padding: 8px 12px;
  z-index: 30;
}

.skip:focus { transform: none; }

/* The card itself --------------------------------------------------- */

.sheet {
  width: min(920px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(88, 72, 40, 0.05) 0.7px, transparent 0.7px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 120px);
  background-size: 4px 4px, 100% 100%;
  color: var(--ink);
}

.frame {
  position: relative;
  border: 2px solid var(--olive);
  margin: 8px;
  padding: 10px 8px 16px;
}

.frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(63, 81, 36, 0.28);
  pointer-events: none;
}

.mast { margin-bottom: 4px; }

.club-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--olive);
  color: var(--paper);
  padding: 7px 10px;
}

.club { 
  margin: 0;
  font-family: var(--type);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.member {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.82rem;
}

.club-copy { min-width: 0; }

h1 {
  margin: 8px 0 0;
  text-align: center;
  font-family: var(--type);
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.tagline {
  margin: 2px 0 0;
  text-align: center;
  font-style: italic;
  font-size: 0.92rem;
}

.nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0 0;
}

.nav button {
  min-height: 44px;
  border: 1.5px solid var(--olive);
  background: transparent;
  color: var(--olive);
  font-family: var(--type);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav button[aria-current="page"] {
  background: var(--olive);
  color: var(--paper);
}

.status {
  min-height: 0;
  margin: 8px 2px 0;
  font-family: var(--hand);
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--olive);
}

.status:empty { display: none; }

.colophon {
  margin: 16px 4px 0;
  text-align: center;
  font-family: var(--type);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: var(--pencil);
}

h2 {
  margin: 2px 0 4px;
  font-family: var(--type);
  font-size: 1.28rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.lead { margin: 0 0 12px; }

.fine {
  margin: 4px 0 0;
  color: var(--pencil);
  font-size: 0.92rem;
}

.label {
  display: block;
  margin-bottom: 2px;
  font-family: var(--type);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--olive);
}

/* Shared buttons and fields ---------------------------------------- */

.btn {
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--olive);
  background: transparent;
  color: var(--olive);
  font-family: var(--type);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--olive);
  color: var(--paper);
}

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

.btn:active:not(:disabled),
.tap:active:not(:disabled) {
  background: var(--olive-soft);
}

.btn-primary:active:not(:disabled) { background: var(--olive-deep); }

.tap {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1.5px solid var(--olive);
  background: rgba(255, 255, 255, 0.28);
  color: var(--olive);
  font-family: var(--type);
  font-size: 1.7rem;
  line-height: 1;
  user-select: none;
}

.tap-lg {
  min-width: 76px;
  min-height: 76px;
  font-size: 2.2rem;
}

.tap-sm {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.35rem;
}

.field { margin: 0 0 14px; }

fieldset {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
}

legend.label { padding: 0; }

.field input[type="text"],
.field input[type="number"],
.field input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 4px 2px;
  border: none;
  border-bottom: 1.5px solid var(--olive);
  border-radius: 0;
  background: transparent;
}

.field input[type="text"] {
  font-family: var(--hand);
  font-size: 1.15rem;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field input[type="number"],
.field input[type="date"] {
  font-family: var(--type);
  font-size: 1rem;
}

.field input[type="number"] { max-width: 5.5rem; }

.field .fine { display: block; margin-top: 4px; }

input[type="text"],
input[type="number"],
textarea { appearance: none; }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

::placeholder {
  color: #6f675c;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: normal;
  text-transform: none;
}

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

.choice {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1.5px solid var(--olive);
  font-family: var(--type);
  cursor: pointer;
}

.choice input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
}

.choice:has(input:checked) {
  background: var(--olive);
  color: var(--paper);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--olive-deep);
  outline-offset: 2px;
}

details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  font-family: var(--type);
  color: var(--olive);
}

.par-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.par-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--type);
  font-size: 0.72rem;
  color: var(--olive);
}

.par-cell input {
  width: 100%;
  min-height: 40px;
  text-align: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
  font-family: var(--type);
  font-size: 1rem;
}

.form-error {
  margin: 0 0 8px;
  color: var(--danger);
  font-family: var(--hand);
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.actions { margin-top: 4px; }

.actions .btn,
.backup-actions .btn { width: 100%; }

/* The open scorecard ------------------------------------------------ */

.identity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: flex-end;
}

.identity .grow { flex: 1 1 160px; min-width: 0; }

.course-input,
.date-input,
.win-input {
  width: 100%;
  border: none;
  border-bottom: 1px dashed rgba(63, 81, 36, 0.55);
  border-radius: 0;
  background: transparent;
  padding: 0 0 2px;
}

.course-input {
  font-family: var(--hand);
  font-size: 1.15rem;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.date-input {
  max-width: 11.5rem;
  min-height: 32px;
  font-family: var(--type);
  font-size: 0.85rem;
}

.meta {
  margin: 6px 0 0;
  font-family: var(--type);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--olive);
}

.running-wrap {
  position: sticky;
  top: 0;
  z-index: 3;
  margin-top: 8px;
  padding: 4px 0 6px;
  background: rgba(243, 236, 220, 0.96);
}

.running {
  display: flex;
  gap: 12px;
  align-items: center;
}

.running-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 0.9;
}

.running-score .unit,
.round-score .unit {
  font-family: var(--type);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.running-copy { flex: 1; min-width: 0; }
.running-copy p { margin: 0; }

.vs { font-family: var(--type); font-size: 0.95rem; }
.lost { font-size: 0.92rem; }
.kind { margin-top: 2px; font-style: italic; }

.tone-good { color: var(--olive); }
.tone-quiet { color: var(--pencil); }

.autosave {
  margin: 2px 0 0;
  font-family: var(--type);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--olive);
}

.win-block { margin-top: 8px; }

.win-input {
  min-height: 42px;
  resize: vertical;
  font-family: var(--hand);
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.grid-hint { margin: 10px 0 0; }

.hole-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 1px;
  margin-top: 8px;
  border: 1px solid var(--olive);
  background: var(--olive);
}

.nine {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 6px;
  align-items: stretch;
  margin-top: 8px;
}

.nine .hole-grid { margin-top: 0; }

.nine-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--olive);
  font-family: var(--type);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nine-label strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
}

.hole-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 3px 0;
  border: 0;
  background: var(--paper);
  line-height: 1.05;
}

.hole-cell[aria-current="true"] {
  background: var(--olive-soft);
  box-shadow: inset 0 0 0 2px var(--olive);
}

.cell-num {
  font-family: var(--type);
  font-size: 0.62rem;
  color: var(--olive);
}

.cell-strokes {
  font-family: var(--type);
  font-size: 1.05rem;
}

.cell-par {
  font-family: var(--serif);
  font-size: 0.62rem;
  color: var(--pencil);
}

.editor {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.editor-head h3 {
  margin: 0;
  font-family: var(--type);
  font-size: 1.2rem;
  font-weight: 400;
}

.par-adjust {
  display: flex;
  align-items: center;
  gap: 6px;
}

.par-value {
  min-width: 3.2rem;
  text-align: center;
  font-family: var(--type);
}

.stepper { margin-top: 10px; }

.stepper-row {
  display: grid;
  grid-template-columns: 76px 4.5rem 76px;
  align-items: center;
  justify-content: center;
  justify-items: center;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  gap: 8px;
}

.stepper-row .tap:not(.tap-lg) {
  width: 56px;
  height: 56px;
}

.stepper-row:has(.tap:not(.tap-lg)) {
  grid-template-columns: 56px 4.5rem 56px;
}

.count {
  width: 100%;
  text-align: center;
  font-family: var(--type);
  font-size: 2.4rem;
  line-height: 1;
}

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

.card-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

/* History ----------------------------------------------------------- */

.history-head,
.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

.history-head .btn { min-width: 140px; }

.bests {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 12px;
}

.best {
  padding: 6px 7px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
  min-width: 0;
}

.best p { overflow-wrap: anywhere; }

.best .fine { font-size: 0.78rem; line-height: 1.25; }

.best h3 {
  margin: 0;
  font-family: var(--type);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--olive);
}

.best-num {
  margin: 2px 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}

.best p { margin: 0; }

.backup {
  margin: 4px 0 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ledger > li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.round-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  align-items: flex-start;
}

.round-title {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.round-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
}

.round-line { margin: 4px 0 0; }

.stamps {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.stamp {
  display: inline-block;
  padding: 2px 6px;
  border: 1.5px solid var(--olive);
  color: var(--olive);
  font-family: var(--type);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}

.stamp:nth-child(2n) { transform: rotate(2deg); }

.win-quote {
  margin: 6px 0 0;
  font-family: var(--hand);
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.win-quote::before { content: "\201C"; }
.win-quote::after { content: "\201D"; }

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.empty-card {
  margin-top: 8px;
  padding: 8px 2px 4px;
}

.empty-mark {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 2px solid var(--olive);
  color: var(--olive);
  font-family: var(--type);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}

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

/* Confirm dialog ---------------------------------------------------- */

#dialog-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 32, 16, 0.55);
}

#dialog-root[hidden] { display: none; }

.dialog {
  width: min(420px, 100%);
  padding: 16px 14px 14px;
  border: 2px solid var(--olive);
  background: var(--paper);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.dialog h2 { margin-top: 0; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.dialog-actions .btn { flex: 1; }

body.dialog-open { overflow: hidden; }

/* Desktop: the same card, with room to breathe on the felt. */

@media (min-width: 840px) {
  body { padding: 0; }

  .sheet {
    min-height: 0;
    margin: 28px auto 48px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }

  .frame { margin: 14px; padding: 18px 20px 22px; }

  h1 { font-size: 2.1rem; }

  .summary-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 8px 28px;
    align-items: start;
  }

  .running-score { font-size: 3.3rem; }
  .win-input { min-height: 72px; font-size: 1.2rem; }

  .editor-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 28px;
    align-items: end;
  }

  .hole-nav { grid-column: 1 / -1; max-width: 420px; }

  .best-num { font-size: 1.7rem; }

  .actions .btn { max-width: 280px; }

  .setup-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 28px;
    max-width: 680px;
  }

  .span-2 { grid-column: 1 / -1; }
}

@media (max-width: 380px) {
  .par-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .backup-actions { grid-template-columns: 1fr; }
}

/* Pencil marks
   The score is real text, updated immediately. These strokes are
   decoration on top: a short underline written with stroke-dashoffset,
   and a circle when that hole is at or under par. Both finish in
   under 400ms. prefers-reduced-motion hides them. */

.count,
.cell-strokes { position: relative; }

.penciled { animation: pencil-ink 180ms ease-out forwards; }

@keyframes pencil-ink {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.scribble,
.pencil-ring {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

.scribble {
  left: -8%;
  width: 116%;
  height: 0.42em;
  bottom: 0.02em;
  color: var(--pencil);
}

.cell-strokes .scribble {
  height: 0.7em;
  bottom: -0.08em;
}

.pencil-ring {
  left: 50%;
  top: 50%;
  width: 1.35em;
  height: 1.45em;
  color: var(--olive);
  transform: translate(-50%, -52%) rotate(-7deg);
}

.cell-strokes .pencil-ring {
  width: 1.7em;
  height: 1.45em;
}

.scribble path,
.pencil-ring path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: pencil-draw 320ms ease-out forwards;
}

.pencil-ring path { animation-duration: 360ms; }

@keyframes pencil-draw {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stamp,
  .empty-mark { transform: none; }

  .penciled,
  .scribble path,
  .pencil-ring path { animation: none; }

  .scribble,
  .pencil-ring { display: none; }
}
