/* Ropeside — mobile-first (iPhone-primary). Desktop enhances at the bottom. */
:root {
  --bg: #F1F4EF;
  --surface: #FFFFFF;
  --surface-2: #E9EFE8;
  --ink: #16201A;
  --muted: #5A655D;
  --green: #2F6B4F;
  --green-deep: #173E2C;
  --green-soft: #DCEADF;
  --line: #D6DFD6;
  --flag: #C2452D;
  --gold: #8A6A1F;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font-family: inherit; }

/* ---------- sticky app bar (header + hole strip) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--green-deep);
  box-shadow: 0 2px 14px rgba(0,0,0,0.18);
}
.topbar {
  display: flex; align-items: center; gap: 11px;
  padding: calc(10px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal));
  color: #EAF2EA;
}
.brand-mark { width: 30px; height: 30px; display: block; border-radius: 7px; flex: none; }
.brand-text { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 900; letter-spacing: 0.02em; }
.topbar .sub {
  margin: 0; font-size: 11px; opacity: 0.72; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em;
}
.player-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: rgba(255,255,255,0.12); color: #EAF2EA;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 700; cursor: pointer;
  max-width: 46vw;
}
.player-btn:active { background: rgba(255,255,255,0.22); }
.pb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-caret { font-size: 10px; opacity: 0.8; }

.hole-strip {
  display: flex; gap: 7px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 0 calc(12px + var(--sar)) 10px calc(12px + var(--sal));
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hole-strip::-webkit-scrollbar { display: none; }
.hole-chip {
  position: relative; flex: none; scroll-snap-align: center;
  border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.06);
  border-radius: 11px; padding: 6px 0; width: 50px; cursor: pointer;
  text-align: center; color: #DCE7DD; transition: background .12s, transform .08s;
}
.hole-chip:active { transform: scale(0.95); }
.hole-chip.locked { opacity: 0.62; }
.hole-chip.locked::after {
  content: "🔒"; position: absolute; top: 2px; right: 4px; font-size: 8px; opacity: 0.85;
}
.hole-chip.active {
  background: #EAF2EA; color: var(--green-deep); border-color: #EAF2EA;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}
.hole-chip .n { display: block; font-weight: 900; font-size: 16px; line-height: 1.05; }
.hole-chip .p { display: block; font-size: 9px; opacity: 0.8; font-family: var(--mono); margin-top: 1px; }

/* ---------- main column ---------- */
.main {
  max-width: 620px; margin: 0 auto;
  padding: 14px calc(16px + var(--sar)) calc(28px + var(--sab)) calc(16px + var(--sal));
  display: flex; flex-direction: column; gap: 14px;
}

.hole-head { display: flex; align-items: baseline; gap: 10px; }
.hole-num { font-size: 40px; font-weight: 900; letter-spacing: -0.02em; line-height: 0.9; }
.hole-meta { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- canvas hero ---------- */
.canvas-wrap {
  position: relative; background: var(--green-deep);
  border-radius: 16px; overflow: hidden; line-height: 0;
  box-shadow: 0 6px 22px rgba(22,32,26,0.18);
}
#hole-canvas { display: block; margin: 0 auto; touch-action: manipulation; }
.tooltip {
  position: absolute; pointer-events: none; background: rgba(12,22,16,0.94);
  color: #EAF2EA; padding: 7px 10px; border-radius: 9px; font-size: 12px;
  line-height: 1.5; white-space: nowrap; z-index: 5; font-family: var(--mono);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3); max-width: 80%;
}
.canvas-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(12,22,16,0.6); color: #DCE7DD; font-size: 11px;
  padding: 4px 11px; border-radius: 999px; line-height: 1.4;
  transition: opacity .4s; pointer-events: none; letter-spacing: 0.01em;
}
.canvas-hint.gone { opacity: 0; }

/* ---------- stand-here cards ---------- */
.stand-here { display: flex; flex-direction: column; gap: 9px; }
.spot {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 5px solid var(--flag); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(22,32,26,0.05);
}
.spot.backup { border-left-color: var(--gold); }
.spot.empty { border-left-color: var(--muted); }
.spot .t {
  font-weight: 900; font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--green-deep);
}
.spot .d { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.spot .d b { color: var(--ink); font-family: var(--mono); font-weight: 600; }

/* ---------- hole-1 unlock teaser ---------- */
.unlock-cta {
  position: fixed; z-index: 60; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 596px; margin: 0 auto;
  overflow: hidden; text-align: left;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--green-deep); color: #fff; border: 0; border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 8px 26px rgba(11,28,20,0.42);
  animation: uc-rise .35s ease both;
}
.unlock-cta[hidden] { display: none; }
/* reserve space so the fixed bar never hides the controls beneath it */
body.has-cta .main { padding-bottom: 96px; }
.unlock-cta:active { transform: scale(0.985); }
.uc-glow {
  position: absolute; top: -40%; right: -10%; width: 55%; height: 180%;
  background: radial-gradient(closest-side, rgba(194,69,45,0.55), transparent 70%);
  filter: blur(4px); pointer-events: none;
}
.uc-body { position: relative; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.uc-eyebrow {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold-lite, #F5C33B); font-family: var(--mono);
}
.uc-eyebrow b { color: #fff; }
.uc-title { font-size: 15px; font-weight: 900; line-height: 1.2; letter-spacing: -0.01em; }
.uc-sub { font-size: 12px; opacity: 0.82; margin-top: 1px; }
.uc-arrow {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--flag); color: #fff; font-size: 18px; font-weight: 900;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(194,69,45,0.5);
  animation: uc-nudge 1.6s ease-in-out infinite;
}
@keyframes uc-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes uc-nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(3px); } }

