/* Golden Hour Open — warm paper, ink and honey. */
:root {
  --ink: #2e241a;
  --ink-soft: #5b4a38;
  --paper: #f7eedb;
  --paper-2: #efe1c3;
  --paper-edge: rgba(94, 70, 40, 0.28);
  --honey: #e0a44a;
  --honey-deep: #b87a2a;
  --green: #45613a;
  --green-soft: #7c9a5e;
  --rose: #c9705a;
  --sky: #9fb8c8;
  --shadow: 0 10px 30px rgba(40, 26, 10, 0.28), 0 2px 6px rgba(40, 26, 10, 0.2);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2d2419; color: var(--ink); font-family: var(--serif); -webkit-font-smoothing: antialiased; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--honey); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- loading */
.loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 18px; justify-items: center; background: radial-gradient(ellipse at 30% 30%, #6b4f2c, #2d2419 70%); color: var(--paper); transition: opacity 0.8s var(--ease-out); z-index: 50; }
.loading.done { opacity: 0; pointer-events: none; }
.loading-title { font-size: clamp(26px, 4vw, 44px); letter-spacing: 0.06em; font-style: italic; }
.loading-bar { width: min(320px, 60vw); height: 4px; border-radius: 4px; background: rgba(255, 240, 210, 0.2); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--honey); transition: width 0.3s; }

/* ---------------------------------------------------------------- HUD cards */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud[hidden] { display: none; }
.hud-card {
  position: absolute; pointer-events: auto;
  background: linear-gradient(180deg, rgba(250, 243, 226, 0.94), rgba(240, 228, 202, 0.94));
  border: 1px solid var(--paper-edge); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(3px);
}
.hole-card { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); padding: 10px 16px 10px 12px; min-width: 230px; }
.hc-top { display: flex; align-items: center; gap: 12px; }
.hc-no { font-size: 40px; line-height: 1; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: var(--paper); font-weight: 600; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.hc-meta { display: grid; }
.hc-name { font-size: 19px; font-style: italic; }
.hc-par { font-family: var(--sans); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.hc-bottom { display: flex; gap: 12px; margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--paper-edge); font-family: var(--sans); font-size: 13px; color: var(--ink-soft); }
.hc-player { font-weight: 600; color: var(--ink); }
.hc-score { margin-left: auto; font-weight: 700; color: var(--green); }

.map-card { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); padding: 6px; }
.map-canvas { display: block; width: 120px; height: auto; max-height: 34vh; object-fit: contain; border-radius: 9px; }

.club-card { left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); padding: 8px 10px; }
.club-row { display: flex; align-items: center; gap: 8px; }
.club-step { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--paper-edge); background: var(--paper); font-size: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); }
.club-text { display: grid; min-width: 132px; text-align: center; }
.club-name { font-size: 21px; }
.club-carry { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); letter-spacing: 0.04em; }
.traj-row { display: flex; gap: 4px; margin-top: 6px; }
.traj { flex: 1; border: 1px solid var(--paper-edge); background: transparent; border-radius: 8px; padding: 4px 6px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.traj.on { background: var(--green); color: var(--paper); border-color: var(--green); }
.hud.putting .traj-row { display: none; }

.info-card { left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 18px; padding: 8px 18px; }
.info-dist { display: grid; text-align: center; }
.to-pin { font-size: 26px; line-height: 1.05; }
.info-sub { font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft); }
.info-lie { display: grid; font-family: var(--sans); font-size: 13px; }
.lie { font-weight: 700; }
.lie[data-lie="bunker"], .lie[data-lie="deep-rough"] { color: var(--rose); }
.plays { color: var(--ink-soft); font-size: 12px; }
.wind { display: flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 13px; }
.wind-arrow { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--sky); transition: transform 0.4s var(--ease-out); }
.wind-arrow svg { width: 16px; height: 16px; fill: var(--ink); }

