:root {
  --bg: #edf3ee;
  --surface: #fffdf7;
  --surface-2: #f7faf6;
  --ink: #102019;
  --muted: #607066;
  --soft: #8a988f;
  --line: rgba(16, 32, 25, 0.12);
  --line-strong: rgba(16, 32, 25, 0.22);
  --brand: #0d2f25;
  --brand-2: #1f6d4d;
  --blue: #1769aa;
  --blue-soft: #dceefd;
  --green: #18804f;
  --green-soft: #dbf4e8;
  --sand: #d9a85d;
  --sand-soft: #fbefd8;
  --red: #b83c3c;
  --red-soft: #fae5e5;
  --shadow: 0 10px 26px rgba(16, 32, 25, 0.08);
  --shadow-soft: 0 2px 10px rgba(16, 32, 25, 0.06);
  --radius: 8px;
  --button-radius: 14px;
  --nav-height: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-outdoor="true"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f8f5;
  --ink: #000000;
  --muted: #26342c;
  --soft: #415247;
  --line: rgba(0, 0, 0, 0.24);
  --line-strong: rgba(0, 0, 0, 0.42);
  --brand: #061f17;
  --blue: #004f8d;
  --shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.24);
  --shadow-soft: 0 0 0 1.5px rgba(0, 0, 0, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

body {
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.42);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  outline: 0;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.app-shell {
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(16, 32, 25, 0.04);
}

.view {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: calc(14px + var(--safe-top)) 14px calc(var(--nav-height) + var(--safe-bottom) + 20px);
  -webkit-overflow-scrolling: touch;
}

.screen {
  display: grid;
  gap: 12px;
  animation: rise 180ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 2px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.lead {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.coach-card {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}

.coach-card .muted,
.coach-card .small,
.coach-card .lead,
.coach-card .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.game-hero,
.game-panel {
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.95), rgba(251, 239, 216, 0.84)),
    var(--surface);
  border-color: rgba(217, 168, 93, 0.38);
  box-shadow: 0 10px 28px rgba(117, 78, 21, 0.1);
}

.game-panel {
  display: grid;
  gap: 10px;
}

.insight-card {
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.98), rgba(220, 238, 253, 0.5)),
    var(--surface);
  border-color: rgba(23, 105, 170, 0.16);
}

.level-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--brand);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(13, 47, 37, 0.18);
  font-size: 13px;
  font-weight: 900;
}

.game-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.game-stat-row div {
  min-width: 0;
  border: 1px solid rgba(217, 168, 93, 0.25);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  padding: 10px 8px;
}

.game-stat-row strong {
  display: block;
  color: var(--brand);
  font-size: 20px;
  line-height: 1;
}

.game-stat-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.game-challenge-grid {
  display: grid;
  gap: 8px;
}

.challenge-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  text-align: left;
  align-items: center;
}

.challenge-card strong,
.challenge-card .small,
.challenge-card .challenge-meta {
  display: block;
}

