:root {
  --bg: #0a120e;
  --bg-2: #0f1a14;
  --ink: #eef6f0;
  --muted: #8aa392;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --panel: rgba(16, 28, 22, 0.92);
  --green: #2d8a4e;
  --green-lit: #5dff9a;
  --fairway: #1e6b3a;
  --sand: #c9a66b;
  --water: #2a6f9e;
  --accent: #f0d060;
  --danger: #e85d5d;
  --hub: #142018;
  --radius: 16px;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(700px 420px at 50% -10%, rgba(45, 138, 78, 0.22), transparent 55%),
    radial-gradient(500px 320px at 8% 85%, rgba(42, 111, 158, 0.12), transparent 50%),
    radial-gradient(480px 300px at 92% 70%, rgba(240, 208, 96, 0.08), transparent 50%),
    var(--bg);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

:focus-visible {
  outline: 2px solid var(--green-lit);
  outline-offset: 3px;
}

.back-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0 14px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s;
}
.back-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.app {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 56px 16px 48px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.brand-mark {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(93, 255, 154, 0.25));
}

h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

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

.scoreboard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-value.under {
  color: var(--green-lit);
}
.stat-value.over {
  color: var(--danger);
}

.stage-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  background: #0d2818;
  touch-action: none;
}

#course {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  cursor: crosshair;
}

.aim-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  font-size: 0.78rem;
  color: rgba(238, 246, 240, 0.85);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.25s;
}
.aim-hint.hidden {
  opacity: 0;
}

.hole-banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 10, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
  animation: banner-in 0.35s ease;
}
.hole-banner.hidden {
  display: none;
}
.hole-banner .banner-card {
  text-align: center;
  padding: 24px 32px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  max-width: 90%;
}
.hole-banner h3 {
  font-family: var(--display);
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.hole-banner p {
  color: var(--muted);
  font-size: 0.95rem;
}
.hole-banner .banner-tap {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--accent);
}

@keyframes banner-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: linear-gradient(160deg, #3aab5e, #1e6b3a);
  color: #fff;
  box-shadow: 0 8px 24px rgba(45, 138, 78, 0.35);
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-ghost {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover {
  border-color: var(--line-strong);
  background: rgba(30, 48, 38, 0.95);
}
.btn-ghost[aria-pressed="true"] {
  border-color: rgba(93, 255, 154, 0.4);
  color: var(--green-lit);
}

.card-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
}
.card-row h2 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.scorecard {
  display: grid;
  grid-template-columns: auto repeat(9, 1fr) auto;
  gap: 4px;
  font-size: 0.78rem;
  text-align: center;
  overflow-x: auto;
}

.scorecard .sc-label {
  color: var(--muted);
  text-align: left;
  padding: 4px 6px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.68rem;
}
.scorecard .sc-cell {
  padding: 6px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}
.scorecard .sc-cell.current {
  outline: 1px solid var(--green-lit);
  background: rgba(45, 138, 78, 0.25);
}
.scorecard .sc-cell.under {
  color: var(--green-lit);
}
.scorecard .sc-cell.over {
  color: var(--danger);
}
.scorecard .sc-cell.total {
  font-weight: 700;
  background: rgba(240, 208, 96, 0.12);
}

.modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  background: transparent;
  max-width: min(420px, calc(100vw - 32px));
  color: var(--ink);
}
.modal::backdrop {
  background: rgba(4, 10, 7, 0.72);
  backdrop-filter: blur(4px);
}
.modal-inner {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-inner h2 {
  font-family: var(--display);
  font-size: 1.35rem;
  margin-bottom: 14px;
}
.modal-inner ol {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 14px;
}
.modal-inner li strong {
  color: var(--ink);
}
.modal-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.modal-note kbd {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
}
.modal-inner .btn-primary {
  width: 100%;
}

.finish-summary {
  color: var(--muted);
  margin-bottom: 12px;
}
.finish-score {
  font-family: var(--display);
  font-size: 2rem;
  text-align: center;
  margin-bottom: 18px;
  color: var(--accent);
}

@media (max-width: 560px) {
  .scoreboard {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat:nth-child(4),
  .stat:nth-child(5) {
    /* keep all 5 — last row spans nicely */
  }
  .scoreboard {
    grid-template-columns: repeat(5, 1fr);
  }
  .stat {
    padding: 8px 4px;
  }
  .stat-value {
    font-size: 1.05rem;
  }
  h1 {
    font-size: 1.45rem;
  }
  .aim-hint {
    font-size: 0.78rem;
    white-space: normal;
    text-align: center;
    max-width: 90%;
  }
}

@media (max-width: 400px) {
  .scoreboard {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat:nth-child(n + 4) {
    /* 4 and 5 on second row of 3 — ok */
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