/* ---------- quick controls ---------- */
.quick { display: flex; gap: 10px; align-items: stretch; }
.seg-group {
  display: flex; flex: 1; background: var(--surface-2); border-radius: 11px;
  padding: 3px; gap: 3px; border: 1px solid var(--line);
}
.seg {
  flex: 1; border: 0; background: none; border-radius: 8px; cursor: pointer;
  padding: 9px 4px; font-size: 13.5px; font-weight: 700; color: var(--muted);
}
.seg.active { background: var(--green-deep); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.opt-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 0 15px; font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.opt-btn.active { background: var(--green-soft); border-color: var(--green); }
.opt-gear { font-size: 14px; }

/* ---------- options (collapsible) ---------- */
.options {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 13px;
}
.options[hidden] { display: none; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt-row.slider { display: grid; grid-template-columns: 1fr; gap: 6px; }
.opt-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  font-size: 13px; font-weight: 700; transition: background .12s;
}
.chip input:checked + span {
  background: var(--green-deep); color: #fff; border-color: var(--green-deep);
}
.chip input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.opt-row.slider input[type="range"] { width: 100%; accent-color: var(--green); height: 26px; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 13.5px;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 13px; font-weight: 500; }

/* ---------- legend + note ---------- */
.legend { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.legend-title { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.ramp {
  display: block; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, rgba(245,195,59,0) 0%, #F5C33B 30%, #E07030 62%, #C2452D 88%, #8E2A1A 100%);
}
.legend-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.legend-ends em { font-style: normal; }
.note { font-size: 11px; color: var(--muted); margin: 0; text-align: center; }

/* ---------- player bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(12,22,16,0.5); z-index: 40;
  opacity: 0; transition: opacity .24s;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  max-height: 82vh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.28);
}
.sheet.show { transform: translateY(0); }
.sheet-grab { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-title { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sheet-close {
  border: 0; background: var(--surface-2); color: var(--ink); border-radius: 999px;
  width: 32px; height: 32px; font-size: 14px; cursor: pointer;
}
#player-search {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  font: inherit; font-size: 16px; margin-bottom: 10px; background: var(--bg); color: var(--ink);
}
#player-search:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.player-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.player-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 8px;
  border: 0; background: none; font: inherit; text-align: left;
  border-radius: 9px; cursor: pointer; color: var(--ink); width: 100%;
  border-bottom: 1px solid var(--surface-2);
}
.player-row:active { background: var(--surface-2); }
.player-row.selected { background: var(--green-soft); font-weight: 800; }
.player-row .pos { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 26px; flex: none; }
.player-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.badge {
  flex: none; font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase;
  background: var(--green); color: #fff;
}
.badge.owgr { background: var(--gold); }
.badge.score { background: none; color: var(--muted); font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 0; letter-spacing: 0; text-transform: none; }

.profile-body { font-size: 13px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.profile-body:empty { display: none; }
.profile-body table { width: 100%; border-collapse: collapse; }
.profile-body td { padding: 4px 0; }
.profile-body td:last-child { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.profile-body .who { font-weight: 800; margin: 0 0 8px; }
.miss-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; margin: 8px 0 3px; background: var(--surface-2); }
.miss-bar span { height: 100%; }
.miss-bar .l { background: var(--gold); }
.miss-bar .c { background: var(--green); }
.miss-bar .r { background: var(--flag); }
.miss-cap { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }

/* ---------- lead-capture gate ---------- */
.gate-backdrop {
  position: fixed; inset: 0; background: rgba(12,22,16,0.62); z-index: 60;
  opacity: 0; transition: opacity .24s;
}
.gate-backdrop.show { opacity: 1; }
.gate {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--surface); border-radius: 20px 20px 0 0; text-align: center;
  padding: 8px calc(20px + var(--sar)) calc(22px + var(--sab)) calc(20px + var(--sal));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 -10px 34px rgba(0,0,0,0.30);
}
.gate.show { transform: translateY(0); }
.gate-mark { font-size: 34px; margin: 4px 0 2px; line-height: 1; }
.gate-title { margin: 0 0 4px; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.gate-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
#gate-form { display: flex; flex-direction: column; gap: 10px; }
#gate-email, #gate-phone {
  width: 100%; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; background: var(--bg); color: var(--ink);
}
#gate-email:focus-visible, #gate-phone:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.gate-err { color: var(--flag); font-size: 13px; margin: 2px 0 0; font-weight: 700; }
.gate-btn {
  margin-top: 4px; width: 100%; padding: 15px; border: 0; border-radius: 12px;
  background: var(--green-deep); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer;
}
.gate-btn:active { background: #0F2C1F; }
.gate-alt {
  border: 0; background: none; color: var(--green); font-size: 13px; font-weight: 700;
  padding: 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.gate-skip {
  border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 8px; cursor: pointer;
}
.gate-fine { margin: 12px 0 0; font-size: 11px; color: var(--muted); }

/* ---------- desktop enhancement ---------- */
@media (min-width: 720px) {
  body { font-size: 15px; }
  .tagline { display: none; }
  .main { max-width: 680px; padding-top: 20px; gap: 16px; }
  .hole-chip { width: 54px; }
  .canvas-hint { font-size: 12px; }
  .sheet {
    left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%) scale(0.96);
    width: 440px; max-height: 78vh; border-radius: 18px; opacity: 0;
    transition: opacity .2s, transform .2s;
  }
  .sheet.show { transform: translate(-50%, 50%) scale(1); opacity: 1; }
  .gate {
    left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%) scale(0.96);
    width: 420px; border-radius: 18px; opacity: 0; transition: opacity .2s, transform .2s;
  }
  .gate.show { transform: translate(-50%, 50%) scale(1); opacity: 1; }
}
