/* Retro Golf — web port of the iOS UI (Classic layout). */

:root {
  --ui-background: rgb(26, 31, 36);
  --ui-panel: rgb(41, 48, 56);
  --ui-accent: rgb(242, 199, 51);
  --meter-empty: rgb(51, 77, 115);
  --meter-mid: rgb(242, 204, 51);
  --meter-high: rgb(230, 64, 51);
  --meter-mark: rgb(255, 107, 23);
  --course-backdrop: rgb(28, 51, 23);
  --tee-box: rgb(87, 140, 56);
  --break-orange: rgb(255, 140, 38);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ui-background);
  color: #fff;
  font-family: -apple-system, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button { font-family: inherit; border: none; cursor: pointer; color: inherit; background: none; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ============ Home ============ */

#home {
  background: linear-gradient(rgb(41, 107, 158), rgb(26, 61, 41));
  align-items: center;
  justify-content: center;
}
.home-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 40px;
  width: min(420px, calc(100vw - 60px));
  height: 100%;
  padding: 24px 0;
}
.logo { text-align: center; }
.logo-retro {
  font-size: 40px; font-weight: 900; letter-spacing: 8px;
  color: var(--ui-accent);
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
.logo-golf {
  font-size: 60px; font-weight: 900; letter-spacing: 12px;
  text-shadow: 4px 4px 0 rgba(0,0,0,.4);
}
.logo-flag { font-size: 38px; margin-top: 10px; }

.mode-list { display: flex; flex-direction: column; gap: 14px; }
.mode-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 22px;
  background: var(--ui-panel);
  border: 2px solid rgba(242, 199, 51, .6);
  border-radius: 14px;
  color: #fff;
  text-align: left;
}
.mode-btn:disabled {
  background: rgba(41, 48, 56, .5);
  border-color: transparent;
  color: rgba(255,255,255,.4);
  cursor: default;
}
.mode-btn:not(:disabled):active { transform: scale(.98); }
.mode-text { display: flex; flex-direction: column; gap: 2px; }
.mode-title { font-size: 21px; font-weight: 700; }
.mode-sub { font-size: 13px; opacity: .7; }
.mode-chev { font-size: 20px; font-weight: 700; }
.home-version { text-align: center; font-size: 11px; color: rgba(255,255,255,.5); }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.85);
  font-size: 20px;
  line-height: 1;
}
#settings-btn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 16px; z-index: 5; }

/* ============ Game ============ */

#game { background: var(--course-backdrop); }

#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(26, 31, 36, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 3;
}
.topbar-left { flex: 1 1 0; min-width: 0; }
.tb-heading { font-size: 15px; font-weight: 700; white-space: nowrap; }
.tb-detail-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; min-height: 16px; }
.tb-strokes { font-size: 11px; font-weight: 700; color: var(--ui-accent); }
.tb-distance { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.85); }
.tb-pill {
  font-size: 11px; font-weight: 700;
  padding: 1px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.topbar-center { flex: 0 0 auto; }
#menu-btn { background: var(--ui-panel); width: 40px; height: 40px; font-size: 19px; font-weight: 700; color: #fff; }

.indicator { display: flex; align-items: center; gap: 7px; }
.indicator-text { display: flex; flex-direction: column; line-height: 1.15; }
.indicator-main { font-size: 13px; font-weight: 700; }
.indicator-sub { font-size: 10px; color: rgba(255,255,255,.6); }
.wind-arrow {
  display: inline-block;
  font-size: 15px;
  color: var(--ui-accent);
  /* ➤ points right; rotate -90° so 0° = up, then add the wind direction via a CSS var. */
  transform: rotate(calc(var(--dir, 0deg) - 90deg));
  transition: transform .2s;
}
.wind-arrow.calm { color: rgba(255,255,255,.4); }
.break-arrow {
  display: inline-block;
  font-size: 15px; font-weight: 700;
  color: var(--break-orange);
  transform: rotate(var(--dir, 0deg));
  transition: transform .2s;
}
.break-pips { display: flex; gap: 3px; margin-top: 3px; }
.break-pips i { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.25); }
.break-pips i.on { background: var(--break-orange); }

