/* Leonay GPS Caddie — V2 3D · pure-black sunlight theme */
:root {
  color-scheme: dark;
  --c90: #34d399;
  --c110: #fbbf24;
  --c130: #60a5fa;
  --glass: rgba(10, 12, 14, 0.78);
  --stroke: rgba(255, 255, 255, 0.10);
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.hidden { display: none !important; }
button { font-family: inherit; }

#app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- 3D stage ---------- */
#stage { position: relative; flex: 1 1 auto; min-height: 0; background: #000; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#stage::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 130px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
  pointer-events: none; z-index: 2;
}

/* floating 3D labels (ring / arc tags) */
#labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.lbl {
  position: absolute; left: 0; top: 0; will-change: transform;
  font-size: 11px; font-weight: 800; letter-spacing: .04em; white-space: nowrap;
  background: rgba(0, 0, 0, 0.62); border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px; padding: 2px 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

/* loading veil */
#veil {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--muted);
}

/* WebGL failure panel */
#glFail {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.72); padding: 24px;
}
#glFail .gfbox {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 18px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: 24px 20px; text-align: center; max-width: 340px;
}
#glFail .msg { font-size: 14px; line-height: 1.5; color: var(--muted); }
#glFail a.big { display: block; text-decoration: none; text-align: center; }

/* ---------- top bar ---------- */
#topBar {
  position: absolute; z-index: 4;
  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; flex-direction: column; gap: 7px;
}
#holePill {
  display: flex; align-items: stretch; gap: 2px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.55);
  height: 50px; padding: 2px;
}
#holePill button {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  font: 800 28px/1 -apple-system, BlinkMacSystemFont, sans-serif;
  min-width: 50px; border-radius: 13px;
}
#holePill button:active { background: rgba(255,255,255,.12); }
#holeLabel {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 17px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
#holeLabel .sep { color: var(--faint); font-weight: 400; }
#holeLen { color: var(--muted); font-weight: 700; }
#autoBtn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font: 700 11px/1 -apple-system, BlinkMacSystemFont, sans-serif !important;
  letter-spacing: .08em; color: var(--muted) !important;
  min-width: 56px !important;
  border: 1px solid transparent !important;
}
.autodot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.28); }
#autoBtn.on { color: #7ef0b0 !important; }
#autoBtn.on .autodot { background: #34d399; box-shadow: 0 0 8px rgba(52,211,153,.9); }

/* ---------- hole strip (1–18 dots) ---------- */
#holeStrip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 4px; height: 22px;
}
#holeStrip button {
  flex: 1 1 0; height: 22px; border: 0; background: transparent; cursor: pointer;
  position: relative; min-width: 0; padding: 0;
}
#holeStrip button::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,.30);
  box-shadow: 0 0 4px rgba(0,0,0,.9);
  transition: transform .18s, background .18s;
}
#holeStrip button.cur::after {
  background: #34d399; transform: translate(-50%, -50%) scale(1.9);
  box-shadow: 0 0 8px rgba(52,211,153,.8);
}

/* ---------- sim banner + toast ---------- */
#simBanner {
  position: absolute; z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 148px);
  left: 0; right: 0;
  background: rgba(245, 158, 11, .94);
  color: #000; text-align: center;
  font-size: 13px; font-weight: 800; letter-spacing: .06em;
  padding: 8px 12px;
}
#toast {
  position: absolute; z-index: 5; left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 100px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: rgba(8, 10, 12, .92); border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 10px 12px 10px 18px;
  box-shadow: 0 8px 28px rgba(0,0,0,.6);
  font-size: 14px; font-weight: 700; white-space: nowrap;
  animation: toastIn .22s ease-out;
}
#simBanner:not(.hidden) ~ #toast { top: calc(env(safe-area-inset-top, 0px) + 140px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }
#toastUndo {
  border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(52,211,153,.16); color: #7ef0b0;
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
  padding: 8px 14px; min-height: 34px;
}