/* ---------------------------------------------------------------- meter */
.meter { position: absolute; right: max(26px, env(safe-area-inset-right)); top: 50%; transform: translateY(-40%); width: 46px; height: min(46vh, 380px); pointer-events: none; opacity: 0.55; transition: opacity 0.3s; }
.meter.active { opacity: 1; }
.meter-track { position: absolute; inset: 0 8px 26px; border-radius: 16px; background: linear-gradient(180deg, rgba(247, 238, 219, 0.95), rgba(236, 222, 192, 0.95)); border: 2px solid rgba(70, 50, 28, 0.55); box-shadow: var(--shadow); overflow: visible; }
.meter-fill { position: absolute; left: 3px; right: 3px; border-radius: 10px 10px 4px 4px; background: linear-gradient(0deg, var(--honey-deep), var(--honey) 60%, #f6d38b); }
.meter.putt .meter-fill { background: linear-gradient(0deg, var(--green), var(--green-soft)); }
.meter-window { position: absolute; left: -4px; right: -4px; background: rgba(69, 97, 58, 0.35); border-top: 1px solid rgba(69, 97, 58, 0.8); border-bottom: 1px solid rgba(69, 97, 58, 0.8); }
.meter.putt .meter-window, .meter.putt .meter-snap { display: none; }
.meter-snap { position: absolute; left: -8px; right: -8px; bottom: calc(0.32 / 1.32 * 100%); height: 2px; background: var(--ink); }
.meter-tick { position: absolute; left: 0; width: 7px; height: 1px; background: rgba(46, 36, 26, 0.45); }
.meter-marker { position: absolute; left: -12px; width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 11px solid var(--ink); transform: translateY(50%); }
.meter-marker.falling { border-left-color: var(--rose); }
.meter-label { position: absolute; bottom: 0; left: -30px; right: -30px; text-align: center; font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.meter.flash-pure .meter-track { animation: pure 0.6s var(--ease-out); }
.meter.flash-miss .meter-track { animation: miss 0.4s var(--ease-out); }
@keyframes pure { 0% { box-shadow: 0 0 0 0 rgba(246, 211, 139, 0.9), var(--shadow); } 100% { box-shadow: 0 0 0 18px rgba(246, 211, 139, 0), var(--shadow); } }
@keyframes miss { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------------------------------------------------------------- messages */
.caddie-line { position: absolute; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 78px); transform: translateX(-50%); max-width: min(560px, 70vw); padding: 6px 14px; border-radius: 20px; background: rgba(46, 36, 26, 0.62); color: var(--paper); font-style: italic; font-size: 15px; text-align: center; }
.caddie-line:empty { display: none; }
.caddie-line.fade-in { animation: fadeUp 0.5s var(--ease-out); }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px) scale(0.9); opacity: 0; font-size: clamp(26px, 3.4vw, 40px); font-style: italic; color: var(--paper); text-shadow: 0 2px 10px rgba(40, 20, 0, 0.55); transition: opacity 0.35s, transform 0.35s var(--ease-back); pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast[data-tone="good"] { color: #ffe3a3; }
.toast[data-tone="bad"] { color: #ffd5c8; }
.score-card { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.6) rotate(-3deg); opacity: 0; display: grid; justify-items: center; gap: 4px; padding: 20px 44px 16px; border-radius: 18px; background: linear-gradient(180deg, #fbf4e3, #eedcb6); border: 1px solid var(--paper-edge); box-shadow: 0 24px 60px rgba(40, 20, 0, 0.4); pointer-events: none; transition: opacity 0.3s, transform 0.5s var(--ease-back); }
.score-card.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-1deg); }
.score-card strong { font-size: clamp(34px, 5vw, 60px); font-style: italic; font-weight: 500; }
.score-card span { font-family: var(--sans); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.score-card[data-tone="birdie"] strong, .score-card[data-tone="eagle"] strong, .score-card[data-tone="ace"] strong { color: var(--rose); }
.score-card[data-tone="par"] strong { color: var(--green); }
.putt-reader { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.target-reticle { position: fixed; left: 0; top: 0; width: 64px; height: 64px; border-radius: 50%; border: 3px dashed rgba(255, 246, 222, 0.85); box-shadow: 0 0 0 2px rgba(46, 36, 26, 0.25); pointer-events: none; opacity: 0; transition: opacity 0.25s; }

/* ---------------------------------------------------------------- touch */
.swing-pad, .pause-button { display: none; }
.pause-button { position: absolute; pointer-events: auto; top: max(14px, env(safe-area-inset-top)); right: calc(max(14px, env(safe-area-inset-right)) + 146px); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--paper-edge); background: var(--paper); box-shadow: var(--shadow); gap: 5px; align-items: center; justify-content: center; }
.pause-button span { display: block; width: 4px; height: 14px; background: var(--ink); border-radius: 2px; }
@media (pointer: coarse) {
  .swing-pad { display: grid; place-items: center; position: absolute; pointer-events: auto; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%; border: 3px solid rgba(255, 244, 220, 0.9); background: radial-gradient(circle at 40% 35%, #f3c77a, var(--honey-deep)); color: var(--ink); font-family: var(--sans); font-weight: 800; letter-spacing: 0.12em; box-shadow: var(--shadow); touch-action: none; }
  .swing-pad:active { transform: scale(0.96); }
  .pause-button { display: flex; }
  .meter { right: max(136px, calc(env(safe-area-inset-right) + 128px)); }
}
@media (max-height: 500px) {
  .hole-card { min-width: 0; padding: 6px 10px; }
  .hc-no { width: 36px; height: 36px; font-size: 26px; }
  .hc-name { font-size: 15px; }
  .hc-bottom { margin-top: 4px; padding-top: 4px; font-size: 11px; }
  .map-canvas { width: 78px; }
  .club-card { padding: 5px 7px; }
  .club-name { font-size: 16px; }
  .club-text { min-width: 96px; }
  .club-step { width: 30px; height: 30px; }
  .info-card { gap: 10px; padding: 5px 12px; }
  .to-pin { font-size: 20px; }
  .caddie-line { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 58px); font-size: 12px; }
  .meter { height: 56vh; top: 44%; }
  .swing-pad { width: 86px; height: 86px; }
  .pause-button { right: calc(max(14px, env(safe-area-inset-right)) + 100px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
