:root {
  --cream: #fbf3dc; --ink: #24402a; --soft: #5f6f55; --coral: #e2603f; --gold: #e9b44c; --leaf: #5aa647;
  --panel: rgba(251, 243, 220, .96); --shadow: 0 18px 50px rgba(30, 18, 8, .45);
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3b2a1c; color: var(--ink); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
.icons { position: absolute; width: 0; height: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: crosshair; }
body[data-mode="menu"] #world { filter: saturate(.85) brightness(.75); }

header { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); z-index: 5; pointer-events: none; }
header > * { pointer-events: auto; }
.header-actions { display: flex; gap: 8px; margin-left: auto; }
.round-button { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--panel); color: var(--ink); box-shadow: 0 4px 14px rgba(0, 0, 0, .3); cursor: pointer; text-decoration: none; transition: transform .15s; }
.round-button:hover { transform: translateY(-1px); }
.round-button:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.round-button.muted { opacity: .7; }
.round-button.muted svg path:last-child { opacity: .25; }

#hud { display: flex; gap: 8px; align-items: stretch; margin: 0 auto; }
#hud[hidden] { display: none; }
.hud-hole, .hud-chip { background: var(--panel); border-radius: 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); padding: 6px 14px; display: flex; flex-direction: column; justify-content: center; line-height: 1.1; }
.hud-hole span, .hud-chip span { font-size: 10px; letter-spacing: .14em; color: var(--soft); font-weight: 700; }
.hud-hole b { font-family: var(--serif); font-size: 18px; white-space: nowrap; }
.hud-chip { align-items: center; min-width: 64px; }
.hud-chip b { font-size: 20px; font-variant-numeric: tabular-nums; }

#hint { position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 99px; background: rgba(25, 16, 9, .55); color: #f6ecd0; font-size: 13px; letter-spacing: .03em; pointer-events: none; transition: opacity .6s; white-space: nowrap; }
#hint.fade { opacity: 0; }

#banner { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9); text-align: center; color: var(--cream); pointer-events: none; opacity: 0; text-shadow: 0 3px 18px rgba(0, 0, 0, .7); z-index: 4; width: min(90vw, 560px); }
#banner.show { animation: banner 2.6s ease forwards; }
#banner span, #banner small { display: block; letter-spacing: .3em; font-size: 13px; font-weight: 700; color: #ffe7a6; }
#banner b { display: block; font-family: var(--serif); font-size: clamp(38px, 8vw, 64px); line-height: 1.05; margin: 6px 0; }
#banner em { display: block; margin-top: 10px; font-size: 15px; font-style: normal; color: #f3e6c4; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.92); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -56%) scale(1); } }

