@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

:root {
  color-scheme: light;
  --pine: #183c32;
  --pine-deep: #102b24;
  --pine-soft: #315a4b;
  --grass: #bed288;
  --grass-light: #dce8b8;
  --chalk: #f5f4ec;
  --paper: #fffef9;
  --ink: #1a3028;
  --muted: #78857a;
  --line: #e4e6dc;
  --orange: #e57949;
  --yellow: #e4bd5c;
  --water: #73b7b2;
  --shadow: 0 18px 48px rgba(16, 43, 36, .12);
  font-family: 'DM Sans', 'Trebuchet MS', sans-serif;
  color: var(--ink);
  background: var(--pine-deep);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--pine-deep); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
button:disabled { opacity: .46; cursor: not-allowed; }
.app-shell { min-height: 100vh; }
.topbar { height: 66px; padding: 0 max(22px, calc((100vw - 1200px) / 2)); display: flex; align-items: center; justify-content: space-between; color: var(--chalk); border-bottom: 1px solid rgba(255,255,255,.11); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 31px; height: 31px; border: 1px solid rgba(245,244,236,.56); border-radius: 50%; display: grid; place-items: center; color: var(--grass-light); font: 500 14px 'DM Mono', monospace; }
.brand-name { font: 500 12px 'DM Mono', monospace; letter-spacing: 0; }
.top-actions { display: flex; gap: 9px; align-items: center; }
.quiet-button, .icon-button { min-height: 38px; border: 1px solid rgba(245,244,236,.24); color: var(--chalk); background: transparent; padding: 0 12px; border-radius: 3px; cursor: pointer; }
.quiet-button:hover, .icon-button:hover { border-color: var(--grass); color: var(--grass-light); }

