/* Phone first. Every control on the scoring screen has to be hittable with a thumb, in sun,
   wearing a glove, while four people wait. Nothing here is decorative for its own sake. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --ink: #1a1f1b;
  --ink-soft: #5c6660;
  --line: #d8ddd7;
  --accent: #1f6f43;
  --accent-soft: #e4f0e9;
  --win: #1f6f43;
  --loss: #a8323b;
  --warn: #8a6100;
  --warn-soft: #fdf3dc;
  --radius: 14px;
  --gutter: 16px;
  --tap: 48px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12150f;
    --surface: #1b1f19;
    --surface-2: #252a22;
    --ink: #eef1ea;
    --ink-soft: #a3ada4;
    --line: #333a30;
    --accent: #6cc38c;
    --accent-soft: #1f3529;
    --win: #6cc38c;
    --loss: #e98b93;
    --warn: #e8c274;
    --warn-soft: #33290f;
  }
}

:root[data-theme='dark'] {
  --bg: #12150f; --surface: #1b1f19; --surface-2: #252a22; --ink: #eef1ea; --ink-soft: #a3ada4;
  --line: #333a30; --accent: #6cc38c; --accent-soft: #1f3529; --win: #6cc38c; --loss: #e98b93;
  --warn: #e8c274; --warn-soft: #33290f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 560px; margin: 0 auto; padding: var(--gutter); }

h1 { font-size: 1.4rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
h3 { font-size: 0.8rem; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.tiny { font-size: 0.78rem; }

/* --- Structure ------------------------------------------------------------------------------ */

header.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
header.bar .grow { flex: 1; min-width: 0; }
header.bar h1 { font-size: 1.05rem; margin: 0; }

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

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap-ok { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* --- Controls -------------------------------------------------------------------------------- */

button, .btn {
  font: inherit; font-weight: 600;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  cursor: pointer; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme='dark'] .btn-primary, .btn-primary { color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .btn-primary { color: #0d1710; }
}
.btn-wide { width: 100%; }
.btn-quiet { background: transparent; }

input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  min-height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 4px; }
input[type='number'] { -moz-appearance: textfield; }

/* Tap targets for "who did this" questions. A chip is a label wrapping a hidden radio/checkbox. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; user-select: none;
  font-weight: 600; font-size: 0.95rem;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .chip:has(input:checked) { color: #0d1710; }
}
.chip.none:has(input:checked) { background: var(--surface-2); border-color: var(--ink-soft); color: var(--ink); }

/* --- Score entry ----------------------------------------------------------------------------- */

.score-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 8px 0; }
.score-row + .score-row { border-top: 1px solid var(--line); }
.score-name { font-weight: 600; }
.score-hint { font-size: 0.78rem; color: var(--ink-soft); font-weight: 400; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { min-width: var(--tap); padding: 0; font-size: 1.3rem; }
.stepper .value {
  min-width: 56px; text-align: center; font-size: 1.5rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper .value.empty { color: var(--ink-soft); font-weight: 400; }

/* --- Ledger ---------------------------------------------------------------------------------- */

.ledger { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.ledger .name { padding: 8px 0; font-weight: 600; }
.ledger .amount { padding: 8px 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.pos { color: var(--win); }
.neg { color: var(--loss); }
.zero { color: var(--ink-soft); }

.big-ledger { display: flex; gap: 8px; }
.big-ledger .player {
  flex: 1; text-align: center; padding: 10px 4px;
  background: var(--surface-2); border-radius: 10px; min-width: 0;
}
.big-ledger .player .n { font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-ledger .player .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.breakdown li:first-child { border-top: 0; }
.breakdown .rule { font-weight: 600; }

.hole-list { list-style: none; margin: 0; padding: 0; }
.hole-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.hole-list li:first-child { border-top: 0; }
.hole-list .no { font-weight: 700; font-variant-numeric: tabular-nums; }
.hole-list .par { font-size: 0.78rem; color: var(--ink-soft); font-weight: 400; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--ink-soft); }
.pill.carry { background: var(--warn-soft); color: var(--warn); }
.pill.live { background: var(--accent-soft); color: var(--accent); }

.notice { padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.error { background: #fdeaec; color: var(--loss); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .notice.error { background: #3a1e21; }
}

.status { font-size: 0.78rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.saved { color: var(--accent); }
.status.pending { color: var(--warn); }
.status.offline { color: var(--loss); }

.hidden { display: none !important; }

/* --- Season tables --------------------------------------------------------------------------- */

table.grid { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.grid th, table.grid td { padding: 7px 8px; text-align: right; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; font-weight: 600; }
table.grid thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); font-weight: 600; border-bottom: 1px solid var(--line);
}
table.grid tbody tr + tr td { border-top: 1px solid var(--line); }
table.grid td { font-variant-numeric: tabular-nums; }

.player-row { display: grid; grid-template-columns: 1fr 84px auto; gap: 8px; align-items: center; padding: 8px 0; }
.player-row + .player-row { border-top: 1px solid var(--line); }
.player-row.retired { opacity: 0.55; }

/* --- Scorecard photo ------------------------------------------------------------------------- */

.card-shot { margin: 0 0 12px; }
.card-shot img {
  width: 100%; border-radius: 10px; border: 1px solid var(--line);
  display: block; cursor: zoom-in; background: var(--surface-2);
}
.card-shot.zoomed img { cursor: zoom-out; }
.card-shot.zoomed {
  position: fixed; inset: 0; z-index: 60; margin: 0; padding: 12px;
  background: rgba(0, 0, 0, .9); display: flex; flex-direction: column; justify-content: center;
}
.card-shot.zoomed img { max-height: 92vh; object-fit: contain; }
.card-shot.zoomed figcaption { color: #fff; text-align: center; margin-top: 8px; }

/* A value that came from the photo and has not been looked at yet must not look like one a
   person typed. The tint is removed the moment the field is touched. */
input.from-photo, select.from-photo {
  background: var(--warn-soft);
  border-color: var(--warn);
}
input.needs-value, select.needs-value {
  border-color: var(--loss);
  background: transparent;
}
