:root {
  color-scheme: light;
  --bg: #f5f8f3;
  --panel: #ffffff;
  --ink: #122218;
  --muted: #657267;
  --line: #d8e4d7;
  --green: #176d3a;
  --green-dark: #0d4324;
  --green-soft: #e5f2e7;
  --green-faint: #f0f7ef;
  --sand: #f4eedf;
  --danger: #9f2f2f;
  --shadow: 0 10px 30px rgba(18, 34, 24, 0.12);
  --shadow-soft: 0 6px 18px rgba(18, 34, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(13, 67, 36, 0.08), transparent 170px),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  color: white;
  background: linear-gradient(135deg, #0d4324, #176d3a);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(13, 67, 36, 0.22);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-size: 1.14rem;
  letter-spacing: 0;
}

.brand span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
}

.scoring-topbar {
  min-height: 92px;
  padding: 12px 16px;
}

.scoring-topbar.hole-flash {
  animation: headerFlash 1.15s ease-out;
}

.score-banner-strip {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(94px, 1.15fr) repeat(3, minmax(68px, 1fr));
  gap: 8px;
}

.score-banner-hole,
.score-banner-stat {
  min-height: 66px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.score-banner-hole {
  background: rgba(255, 255, 255, 0.16);
}

.score-banner-round {
  color: var(--green-dark);
  background: #f4eedf;
  border-color: rgba(244, 238, 223, 0.8);
}

.score-banner-hole span,
.score-banner-stat span {
  color: currentColor;
  opacity: 0.78;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-banner-hole strong,
.score-banner-stat strong {
  color: currentColor;
  font-size: 1.7rem;
  line-height: 1;
}

.score-banner-hole strong {
  font-size: 2rem;
}

.small {
  color: var(--muted);
  font-size: 0.84rem;
}

.screen {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.metric-value {
  color: var(--green-dark);
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(180deg, #1d7a43, var(--green));
  box-shadow: 0 4px 10px rgba(23, 109, 58, 0.2);
  font-weight: 700;
}

.btn.secondary {
  color: var(--green-dark);
  background: var(--green-soft);
  box-shadow: none;
}

.btn.ghost {
  color: white;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

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

.btn.quiet {
  color: var(--muted);
  background: #edf3ec;
  box-shadow: none;
}

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

.field label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.input,
.textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
}

.input:focus,
.textarea:focus {
  outline: 2px solid rgba(23, 109, 58, 0.2);
  border-color: rgba(23, 109, 58, 0.46);
}

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

.chat-start {
  display: grid;
  gap: 14px;
}

.scorecard-screen {
  position: relative;
  display: grid;
  gap: 12px;
}

.score-header-card {
  display: grid;
  gap: 10px;
  border-color: rgba(13, 67, 36, 0.16);
}

.score-header-card.hole-flash {
  animation: headerFlash 1.15s ease-out;
}

.hole-transition {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
  animation: overlayFade 3.1s ease-in-out forwards;
}

.hole-transition-card {
  width: min(320px, 86vw);
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px solid rgba(13, 67, 36, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
  animation: cardPop 3.1s ease-in-out forwards;
}

.hole-transition-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hole-transition-card strong {
  color: var(--green-dark);
  font-size: 4rem;
  line-height: 0.95;
}

.hole-transition-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

@keyframes overlayFade {
  0% {
    opacity: 0;
  }
  18%,
  76% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes cardPop {
  0% {
    transform: translateY(10px) scale(0.96);
  }
  18%,
  76% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(-8px) scale(0.99);
  }
}

@keyframes headerFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(23, 109, 58, 0.28);
    border-color: var(--line);
  }
  28% {
    box-shadow: 0 0 0 5px rgba(23, 109, 58, 0.16);
    border-color: rgba(23, 109, 58, 0.42);
  }
  100% {
    box-shadow: 0 4px 14px rgba(18, 34, 24, 0.06);
    border-color: var(--line);
  }
}

.hole-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hole-stat {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 11px 10px;
  border: 1px solid rgba(13, 67, 36, 0.12);
  border-radius: 8px;
  background: var(--green-faint);
  text-align: center;
  justify-items: center;
}

.hole-stat strong {
  color: var(--green-dark);
  font-size: 1.42rem;
  line-height: 1;
  font-weight: 700;
}

.hole-stat-primary {
  color: white;
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.hole-stat-primary .small,
.hole-stat-primary strong {
  color: white;
}

.round-stat {
  background: var(--sand);
}

.full-width {
  width: 100%;
}

.hole-map-panel {
  display: grid;
  gap: 8px;
}

.btn.compact {
  min-height: 38px;
  padding: 8px 11px;
  font-size: 0.88rem;
}

.map-frame {
  position: relative;
}

.hole-map {
  position: relative;
  height: clamp(210px, 34vh, 320px);
  overflow: hidden;
  border: 1px solid rgba(13, 67, 36, 0.18);
  border-radius: 8px;
  background: #d8e4d7;
}

.map-locate {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  background: rgba(229, 242, 231, 0.94);
  backdrop-filter: blur(8px);
}

.map-footer {
  display: grid;
  gap: 3px;
}

.map-status:empty {
  display: none;
}

.map-status {
  margin: 0;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 700;
}

.map-distance {
  margin: 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.86rem;
}

.map-marker {
  display: grid;
  place-items: center;
  transform: translateY(-2px);
  border: 2px solid white;
  box-shadow: 0 4px 10px rgba(18, 34, 24, 0.24);
  font-weight: 800;
}

.map-marker-shot,
.map-marker-hole {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.map-marker-shot {
  color: white;
  background: var(--green);
}

.map-marker-hole {
  color: var(--green-dark);
  background: #f8f3d8;
}

.map-marker-current,
.map-marker-target {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.map-marker-current {
  background: #2f80ed;
  box-shadow:
    0 0 0 6px rgba(47, 128, 237, 0.2),
    0 4px 10px rgba(18, 34, 24, 0.24);
}

.map-marker-target {
  background: var(--danger);
  box-shadow:
    0 0 0 6px rgba(159, 47, 47, 0.16),
    0 4px 10px rgba(18, 34, 24, 0.24);
}

.shot-tracker {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(13, 67, 36, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f7fbf6);
}

.shot-controls,
.shot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shot-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shot-primary {
  min-height: 52px;
  font-size: 1.05rem;
  grid-column: 1 / -1;
}

.shot-history {
  position: relative;
  display: grid;
  gap: 7px;
}

.shot-history::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 15px;
  width: 1px;
  background: var(--line);
}

.shot-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 7px 9px 7px 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.92rem;
}

.shot-index {
  z-index: 1;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(13, 67, 36, 0.18);
  border-radius: 50%;
  color: var(--green-dark);
  background: white;
  font-weight: 800;
  line-height: 1;
}

.shot-main {
  display: grid;
  gap: 2px;
  font-weight: 700;
}

.shot-main em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 700;
}

.shot-row strong {
  color: var(--green-dark);
}

.penalty-row .shot-index {
  color: var(--danger);
  border-color: rgba(159, 47, 47, 0.25);
}

.penalty-row strong {
  color: var(--danger);
}

.hole-row .shot-index {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.round-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.review-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.review-score {
  min-width: 72px;
  display: grid;
  gap: 4px;
  text-align: right;
}

.review-score strong {
  color: var(--green-dark);
  font-size: 1.8rem;
  line-height: 1;
}

.round-scorecard {
  display: grid;
  gap: 4px;
}

.scorecard-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8fbf7;
  text-align: center;
}

.scorecard-row-head {
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 700;
}

.prior-list {
  display: grid;
  gap: 10px;
}

.active-round-list {
  display: grid;
  gap: 10px;
}

.round-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.active-round {
  align-items: start;
}

.round-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.btn.danger-text {
  color: var(--danger);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 720px) {
  .screen {
    padding: 12px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    min-height: 58px;
    padding: 10px 12px;
  }

  .scoring-topbar {
    min-height: 82px;
    padding: 9px 10px;
  }

  .score-banner-strip {
    grid-template-columns: minmax(76px, 1.1fr) repeat(3, minmax(58px, 1fr));
    gap: 6px;
  }

  .score-banner-hole,
  .score-banner-stat {
    min-height: 60px;
    padding: 8px 6px;
  }

  .score-banner-hole strong,
  .score-banner-stat strong {
    font-size: 1.38rem;
  }

  .score-banner-hole strong {
    font-size: 1.7rem;
  }

  .score-banner-hole span,
  .score-banner-stat span {
    font-size: 0.68rem;
  }

  .hole-strip {
    grid-template-columns: repeat(4, minmax(64px, 1fr));
    gap: 6px;
  }

  .shot-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card {
    padding: 12px;
  }

  .review-header {
    grid-template-columns: 1fr 72px 72px;
  }

  .round-item,
  .active-round {
    grid-template-columns: 1fr;
  }

  .round-item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }
}