#course-wrap { flex: 1 1 0; position: relative; min-height: 0; }
#course { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---- Layouts ----
   Hybrid (default): no top bar; details/club notch floats on the right edge;
   the bottom deck holds aim ◂ SWING ▸ (club selection lives in the notch). */

#game.layout-hybrid #topbar { display: none; }
#game.layout-hybrid #club-btn { display: none; }
#game.layout-hybrid #aim-left { order: 0; }
#game.layout-hybrid #swing-btn { order: 1; }
#game.layout-hybrid #aim-right { order: 2; }
#game:not(.layout-hybrid) #sidebar,
#game:not(.layout-hybrid) #sb-club-popup { display: none; }

/* ---- Hybrid sidebar notch ---- */

#sidebar {
  position: absolute; right: 0; bottom: 12px;
  width: 62px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 6px;
  background: rgba(26, 31, 36, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 18px 0 0 18px;
  z-index: 4;
}
#sb-menu {
  height: 28px;
  border-radius: 9px;
  background: var(--ui-panel);
  color: rgba(255,255,255,.85);
  font-size: 15px; font-weight: 700;
}
.sb-spacer { height: 6px; }
#sb-clubs { display: flex; flex-direction: column; gap: 6px; }
.sb-chev {
  height: 32px;
  border-radius: 9px;
  background: var(--ui-panel);
  color: #fff;
  font-size: 11px;
}
.sb-chev:disabled { color: rgba(255,255,255,.35); cursor: default; }
.sb-chev:not(:disabled):active { transform: scale(.95); }
#sb-club-chip {
  height: 36px;
  border-radius: 9px;
  background: rgba(242, 199, 51, .25);
  border: 2px solid var(--ui-accent);
  color: #fff;
  font-size: 16px; font-weight: 800;
}
#sb-club-chip:disabled { opacity: .5; cursor: default; }
#sb-info { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#sb-strokes { font-size: 14px; font-weight: 800; color: var(--ui-accent); }
.sb-ind {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,.85);
}
#sb-wind .wind-arrow { font-size: 22px; }
#sb-break .break-arrow { font-size: 18px; }
.sb-break-label { font-size: 11px; font-weight: 700; color: #fff; }
#sb-distance {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.85);
  min-height: 14px;
}
#sb-pill-slot { height: 18px; display: flex; justify-content: center; align-items: center; }
#sb-pill { font-size: 8px; padding: 2px 5px; }

#sb-club-popup {
  position: absolute; right: 72px; bottom: 12px;
  display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 6px;
  background: rgba(26, 31, 36, .98);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  box-shadow: -2px 2px 8px rgba(0,0,0,.4);
  z-index: 5;
}
#sb-club-popup button {
  width: 48px; height: 32px;
  border-radius: 8px;
  background: var(--ui-panel);
  color: rgba(255,255,255,.75);
  font-size: 15px; font-weight: 800;
  flex: 0 0 auto;
}
#sb-club-popup button.selected { background: rgba(242, 199, 51, .3); color: #fff; }

/* ---- Bottom deck: power meter + controls ---- */

#deck {
  background: rgba(26, 31, 36, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 3;
}
.deck-inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 14px;
}

#meter { position: relative; height: 36px; }
#meter-bars {
  display: flex; gap: 1.5px;
  height: 22px;
}
#meter-bars i { flex: 1 1 0; background: var(--meter-empty); border-radius: 1px; }
#meter-bars i.sweet { background: #fff; }
#meter-track { position: absolute; left: 0; right: 0; top: 22px; height: 14px; }
#meter-dots { position: absolute; inset: 0; }
#meter-dots i {
  position: absolute; top: 50%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,.7);
  transform: translate(-50%, -50%);
}
#meter-dots i.major { width: 5px; height: 5px; background: #fff; }
#meter-dots i.sweetdot { width: 7px; height: 7px; background: #fff; }
#meter-marker {
  position: absolute; top: 1px; left: 0;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid #fff;
  transform: translateX(-50%);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
#meter-mark { position: absolute; top: 0; left: 0; height: 100%; }
#meter-mark .mark-line {
  position: absolute; top: -2px; left: -1.5px;
  width: 3px; height: 26px;
  background: var(--meter-mark);
}
#meter-mark .mark-caret {
  position: absolute; top: 0; left: -6px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--meter-mark);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}

