/* Woodson Range — landscape-first HUD over a full-bleed 3D range.
   Top: brand + R10 status (left), cameras (right). Bottom centre: Hit, kept just under the ball.
   Bottom right: compact readout with Session above it. Fly-out sheets: club & shot (left), session (right). */
:root {
  color-scheme: dark;
  --ink: #0d1b17;            /* spruce glass */
  --glass: rgba(13, 27, 23, 0.72);
  --glass-hi: rgba(26, 46, 39, 0.88);
  --line: rgba(214, 226, 205, 0.14);
  --bone: #f1eee3;
  --sage: #a3b59c;
  --flag: #f5c542;           /* range-flag yellow */
  --flag-ink: #2a2206;
  --left: #8fc3ff;
  --right: #ffad7a;
  --f-data: "Saira Semi Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body { margin: 0; background: #0d1b17; color: var(--bone); font-family: var(--f-body); overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2); }
.lbl { font-family: var(--f-data); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sage); font-weight: 500; }
.num { font-family: var(--f-data); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- top bar ---------- */
#top { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
.brand { padding: 5px 10px 6px; display: flex; flex-direction: column; gap: 1px; }
.brand b { font-family: var(--f-data); font-weight: 700; font-size: 14px; letter-spacing: 0.08em; line-height: 1.1; text-transform: uppercase; }
.brand .status { font-size: 11px; color: var(--sage); }
.tools { display: flex; gap: 2px; align-items: center; padding: 3px; }
.seg { display: flex; gap: 2px; }
.tbtn { appearance: none; border: 0; background: transparent; padding: 6px 9px; border-radius: 7px; cursor: pointer; font-family: var(--f-data); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sage); white-space: nowrap; }
.tbtn:hover { color: var(--bone); background: rgba(255,255,255,0.06); }
.tbtn[aria-pressed="true"] { background: var(--bone); color: var(--ink); }

