/* Life of Golf — a quiet, rich HUD: ivory, deep green, hairline gold, fine serif type and room to breathe.
   Two moods: Ivory (daylight) and Evergreen (a lit model in a dark green room). */

@font-face { font-family: "Playfair Display"; font-weight: 600; font-style: normal; font-display: swap; src: url("./fonts/playfair-display-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-style: italic; font-display: swap; src: url("./fonts/playfair-display-latin-600-italic.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 800; font-style: normal; font-display: swap; src: url("./fonts/playfair-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 500; font-style: normal; font-display: swap; src: url("./fonts/eb-garamond-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 500; font-style: italic; font-display: swap; src: url("./fonts/eb-garamond-latin-500-italic.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 600; font-style: normal; font-display: swap; src: url("./fonts/eb-garamond-latin-600-normal.woff2") format("woff2"); }

:root {
  --font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;

  /* constants */
  --green: #14432f;
  --green-deep: #0c2a1e;
  --gold: #a8843a;
  --card: #fffdf8;
  --card-ink: #17251d;
  --suit-roll: #1b5a3e;
  --suit-chip: #1f4c84;
  --suit-pitch: #8f6210;
  --suit-spin: #8a2333;
  --suit-lob: #563a80;

  /* Ivory */
  --bg: #f3eee3;
  --ink: #16301f;
  --ink-soft: #5d6e63;
  --panel: rgba(255, 253, 248, 0.86);
  --panel-solid: #fbf8f0;
  --line: rgba(22, 48, 31, 0.14);
  --line-strong: rgba(22, 48, 31, 0.3);
  --accent: var(--green);
  --on-accent: #f6f1e4;
  --hairline-gold: rgba(168, 132, 58, 0.75);
  --warn: #9a2a35;
  --scrim: rgba(20, 30, 24, 0.32);
  --shadow: 0 1px 2px rgba(22, 48, 31, 0.06), 0 10px 30px rgba(22, 48, 31, 0.1);
  --shadow-lift: 0 2px 4px rgba(22, 48, 31, 0.08), 0 18px 40px rgba(22, 48, 31, 0.18);
  --dock-fade: rgba(243, 238, 227, 0.94);
}

[data-theme="dark"] {
  /* Evergreen */
  --bg: #0c241b;
  --ink: #f1ead9;
  --ink-soft: #a5b5a9;
  --panel: rgba(18, 48, 36, 0.82);
  --panel-solid: #12302a;
  --line: rgba(241, 234, 217, 0.16);
  --line-strong: rgba(241, 234, 217, 0.34);
  --accent: #ecdfbd;
  --on-accent: #0f2a20;
  --gold: #cdb06a;
  --hairline-gold: rgba(205, 176, 106, 0.8);
  --warn: #f0a59c;
  --scrim: rgba(3, 12, 8, 0.55);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 40px rgba(0, 0, 0, 0.5);
  --dock-fade: rgba(10, 31, 23, 0.94);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.ico { width: 1.2em; height: 1.2em; flex: 0 0 auto; display: block; stroke-width: 1.6; }
[data-icon], [data-laurel] { display: inline-flex; }
.hidden:not(.drawer):not(.modal) { display: none !important; }

/* small caps label, used everywhere */
.stat-k, .card-kind, .dock-btn, .btn-lbl, .drawer-body h3, .ai-stat-label, .pill, .badge-edge, .splash-sub, .card-badge-ai {
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- Shell ---------- */
.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  z-index: 0;
  background: var(--bg);
}

/* ---------- Header ---------- */
.top-bar {
  grid-row: 1;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
}

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

.top-row > *, .scoreboard { pointer-events: auto; }

.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; color: var(--ink); }
.brand-mark { font-size: 21px; color: var(--gold); }

.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 22px;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.brand-title b { font-weight: 600; }

.action-cluster { display: flex; align-items: center; gap: 8px; }

/* Round hairline buttons */
.icon-btn, .fab, .dir-btn, .close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-size: 17px;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.icon-btn .btn-lbl { font-size: 12px; }

.icon-btn:active, .dock-btn:active, .fab:active, .close-btn:active { transform: scale(0.95); }

@media (hover: hover) {
  .icon-btn:hover, .fab:hover, .close-btn:hover, .dock-btn:hover:not(:disabled):not(.dock-btn-primary):not(.dock-btn-ai) {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
  }
}

/* ---------- Scorecard: four figures and a name, set in type ---------- */
.scoreboard {
  align-self: center;
  display: flex;
  align-items: stretch;
  width: min(100%, 520px);
  padding: 9px 6px 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0 8px;
  border-left: 1px solid var(--line);
}

.stat:first-child { border-left: 0; }

.stat-k { font-size: 10.5px; margin-right: -0.2em; color: var(--ink-soft); white-space: nowrap; }

.stat-v {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 25px;
  line-height: 1.15;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-hole .stat-v.date { font-size: 17px; line-height: 1.7; }
.stat-strokes .stat-v.over { color: var(--warn); }
.stat-streak .stat-v { color: var(--gold); }
.stat-streak .stat-v.zero { color: var(--ink-soft); opacity: 0.5; }
.stat-course { flex: 1.7 1 0; }
.stat-course .stat-v { font-style: italic; font-size: 17px; line-height: 1.7; }
.stat-v.bump { animation: bump 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes bump { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* ---------- Stage (free area over the canvas) ---------- */
.stage-wrap {
  grid-row: 2;
  position: relative;
  min-height: 0;
  min-width: 0;
  z-index: 10;
  pointer-events: none;
}

.stage-wrap > * { pointer-events: auto; }

.stage-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -6px);
  padding: 8px 20px 9px;
  font-size: 16.5px;
  font-style: italic;
  text-align: center;
  line-height: 1.25;
  width: max-content;
  max-width: min(92vw, 430px);
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-toast.show { opacity: 1; transform: translate(-50%, 0); }
.stage-toast.warn { color: var(--warn); }
.stage-toast.gold { border-color: var(--hairline-gold); }

.fab, .dir-btn { width: 46px; min-width: 46px; height: 46px; padding: 0; }
.fab { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: 12px; }

/* Diagonal pad: 2×2, each button fires along one isometric axis */
.mobile-dir-pad {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: 12px;
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 6px;
}

.dir-btn { width: 44px; min-width: 44px; height: 44px; }

.dir-btn span {
  width: 11px;
  height: 11px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: translate(2px, 2px);
}

.dir-btn:nth-child(2) span { transform: translate(-2px, 2px) rotate(90deg); }
.dir-btn:nth-child(3) span { transform: translate(2px, -2px) rotate(270deg); }
.dir-btn:nth-child(4) span { transform: translate(-2px, -2px) rotate(180deg); }
.dir-btn:active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); transform: scale(0.94); }

/* ---------- Bottom: controls and the hand ---------- */
.bottom-dock {
  grid-row: 3;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, transparent 0%, var(--dock-fade) 34%);
}

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

.dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  white-space: nowrap;
  transition: transform 0.14s ease, opacity 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.dock-btn-primary, .dock-btn-ai {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.dock-btn-xl {
  min-height: 54px;
  width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 21px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.dock-btn:disabled { opacity: 0.36; cursor: not-allowed; }
.dock-btn.attn { border-color: var(--gold); animation: attn 1.4s ease-in-out infinite; }

@keyframes attn {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 60%, transparent); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.card-hand {
  /* --n (card count) is set from JS; every card gets an equal share of the row, capped. */
  --n: 5;
  --gap: 10px;
  --cw-max: 84px;
  --cw: min(var(--cw-max), calc((100vw - 32px - (var(--n) - 1) * var(--gap)) / var(--n)));
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--gap);
  padding-top: 14px;
}

@supports (width: 1cqw) {
  .bottom-dock { container-type: inline-size; }
  .card-hand { --cw: min(var(--cw-max), calc((100cqw - (var(--n) - 1) * var(--gap)) / var(--n))); }
}

/* Shot cards: crisp white stock, one fine rule in the suit colour */
.golf-card {
  --k: var(--suit-roll);
  position: relative;
  flex: 0 0 auto;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--cw) * 0.15) 2px calc(var(--cw) * 0.13);
  border-radius: calc(var(--cw) * 0.1);
  background: var(--card);
  color: var(--card-ink);
  box-shadow: 0 0 0 1px rgba(22, 48, 31, 0.1), 0 1px 2px rgba(22, 48, 31, 0.12), 0 8px 18px rgba(22, 48, 31, 0.16);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, opacity 0.25s ease;
}

.golf-card::before {
  content: "";
  position: absolute;
  inset: calc(var(--cw) * 0.065);
  border: 1px solid color-mix(in srgb, var(--k) 50%, transparent);
  border-radius: calc(var(--cw) * 0.055);
  pointer-events: none;
}

.golf-card.kind-roll { --k: var(--suit-roll); }
.golf-card.kind-chip { --k: var(--suit-chip); }
.golf-card.kind-chip_roll { --k: var(--suit-pitch); }
.golf-card.kind-backspin { --k: var(--suit-spin); }
.golf-card.kind-super_lob { --k: var(--suit-lob); }

.golf-card.deal {
  animation: deal 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 60ms + 150ms);
}

@keyframes deal { from { transform: translateY(60%); opacity: 0; } }

@media (hover: hover) {
  .golf-card:hover:not(.used):not(.selected) { transform: translateY(-5px); }
}

.golf-card.selected {
  transform: translateY(-14px);
  box-shadow: 0 0 0 1.5px var(--gold), 0 2px 4px rgba(22, 48, 31, 0.12), 0 20px 30px rgba(22, 48, 31, 0.28);
}

.golf-card.ai-pick { box-shadow: 0 0 0 2px #e9b949, 0 8px 18px rgba(22, 48, 31, 0.2); }
.golf-card.ai-pick.selected { box-shadow: 0 0 0 2.5px #e9b949, 0 20px 30px rgba(22, 48, 31, 0.28); }

/* A played card is turned face down */
.golf-card.used {
  background: var(--green);
  box-shadow: inset 0 0 0 calc(var(--cw) * 0.065) var(--green), inset 0 0 0 calc(var(--cw) * 0.065 + 1px) rgba(205, 176, 106, 0.6), 0 1px 3px rgba(0, 0, 0, 0.2);
  transform: scale(0.94);
  opacity: 0.5;
  pointer-events: none;
}

.golf-card.used::before { display: none; }
.golf-card.used > * { visibility: hidden; }

.card-kind { font-size: clamp(8px, calc(var(--cw) * 0.135), 11.5px); letter-spacing: 0.18em; margin-right: -0.18em; color: var(--k); }
.card-svg { width: calc(var(--cw) * 0.58); height: calc(var(--cw) * 0.46); color: var(--k); }
.card-svg * { stroke-width: 2; }

.card-val {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(16px, calc(var(--cw) * 0.38), 32px);
  line-height: 1;
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

.card-val small { font-family: var(--font-body); font-size: 0.62em; font-weight: 600; margin-left: 0.06em; color: var(--k); }

.card-badge-ai {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: #e9b949;
  color: #2a2006;
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 2px 8px;
  border-radius: 999px;
  z-index: 2;
}

/* ---------- Drawers ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.app-shell:has(.drawer:not(.hidden)) .scrim { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 94vw);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(10, 25, 18, 0.25);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.36s;
}

.drawer.hidden { transform: translateX(105%); visibility: hidden; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 18px 16px 24px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 26px;
}

.drawer-header h2 > [data-icon] { display: none; }

.badge-edge {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 3px 9px;
  border: 1px solid var(--hairline-gold);
  border-radius: 999px;
  color: var(--gold);
  white-space: nowrap;
}

.close-btn { width: 40px; min-width: 40px; height: 40px; padding: 0; font-size: 14px; box-shadow: none; }

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 24px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.drawer-body h3 { margin: 0 0 14px; font-size: 11.5px; color: var(--ink-soft); }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.preset-btn {
  text-align: left;
  padding: 14px 16px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.preset-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.preset-btn strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 19px; }
.preset-btn span { display: block; font-size: 15px; font-style: italic; color: var(--ink-soft); margin-top: 3px; line-height: 1.25; }
.preset-btn.active span { color: inherit; opacity: 0.75; }

.slider-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.slider-row label { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; }
.slider-row label strong { font-family: var(--font-display); font-weight: 600; font-size: 19px; }

.slider-row input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0; background: transparent; }
.slider-row input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--line-strong); }
.slider-row input[type="range"]::-moz-range-track { height: 1px; background: var(--line-strong); }

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--panel-solid);
  box-shadow: 0 0 0 1px var(--accent);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--panel-solid);
  box-shadow: 0 0 0 1px var(--accent);
}

.toggle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 18px; }

/* Terrain swatches (toggles + legend) */
.t-sand { --sw: #e6d3a2; }
.t-water { --sw: #6fbcd8; }
.t-wall { --sw: #2f6f48; }
.t-ice { --sw: #cfe8f0; }
.t-mud { --sw: #8d6d50; }
.t-ramp { --sw: #7cc86e; }
.t-boost { --sw: #b98f61; }
.t-spring { --sw: #d9412f; }
.t-portal { --sw: #1f9f93; }

.chip-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 16px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }

.chip-toggle i, .legend-list i {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--sw);
  opacity: 0.3;
}

.chip-toggle:has(input:checked) { border-color: var(--line-strong); color: var(--ink); }
.chip-toggle:has(input:checked) i, .legend-list i { opacity: 1; }
.chip-toggle:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

.seed-row { display: flex; gap: 10px; }

.seed-row input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px; /* 16px+ keeps iOS from zooming the page on focus */
  user-select: text;
  -webkit-user-select: text;
}

.seed-row input::placeholder { color: var(--ink-soft); font-style: italic; opacity: 0.8; }
.seed-row input:focus { outline: none; border-bottom-color: var(--gold); }
.seed-row .dock-btn { min-height: 46px; padding: 0 26px; }

.legend-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 11px; font-size: 16.5px; color: var(--ink-soft); line-height: 1.35; }
.legend-list li { display: flex; align-items: baseline; gap: 13px; }
.legend-list strong { font-weight: 600; color: var(--ink); }

/* ---------- Caddie drawer ---------- */
.ai-subtitle { margin: 0; font-size: 16px; font-style: italic; color: var(--ink-soft); line-height: 1.4; }
.ai-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); }
.ai-stat { padding: 2px 8px; text-align: center; border-left: 1px solid var(--line); }
.ai-stat:first-child { border-left: 0; }
.ai-stat-label { display: block; font-size: 10px; letter-spacing: 0.14em; color: var(--ink-soft); }
.ai-stat strong { display: block; margin-top: 2px; font-family: var(--font-display); font-weight: 600; font-size: 21px; white-space: nowrap; }

.ai-actions { display: flex; gap: 10px; }
.ai-actions .dock-btn { flex: 1; font-size: 11.5px; padding: 0 10px; letter-spacing: 0.14em; }

.caddie-moves { display: flex; flex-direction: column; }
.caddie-row { padding: 11px 0 12px; border-top: 1px solid var(--line); cursor: pointer; }
.caddie-row:last-child { border-bottom: 1px solid var(--line); }
.caddie-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: 17px; margin-bottom: 7px; }
.caddie-row-top small { color: var(--ink-soft); font-style: italic; }
.caddie-bar-bg { height: 2px; background: var(--line); }
.caddie-bar-fill { height: 100%; background: var(--gold); }

.activation-bars { display: flex; align-items: flex-end; gap: 3px; flex: 0 0 56px; height: 56px; border-bottom: 1px solid var(--line-strong); }
.act-bar { flex: 1; min-height: 1px; background: var(--ink); opacity: 0.75; }

/* ---------- Hole complete ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim);
  transition: opacity 0.3s ease, visibility 0.3s;
}

.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.modal-card {
  width: min(350px, 100%);
  padding: 30px 26px 24px;
  text-align: center;
  border-radius: 24px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(8, 22, 15, 0.35);
  transition: transform 0.5s cubic-bezier(0.22, 1.2, 0.36, 1);
}

.modal.hidden .modal-card { transform: translateY(22px) scale(0.96); }

.win-crest { position: relative; width: 116px; height: 100px; margin: 0 auto; color: var(--gold); }
.win-crest svg { width: 100%; height: 100%; }

.win-emoji {
  position: absolute;
  inset: 2px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  font-variant-numeric: lining-nums;
  color: var(--ink);
}

.win-emoji.long { font-size: 23px; font-style: italic; }

.modal-card h2 {
  margin: 10px 0 2px;
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(36px, 11vw, 46px);
  line-height: 1.05;
}

.win-detail { margin: 0 0 16px; color: var(--ink-soft); font-size: 17.5px; font-style: italic; }
.win-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 22px; }

.pill { font-size: 10.5px; letter-spacing: 0.16em; color: var(--ink-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-accent { color: var(--gold); }

.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions .dock-btn-xl { grid-column: 1 / -1; }

/* ---------- Title card ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(90% 70% at 50% 45%, #1a5139 0%, #103626 60%, #0b261a 100%);
  transition: opacity 0.8s ease, visibility 0.8s;
}

.splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-logo { display: flex; flex-direction: column; align-items: center; text-align: center; color: #f1ead9; }
.splash-crest { width: clamp(104px, 28vw, 140px); color: #cdb06a; }
.splash-crest svg { width: 100%; height: auto; }

.splash-main {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(40px, 12vw, 64px);
  line-height: 1.08;
}

.splash-main i { color: #cdb06a; }

.splash-sub {
  margin-top: 16px;
  font-size: clamp(11px, 3vw, 13px);
  letter-spacing: 0.4em;
  margin-right: -0.4em;
  color: #cdb06a;
}

/* ---------- Phones (portrait) ---------- */
@media (max-width: 720px) and (orientation: portrait) {
  .drawer {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 88dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -20px 60px rgba(10, 25, 18, 0.3);
  }

  .drawer.hidden { transform: translateY(105%); }
  .drawer-header { padding-top: 24px; }
  .btn-lbl { display: none; }
  .icon-btn { padding: 0; }
  .brand-mark { display: none; }
  .stat { padding: 0 5px; }
  .stat-k { letter-spacing: 0.14em; margin-right: -0.14em; font-size: 10px; }
  .stat-course { flex: 2.4 1 0; }
  .stat-course .stat-v { font-size: 14px; line-height: 2.1; }
  .dock-controls .dock-btn { flex: 1 1 0; padding: 0 8px; }
}

@media (max-width: 380px) {
  .top-bar { padding-left: 12px; padding-right: 12px; }
  .action-cluster { gap: 6px; }
  .icon-btn { min-width: 38px; height: 38px; font-size: 16px; }
  .brand-title { font-size: 20px; }
  .stat { padding: 0 3px; }
  .stat-k { letter-spacing: 0.08em; margin-right: 0; font-size: 9.5px; }
  .stat-v { font-size: 22px; }
  .card-hand { --gap: 7px; }
  .bottom-dock { padding-left: 12px; padding-right: 12px; }
}

/* ---------- Wide screens: the scorecard centres in the header once the menu buttons clear it ---------- */
@media (min-width: 1100px) {
  .top-bar { position: relative; padding: 22px 30px 0; }
  .scoreboard { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 540px; }
  .btn-lbl { display: none; }
  .icon-btn { padding: 0; }
  .brand-title { font-size: 26px; }
  .brand-mark { font-size: 24px; }
  .stat-v { font-size: 27px; }
  .stat-course .stat-v { font-size: 19px; line-height: 1.62; }
  .card-hand { --cw-max: 96px; --gap: 14px; }
  .bottom-dock { padding-bottom: 28px; gap: 16px; }
  .fab { left: 30px; bottom: 20px; }
  .mobile-dir-pad { right: 30px; bottom: 20px; }
}

@media (min-width: 1500px) {
  .btn-lbl { display: inline; }
  .icon-btn { padding: 0 16px; }
  #btn-theme, #btn-mute { padding: 0; }
}

/* ---------- Phones (landscape): the hand becomes a side rail ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .app-shell { grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) auto; }
  .top-bar {
    position: static;
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  }
  .top-row { display: contents; }
  .brand { order: 1; }
  .brand-title { font-size: 19px; }
  .btn-lbl, .stat-course, .mobile-dir-pad { display: none; }
  .icon-btn { padding: 0; min-width: 38px; height: 38px; }
  .scoreboard { position: static; transform: none; order: 2; flex: 1 1 auto; width: auto; max-width: 400px; margin: 0 auto; padding: 4px; border-radius: 999px; }
  .stat { flex-direction: row; gap: 7px; padding: 0 6px; }
  .stat-k { letter-spacing: 0.1em; margin-right: 0; font-size: 10px; }
  .stat-v { font-size: 18px; }
  .action-cluster { order: 3; gap: 6px; }
  .stage-wrap { grid-row: 2; grid-column: 1; }
  .bottom-dock {
    grid-row: 2;
    grid-column: 2;
    width: 248px;
    flex-direction: column-reverse;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) 22px;
    background: linear-gradient(90deg, transparent 0%, var(--dock-fade) 26%);
  }
  .card-hand {
    --gap: 7px;
    --cw: calc((248px - 36px - 3 * var(--gap)) / 4 - 1px);
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    padding-top: 6px;
  }
  .golf-card.selected { transform: translateY(-4px); }
  @supports (width: 1cqw) {
    /* four across the rail's real content width, which shrinks with the safe-area inset on notched phones */
    .card-hand { --cw: calc((100cqw - 3 * var(--gap)) / 4 - 1px); }
  }
  .dock-controls { flex-wrap: wrap; gap: 6px; }
  .dock-controls .dock-btn { flex: 1 1 30%; min-height: 36px; padding: 0 6px; font-size: 10.5px; letter-spacing: 0.1em; }
  .stage-toast { top: 6px; }
}

/* Narrow landscape phones: no room for the wordmark beside the scorecard */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 740px) {
  .brand { display: none; }
  .scoreboard { margin: 0; max-width: none; }
  .stat { gap: 5px; padding: 0 5px; }
  .stat-k { font-size: 9.5px; letter-spacing: 0.04em; }
  .stat-v { font-size: 16px; }
  .action-cluster { gap: 5px; }
  .icon-btn { min-width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