#controls { display: flex; gap: 12px; }
.ctrl-btn {
  flex: 0 0 58px;
  width: 58px; height: 58px;
  border-radius: 14px;
  background: var(--ui-panel);
  color: #fff;
  font-size: 22px; font-weight: 800;
}
.ctrl-btn:disabled { color: rgba(255,255,255,.35); cursor: default; }
.ctrl-btn:not(:disabled):active { transform: scale(.96); }
#swing-btn {
  flex: 1 1 0;
  height: 58px;
  border-radius: 14px;
  background: var(--ui-accent);
  color: #000;
  font-size: 17px; font-weight: 800;
  letter-spacing: .5px;
}
#swing-btn:active { transform: scale(.98); }
#swing-btn.backswing { background: var(--meter-mid); }
#swing-btn.downswing { background: var(--meter-high); }
#swing-btn.inflight { background: #888; }

/* ============ Scorecard ============ */

#scorecard {
  background: linear-gradient(rgb(26, 61, 41), rgb(15, 31, 26));
  align-items: center;
}
.score-inner {
  display: flex; flex-direction: column;
  width: min(440px, calc(100vw - 40px));
  height: 100%;
  padding: max(24px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
  gap: 16px;
}
.score-inner h1 { text-align: center; font-size: 30px; font-weight: 900; }
.score-rows { flex: 1 1 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.score-header {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,.5);
  padding: 4px 14px;
}
.score-header span:nth-child(1) { width: 90px; }
.score-header span:nth-child(2) { width: 44px; text-align: center; }
.score-header span:nth-child(3) { width: 60px; text-align: right; }
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ui-panel);
  border-radius: 10px;
  padding: 10px 14px;
}
.score-hole { width: 90px; }
.score-hole b { display: block; font-size: 15px; font-weight: 600; }
.score-hole span { font-size: 10px; color: rgba(255,255,255,.5); }
.score-par { width: 44px; text-align: center; }
.score-strokes-cell { width: 60px; text-align: right; font-size: 17px; font-weight: 800; }
.under { color: rgb(89, 217, 115); }
.over { color: rgb(255, 153, 102); }
.score-total { text-align: center; }
.score-strokes { font-size: 40px; font-weight: 900; color: var(--ui-accent); }
.score-topar { font-size: 15px; font-weight: 700; color: rgba(255,255,255,.85); }

.primary-btn {
  height: 52px;
  border-radius: 14px;
  background: var(--ui-accent);
  color: #000;
  font-size: 17px; font-weight: 700;
  margin: 0 20px;
}

/* ============ Modals ============ */

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 20;
}
.modal-card {
  width: min(520px, 100vw);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--ui-background);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.modal-card h2 { font-size: 17px; font-weight: 700; text-align: center; }
.modal-close {
  height: 46px;
  border-radius: 12px;
  background: var(--ui-panel);
  color: #fff;
  font-size: 15px; font-weight: 600;
}

.club-list { display: flex; flex-direction: column; gap: 6px; }
.club-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--ui-panel);
  color: #fff;
  text-align: left;
}
.club-row.selected { outline: 2px solid var(--ui-accent); }
.club-row .club-abbr {
  width: 40px;
  font-size: 17px; font-weight: 800;
  color: var(--ui-accent);
}
.club-row .club-name { flex: 1; font-size: 15px; font-weight: 600; }
.club-row .club-yards { font-size: 13px; color: rgba(255,255,255,.6); }

.menu-actions { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  height: 48px;
  border-radius: 12px;
  background: var(--ui-panel);
  color: #fff;
  font-size: 15px; font-weight: 600;
}
.menu-item.destructive { color: rgb(255, 92, 92); }

.setting-group-title {
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px;
  background: var(--ui-panel);
  border-radius: 12px;
  cursor: pointer;
}
.setting-row > span { display: flex; flex-direction: column; gap: 3px; }
.setting-title { font-size: 15px; font-weight: 600; }
.setting-sub { font-size: 12px; color: rgba(255,255,255,.6); }
.setting-row input { width: 22px; height: 22px; accent-color: var(--ui-accent); }
