:root {
  --bg: #f6f2e7;
  --bg-elevated: #ffffff;
  --ink: #1e2a1f;
  --ink-muted: #5b6b5c;
  --fairway: #2f5233;
  --fairway-light: #6b9362;
  --fairway-wash: #e7efe4;
  --gold: #9c7a24;
  --gold-wash: #f3ead1;
  --line: #ddd5c0;
  --danger: #a24b3e;
  --focus: #2f5233;
  --shadow: 0 1px 2px rgba(30, 42, 31, 0.06), 0 4px 16px rgba(30, 42, 31, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12160f;
    --bg-elevated: #1b211a;
    --ink: #ece7d8;
    --ink-muted: #99a693;
    --fairway: #7bb083;
    --fairway-light: #97c99c;
    --fairway-wash: #223122;
    --gold: #dcb75e;
    --gold-wash: #322a17;
    --line: #333c30;
    --danger: #d38676;
    --focus: #97c99c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #12160f;
  --bg-elevated: #1b211a;
  --ink: #ece7d8;
  --ink-muted: #99a693;
  --fairway: #7bb083;
  --fairway-light: #97c99c;
  --fairway-wash: #223122;
  --gold: #dcb75e;
  --gold-wash: #322a17;
  --line: #333c30;
  --danger: #d38676;
  --focus: #97c99c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #f6f2e7;
  --bg-elevated: #ffffff;
  --ink: #1e2a1f;
  --ink-muted: #5b6b5c;
  --fairway: #2f5233;
  --fairway-light: #6b9362;
  --fairway-wash: #e7efe4;
  --gold: #9c7a24;
  --gold-wash: #f3ead1;
  --line: #ddd5c0;
  --danger: #a24b3e;
  --focus: #2f5233;
  --shadow: 0 1px 2px rgba(30, 42, 31, 0.06), 0 4px 16px rgba(30, 42, 31, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior-y: none;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.serif {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--fairway);
  color: #f6f2e7;
  padding: max(14px, env(safe-area-inset-top)) 20px 16px;
  box-shadow: var(--shadow);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(246, 242, 231, 0.7);
  font-weight: 600;
}

.headline {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  margin: 2px 0 10px;
  text-wrap: balance;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(246, 242, 231, 0.75);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d9b45c;
}

.status[data-state="live"] .status-dot { background: #8fd6a0; }
.status[data-state="connecting"] .status-dot { background: #d9b45c; animation: pulse 1.2s infinite ease-in-out; }
.status[data-state="offline"] .status-dot { background: #d38676; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.leader-strip {
  font-size: 14px;
  color: #f6f2e7;
  background: rgba(246, 242, 231, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
}

.leader-strip strong {
  font-weight: 700;
}

/* ---------- Main / views ---------- */

.view-root {
  flex: 1;
  padding: 18px 16px 24px;
}

.view-intro {
  margin-bottom: 16px;
}

.view-title {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 21px;
  font-weight: 600;
  margin: 0 0 4px;
}

.view-subtitle {
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.45;
  margin: 0;
}

.hole-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.hole-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hole-num {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--fairway);
}

.pairing-label {
  font-size: 12.5px;
  color: var(--ink-muted);
  text-align: right;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.team-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-col-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

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

.player-name {
  font-size: 13px;
  color: var(--ink-muted);
  flex: 1;
}

input[type="number"] {
  width: 56px;
  padding: 8px 6px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}

input[type="number"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input[type="number"]::-webkit-inner-spin-button {
  opacity: 1;
}

.result-chip {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--fairway-wash);
  color: var(--fairway);
}

.result-chip.tie {
  background: var(--line);
  color: var(--ink-muted);
}

.result-chip.pending {
  background: transparent;
  color: var(--ink-muted);
  font-weight: 400;
  padding-left: 0;
}

.result-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}

/* ---------- Category rows (Bingo Bango Bongo) ---------- */

.category-row {
  margin-bottom: 12px;
}

.category-row:last-child { margin-bottom: 0; }

.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.category-name {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.category-points {
  font-size: 11.5px;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.player-pill-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.player-pill {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 4px;
  font-size: 12.5px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
}

.player-pill.selected {
  background: var(--gold-wash);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 700;
}

/* ---------- Breakfast ball ---------- */

.breakfast-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.breakfast-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.breakfast-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}

.breakfast-row:last-child { border-bottom: none; }

.breakfast-name {
  font-size: 13.5px;
  font-weight: 600;
}

.breakfast-row select {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Leaderboard ---------- */

.prize-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.prize-item {
  background: var(--gold-wash);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}

.prize-rank {
  font-size: 10.5px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prize-amount {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
}

.standing-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.standing-rank {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--fairway);
  text-align: center;
}

.standing-name {
  font-size: 16px;
  font-weight: 700;
}

.standing-breakdown {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.standing-total {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rules-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
}

.rules-note strong {
  color: var(--ink);
}

/* ---------- Tab bar ---------- */

.tab-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-elevated);
  border-top: 1px solid var(--line);
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 8px 2px;
  border-radius: 10px;
  font-family: inherit;
  color: var(--ink-muted);
  cursor: pointer;
}

.tab-btn .tab-num {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 15px;
  font-weight: 700;
}

.tab-btn .tab-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tab-btn.active {
  color: var(--fairway);
  background: var(--fairway-wash);
}

.tab-btn:focus-visible,
.player-pill:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .status-dot { animation: none; }
}