/* ---------- right rail ---------- */
#rail {
  position: absolute; z-index: 4; right: max(10px, env(safe-area-inset-right, 0px));
  top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
}
#rail button {
  width: 46px; height: 46px; border-radius: 15px; cursor: pointer;
  border: 1px solid var(--stroke);
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: #fff; font-size: 24px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
#rail button:active { background: rgba(255,255,255,.16); }
#recenterBtn { font-size: 26px; }
#rail button.txt { font-size: 12px; font-weight: 800; letter-spacing: .06em; }
#flyBtn { color: #7ef0b0 !important; }
#flyBtn.on { background: rgba(52,211,153,.2) !important; border-color: rgba(52,211,153,.5) !important; }

/* ---------- bottom panel ---------- */
#panel {
  flex: 0 0 auto; z-index: 4;
  background: linear-gradient(180deg, rgba(13,15,17,.94), rgba(6,7,8,.99));
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--stroke);
  border-radius: 18px 18px 0 0;
  margin-top: -18px;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 10px);
  text-align: center;
}
#panel > div { display: none; }
#panel[data-mode="gate"]    #gate    { display: flex; }
#panel[data-mode="denied"]  #denied  { display: flex; }
#panel[data-mode="waiting"] #waiting { display: flex; }
#panel[data-mode="read"]    #readout { display: block; }

