/* ==========================================================================
   ScoreBarn.com — MVP v1 Clean Round Entry UI
   Warm Clubhouse Paper + ScoreBarn Red (#C81E1E) + Crisp Tabular Math
   ========================================================================== */

:root {
  --red: #C81E1E;
  --red-hover: #A51616;
  --red-soft: rgba(200, 30, 30, 0.08);
  --green: #0F766E;
  --green-soft: rgba(16, 185, 129, 0.12);
  --green-text: #047857;
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-muted: #F1EFEA;
  --ink: #111827;
  --ink-muted: #5B6472;
  --border: rgba(17, 24, 39, 0.11);
  --border-strong: rgba(17, 24, 39, 0.22);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 10px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 12px 30px rgba(17, 24, 39, 0.08);

  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.025em;
}
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.brand-text { color: var(--red); }
.muted-sm { font-size: 12.5px; color: var(--ink-muted); }

/* ==========================================================================
   Top Bar
   ========================================================================== */
.topbar {
  background: #111418;
  color: #F9FAFB;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-name strong { color: #EF4444; font-weight: 800; }
.brand-tld { font-size: 13px; color: #9CA3AF; font-weight: 600; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-fgi-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.header-fgi-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #9CA3AF;
}
.header-fgi-val {
  font-size: 13.5px;
  font-weight: 700;
  color: #FFFFFF;
}
.header-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12.5px;
  font-weight: 600;
  color: #E5E7EB;
  transition: background 0.15s ease;
}
.header-link-chip:hover { background: rgba(255, 255, 255, 0.14); }
.header-link-chip img { width: 16px; height: 16px; }

/* ==========================================================================
   Page Container & Intro
   ========================================================================== */
.page {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 56px;
  flex: 1;
}

.intro {
  margin-bottom: 22px;
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: var(--red);
  margin-bottom: 6px;
}
.intro h1 {
  font-size: 34px;
  line-height: 1.12;
  font-weight: 800;
}
.intro-sub {
  font-size: 15px;
  color: var(--ink-muted);
  margin-top: 8px;
  max-width: 640px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* ==========================================================================
   Cards & Form Layout
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 20px; }
.card-sub { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }

/* 18H / 9H Toggle */
.holes-toggle {
  display: inline-flex;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.holes-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.14s ease;
}
.holes-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

#round-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .label-row label, .group-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #374151;
}
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.text-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--red);
}
.text-btn:hover { text-decoration: underline; }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 30, 30, 0.13);
}

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

/* Course Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}
.autocomplete-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--red-soft); }
.autocomplete-loc { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

.selected-course-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
.selected-course-bar strong { display: block; font-size: 14px; }

.custom-course-box {
  padding: 13px;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
}

/* Compact Rating Strip */
.rating-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
.rating-strip input {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Hero Gross Score Input */
.score-hero-box {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(200, 30, 30, 0.05), #FFFFFF 70%);
  border: 1.5px solid rgba(200, 30, 30, 0.28);
}
.score-input-wrap label {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 6px;
}
#input-gross {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 800;
  padding: 10px 14px;
  height: 58px;
  text-align: center;
  border-width: 1.5px;
}
.score-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.preview-metric { text-align: center; }
.preview-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.preview-val { font-size: 22px; font-weight: 800; }
.preview-divider { width: 1px; height: 34px; background: var(--border); }

/* Round Type Pills */
.type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.type-pill {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.14s ease;
}
.type-pill:hover { border-color: var(--red); }
.type-pill.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

/* Optional Collapsible Stats */
.optional-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.optional-trigger {
  width: 100%;
  background: var(--surface-muted);
  border: none;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
}
.optional-hint { font-size: 11.5px; color: var(--ink-muted); font-weight: 500; }
.optional-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-top: 1px solid var(--border);
}

/* Profile Identity Box */
.profile-box {
  padding: 15px;
  border-radius: 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.saved-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.optin-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: #374151;
  cursor: pointer;
}
.optin-check input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--red);
  flex-shrink: 0;
}

.form-error {
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #B91C1C;
  font-size: 13px;
  font-weight: 600;
}

.btn-submit {
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  background: var(--red);
  color: #FFFFFF;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 20px rgba(200, 30, 30, 0.25);
  transition: background 0.15s ease, transform 0.12s ease;
}
.btn-submit:hover { background: var(--red-hover); transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }

/* Success Banner */
.success-banner {
  margin-bottom: 18px;
  padding: 16px 20px;
  border-radius: 16px;
  background: linear-gradient(125deg, rgba(16, 185, 129, 0.13), #FFFFFF 70%);
  border: 1.5px solid rgba(16, 185, 129, 0.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Right Column: Free Golf Index Card & Score History
   ========================================================================== */
.side-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.index-card {
  background: linear-gradient(155deg, #11161B 0%, #1C2229 100%);
  color: #F9FAFB;
  border-color: rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}
.index-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.index-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: #FCA5A5;
}
.index-number {
  font-size: 46px;
  line-height: 1.05;
  font-weight: 800;
  margin-top: 6px;
  color: #FFFFFF;
}
.index-caption {
  font-size: 12.5px;
  color: #9CA3AF;
  margin-top: 5px;
}
.index-watermark {
  width: 44px;
  height: 44px;
  opacity: 0.92;
  flex-shrink: 0;
}

.road-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.road-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #E5E7EB;
  margin-bottom: 8px;
}
.road-head .muted-sm { color: #9CA3AF; }
.road-bar {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}
.road-slot {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.road-slot.filled { background: #64748B; }
.road-slot.counting { background: #10B981; }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.mini-stat {
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}
.mini-label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9CA3AF;
  margin-bottom: 2px;
}
.mini-stat strong { font-size: 17px; color: #FFFFFF; }

.btn-secondary-full {
  width: 100%;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
}
.btn-secondary-full:hover { background: rgba(255, 255, 255, 0.16); }

/* Rounds History List */
.rounds-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty-rounds {
  padding: 22px 14px;
  text-align: center;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--ink-muted);
}
.round-item {
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.round-item.counting {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.35);
}
.round-item-main { min-width: 0; flex: 1; }
.round-course {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.round-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface-muted);
  color: #374151;
}
.tag-chip.counting {
  background: rgba(16, 185, 129, 0.16);
  color: var(--green-text);
}
.round-score-col {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.score-pill {
  text-align: right;
}
.score-pill strong {
  display: block;
  font-size: 19px;
  line-height: 1.05;
}
.score-pill span {
  font-size: 11px;
  color: var(--ink-muted);
}
.btn-del-round {
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
}
.btn-del-round:hover { color: var(--red); background: var(--red-soft); }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #FFFFFF;
  border-left: 4px solid #10B981;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.footer-line { font-size: 13px; }
.footer-legal { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; max-width: 620px; }
.footer-tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.footer-btn, .footer-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-muted);
}
.footer-btn:hover, .footer-link:hover { color: var(--red); text-decoration: underline; }

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .intro h1 { font-size: 28px; }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .score-hero-box { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .optional-hint { display: none; }
}
