:root {
  --green-dark: #1B5E20;
  --green-mid: #2E7D32;
  --green-light: #4CAF50;
  --green-pale: #81C784;
  --white: #FFFFFF;
  --off-white: #F5F5F5;
  --gray: #9E9E9E;
  --gray-dark: #616161;
  --eagle: #FFD700;
  --birdie: #4CAF50;
  --par: #FFFFFF;
  --bogey: #FF9800;
  --double: #F44336;
  --card-bg: rgba(255,255,255,0.08);
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --safe-top: env(safe-area-inset-top, 20px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  background: var(--green-dark);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }

.screen {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: none; flex-direction: column;
  padding: calc(var(--safe-top) + 10px) 20px calc(var(--safe-bottom) + 10px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* HOME */
.home-header { text-align: center; padding: 40px 0 20px; }
.logo-icon { font-size: 56px; margin-bottom: 8px; }
.home-header h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.subtitle { color: var(--green-pale); font-size: 15px; margin-top: 4px; font-weight: 500; }

.home-stats {
  display: flex; justify-content: center; gap: 24px;
  padding: 16px 0; margin-bottom: 8px;
}
.home-stat { text-align: center; }
.home-stat .stat-val { font-size: 24px; font-weight: 700; }
.home-stat .stat-label { font-size: 11px; color: var(--green-pale); text-transform: uppercase; letter-spacing: 0.5px; }

.game-mode-tabs {
  display: flex; gap: 4px; background: var(--card-bg); border-radius: 12px;
  padding: 4px; margin-bottom: 16px; border: 1px solid rgba(255,255,255,0.08);
}
.mode-tab {
  flex: 1; padding: 10px 8px; border: none; border-radius: 9px;
  background: transparent; color: var(--green-pale); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all 0.25s; font-family: inherit;
}
.mode-tab.active { background: var(--green-light); color: var(--white); }

.home-buttons { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

/* HTG shot buttons */
.htg-shots { padding: 4px 0; flex-shrink: 0; }
.htg-shots-label { font-size: 13px; color: var(--green-pale); text-align: center; margin-bottom: 8px; }
.htg-shot-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: var(--card-bg); border-radius: 10px; margin-bottom: 6px;
}
.htg-shot-label { font-size: 14px; font-weight: 500; min-width: 60px; }
.htg-shot-buttons { display: flex; gap: 6px; }
.htg-shot-btn {
  padding: 8px 14px; border: 2px solid rgba(255,255,255,0.2); border-radius: 8px;
  background: transparent; color: var(--white); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; font-family: inherit; min-width: 60px;
}
.htg-shot-btn:active { transform: scale(0.95); }
.htg-shot-btn.selected-miss { background: var(--double); border-color: var(--double); }
.htg-shot-btn.selected-fringe { background: var(--bogey); border-color: var(--bogey); }
.htg-shot-btn.selected-green { background: var(--birdie); border-color: var(--birdie); }
.htg-hole-points {
  text-align: center; padding: 8px 0 4px; font-size: 20px; font-weight: 700; flex-shrink: 0;
}

.btn {
  display: block; width: 100%; padding: 16px; border: none; border-radius: 14px;
  font-size: 17px; font-weight: 600; cursor: pointer; transition: transform 0.15s, opacity 0.15s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: var(--green-light); color: var(--white); }
.btn-secondary { background: var(--card-bg); color: var(--white); border: 1px solid rgba(255,255,255,0.15); }
.btn-finish { background: var(--eagle); color: var(--green-dark); padding: 12px 24px; width: auto; border-radius: 25px; font-size: 15px; }

.course-info {
  background: var(--card-bg); border-radius: 14px; padding: 16px 20px;
  border: 1px solid rgba(255,255,255,0.08);
}
.info-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.info-row span:first-child { color: var(--green-pale); }
.info-row span:last-child { font-weight: 600; }

/* SCORECARD */
.sc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 12px; flex-shrink: 0;
}
.back-btn {
  background: var(--card-bg); border: none; color: var(--white);
  width: 36px; height: 36px; border-radius: 50%; font-size: 18px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-family: inherit;
}
.sc-title { font-size: 17px; font-weight: 600; }
.sc-total { font-size: 15px; color: var(--green-pale); font-weight: 600; }

.sc-date-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 0; flex-shrink: 0;
}
.sc-date-row label { font-size: 13px; color: var(--green-pale); font-weight: 500; }
.sc-date-row input[type="date"] {
  background: var(--card-bg); border: 1px solid rgba(255,255,255,0.2);
  color: var(--white); padding: 6px 12px; border-radius: 8px;
  font-size: 14px; font-family: inherit;
  color-scheme: dark;
}

.sc-dots { display: flex; justify-content: center; gap: 8px; padding: 8px 0; flex-shrink: 0; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.2);
  transition: all 0.3s;
}
.dot.active { background: var(--white); transform: scale(1.3); }
.dot.scored { background: var(--green-light); }