.challenge-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.challenge-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.target-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(13, 47, 37, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.dark-target {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
}

.dark-target .small {
  color: rgba(255, 255, 255, 0.72);
}

.focus-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.focus-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.focus-title {
  font-size: 21px;
  font-weight: 850;
  line-height: 1.12;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.pill.dark {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.pill.good {
  background: var(--green-soft);
  color: #0e5b38;
  border-color: rgba(24, 128, 79, 0.16);
}

.pill.warn {
  background: var(--sand-soft);
  color: #835a14;
  border-color: rgba(217, 168, 93, 0.28);
}

.pill.bad {
  background: var(--red-soft);
  color: #8a2424;
  border-color: rgba(184, 60, 60, 0.2);
}

.btn {
  min-height: 48px;
  border-radius: var(--button-radius);
  padding: 12px 15px;
  font-size: 15px;
  font-weight: 780;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 110ms ease, background 110ms ease, border-color 110ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 47, 37, 0.18);
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.blue {
  background: var(--blue);
  color: #fff;
}

.btn.danger {
  background: var(--red-soft);
  color: var(--red);
}

.btn.small-btn {
  min-height: 40px;
  padding: 9px 12px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

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

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

.metric {
  min-height: 86px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.insight-tile {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.metric-value {
  font-size: 24px;
  font-weight: 860;
  letter-spacing: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.metric-conclusion {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.action-card {
  min-height: 110px;
  display: grid;
  align-content: space-between;
  text-align: left;
}

.action-card.primary-action {
  background: #fff;
  border-color: rgba(23, 105, 170, 0.22);
}

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

.glyph {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 850;
}

.glyph.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.glyph.sand {
  background: var(--sand-soft);
  color: #8b5d15;
}

.club-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.club-strip::-webkit-scrollbar {
  display: none;
}

.club-chip {
  flex: 0 0 auto;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.club-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.session-bar {
  position: sticky;
  top: calc(4px + var(--safe-top));
  z-index: 5;
  display: grid;
  gap: 8px;
  background: rgba(237, 243, 238, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  margin: -2px -14px 0;
  padding: 8px 14px 10px;
  border-bottom: 1px solid rgba(16, 32, 25, 0.06);
}

.range-field {
  position: relative;
  height: min(58vh, 520px);
  min-height: 390px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(13, 47, 37, 0.25);
  background:
    linear-gradient(90deg, rgba(13, 47, 37, 0.18), transparent 26%, transparent 74%, rgba(13, 47, 37, 0.18)),
    linear-gradient(180deg, #bfe5c6 0%, #6fb578 52%, #2d744f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), var(--shadow);
  touch-action: none;
}

.range-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.range-label {
  fill: rgba(255, 255, 255, 0.92);
  font-size: 3.2px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.range-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 253, 247, 0.9);
  color: var(--brand);
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 820;
  pointer-events: none;
  white-space: nowrap;
}

.shot-dot {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.28));
}

.shot-list {
  display: grid;
  gap: 8px;
}

.shot-row,
.club-row,
.session-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.shot-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.progress-line {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(16, 32, 25, 0.09);
}

.progress-fill {
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: var(--brand-2);
}

.trend-grid,
.health-grid,
.plan-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.radar {
  display: grid;
  gap: 10px;
}

.radar-row {
  display: grid;
  grid-template-columns: 66px 1fr 38px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.radar-track {
  height: 9px;
  border-radius: 99px;
  background: rgba(16, 32, 25, 0.08);
  overflow: hidden;
}

.radar-fill {
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: var(--blue);
}

.contact-row,
.prompt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-chip,
.prompt-chip {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.contact-chip.active,
.prompt-chip:active {
  background: var(--brand);
  color: #fff;
}

.coach-answer {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.48;
}

.plan-list {
  display: grid;
  gap: 8px;
}

.plan-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 11px;
}

.plan-min {
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
}

.plan-choice {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.plan-choice strong,
.plan-choice span {
  display: block;
}

.plan-choice span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.dispersion-map {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.dispersion-map svg {
  width: 100%;
  height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(219, 244, 232, 0.8), rgba(247, 250, 246, 0.95));
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.legend {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
}

.legend.good {
  background: var(--green);
}

.legend.warn {
  background: var(--sand);
}

.legend.bad {
  background: var(--red);
}

.empty-mini {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
  padding: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.field-group {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 30;
  width: min(100%, 480px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  min-height: calc(var(--nav-height) + var(--safe-bottom));
  padding: 8px 8px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.94);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.nav-btn {
  min-height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
}

.nav-mark {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(16, 32, 25, 0.06);
  font-size: 11px;
  font-weight: 850;
}

.nav-btn.active {
  color: var(--brand);
  background: rgba(24, 128, 79, 0.08);
}

.nav-btn.active .nav-mark {
  background: var(--brand);
  color: #fff;
}

.toast,
.undo-bar {
  position: fixed;
  left: 50%;
  z-index: 50;
  width: calc(min(100%, 480px) - 28px);
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast {
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  border-radius: var(--button-radius);
  background: rgba(16, 32, 25, 0.94);
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: var(--shadow);
}

.undo-bar {
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--button-radius);
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px;
  box-shadow: var(--shadow);
}

.toast.show,
.undo-bar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(13, 47, 37, 0.42);
}

.sheet-root.open {
  display: flex;
}

.sheet {
  width: min(100%, 480px);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  padding: 10px 14px calc(18px + var(--safe-bottom));
  box-shadow: 0 -18px 40px rgba(13, 47, 37, 0.24);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: rgba(16, 32, 25, 0.18);
  margin: 4px auto 14px;
}

.sheet-body {
  display: grid;
  gap: 12px;
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.62);
  padding: 18px;
}

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

.switch {
  position: relative;
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: rgba(16, 32, 25, 0.14);
  padding: 3px;
}

.switch::after {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transform: translateX(0);
  transition: transform 150ms ease;
}

.switch.on {
  background: var(--brand-2);
}

.switch.on::after {
  transform: translateX(22px);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 360px) {
  .grid-2,
  .action-grid,
  .trend-grid,
  .health-grid,
  .plan-choice-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .range-field {
    min-height: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-outdoor="true"] .session-bar,
html[data-outdoor="true"] .bottom-nav {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-outdoor="true"] .range-field {
  border-width: 2px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 27%, transparent 73%, rgba(0, 0, 0, 0.22)),
    linear-gradient(180deg, #d9f7d5 0%, #72c579 48%, #17653e 100%);
}

html[data-outdoor="true"] .range-hint,
html[data-outdoor="true"] .club-chip,
html[data-outdoor="true"] .contact-chip,
html[data-outdoor="true"] .prompt-chip,
html[data-outdoor="true"] .plan-choice {
  border-width: 1.5px;
}

@media (min-width: 481px) {
  .app-shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
