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

:root {
  --green-dark: #14532d;
  --green-mid: #16a34a;
  --green-light: #22c55e;
  --green-bg: #f0fdf4;
  --gold: #ca8a04;
  --gold-light: #fef3c7;
  --gold-bright: #facc15;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --red: #dc2626;
  --red-light: #fef2f2;
  --blue: #2563eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ========== HEADER ========== */
.header {
  background: linear-gradient(135deg, var(--green-dark) 0%, #166534 100%);
  color: var(--white);
  padding: 18px 20px;
  text-align: center;
}

.header h1 {
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header .subtitle {
  font-size: 0.8em;
  opacity: 0.85;
  margin-top: 3px;
  color: var(--gold-light);
  font-weight: 500;
}

/* ========== NAVIGATION ========== */
.nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.nav a {
  text-decoration: none;
  padding: 8px 20px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.85em;
  transition: all 0.15s ease;
}

.nav a.primary {
  background: var(--green-mid);
  color: var(--white);
}

.nav a.secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.nav a:active {
  transform: scale(0.96);
}

/* ========== LAYOUT ========== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.container.wide {
  max-width: 1000px;
}

/* ========== CARDS ========== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1em;
  color: var(--green-dark);
  margin-bottom: 16px;
  font-weight: 700;
}

/* ========== FORMS ========== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.8em;
  margin-bottom: 5px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1em;
  background: var(--gray-50);
  transition: all 0.15s ease;
  color: var(--gray-900);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green-mid);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  width: 100%;
  user-select: none;
}

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

.btn-primary {
  background: var(--green-mid);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--green-dark);
}

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

.btn-small {
  padding: 8px 16px;
  font-size: 0.8em;
  width: auto;
}

/* ========== PIN OVERLAY ========== */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.pin-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.pin-card h2 {
  font-size: 1.2em;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.pin-card p {
  color: var(--gray-500);
  font-size: 0.9em;
  margin-bottom: 24px;
}

.pin-input, .code-input {
  font-size: 2em;
  text-align: center;
  letter-spacing: 10px;
  width: 180px;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  color: var(--gray-900);
  font-weight: 700;
}

.code-input:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.pin-input:focus {
  outline: none;
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.pin-error {
  color: var(--red);
  font-size: 0.85em;
  margin-top: 10px;
  min-height: 20px;
}

.pin-card .btn {
  margin-top: 16px;
}

/* ========== SCORECARD HOLES ========== */
.hole-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 3px solid var(--gray-200);
  transition: all 0.3s ease;
  user-select: none;
}

.hole-card.hole-saved {
  border-color: var(--green-mid);
  background: #f0fdf4;
}

/* Top row: #1, Hole 3, Par 4, save status */
.hole-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hole-order {
  font-size: 0.7em;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
}

.hole-number-big {
  font-size: 1.15em;
  font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
}

.hole-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7em;
  font-weight: 700;
}

.hole-badge.par-badge {
  background: var(--green-bg);
  color: var(--green-dark);
}

.hole-top .save-status {
  margin-left: auto;
}

/* Score picker: row of number buttons */
.score-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.score-num {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 1.2em;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  color: var(--gray-700);
  user-select: none;
  position: relative;
}

.score-num:active {
  transform: scale(0.9);
}

/* Par indicator dot under the number */
.score-num.is-par {
  border-color: var(--green-mid);
  border-width: 2.5px;
}

.par-dot {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green-mid);
  position: absolute;
  bottom: 4px;
}

/* Selected score - filled background with score color */
.score-num.selected {
  color: var(--white);
  border-color: transparent;
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.score-num.selected .par-dot { background: var(--white); }

.score-num.selected.score-eagle { background: #d97706; }
.score-num.selected.score-birdie { background: #dc2626; }
.score-num.selected.score-par { background: var(--gray-600, #4b5563); }
.score-num.selected.score-bogey { background: #2563eb; }
.score-num.selected.score-double { background: #7c3aed; }

/* +/- buttons on edges */
.score-adj {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  background: var(--white);
  font-size: 1.2em;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  color: var(--gray-400);
  user-select: none;
  flex-shrink: 0;
}

.score-adj:active {
  transform: scale(0.85);
  background: var(--green-bg);
  border-color: var(--green-mid);
}

/* Score colors */
.score-eagle { color: #d97706; }
.score-birdie { color: var(--red); }
.score-par { color: var(--gray-700); }
.score-bogey { color: var(--blue); }
.score-double { color: #7c3aed; }

/* ========== PROGRESS BAR ========== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-mid), var(--green-light));
  border-radius: 100px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.8em;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 12px;
}

/* ========== STICKY TOTAL BAR ========== */
.sticky-total {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  padding: 12px 20px;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sticky-total .total-label {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.85em;
}

.sticky-total .total-number {
  font-size: 1.6em;
  font-weight: 800;
  color: var(--green-dark);
}

.sticky-total .to-par-badge {
  padding: 4px 12px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 0.9em;
}

.to-par-badge.under { background: #fef2f2; color: var(--red); }
.to-par-badge.even { background: var(--green-bg); color: var(--green-dark); }
.to-par-badge.over { background: #eff6ff; color: var(--blue); }

/* Add bottom padding to page content so sticky bar doesn't overlap */
.has-sticky-bar {
  padding-bottom: 80px;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 0.85em;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2s forwards;
  white-space: nowrap;
}

.toast-success {
  background: var(--green-dark);
  color: var(--white);
}

.toast-error {
  background: var(--red);
  color: var(--white);
}

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

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ========== LEADERBOARD TABLE ========== */
.leaderboard-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  background: var(--white);
}

.lb-table th {
  background: var(--green-dark);
  color: var(--white);
  padding: 12px 8px;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.lb-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
}

.lb-table tbody tr:hover {
  background: var(--gray-50);
}

.lb-table .team-name-cell {
  text-align: left;
  padding-left: 14px;
  vertical-align: middle;
}

.lb-table .team-name-cell .player-name {
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.4;
  font-size: 0.9em;
}

.lb-table .rank-cell {
  font-weight: 800;
  color: var(--green-dark);
  font-size: 1.1em;
}

.lb-table .total-cell {
  font-weight: 800;
  font-size: 1em;
}

.lb-table .par-row td {
  background: var(--gold-light);
  font-weight: 700;
  color: var(--green-dark);
  font-size: 0.9em;
}

.to-par {
  font-weight: 800;
  font-size: 1em;
}

.to-par.under { color: var(--red); }
.to-par.even { color: var(--green-dark); }
.to-par.over { color: var(--blue); }

/* Best score highlight */
.best-score {
  background: var(--gold-bright) !important;
  font-weight: 800;
}

/* ========== PROSHOP MONITOR / FULLSCREEN ========== */
body.fullscreen {
  background: #091a10;
  overflow: hidden;
  color: #e2e8f0;
}

body.fullscreen .last-updated {
  color: rgba(255,255,255,0.2);
  padding: 6px;
  font-size: 0.65em;
}

.proshop-header {
  background: linear-gradient(180deg, #14532d 0%, #0f3621 100%);
  color: var(--white);
  padding: 14px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #b8860b;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.proshop-header h1 {
  font-size: 1.4em;
  letter-spacing: 3px;
  font-weight: 800;
}

.proshop-header .event-name {
  color: #d4a843;
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 1px;
}

.proshop-header .clock {
  font-size: 1.2em;
  font-weight: 700;
  color: #d4a843;
  letter-spacing: 1px;
}

/* Force dark backgrounds on everything in fullscreen */
body.fullscreen .leaderboard-container {
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
}

body.fullscreen .lb-table {
  font-size: 1.15em;
  background: #0d2418 !important;
  border-collapse: collapse;
}

body.fullscreen .lb-table th {
  background: #143d28 !important;
  color: #d4a843 !important;
  padding: 10px 12px;
  font-size: 0.8em;
  letter-spacing: 1.5px;
  border-bottom: 3px solid #8b6914;
}

/* All cells: force light text on dark */
body.fullscreen .lb-table td {
  padding: 9px 12px;
  color: #e2e8f0 !important;
  background: transparent;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Alternating rows */
body.fullscreen .lb-table tbody tr {
  background: #0d2418 !important;
}

body.fullscreen .lb-table tbody tr:nth-child(even) {
  background: #13321e !important;
}

body.fullscreen .lb-table tbody tr:hover {
  background: #1a4030 !important;
}

/* Par row */
body.fullscreen .lb-table .par-row td {
  background: #2a2010 !important;
  color: #d4a843 !important;
  font-weight: 800;
  padding: 8px 12px;
  border-bottom: 2px solid #8b6914;
  font-size: 0.95em;
}

/* Team names - bright white, bold */
body.fullscreen .lb-table .team-name-cell {
  padding-left: 16px;
  white-space: nowrap;
  color: #ffffff !important;
}

body.fullscreen .lb-table .team-name-cell .player-name {
  display: inline;
  font-size: 1.1em;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff !important;
}

body.fullscreen .lb-table .team-name-cell .holes-progress {
  display: inline;
  margin-left: 8px;
  color: #6b8f7a !important;
  font-size: 0.85em;
}

/* Position number */
body.fullscreen .lb-table .rank-cell {
  font-size: 1.25em;
  font-weight: 800;
  color: #d4a843 !important;
}

/* Total score */
body.fullscreen .lb-table .total-cell {
  font-weight: 800;
  color: #ffffff !important;
  font-size: 1.2em;
}

/* To-par column */
body.fullscreen .lb-table .to-par {
  font-weight: 800;
  font-size: 1.2em;
}

body.fullscreen .lb-table .to-par.under { color: #f87171 !important; }
body.fullscreen .lb-table .to-par.even { color: #4ade80 !important; }
body.fullscreen .lb-table .to-par.over { color: #60a5fa !important; }

/* Score colors - bright on dark */
body.fullscreen .lb-table td.score-eagle { color: #fbbf24 !important; font-weight: 800; }
body.fullscreen .lb-table td.score-birdie { color: #f87171 !important; font-weight: 700; }
body.fullscreen .lb-table td.score-par { color: #cbd5e1 !important; }
body.fullscreen .lb-table td.score-bogey { color: #60a5fa !important; }
body.fullscreen .lb-table td.score-double { color: #a78bfa !important; }

body.fullscreen .lb-table td.best-score {
  background: #b8860b !important;
  color: #ffffff !important;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ========== ALERT MESSAGES ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 500;
  font-size: 0.9em;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ========== ADMIN TEAM LIST ========== */
.team-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.team-list-item:last-child {
  border-bottom: none;
}

.team-list-name {
  font-weight: 700;
  font-size: 0.95em;
}

.team-list-players {
  font-size: 0.8em;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ========== ADMIN HOLES TABLE ========== */
.holes-table {
  width: 100%;
  border-collapse: collapse;
}

.holes-table th {
  background: var(--green-dark);
  color: var(--white);
  padding: 10px 8px;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.holes-table td {
  padding: 8px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
}

/* ========== DANGER ZONE ========== */
.danger-zone {
  border: 2px solid #fecaca;
  border-radius: var(--radius-lg);
}

.danger-zone h2 {
  color: var(--red) !important;
}

/* ========== LAST UPDATED ========== */
.last-updated {
  text-align: center;
  color: var(--gray-400);
  font-size: 0.75em;
  padding: 12px;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state h3 {
  color: var(--gray-500);
  margin-bottom: 8px;
}

/* ========== FOOTER LINK ========== */
.footer-link {
  text-align: center;
  padding: 24px;
}

.footer-link a {
  color: var(--gray-400);
  font-size: 0.8em;
  text-decoration: none;
}

.footer-link a:hover {
  color: var(--gray-500);
}

/* ========== DASHBOARD SUMMARY COUNTS ========== */
.dashboard-counts {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.count-badge {
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius);
  flex: 1;
}

.count-badge .count-number {
  font-size: 1.5em;
  font-weight: 800;
  line-height: 1;
}

.count-badge .count-label {
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.count-playing { background: var(--green-bg); color: var(--green-dark); }
.count-pending { background: var(--gold-light); color: var(--gold); }
.count-inactive { background: var(--gray-100); color: var(--gray-500); }
.count-claimed { background: #eff6ff; color: var(--blue); }

/* ========== AUTO-SAVE INDICATORS ========== */
.save-status {
  text-align: center;
  min-width: 90px;
}

.save-indicator {
  font-size: 0.75em;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  display: inline-block;
}

.save-indicator.saved {
  background: #dcfce7;
  color: #166534;
}

.save-indicator.saving, .save-indicator.pending {
  background: var(--gold-light);
  color: var(--gold);
}

.save-indicator.error {
  background: #fef2f2;
  color: var(--red);
}

.save-indicator.error a {
  color: var(--red);
  text-decoration: underline;
  font-weight: 700;
}

.save-indicator.hint {
  background: var(--gray-100);
  color: var(--gray-400);
  font-size: 0.65em;
}

/* ========== ROUND COMPLETE ========== */
.round-complete-card {
  text-align: center;
  padding: 32px 20px;
  border: 3px solid var(--green-mid);
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

/* ========== LEADERBOARD HOLES PROGRESS ========== */
.holes-progress {
  font-size: 0.7em;
  color: var(--gray-400);
  font-weight: 600;
  font-style: italic;
  margin-top: 2px;
}

/* ========== SCORE LEGEND ========== */
.score-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.score-legend span {
  font-size: 0.7em;
  font-weight: 700;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
  .header h1 { font-size: 1em; }
  .header .subtitle { font-size: 0.75em; }
  .nav { gap: 6px; padding: 10px 12px; }
  .nav a { padding: 7px 14px; font-size: 0.8em; }
  .container { padding: 12px; }
  .hole-card { padding: 10px 12px; }
  .score-num { width: 42px; height: 42px; font-size: 1.1em; border-radius: 10px; }
  .score-adj { width: 30px; height: 30px; font-size: 1em; }
  .score-picker { gap: 4px; }
  body.fullscreen .lb-table { font-size: 0.9em; }
  .proshop-header h1 { font-size: 1.2em; }
  .dashboard-counts { gap: 4px; }
  .count-badge { padding: 6px 4px; }
  .count-badge .count-number { font-size: 1.2em; }
  .count-badge .count-label { font-size: 0.6em; }
  .score-legend { gap: 8px; }
}