.sc-swipe-container { flex: 1; overflow: hidden; position: relative; min-height: 0; }

.nav-arrow {
  display: none; position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 10; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
  color: var(--white); font-size: 24px; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.2s, background 0.2s;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.nav-arrow:hover { background: rgba(255,255,255,0.25); }
.nav-arrow:active { transform: translateY(-50%) scale(0.92); }
.nav-arrow.hidden { opacity: 0; pointer-events: none; }
.nav-left { left: 4px; }
.nav-right { right: 4px; }

@media (pointer: fine) {
  .nav-arrow { display: flex; }
}
@media (hover: none) and (pointer: coarse) {
  .nav-arrow { display: none; }
}
.sc-cards {
  display: flex; height: 100%; transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}
.hole-card {
  min-width: 100%; height: 100%; display: flex; flex-direction: column;
  padding: 0 4px;
}

.hole-img-wrap {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 8px 0;
}
.hole-img {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

/* hole info is now baked into the images */

.score-control {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 12px 0 4px; flex-shrink: 0;
}
.score-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3);
  background: var(--card-bg); color: var(--white); font-size: 28px; font-weight: 300;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.score-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.9); }
.score-display {
  text-align: center; min-width: 80px;
}
.score-number { font-size: 48px; font-weight: 800; transition: color 0.3s; }
.score-label { font-size: 13px; font-weight: 600; margin-top: -2px; transition: color 0.3s; }

.sc-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 4px; flex-shrink: 0;
}
.sc-par-total { font-size: 15px; color: var(--green-pale); }
.score-vs-par { font-weight: 700; color: var(--white); }

/* SUMMARY */
.summary-header { text-align: center; padding: 40px 0 24px; }
.summary-header h2 { font-size: 28px; font-weight: 800; margin-bottom: 16px; }
.summary-total { font-size: 64px; font-weight: 800; }
.summary-vs-par { font-size: 20px; font-weight: 600; margin-top: 4px; }

.summary-card {
  background: var(--card-bg); border-radius: 16px; padding: 20px;
  border: 1px solid rgba(255,255,255,0.08); margin-bottom: 24px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.summary-row:last-child { border-bottom: none; }
.summary-hole-name { font-size: 15px; }
.summary-hole-name span { color: var(--green-pale); font-size: 12px; }
.summary-hole-score { font-size: 18px; font-weight: 700; min-width: 60px; text-align: right; }

.summary-actions { display: flex; flex-direction: column; gap: 12px; }

/* SCREEN HEADER */
.screen-header {
  display: flex; align-items: center; gap: 12px; padding: 8px 0 20px; flex-shrink: 0;
}
.screen-header h2 { font-size: 24px; font-weight: 800; }

/* HISTORY */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: var(--card-bg); border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08); cursor: pointer;
  transition: background 0.2s;
}
.history-item:active { background: rgba(255,255,255,0.12); }
.history-main {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
}
.history-date { font-size: 15px; font-weight: 500; }
.history-date-sub { font-size: 12px; color: var(--gray); margin-top: 2px; }
.history-score { text-align: right; }
.history-score-num { font-size: 24px; font-weight: 800; }
.history-score-par { font-size: 13px; font-weight: 600; }
.history-detail {
  display: none; padding: 0 20px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.history-detail.open { display: block; padding-top: 12px; }
.history-detail-row {
  display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px;
}
.history-detail-row span:first-child { color: var(--green-pale); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--gray); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* LEADERBOARD */
.lb-subtitle { text-align: center; color: var(--green-pale); font-size: 14px; margin-bottom: 16px; }
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-bg); border-radius: 14px; padding: 14px 18px;
  border: 1px solid rgba(255,255,255,0.08);
}
.lb-rank {
  font-size: 20px; font-weight: 800; min-width: 32px; text-align: center;
}
.lb-rank.gold { color: var(--eagle); }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }
.lb-info { flex: 1; }
.lb-name { font-size: 15px; font-weight: 600; }
.lb-date { font-size: 12px; color: var(--gray); }
.lb-score { text-align: right; }
.lb-score-num { font-size: 22px; font-weight: 800; }
.lb-score-par { font-size: 12px; font-weight: 600; }
.lb-item-me { border-color: var(--green-light); background: rgba(76,175,80,0.12); }