#toast { position: fixed; left: 50%; top: 92px; transform: translate(-50%, -10px); background: var(--panel); padding: 8px 18px; border-radius: 99px; font-weight: 700; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; z-index: 6; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.screen { position: fixed; inset: 0; display: grid; place-items: center; z-index: 8; padding: 20px; }
.screen[hidden] { display: none; }
.overlay { background: rgba(28, 18, 10, .45); backdrop-filter: blur(3px); }
.intro { text-align: center; color: var(--cream); text-shadow: 0 4px 24px rgba(0, 0, 0, .55); }
.eyebrow { letter-spacing: .28em; font-size: 12px; font-weight: 800; margin: 0 0 8px; color: var(--coral); }
.intro .eyebrow { color: #ffd98a; }
h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(54px, 12vw, 108px); line-height: .9; margin: 0; letter-spacing: -.02em; }
h1 span { display: block; font-family: var(--sans); font-size: .26em; letter-spacing: .75em; margin-top: 14px; padding-left: .75em; color: #cfe8a4; }
.intro-copy { font-size: 18px; line-height: 1.5; margin: 22px 0 26px; color: #f2e6c6; }
.menu-controls { font-size: 13px; color: #e9dcb8; margin-top: 18px; }
.record { font-size: 12px; letter-spacing: .2em; color: #e9dcb8; }
.record b { color: #fff; font-size: 16px; letter-spacing: 0; margin-left: 6px; }

.primary, .secondary { font: inherit; font-weight: 800; border: 0; border-radius: 99px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.primary { background: var(--coral); color: #fff; padding: 15px 30px; font-size: 18px; box-shadow: 0 8px 0 #a8402a, 0 14px 30px rgba(0, 0, 0, .35); transition: transform .12s, box-shadow .12s; }
.primary:hover { transform: translateY(-2px); }
.primary:active { transform: translateY(5px); box-shadow: 0 3px 0 #a8402a, 0 6px 14px rgba(0, 0, 0, .3); }
.secondary { background: transparent; color: var(--soft); padding: 12px 20px; margin-top: 10px; text-decoration: underline; text-underline-offset: 4px; }

.panel { background: var(--panel); border-radius: 26px; box-shadow: var(--shadow); padding: 28px 30px 24px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.panel.compact { width: min(430px, 100%); }
h2 { font-family: var(--serif); font-size: clamp(34px, 7vw, 46px); line-height: 1; margin: 0 0 12px; }
h2 span { color: var(--leaf); }
.panel p { color: var(--soft); line-height: 1.5; margin: 4px 0 12px; }
.result-stats { display: flex; gap: 10px; width: 100%; margin: 8px 0 20px; }
.result-stats div { flex: 1; background: #efe3c1; border-radius: 14px; padding: 10px 6px; }
.result-stats span { display: block; font-size: 10px; letter-spacing: .16em; font-weight: 800; color: var(--soft); }
.result-stats b { font-size: 24px; font-variant-numeric: tabular-nums; }
.instructions-copy { text-align: left; font-size: 15px; }
.instructions-copy b { color: var(--ink); }
.keyboard-help { font-size: 13px; background: #efe3c1; padding: 10px 12px; border-radius: 12px; }

.scorecard { border-collapse: separate; border-spacing: 3px; margin: 6px 0 14px; font-variant-numeric: tabular-nums; width: 100%; }
.scorecard th, .scorecard td { padding: 6px 2px; border-radius: 8px; font-size: 14px; min-width: 26px; }
.scorecard th { color: var(--soft); font-size: 11px; }
.scorecard tr > :first-child { text-align: left; font-size: 11px; letter-spacing: .1em; color: var(--soft); font-weight: 800; padding-right: 6px; }
.scorecard #scPar td { background: #efe3c1; }
.scorecard #scYou td { background: #fff7e2; font-weight: 800; }
.scorecard td.under { background: #cfe8a4 !important; }
.scorecard td.ace { background: var(--gold) !important; }
.scorecard td.over { color: var(--coral); }

.leaders { width: 100%; margin-top: 14px; text-align: left; }
.leaders > span { font-size: 11px; letter-spacing: .2em; font-weight: 800; color: var(--soft); }
.leaders ol { margin: 6px 0 0; padding-left: 24px; }
.leaders li { padding: 3px 0; color: var(--ink); }
.leaders li b { float: right; font-variant-numeric: tabular-nums; }
.leaders ol:empty::after { content: 'Scores appear when the clubhouse is online.'; color: var(--soft); font-size: 13px; margin-left: -24px; }

@media (max-width: 640px) {
  header { flex-wrap: wrap; row-gap: 8px; }
  #hud { order: 3; width: 100%; justify-content: center; }
  .hud-hole { padding: 5px 10px; flex: 1; max-width: 230px; }
  .hud-hole b { font-size: 16px; }
  .hud-chip { min-width: 56px; padding: 5px 8px; }
  #toast { top: 120px; }
  .panel { padding: 22px 16px 18px; }
  .scorecard th, .scorecard td { font-size: 12px; min-width: 20px; padding: 5px 1px; }
}
@media (prefers-reduced-motion: reduce) { #banner.show { animation-duration: 2.2s; } .primary { transition: none; } }