.home { min-height: calc(100vh - 66px); max-width: 1200px; margin: auto; padding: 54px 7vw 34px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .75fr); gap: 6vw; align-items: center; color: var(--chalk); }
.home-copy { max-width: 640px; animation: appear .7s ease both; }
.eyebrow { margin: 0 0 18px; color: var(--grass); font: 500 11px 'DM Mono', monospace; letter-spacing: 1.5px; }
.home h1 { margin: 0; font: 600 clamp(54px, 8vw, 94px)/.93 'Fraunces', Georgia, serif; letter-spacing: 0; }
.home h1 span { display: block; color: var(--grass-light); }
.tagline { margin: 25px 0 12px; font: 500 17px 'DM Mono', monospace; }
.mission { max-width: 370px; color: rgba(245,244,236,.72); line-height: 1.65; }
.home-actions { display: grid; gap: 10px; margin-top: 30px; max-width: 330px; }
.primary-button, .secondary-button, .text-button { min-height: 50px; border: 0; border-radius: 3px; padding: 0 18px; cursor: pointer; font-weight: 700; }
.primary-button { background: var(--grass-light); color: var(--pine-deep); }
.primary-button:hover { background: #e8efca; }
.secondary-button { border: 1px solid rgba(245,244,236,.34); background: transparent; color: var(--chalk); }
.secondary-button:hover { border-color: var(--grass-light); }
.text-button { min-height: 40px; padding: 0; color: var(--grass-light); background: transparent; text-align: left; }
.hero-art { position: relative; min-height: 450px; display: grid; place-items: center; animation: appear .85s .1s ease both; }
.course-art { width: min(100%, 470px); aspect-ratio: 1 / 1.04; border-radius: 46% 46% 2px 2px; overflow: hidden; background: var(--pine-soft); position: relative; }
.course-art svg { width: 100%; height: 100%; }
.art-stamp { position: absolute; right: 0; bottom: 26px; padding: 15px 19px; color: var(--pine-deep); background: var(--yellow); font: 500 11px 'DM Mono', monospace; line-height: 1.6; transform: rotate(-3deg); }
.home-foot { position: absolute; bottom: 22px; left: 7vw; color: rgba(245,244,236,.48); font: 10px 'DM Mono', monospace; }

.game-page { max-width: 1200px; margin: auto; padding: 23px 26px 52px; }
.game-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 15px; color: var(--chalk); }
.hole-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 11px; }
.hole-heading h1 { margin: 0; font: 500 31px 'Fraunces', Georgia, serif; letter-spacing: 0; }
.hole-subtitle { color: rgba(245,244,236,.63); font: 11px 'DM Mono', monospace; }
.score-chip { min-width: 98px; padding: 8px 11px; border: 1px solid rgba(245,244,236,.24); text-align: right; }
.score-chip strong { display: block; font: 500 16px 'DM Mono', monospace; }
.score-chip span { color: rgba(245,244,236,.62); font: 9px 'DM Mono', monospace; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(315px, .75fr); gap: 16px; align-items: start; }
.course-column, .decision-column { min-width: 0; }
.map-frame { overflow: hidden; background: #cad99b; box-shadow: var(--shadow); }
.map-topline { min-height: 44px; padding: 0 14px; display: flex; justify-content: space-between; align-items: center; color: var(--pine-deep); background: var(--paper); font: 10px 'DM Mono', monospace; }
.map-topline span:last-child { color: var(--muted); }
.course-map { display: block; width: 100%; height: auto; min-height: 250px; touch-action: manipulation; }
.map-click-area { cursor: crosshair; }
.map-readout { padding: 12px 15px; display: flex; justify-content: space-between; gap: 8px; background: #e6edce; font: 10px 'DM Mono', monospace; }
.map-readout span:last-child { color: #647563; }
.situation-strip { display: flex; gap: 7px; flex-wrap: wrap; padding: 12px 0 17px; }
.situation-tag { padding: 6px 9px; background: rgba(255,255,255,.11); color: var(--chalk); font: 10px 'DM Mono', monospace; }
.decision-panel { color: var(--ink); background: var(--paper); padding: 18px 19px 20px; box-shadow: var(--shadow); }
.panel-step { color: #79867a; font: 10px 'DM Mono', monospace; }
.decision-panel h2 { margin: 7px 0 4px; font: 500 24px 'Fraunces', Georgia, serif; }
.panel-copy { margin: 0 0 15px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.control-label { display: flex; align-items: center; gap: 6px; margin: 14px 0 8px; color: #5e6f62; font: 10px 'DM Mono', monospace; text-transform: uppercase; }
.club-select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 2px; background: white; color: var(--ink); }
.club-meta { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { width: 100%; accent-color: var(--pine-soft); }
.range-value { min-width: 61px; text-align: right; font: 500 12px 'DM Mono', monospace; }
.shape-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.shape-choice { min-height: 39px; border: 1px solid var(--line); border-radius: 2px; background: white; cursor: pointer; font-size: 12px; }
.shape-choice[aria-pressed=true] { border-color: var(--pine); color: var(--pine-deep); background: #e5edd2; }
.strategy-call { min-height: 47px; margin: 14px 0 12px; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #f1f3ea; }
.strategy-call strong { font: 500 11px 'DM Mono', monospace; }
.strategy-call span { color: #687869; font-size: 10px; text-align: right; }
.full-button { width: 100%; }
.back-link { margin: 9px 0 0; width: 100%; min-height: 35px; border: 0; background: transparent; color: #687869; cursor: pointer; font-size: 11px; }
.wind-note { padding: 11px 12px; border-left: 2px solid var(--yellow); background: #f7f5eb; color: #6d7268; font-size: 11px; line-height: 1.5; }
.glossary { margin-top: 11px; border-top: 1px solid var(--line); padding-top: 10px; }
.glossary summary { cursor: pointer; color: #647666; font: 10px 'DM Mono', monospace; }
.glossary div { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding-top: 10px; }
.glossary div span { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #657365; font-size: 10px; }

.swing-panel { padding-bottom: 15px; }
.swing-stats { display: flex; justify-content: space-between; gap: 8px; margin: 13px 0 7px; color: #6d7b6e; font: 10px 'DM Mono', monospace; }
.meter { height: 14px; position: relative; overflow: hidden; border-radius: 10px; background: #e8e9df; }
.meter-perfect { position: absolute; top: 0; bottom: 0; left: 68%; width: 9%; background: #b8d38c; }
.meter-indicator { position: absolute; left: 0; top: -3px; width: 4px; height: 20px; border-radius: 3px; background: var(--orange); box-shadow: 0 0 0 2px rgba(229,121,73,.18); transform: translateX(-50%); }
.meter-scale { display: flex; justify-content: space-between; margin-top: 4px; color: #97a094; font: 9px 'DM Mono', monospace; }
.track-wrap { margin-top: 14px; border: 1px solid var(--line); background: #f5f6ef; }
.pull-track { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.track-line { fill: none; stroke: #b7c8a4; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 4 9; }
.track-active { fill: none; stroke: var(--pine-soft); stroke-width: 7; stroke-linecap: round; opacity: .21; }
.track-ball { fill: var(--orange); stroke: white; stroke-width: 5; filter: drop-shadow(0 3px 4px rgba(0,0,0,.2)); }
.track-guide { fill: #81947c; font: 13px 'DM Mono', monospace; }
.shape-warning { min-height: 34px; margin: 8px 0 0; color: #6d7b6e; font-size: 10px; line-height: 1.45; }
.drag-hint { text-align: center; color: var(--muted); font-size: 11px; }

.review-panel { padding: 17px 19px 19px; }
.result-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; padding: 11px; background: #edf2e2; }
.result-banner strong { font: 500 14px 'DM Mono', monospace; }
.result-banner span { color: #637464; font-size: 11px; }
.grade-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 11px 0; }
.grade-card { padding: 11px; background: #f4f4ec; }
.grade-card strong { display: block; font: 500 26px 'Fraunces', Georgia, serif; }
.grade-card span { color: #748073; font: 9px 'DM Mono', monospace; text-transform: uppercase; }
.review-copy { margin: 9px 0; color: #59695b; font-size: 12px; line-height: 1.55; }
.review-panel .secondary-button { border-color: #9baa91; color: var(--pine); background: #f1f3ea; }
.replay { margin-top: 15px; border-top: 1px solid var(--line); padding-top: 12px; }
.replay summary { cursor: pointer; color: var(--pine-soft); font: 500 11px 'DM Mono', monospace; }
.replay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 9px 0; }
.replay-grid label { color: #768174; font: 9px 'DM Mono', monospace; }
.replay-grid select, .replay-grid input { width: 100%; height: 35px; margin-top: 5px; padding: 0 7px; border: 1px solid var(--line); background: white; }
.replay-result { margin: 10px 0 0; padding: 10px; background: #f4f4ec; color: #59695b; font-size: 11px; line-height: 1.5; }
.after-shot { margin-top: 11px; }

.score-page { max-width: 940px; margin: auto; padding: 60px 24px; color: var(--chalk); }
.score-page h1 { margin: 7px 0 8px; font: 500 clamp(40px, 7vw, 68px)/1 'Fraunces', Georgia, serif; }
.score-intro { color: rgba(245,244,236,.72); line-height: 1.6; }
.score-list { margin: 27px 0; border-top: 1px solid rgba(255,255,255,.18); }
.score-row { display: grid; grid-template-columns: 1.3fr .65fr .7fr .7fr; align-items: center; gap: 8px; padding: 14px 5px; border-bottom: 1px solid rgba(255,255,255,.16); font: 11px 'DM Mono', monospace; }
.score-row.heading { color: var(--grass); font-size: 9px; }
.score-row strong { font-size: 13px; }
.takeaway { max-width: 680px; padding: 16px 18px; border-left: 2px solid var(--yellow); background: rgba(255,255,255,.07); color: rgba(245,244,236,.84); line-height: 1.6; }
.score-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 23px; }
.score-actions .primary-button { min-width: 220px; }
.score-actions .secondary-button { border-color: rgba(245,244,236,.34); color: var(--chalk); }
.hole-intro { max-width: 720px; margin: 6vh auto; padding: 0 24px; color: var(--chalk); }
.hole-intro h1 { font: 500 clamp(45px, 7vw, 72px)/1 'Fraunces', Georgia, serif; }
.intro-map { margin: 20px 0; padding: 12px; background: var(--paper); }
.intro-map svg { width: 100%; display: block; }
.intro-brief { max-width: 600px; color: rgba(245,244,236,.75); line-height: 1.65; }
.intro-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.intro-facts span { padding: 7px 10px; border: 1px solid rgba(245,244,236,.24); color: var(--grass-light); font: 10px 'DM Mono', monospace; }

.tutorial { width: min(460px, calc(100vw - 32px)); padding: 27px; border: 0; border-radius: 3px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.tutorial::backdrop, .term-dialog::backdrop { background: rgba(8,24,20,.75); }
.tutorial h2, .term-dialog h2 { margin: 0 0 9px; font: 500 31px 'Fraunces', Georgia, serif; }
.tutorial p, .term-dialog p { color: #657365; font-size: 13px; line-height: 1.65; }
.tutorial-actions { display: flex; gap: 9px; margin-top: 20px; }
.tutorial .secondary-button { color: var(--pine); border-color: var(--line); }
.term-dialog { width: min(390px, calc(100vw - 32px)); padding: 25px; border: 0; border-radius: 3px; background: var(--paper); color: var(--ink); }
.term-dialog .eyebrow { margin: 0 0 12px; color: var(--pine-soft); }
.term-dialog form { position: absolute; top: 12px; right: 12px; }
.dialog-close { color: var(--ink); border-color: var(--line); min-width: 34px; padding: 0; font-size: 20px; }
.question { display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; border: 1px solid #aeb8a6; border-radius: 50%; color: #647666; background: transparent; cursor: pointer; font: 10px 'DM Mono', monospace; vertical-align: 1px; }
.debug { max-width: 1200px; margin: 0 auto 35px; color: rgba(245,244,236,.8); font: 10px 'DM Mono', monospace; }
.debug summary { padding: 10px 25px; cursor: pointer; }
.debug-body { margin: 0 25px; padding: 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid rgba(255,255,255,.17); }
.debug button, .debug select { min-height: 33px; padding: 0 9px; border: 1px solid rgba(255,255,255,.26); border-radius: 2px; color: var(--chalk); background: transparent; cursor: pointer; font: inherit; }
.debug-output { flex-basis: 100%; min-height: 14px; color: var(--grass-light); }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20; max-width: calc(100vw - 32px); padding: 11px 15px; color: white; background: var(--pine-deep); box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.home-foot, .score-page, .game-page, .hole-intro { animation: appear .45s ease both; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fly { 0% { opacity: 1; } 100% { opacity: 1; } }

@media (max-width: 780px) {
  .topbar { height: 58px; padding: 0 16px; }
  .home { min-height: calc(100vh - 58px); padding: 37px 24px 70px; grid-template-columns: 1fr; gap: 16px; align-content: start; }
  .home h1 { font-size: clamp(55px, 15vw, 80px); }
  .hero-art { min-height: auto; margin: 8px auto 0; width: min(100%, 390px); }
  .course-art { width: 100%; aspect-ratio: 1.3 / 1; border-radius: 42% 42% 2px 2px; }
  .home-foot { left: 24px; bottom: 15px; }
  .game-page { padding: 17px 12px 34px; }
  .game-header { margin: 0 2px 12px; }
  .hole-heading h1 { font-size: 26px; }
  .game-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .course-map { min-height: 0; }
  .map-frame { box-shadow: none; }
  .decision-panel { padding: 16px; }
  .situation-strip { padding: 9px 0 12px; }
  .debug summary { padding: 10px 15px; }
  .debug-body { margin: 0 12px; }
  .score-page { padding: 38px 18px; }
  .score-row { grid-template-columns: 1.1fr .5fr .65fr .65fr; font-size: 9px; }
  .score-row strong { font-size: 11px; }
  .hole-intro { margin: 5vh auto; padding: 0 16px; }
}
@media (max-width: 390px) {
  .brand-name { font-size: 10px; }
  .topbar { padding: 0 10px; }
  .quiet-button { padding: 0 8px; font-size: 11px; }
  .score-chip { min-width: 78px; padding: 6px 8px; }
  .map-topline { padding: 0 9px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; } }