/* HANDICAP */
.hc-content { padding-top: 8px; }
.hc-big {
  text-align: center; padding: 32px 0;
  background: var(--card-bg); border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08); margin-bottom: 20px;
}
.hc-number { font-size: 72px; font-weight: 800; }
.hc-label { font-size: 14px; color: var(--green-pale); margin-top: 4px; }
.hc-trend { font-size: 16px; font-weight: 600; margin-top: 8px; }

.hc-details {
  background: var(--card-bg); border-radius: 14px; padding: 20px;
  border: 1px solid rgba(255,255,255,0.08);
}
.hc-detail-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 14px;
}
.hc-detail-row:last-child { border-bottom: none; }
.hc-detail-row span:first-child { color: var(--green-pale); }
.hc-scores-used {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1);
}
.hc-scores-used h4 { font-size: 13px; color: var(--green-pale); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.hc-score-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hc-chip {
  background: var(--green-mid); padding: 4px 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
}
.hc-chip.used { background: var(--green-light); }

/* MODAL */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--green-dark); border-radius: 20px; padding: 40px 28px;
  text-align: center; max-width: 340px; width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-icon { font-size: 48px; margin-bottom: 16px; }
.modal-content h2 { font-size: 22px; margin-bottom: 8px; }
.modal-content p { color: var(--green-pale); font-size: 14px; margin-bottom: 24px; }
.modal-content input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08); color: var(--white); font-size: 17px; text-align: center;
  margin-bottom: 16px; outline: none; font-family: inherit;
}
.modal-content input:focus { border-color: var(--green-light); }
.modal-content input::placeholder { color: rgba(255,255,255,0.3); }

/* Auth */
.auth-card {
  background: var(--card-bg); border-radius: 16px; padding: 24px;
  border: 1px solid rgba(255,255,255,0.08);
}
.auth-tabs {
  display: flex; gap: 4px; background: rgba(255,255,255,0.05); border-radius: 10px;
  padding: 3px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 8px; border: none; border-radius: 8px;
  background: transparent; color: var(--green-pale); font-size: 14px;
  font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.auth-tab.active { background: var(--green-light); color: var(--white); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  width: 100%; padding: 14px 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06);
  color: var(--white); font-size: 16px; font-family: inherit; outline: none;
}
.auth-form input:focus { border-color: var(--green-light); }
.auth-form input::placeholder { color: rgba(255,255,255,0.3); }
.auth-divider {
  text-align: center; margin: 16px 0; color: var(--gray); font-size: 13px;
  display: flex; align-items: center; gap: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1);
}
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px; background: rgba(255,255,255,0.06); color: var(--white);
  font-size: 15px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: background 0.2s;
}
.btn-google:active { background: rgba(255,255,255,0.12); }
.auth-error { color: var(--double); font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }

.home-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; flex-shrink: 0;
}
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2);
  background: var(--card-bg); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.avatar-btn:active { background: rgba(255,255,255,0.15); }

.syncing-badge {
  font-size: 11px; color: var(--green-pale); text-align: center;
  padding: 4px 0; opacity: 0.7;
}

/* Edit/Delete */
.history-actions {
  display: flex; gap: 8px; padding: 8px 20px 12px; justify-content: flex-end;
}
.history-actions button {
  padding: 6px 16px; border-radius: 8px; border: none; font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit; transition: opacity 0.15s;
}
.history-actions button:active { opacity: 0.7; }
.btn-edit { background: rgba(255,255,255,0.12); color: var(--white); }
.btn-delete-sm { background: rgba(244,67,54,0.2); color: var(--double); }
.btn-delete { background: var(--double); color: var(--white); width: 100%; padding: 14px; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-delete:active { opacity: 0.8; }

.edit-hole-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card-bg); border-radius: 12px;
  margin-bottom: 8px; border: 1px solid rgba(255,255,255,0.06);
}
.edit-hole-name { font-size: 15px; font-weight: 500; }
.edit-hole-name span { font-size: 12px; color: var(--green-pale); }
.edit-score-control { display: flex; align-items: center; gap: 12px; }
.edit-score-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2);
  background: var(--card-bg); color: var(--white); font-size: 20px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-family: inherit;
}
.edit-score-btn:active { background: rgba(255,255,255,0.15); }
.edit-score-val { font-size: 24px; font-weight: 700; min-width: 30px; text-align: center; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