/* ---------- readout (bottom right) ---------- */
#rightDock { position: fixed; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); width: 236px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; z-index: 5; }
#readout { padding: 8px 10px 9px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.carryRow { display: flex; align-items: flex-end; gap: 8px; }
.carryNum { font-size: 34px; line-height: 0.85; letter-spacing: -0.01em; }
.carryNum small { font-size: 13px; color: var(--sage); font-weight: 500; margin-left: 2px; }
.carryMeta { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-bottom: 1px; }
.carryMeta .clubName { font-family: var(--f-data); font-size: 12px; color: var(--flag); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src { font-size: 9.5px; letter-spacing: 0.12em; color: var(--sage); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 3px; vertical-align: 1px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.m { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.m .num { font-size: 15px; line-height: 1.1; white-space: nowrap; }
.m .num small { font-size: 10px; color: var(--sage); font-weight: 500; margin-left: 1px; }
.L { color: var(--left); } .R { color: var(--right); }
.carryRow .more { margin-left: auto; align-self: center; font-size: 22px; line-height: 1; color: var(--sage); padding-left: 4px; }
#readout:hover .more { color: var(--flag); }

/* ---------- chips + hit ---------- */
.chip { appearance: none; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 10px; cursor: pointer; color: var(--bone); font-family: var(--f-data); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 4px 12px; min-height: 52px; min-width: 56px; }
.chip b { font-size: 18px; font-weight: 700; line-height: 1; color: var(--flag); }
.chip span { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sage); }
.chip:hover { background: var(--glass-hi); }
.chip[aria-expanded="true"] { border-color: var(--flag); }
.chip.wide { flex-direction: row; justify-content: space-between; min-height: 34px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; padding: 0 10px; }
.chip.wide .count { font-size: 11px; letter-spacing: 0.06em; text-transform: none; }
/* bottom-left controls: the ball owns the bottom centre */
#hitbar { position: fixed; left: max(12px, env(safe-area-inset-left, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); display: flex; gap: 8px; align-items: stretch; z-index: 5; }
#hit { appearance: none; border: 0; border-radius: 12px; min-height: 52px; min-width: 140px; padding: 0 22px; background: var(--flag); color: var(--flag-ink); cursor: pointer; font-family: var(--f-data); font-weight: 700; font-size: 18px; letter-spacing: 0.18em; text-transform: uppercase; box-shadow: 0 6px 20px rgba(0,0,0,0.35); transition: transform .08s ease, opacity .2s ease; }
#hit:active { transform: translateY(1px) scale(0.98); }
#hit[disabled] { opacity: 0.35; cursor: default; }

/* ---------- fly-out sheets ---------- */
.sheet { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 52px); bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); overflow-y: auto; padding: 10px 14px 14px; z-index: 8; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; overscroll-behavior: contain; }
.sheet.left { left: max(12px, env(safe-area-inset-left, 0px)); width: min(320px, 44vw); }
.sheet.right { right: max(12px, env(safe-area-inset-right, 0px)); width: min(700px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)), 72vw); }
.sheet h2 { margin: 0; font-family: var(--f-data); font-weight: 600; font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; position: sticky; top: -10px; padding-top: 2px; }
.sheet .x { appearance: none; border: 0; background: transparent; color: var(--sage); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; }
.group { display: flex; flex-direction: column; gap: 9px; }
.group + .group { border-top: 1px solid var(--line); padding-top: 12px; }
.row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: baseline; gap: 2px 8px; font-size: 13.5px; }
.row output { font-family: var(--f-data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--flag); margin: 2px 0 0; }
.row select { grid-column: 1 / -1; background: rgba(0,0,0,0.25); color: var(--bone); border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px; font-family: var(--f-data); font-size: 14px; }
.note { font-size: 12px; color: var(--sage); line-height: 1.4; margin: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--flag); flex: none; }
.swatches { display: flex; gap: 8px; }
.sw { appearance: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.sw[aria-pressed="true"] { border-color: var(--bone); box-shadow: 0 0 0 2px var(--ink) inset; }
.ghost { appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,0.04); border-radius: 9px; padding: 0 14px; min-height: 38px; cursor: pointer; font-family: var(--f-data); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bone); }
.ghost:hover { background: rgba(255,255,255,0.09); }
.clubs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.club { appearance: none; border: 1px solid var(--line); padding: 9px 0; border-radius: 8px; background: rgba(255,255,255,0.03); cursor: pointer; font-family: var(--f-data); font-weight: 600; font-size: 15px; color: var(--bone); }
.club:hover { background: rgba(255,255,255,0.08); }
.club[aria-pressed="true"] { background: var(--flag); border-color: var(--flag); color: var(--flag-ink); }

