:root {
  color-scheme: dark;
  --bg: #102117;
  --bg-raise: #1a3326;
  --line: #2d5340;
  --text: #f7f6ef;
  --muted: #c5d3c4;
  --accent: #f4e04d;
  --accent-ink: #17240f;
  --danger: #ffb4a8;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  padding:
    calc(12px + var(--safe-top))
    calc(16px + var(--safe-right))
    calc(16px + var(--safe-bottom))
    calc(16px + var(--safe-left));
}

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

button {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--bg-raise);
  touch-action: manipulation;
  cursor: pointer;
}

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

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.app {
  width: min(100%, 440px);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.brand h1, .hole-title {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 50%, var(--bg) 0 7px, var(--accent) 8px 18px, transparent 19px),
    var(--bg-raise);
  box-shadow: inset 0 0 0 2px var(--line);
}

.panel, .player-card, .hole-block, .dialog {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel { padding: 14px; }

.note, .status, .error {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.error { color: var(--danger); }

.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c1b13;
  padding: 0 12px;
  font-size: 16px;
}

.primary, .plus {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.primary { padding: 0 16px; }

.wide {
  width: 100%;
  margin-top: 12px;
  min-height: 52px;
  font-weight: 700;
}

.player-list, .score-list, .hole-list, .standing-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.player-card, .score-row, .hole-block, .standing {
  margin-top: 8px;
}

.player-card, .score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.player-card label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
}

.player-card input, .switch input { accent-color: var(--accent); }

.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.ghost, .minus {
  background: transparent;
  border: 1px solid var(--line);
}

.hole-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px 12px;
  padding: 8px 16px 10px;
  background: #102117;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}

.hole-title {
  min-width: 5.2rem;
  text-align: center;
}

.hole-bar button {
  padding: 8px 10px;
  font-size: 0.95rem;
}

.score-row { min-height: 76px; }

.who { flex: 1; min-width: 0; }

.total {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.minus, .plus {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 2rem;
  line-height: 1;
}

.plus { width: 68px; height: 68px; }

.score {
  width: 2.2rem;
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 8px;
}

.standing, .hole-block { padding: 12px 14px; }

.standing { display: flex; justify-content: space-between; gap: 12px; }

.place { color: var(--accent); font-weight: 800; margin-right: 8px; }

.hole-block h2 { margin: 0 0 8px; font-size: 1.05rem; }

.hole-block p, .untouched { margin: 4px 0; }

.untouched { color: var(--muted); }

.actions { display: flex; flex-direction: column; }

.dialog-back {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: calc(16px + var(--safe-bottom)) 16px 16px;
  background: rgba(0, 0, 0, 0.55);
}

.dialog {
  width: min(100%, 440px);
  padding: 16px;
}

.dialog p { line-height: 1.45; }

.dialog .row { justify-content: stretch; }

.dialog .row button { flex: 1; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 359px) {
  .plus, .minus { width: 48px; height: 48px; }
  .plus { width: 58px; }
  .score { font-size: 2rem; }
}