/* gate boxes */
.gatebox { flex-direction: column; align-items: center; gap: 10px; padding: 8px 4px 6px; }
.brand { font-size: 12px; font-weight: 800; letter-spacing: .3em; color: #8fd6a0; }
.brand.warn { color: #fbbf24; }
.gatebox .msg, .gfbox .msg { font-size: 15px; line-height: 1.45; color: var(--muted); max-width: 36ch; }
.gatebox .msg b { color: #fff; }
button.big, a.big {
  width: 100%; max-width: 320px; padding: 16px;
  border: 0; border-radius: 14px; cursor: pointer;
  background: #1f7a3d; color: #fff;
  font-size: 18px; font-weight: 800; letter-spacing: .01em;
  box-shadow: 0 4px 18px rgba(31,122,61,.4);
}
button.big:active, a.big:active { background: #2a9c50; }
.privacy { font-size: 12px; color: var(--faint); }
.linkbtn {
  border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  padding: 8px 16px;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- readout ---------- */
sup { font-size: .62em; font-weight: 800; vertical-align: super; margin-left: 3px; }
sup.up { color: #fbbf24; }
sup.dn { color: #60a5fa; }

#targetRow {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 15px; min-height: 28px; margin-bottom: 1px;
}
#targetRow .tlab { font-size: 10px; font-weight: 800; letter-spacing: .18em; color: var(--faint); }
#targetRow .tnum { font-size: 19px; font-weight: 800; color: #fff; }
#targetRow sup { font-size: 12px; }
#targetRow .tarrow { color: var(--faint); font-size: 14px; margin: 0 2px; }
#targetRow.idle { opacity: .35; }
.tclub {
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(52,211,153,.16); color: #7ef0b0; margin-left: 4px;
}
.tclear {
  border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.10); color: var(--muted);
  width: 26px; height: 26px; font-size: 12px; line-height: 1; margin-left: 2px;
}

#heroLabel { font-size: 11px; font-weight: 800; letter-spacing: .34em; color: var(--faint); }
#hero { line-height: 0.95; margin: 0; white-space: nowrap; }
#heroNum { font-size: 72px; font-weight: 800; letter-spacing: -0.02em; color: #fff; transition: opacity .3s; }
#heroPl { font-size: 24px; font-weight: 800; vertical-align: 38px; margin-left: 6px; color: var(--muted); }
#heroPl.up { color: #fbbf24; }
#heroPl.dn { color: #60a5fa; }
#readout.stale #heroNum { opacity: .45; }
#readout.attack #heroLabel::after { content: " · ATTACK"; color: #34d399; letter-spacing: .2em; }
#acc { font-size: 12px; color: var(--faint); font-weight: 600; margin-top: 1px; min-height: 15px; }
#acc.poor { color: #fbbf24; }

#fcb {
  display: flex; justify-content: center; gap: 8px; margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,.07); padding-top: 6px;
}
#fcb .fcbi { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; }
#fcb .flab { font-size: 9px; font-weight: 800; letter-spacing: .22em; color: var(--faint); }
#fcb b { color: #e8edf2; font-size: 23px; font-weight: 800; line-height: 1.1; }
#fcb .fcbi.on b { color: #fff; font-size: 28px; }
#fcb sup { font-size: 11px; }

/* ---------- bag strip ---------- */
#bagStrip {
  display: flex; gap: 8px; margin-top: 8px; padding: 2px 2px 4px;
  overflow-x: auto; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
#bagStrip::-webkit-scrollbar { display: none; }
.clubchip {
  position: relative; flex: 0 0 auto; min-width: 86px;
  scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 12px 7px; border-radius: 13px;
  border: 1px solid var(--stroke); background: rgba(255,255,255,.05);
  color: #fff; cursor: pointer;
  transition: border-color .2s, background .2s, opacity .2s;
}
.clubchip:active { background: rgba(255,255,255,.12); }
.clubchip .cname { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.clubchip .ccarry { font-size: 19px; font-weight: 800; }
.clubchip .chit { font-size: 11px; font-weight: 700; color: var(--muted); min-height: 14px; white-space: nowrap; }
.clubchip .chit b { color: #fff; font-size: 13px; }
.clubchip.reach { border-color: rgba(52,211,153,.55); background: rgba(52,211,153,.10); }
.clubchip.long  { border-color: rgba(251,191,36,.40); background: rgba(251,191,36,.07); }
.clubchip.short { opacity: .38; }
.clubchip.sel   { border-color: rgba(255,255,255,.75); box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.ringIco {
  position: absolute; top: 5px; right: 5px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
}
.clubchip.ring-on .ringIco { border-color: var(--cc, #fff); box-shadow: 0 0 7px var(--cc, #fff); }

#hint { font-size: 11px; color: var(--faint); margin-top: 6px; }

@media (max-height: 760px) {
  #heroNum { font-size: 56px; }
  #heroPl { font-size: 19px; vertical-align: 28px; }
  #fcb b { font-size: 19px; }
  #fcb .fcbi.on b { font-size: 23px; }
  #fcb { margin-top: 4px; padding-top: 4px; }
  #bagStrip { margin-top: 5px; }
  .clubchip { padding: 6px 10px 5px; min-width: 80px; }
  .clubchip .ccarry { font-size: 17px; }
}

/* ---------- scorecard HUD bits ---------- */
#holePar { font-weight: 800; color: #fff; }
#holeSi { color: var(--muted); font-weight: 700; font-size: 13px; }

/* ---------- shot pill: club · verdict · plays-like ---------- */
#shotPill {
  position: absolute; z-index: 3; left: 50%; bottom: 14px;
  transform: translateX(-50%);
  min-width: 210px; max-width: calc(100% - 88px);
  text-align: center; pointer-events: none;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 8px 16px 7px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
#spTop { display: flex; gap: 10px; align-items: baseline; justify-content: center; white-space: nowrap; }
#spClub { font-size: 13px; font-weight: 800; letter-spacing: .04em; color: var(--muted); }
#spVerdict { font-size: 16px; font-weight: 900; letter-spacing: .05em; }
#spSub { margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
#shotPill.v-clear #spVerdict { color: #34d399; text-shadow: 0 0 12px rgba(52,211,153,.5); }
#shotPill.v-tight #spVerdict { color: #fbbf24; text-shadow: 0 0 12px rgba(251,191,36,.5); }
#shotPill.v-blocked #spVerdict { color: #f87171; text-shadow: 0 0 12px rgba(248,113,113,.55); }
#shotPill.v-blocked { border-color: rgba(248,113,113,.4); }

/* ---------- plan chip: playing from a tapped point ---------- */
#planChip {
  position: absolute; z-index: 3; left: 10px;
  top: calc(env(safe-area-inset-top, 0px) + 148px);
  display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid rgba(255,255,255,.22); border-radius: 999px;
  padding: 6px 6px 6px 12px;
  font-size: 11px; font-weight: 800; letter-spacing: .07em; color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#planChip button {
  border: 0; border-radius: 50%; width: 24px; height: 24px; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 12px; font-weight: 800;
}
#planChip button:active { background: rgba(255,255,255,.3); }

/* sim banner visible -> plan chip drops below it */
#simBanner:not(.hidden) ~ #planChip { top: calc(env(safe-area-inset-top, 0px) + 196px); }

/* ---------- live GPS chip ---------- */
#gpsChip {
  position: absolute; z-index: 3; left: 10px;
  top: calc(env(safe-area-inset-top, 0px) + 152px);
  display: flex; align-items: center; gap: 6px;
  background: var(--glass); border: 1px solid rgba(52,211,153,.35); border-radius: 999px;
  padding: 4px 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; color: #7ef0b0;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  pointer-events: none;
}
.livedot {
  width: 7px; height: 7px; border-radius: 50%; background: #34d399;
  box-shadow: 0 0 8px rgba(52,211,153,.9);
  animation: livepulse 1.6s ease-in-out infinite;
}
@keyframes livepulse { 50% { opacity: .35; } }
/* live chip present -> plan chip drops below it */
#gpsChip:not(.hidden) ~ #planChip { top: calc(env(safe-area-inset-top, 0px) + 190px); }

/* ---------- sim banner: USE MY GPS action ---------- */
#simBanner { display: flex; align-items: center; justify-content: center; gap: 12px; }
#simBanner.hidden { display: none; }
#useGpsBtn {
  border: 0; border-radius: 999px; cursor: pointer;
  background: #000; color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  padding: 5px 12px; white-space: nowrap;
}
#useGpsBtn:active { background: #222; }

/* ---------- locate button: eye-view mode ---------- */
#rail button.on { color: #7ef0b0; border-color: rgba(52,211,153,.5); box-shadow: 0 0 10px rgba(52,211,153,.35); }

/* ---------- collapse to map-dominant mode ---------- */
#collapseBtn {
  display: block; width: 100%; height: 20px; margin: -4px 0 0;
  border: 0; background: transparent; cursor: pointer; position: relative;
}
.chev {
  display: inline-block; width: 10px; height: 10px;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint);
  transform: rotate(45deg) translateY(-2px);   /* points down = collapse */
}
.chev.up { transform: rotate(-135deg) translateY(-1px); }
#collapseBtn .chev { position: absolute; left: 50%; top: 2px; margin-left: -5px; }
#collapseBtn:active .chev { border-color: #fff; }

#miniPill {
  display: none; width: 100%;
  align-items: center; justify-content: center; gap: 10px;
  border: 0; border-top: 1px solid var(--stroke); cursor: pointer;
  background: var(--glass); color: #fff;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  font-family: inherit; font-variant-numeric: tabular-nums;
}
#miniPill #miniTo { font-size: 26px; font-weight: 900; line-height: 1; }
#miniPill .munit { font-size: 13px; font-weight: 700; color: var(--muted); margin-left: -6px; }
#miniPill #miniClub { font-size: 13px; font-weight: 800; letter-spacing: .04em; color: var(--muted); }
.mdot { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.25); }
.mdot.clear { background: #34d399; box-shadow: 0 0 9px rgba(52,211,153,.8); }
.mdot.tight { background: #fbbf24; box-shadow: 0 0 9px rgba(251,191,36,.8); }
.mdot.blocked { background: #f87171; box-shadow: 0 0 9px rgba(248,113,113,.8); }

#panel.collapsed[data-mode="read"] #readout { display: none; }
#panel.collapsed[data-mode="read"] #miniPill { display: flex; }