/* shot detail sheet: header numbers, then club / launch / spin cards with illustrations */
.sheet.center { left: 50%; transform: translateX(-50%); width: min(880px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); gap: 10px; }
.dNav { display: flex; align-items: center; gap: 4px; }
.navb { appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--bone); border-radius: 7px; width: 32px; height: 28px; font-size: 18px; line-height: 1; cursor: pointer; }
.navb:disabled { opacity: 0.3; cursor: default; }
.dHead { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; padding-bottom: 2px; }
.dBig { display: flex; align-items: baseline; gap: 4px; }
.dBig .num { font-size: 34px; line-height: 0.9; }
.dBig small { font-family: var(--f-data); font-size: 12px; color: var(--sage); letter-spacing: 0.04em; }
.dSmall { display: flex; gap: 16px; }
.dShape { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.dShape b { font-family: var(--f-data); font-size: 18px; font-weight: 700; color: var(--flag); letter-spacing: 0.04em; line-height: 1; }
.dShape span { font-family: var(--f-data); font-size: 11.5px; color: var(--sage); letter-spacing: 0.06em; text-transform: uppercase; }
.dGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dCard { background: rgba(0,0,0,0.18); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dCard h3 { margin: 0; font-family: var(--f-data); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sage); }
.dCard .note { font-size: 11px; }
.dMetrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; }
.dm { display: flex; flex-direction: column; min-width: 0; }
.dm .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm .num { font-size: 15px; line-height: 1.15; white-space: nowrap; }
.dm .num small { font-size: 10px; color: var(--sage); font-weight: 500; margin-left: 1px; }
.dm em { font-style: normal; font-size: 10.5px; font-weight: 500; color: var(--sage); margin-left: 2px; letter-spacing: 0.04em; text-transform: uppercase; }
.dm em.L { color: var(--left); } .dm em.R { color: var(--right); }
.estMark { font-style: normal; color: var(--sage); margin-right: 1px; }
.dIll { width: 100%; height: auto; max-height: 112px; display: block; overflow: visible; }
.dIll text { font-family: var(--f-data); font-size: 9.5px; fill: var(--sage); letter-spacing: 0.04em; }
.dIll .val { fill: var(--bone); font-weight: 600; font-size: 10.5px; }
.dIll .tgt { stroke: rgba(241,238,227,0.35); stroke-width: 1; stroke-dasharray: 3 4; }
.dIll .ground { stroke: rgba(241,238,227,0.3); stroke-width: 1; }
.dIll .path { stroke: var(--left); stroke-width: 2.5; stroke-linecap: round; }
.dIll .pathHead { fill: var(--left); }
.dIll .face { stroke: var(--flag); stroke-width: 4; stroke-linecap: round; }
.dIll .ballLine { fill: none; stroke: var(--bone); stroke-width: 1.5; stroke-dasharray: 2 3; }
.dIll .ballHead { fill: var(--bone); }
.dIll .ball { fill: #ffffff; stroke: rgba(0,0,0,0.4); stroke-width: 0.8; }
.dIll .traj { fill: none; stroke: var(--flag); stroke-width: 2; stroke-linejoin: round; }
.dIll .launchLine { stroke: var(--bone); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.dIll .apexDot { fill: var(--flag); }
.dIll .ballBig { fill: #f4f2ec; }
.dIll .dimples circle { fill: rgba(13,27,23,0.09); }
.dIll .axis { stroke: var(--right); stroke-width: 2.5; stroke-linecap: round; }
.dIll .spinRing { fill: none; stroke: var(--left); stroke-width: 1.8; }
.dIll .ringHead { fill: var(--left); }
.dIll .comp { stroke: var(--bone); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: 0.75; }
.dIll .legend text { font-size: 9.5px; fill: var(--sage); }
.dIll .lgPath { fill: var(--left); } .dIll .lgFace { fill: var(--flag); } .dIll .lgBall { fill: var(--bone); }
button.shot { appearance: none; background: transparent; border: 0; border-top: 1px solid var(--line); color: inherit; width: 100%; text-align: left; cursor: pointer; }
button.shot:hover { background: rgba(255,255,255,0.05); }

/* session sheet: map on the left, numbers on the right */
.sessionBody { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; min-height: 0; flex: 1; }
#disp { width: 100%; height: 100%; min-height: 200px; display: block; border-radius: 8px; background: rgba(0,0,0,0.18); }
.sessionSide { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
table.gap { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.gap th { text-align: right; font-family: var(--f-data); font-weight: 500; font-size: 10.5px; letter-spacing: 0.1em; color: var(--sage); text-transform: uppercase; padding: 0 0 5px; }
table.gap th:first-child, table.gap td:first-child { text-align: left; }
table.gap td { text-align: right; font-family: var(--f-data); font-size: 14px; padding: 4px 0; border-top: 1px solid var(--line); }
table.gap td:first-child { color: var(--flag); font-weight: 600; }
.shots { display: flex; flex-direction: column; }
.shot { display: grid; grid-template-columns: 2.2em 2.6em minmax(0,1fr) auto auto; gap: 8px; align-items: baseline; padding: 5px 0; border-top: 1px solid var(--line); font-family: var(--f-data); font-variant-numeric: tabular-nums; font-size: 14px; }
.shot .n { color: var(--sage); font-size: 12px; }
.shot .c { color: var(--flag); font-weight: 600; }
.empty { font-size: 13px; color: var(--sage); margin: 0; }

.soundRow { appearance: none; width: 100%; background: transparent; border: 0; padding: 4px 0; color: var(--bone); }
.tog { width: 36px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.18); position: relative; flex: none; transition: background .15s ease; }
.tog::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--bone); transition: transform .15s ease; }
.soundRow[aria-pressed="true"] .tog { background: var(--flag); }
.soundRow[aria-pressed="true"] .tog::after { transform: translateX(16px); background: var(--flag-ink); }

/* ---------- world-anchored labels, toast ---------- */
.tag { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: none; z-index: 3; font-family: var(--f-data); font-weight: 600; font-size: 12px; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 5px; background: rgba(13,27,23,0.78); color: var(--bone); white-space: nowrap; border: 1px solid var(--line); }
.tag::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 1px; height: 6px; background: rgba(241,238,227,0.7); }
.tag b { color: var(--flag); font-weight: 700; }
.tag-apex { background: rgba(13,27,23,0.55); font-size: 11px; }
.tag-apex::after { display: none; }
#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 54px); transform: translateX(-50%); padding: 6px 12px; font-size: 13px; z-index: 7; opacity: 0; transition: opacity .25s ease; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; }

/* ---------- bigger screens (desktop, tablets) ---------- */
@media (min-height: 560px) and (min-width: 900px) {
  .brand b { font-size: 17px; }
  .brand .status { font-size: 12px; }
  .tbtn { font-size: 13px; padding: 7px 10px; }
  #rightDock { width: 300px; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  #readout { padding: 12px 14px; gap: 8px; }
  .carryNum { font-size: 48px; }
  .carryNum small { font-size: 16px; }
  .m .num { font-size: 19px; }
  .lbl { font-size: 11px; }
  #hit { min-height: 54px; min-width: 170px; font-size: 21px; }
  .chip { min-height: 54px; }
  .chip.wide { min-height: 40px; }
  .sheet { top: calc(env(safe-area-inset-top, 0px) + 64px); }
}

/* ---------- small landscape phones ---------- */
@media (max-width: 760px) and (orientation: landscape) {
  #rightDock { width: 188px; }
  .carryNum { font-size: 28px; }
  .m .num { font-size: 14px; }
  #hit { min-width: 112px; padding: 0 16px; font-size: 17px; }
  .tbtn { padding: 6px 7px; font-size: 11px; }
  .tools .menu-link .mlong { display: none; } .tools .menu-link .mshort { display: inline; }
}

@media (max-height: 420px) {
  .dBig .num { font-size: 28px; }
  .dIll { max-height: 92px; }
  .dCard { padding: 6px 8px 8px; gap: 4px; }
  .dm .num { font-size: 14px; }
}
/* ---------- portrait phones: it still works, with a nudge to rotate ---------- */
@media (orientation: portrait) {
  #rightDock { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; top: calc(env(safe-area-inset-top, 0px) + 96px); bottom: auto; flex-direction: column-reverse; }
  #top { flex-direction: column; align-items: stretch; gap: 6px; }
  .tools { justify-content: space-between; }
  .sheet.left, .sheet.right { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; top: 30%; }
  .sessionBody { grid-template-columns: minmax(0, 1fr); }
  .dGrid { grid-template-columns: minmax(0, 1fr); }
  .sheet.center { top: calc(env(safe-area-inset-top, 0px) + 96px); }
  #disp { height: 300px; }
}
#rotate { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(300px, calc(100% - 32px)); z-index: 30; padding: 18px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
#rotate b { font-family: var(--f-data); font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase; }
#rotate span { font-size: 13.5px; color: var(--sage); line-height: 1.45; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.m .lbl { white-space: nowrap; }
