/* ============================================
   Village Golf — Premium UI Stylesheet
   Aldenham Course Identity Update
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Source+Sans+3:wght@400;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --club-green: #0c352a;
  --club-green-deep: #082319;
  --gold: #c9a544;
  --gold-bright: #e8c96a;
  --cream: #f4efdf;
  --ink: #16261f;
  --danger: #c0392b;
  --meter-h: 26px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
  background: var(--club-green-deep);
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: var(--cream);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.serif {
  font-family: 'Cinzel', Georgia, serif;
}

/* ---------- Title / setup screen ---------- */
#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #14543f 0%, transparent 60%),
    linear-gradient(180deg, #0d3a2c 0%, #082319 70%, #051710 100%);
  z-index: 1001; /* Above loading screen */
  overflow: auto;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#menu.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#menu .card {
  width: min(680px, 94vw);
  margin: 24px auto;
  background: rgba(8, 33, 24, 0.82);
  border: 1px solid rgba(201, 165, 68, 0.55);
  border-radius: 14px;
  padding: 34px 34px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.crest {
  width: 74px;
  height: 84px;
  margin: 0 auto 14px;
  border: 2px solid var(--gold);
  border-radius: 10px 10px 26px 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-bright);
  font-family: "Cinzel", serif;
  font-size: 34px;
  font-weight: 700;
  background: linear-gradient(160deg, rgba(201, 165, 68, 0.12), transparent);
}

h1.serif {
  font-family: "Cinzel", Georgia, serif;
  text-align: center;
  font-weight: 700;
  font-size: clamp(26px, 4.6vw, 40px);
  letter-spacing: 0.12em;
  color: var(--gold-bright);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.sub {
  text-align: center;
  letter-spacing: 0.34em;
  font-size: 11px;
  color: var(--cream);
  opacity: 0.85;
  margin: 6px 0 26px;
  text-transform: uppercase;
}

.rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 18px 0;
}

.opt-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 14px 0 8px;
  font-weight: 600;
}
.opt-row {
  display: grid;
  gap: 10px;
}

#golferRow { grid-template-columns: repeat(2, 1fr); }
#weatherRow { grid-template-columns: repeat(5, 1fr); }
#courseRow { grid-template-columns: repeat(3, 1fr); }
#colorRow { grid-template-columns: repeat(3, 1fr); }
#modeRow { grid-template-columns: repeat(2, 1fr); }

.opt {
  padding: 12px 10px;
  border-radius: 10px;
  border: 1px solid rgba(244, 239, 223, 0.25);
  background: rgba(244, 239, 223, 0.06);
  color: var(--cream);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
}

.opt .big {
  font-size: 24px;
  display: block;
  margin-bottom: 4px;
}

.opt:hover {
  border-color: var(--gold);
  background: rgba(244, 239, 223, 0.1);
}

.opt.sel {
  background: rgba(201, 165, 68, 0.18);
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold) inset;
}

#teeOff {
  display: block;
  width: 100%;
  margin-top: 26px;
  padding: 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--club-green-deep);
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: filter 0.15s ease;
}

#teeOff:hover {
  filter: brightness(1.1);
}

details.howto {
  margin-top: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #e9e3cf;
}

details.howto summary {
  cursor: pointer;
  color: var(--gold-bright);
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 0;
}

details.howto li {
  margin: 7px 0 0 20px;
}

kbd {
  background: rgba(244, 239, 223, 0.14);
  border: 1px solid rgba(244, 239, 223, 0.3);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: inherit;
}

/* ---------- Canvas ---------- */
#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: none;
}

/* ---------- Loading Screen ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #040d04 0%, #0c1f0c 40%, #0a180a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 1s ease, visibility 1s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.loader-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.loader h1 {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #4ade80, #a7f3d0, #4ade80);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease-in-out infinite;
  margin-bottom: 2rem;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 200% center; }
}

.loading-bar {
  width: 320px;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 auto 1.2rem;
}

.loading-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80, #86efac);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.loader p {
  color: rgba(255,255,255,0.35);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  font-weight: 300;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 24px;
  left: 24px;
  display: flex;
  gap: 12px;
  z-index: 10;
  pointer-events: none;
}

.hud-card {
  background: rgba(8, 33, 24, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(201, 165, 68, 0.35);
  border-radius: 12px;
  padding: 10px 16px;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.hud-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(244, 239, 223, 0.6);
  margin-bottom: 2px;
  font-weight: 600;
}

.hud-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1.1;
}

.hud-value.small {
  font-size: 1.1rem;
  font-weight: 600;
}

.hud-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
  font-weight: 400;
}

/* ---------- Wind ---------- */
#wind-info {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
  pointer-events: none;
  min-width: 90px;
}

#wind-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.wind-unit {
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(147, 197, 253, 0.6);
}

#wind-arrow {
  font-size: 1.6rem;
  line-height: 1;
  transition: transform 0.6s ease;
}

/* ---------- Swing UI ---------- */
#swing-ui {
  position: fixed;
  bottom: 24px;   /* aligned with bottom-bar-hud bottom */
  right: 360px;   /* placed neatly to the left of bottom-bar-hud */
  z-index: 30;    /* higher than bottom-bar-hud to prevent overlap */
  display: flex;
  flex-direction: row;  /* power and accuracy side by side */
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
}

#power-bar, #accuracy-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Active/Inactive Swing Bars */
.bar-track {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}
#power-bar.active .bar-track,
#accuracy-bar.active .bar-track {
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.25), inset 0 2px 8px rgba(0,0,0,0.4);
  transform: scale(1.06);
}
#power-bar.inactive .bar-track,
#accuracy-bar.inactive .bar-track {
  opacity: 0.35;
  transform: scale(0.94);
}
#power-bar.active .bar-label,
#accuracy-bar.active .bar-label {
  color: #4ade80;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}
#power-bar.inactive .bar-label,
#accuracy-bar.inactive .bar-label {
  color: rgba(255,255,255,0.25);
}

.bar-track {
  width: 24px;
  height: 160px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

.bar-track.horizontal {
  width: 160px;
  height: 24px;
}

#power-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(to top,
    #22c55e 0%, #22c55e 40%,
    #eab308 40%, #eab308 70%,
    #ef4444 70%, #ef4444 100%
  );
  border-radius: 0 0 14px 14px;
  transition: height 0.03s linear;
}

#power-marker {
  position: absolute;
  left: -3px;
  right: -3px;
  height: 4px;
  background: #fff;
  border-radius: 2px;
  box-shadow:
    0 0 6px rgba(255,255,255,0.9),
    0 0 16px rgba(255,255,255,0.4);
  bottom: 0%;
  transition: bottom 0.03s linear;
  z-index: 2;
}

#accuracy-marker {
  position: absolute;
  left: -3px;
  right: -3px;
  height: 4px;
  background: #fff;
  border-radius: 2px;
  box-shadow:
    0 0 6px rgba(255,255,255,0.9),
    0 0 16px rgba(255,255,255,0.4);
  top: 50%;
  z-index: 2;
  transition: top 0.03s linear;
}

.accuracy-center-line {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(74, 222, 128, 0.5);
  border-radius: 1px;
  z-index: 1;
}

.bar-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
}

#power-dist-val {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fbbf24; /* Amber-gold color matching the visual theme */
  margin-top: 2px;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

/* ---------- Aim Indicator ---------- */
#aim-indicator {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(2, 18, 2, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(74, 222, 128, 0.15);
  border-radius: 24px;
  padding: 10px 28px;
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  animation: fadeIn 0.4s ease;
}

#aim-indicator p {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.04em;
  font-weight: 400;
  white-space: nowrap;
}

/* ---------- Message Overlay ---------- */
#message-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  text-align: center;
  pointer-events: none;
}

#message-text {
  font-size: 3.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow:
    0 0 30px rgba(74, 222, 128, 0.5),
    0 2px 4px rgba(0,0,0,0.5);
  animation: messagePopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#message-sub {
  font-size: 1.2rem;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  margin-top: 8px;
  letter-spacing: 0.08em;
  animation: messageFadeIn 0.6s ease 0.2s both;
}

@keyframes messagePopIn {
  from { opacity: 0; transform: scale(0.3) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

/* ---------- Scorecard ---------- */
#scorecard {
  position: fixed;
  top: 20px;
  right: 20px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  background: rgba(5, 20, 14, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  z-index: 30;
  border-radius: 12px;
  border: 2px solid var(--gold);
  padding: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.scorecard-inner {
  background: transparent;
  color: var(--cream);
  min-width: 380px;
}

.scorecard-inner h2 {
  font-family: "Cinzel", serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 4px;
  color: var(--club-green);
  background: none;
  -webkit-text-fill-color: initial;
}

#score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 28px;
}

#score-table th,
#score-table td {
  padding: 10px 10px;
  text-align: center;
  font-size: 0.85rem;
}

#score-table th {
  color: rgba(22, 38, 31, 0.6);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(22, 38, 31, 0.15);
  padding-bottom: 12px;
}

#score-table td {
  border-bottom: 1px solid rgba(22, 38, 31, 0.1);
  color: var(--ink);
}

.row-label {
  color: var(--ink) !important;
  opacity: 0.7;
  text-align: left !important;
}

#score-table td.eagle,
#score-table td.birdie {
  color: #ef4444; /* Red for under par */
  font-weight: 800;
}

#score-table td.bogey,
#score-table td.double-bogey,
#score-table td.over {
  color: #3b82f6; /* Blue for over par */
  font-weight: 800;
}


.total-col {
  border-left: 1px solid rgba(22, 38, 31, 0.15) !important;
  font-weight: 700 !important;
}

#par-row td {
  color: rgba(22, 38, 31, 0.75);
  font-weight: 500;
}

#score-row td {
  font-weight: 700;
  font-size: 1.05rem !important;
  color: #4ade80;
}

#score-row td.birdie { color: #60a5fa; }
#score-row td.eagle { color: #a78bfa; }
#score-row td.bogey { color: #fbbf24; }
#score-row td.double-bogey { color: #f97316; }
#score-row td.over { color: #ef4444; }

#next-hole-btn,
#play-again-btn {
  display: block;
  margin: 0 auto;
  padding: 14px 40px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.25);
}

#next-hole-btn:hover,
#play-again-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.35);
}

#next-hole-btn:active,
#play-again-btn:active {
  transform: translateY(-1px) scale(0.98);
}

/* ---------- Minimap ---------- */
#minimap {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 10;
  background: rgba(2, 18, 2, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(74, 222, 128, 0.15);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  pointer-events: none;
}

#minimap-canvas {
  display: block;
  border-radius: 8px;
}

/* ---------- Utilities ---------- */
.hidden {
  display: none !important;
}

/* Scorecard tucked out of the way while playing */
#scorecard.collapsed {
  opacity: 0;
  transform: translateY(-16px) scale(0.97);
  pointer-events: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  /* Main Menu Adjustments */
  #menu .card {
    padding: 20px 16px 16px;
    margin: 12px auto;
  }
  .sub {
    margin: 6px 0 16px;
  }
  #teeOff {
    margin-top: 16px;
    padding: 12px;
    font-size: 16px;
  }
  #weatherRow { grid-template-columns: repeat(2, 1fr); }
  #weatherRow button:last-child { grid-column: span 2; }
  #courseRow { grid-template-columns: 1fr; }
  #modeRow { grid-template-columns: 1fr; }

  /* Top HUD & Wind */
  #hud {
    top: 8px;
    left: 8px;
    gap: 6px;
    max-width: calc(100vw - 110px);
  }

  .hud-card {
    padding: 6px 10px;
    min-width: 50px;
    border-radius: 8px;
  }

  .hud-label {
    font-size: 0.55rem;
    letter-spacing: 0.1em;
  }

  .hud-value {
    font-size: 1.2rem;
  }

  .hud-value.small {
    font-size: 0.9rem;
  }

  .hud-sub {
    font-size: 0.6rem;
  }

  #club-info {
    display: none; /* Club selection is clear from bottom-bar club row */
  }

  #wind-info {
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    min-width: 75px;
    border-radius: 8px;
  }

  #wind-display {
    font-size: 0.95rem;
  }

  #wind-arrow {
    font-size: 1.2rem;
  }

  #minimap {
    display: none;
  }

  /* Swing UI Left-Side Docking */
  #swing-ui {
    position: fixed;
    top: 55%;
    left: 16px;
    bottom: auto;
    right: auto;
    transform: translateY(-50%);
    flex-direction: row;
    align-items: flex-end;
    gap: 12px;
    z-index: 30;
  }

  .bar-track {
    height: 110px;
    width: 18px;
    border-radius: 8px;
  }

  .bar-track.horizontal {
    width: 110px;
    height: 18px;
  }

  /* Unified Bottom Bar HUD */
  #bottom-bar-hud {
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    border-radius: 16px;
    padding: 10px 12px;
    gap: 8px;
  }

  #club-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    width: 100%;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  #club-row::-webkit-scrollbar {
    display: none;
  }

  .club-btn {
    padding: 6px 11px;
    font-size: 12px;
    flex: 0 0 auto;
    border-radius: 6px;
  }

  #bottom-bar-hud #action-row {
    gap: 16px;
    justify-content: center;
    width: 100%;
  }

  .action-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  /* Respect notches and home indicators */
  #hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
  }

  #wind-info {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
  }

  #bottom-bar-hud {
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  #swing-action-btn {
    width: 76px;
    height: 76px;
    font-size: 14px;
  }

  #cancel-action-btn.secondary-btn {
    border-color: rgba(239, 68, 68, 0.6);
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
  }

  #cancel-action-btn.secondary-btn:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    color: #fff;
  }

  /* Scorecard — compact bottom sheet on mobile, course stays visible */
  #scorecard {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    border: none;
    border-radius: 20px 20px 0 0;
    background: rgba(5, 20, 14, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    max-height: 62vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.6);
    /* Drag handle visual cue */
    border-top: 3px solid rgba(201, 165, 68, 0.5);
  }

  .scorecard-inner {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 12px 12px 20px;
    box-sizing: border-box;
    min-width: 0;
  }

  .scorecard-inner h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
  }

  #score-table {
    width: 100%;
    table-layout: fixed;
    margin-bottom: 14px;
  }

  #score-table th,
  #score-table td {
    padding: 6px 2px;
    font-size: 0.65rem;
    word-break: break-word;
  }

  #score-row td {
    font-size: 0.8rem !important;
  }

  #next-hole-btn,
  #play-again-btn {
    width: 85%;
    padding: 12px 20px;
    font-size: 0.95rem;
  }
}

/* ---------- Pin Waypoint Marker ---------- */
@keyframes pulseGlow {
  0%, 100% { 
    box-shadow: 0 4px 18px rgba(239, 68, 68, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15);
  }
  50% { 
    box-shadow: 0 4px 26px rgba(239, 68, 68, 0.8), 0 0 0 2px rgba(255, 255, 255, 0.3);
  }
}

#pin-waypoint {
  position: fixed;
  transform: translate(-50%, -100%);
  background: rgba(239, 68, 68, 0.82); /* Elegant red glass */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: opacity 0.15s ease;
  white-space: nowrap;
  animation: pulseGlow 2s infinite ease-in-out;
}

#pin-waypoint::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(239, 68, 68, 0.82) transparent;
  display: block;
  width: 0;
}

#pin-waypoint.clamped {
  background: rgba(239, 68, 68, 0.95);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 11px;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

#pin-waypoint.clamped::after {
  display: none;
}

.waypoint-arrow {
  display: none;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.05s linear;
}

/* ---------- Mobile Touch Controls ---------- */
#mobile-controls {
  display: none;
}

@media (max-width: 1023px), (pointer: coarse) {
  #mobile-controls {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 12px;
    z-index: 100;
    pointer-events: auto;
  }
}

.mobile-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 14px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-btn.primary-btn {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
  border: 1px solid rgba(74, 222, 128, 0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.mobile-btn.primary-btn.action-aim {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  border-color: rgba(56, 189, 248, 0.3);
}

.mobile-btn.primary-btn.action-power {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  border-color: rgba(251, 191, 36, 0.3);
}

.mobile-btn.primary-btn.action-hit {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: rgba(239, 68, 68, 0.3);
  animation: pulseButton 1s infinite alternate;
}

.mobile-btn.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.mobile-btn:active {
  transform: scale(0.92) translateY(2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes pulseButton {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4); }
  100% { box-shadow: 0 0 16px 4px rgba(239, 68, 68, 0.6), 0 8px 24px rgba(0, 0, 0, 0.4); }
}

/* ---------- Interactive HUD Cards ---------- */
.hud-card.interactive {
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.2s ease;
}
.hud-card.interactive:hover {
  background: rgba(4, 32, 4, 0.85);
  border-color: rgba(74, 222, 128, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 8px rgba(74, 222, 128, 0.2);
}
.hud-card.interactive:active {
  transform: translateY(0);
}

.hud-btn-toggle {
  font-size: 0.95rem;
  font-weight: 700;
  color: #94a3b8;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

#auto-play-btn.active {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
  box-shadow: inset 0 0 8px rgba(34, 197, 94, 0.2);
}

#settings-btn {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

/* ---------- Instant Replay HUD Card ---------- */
.replay-card {
  transition: all 0.25s ease;
}
.replay-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.replay-card.disabled .hud-btn-toggle {
  color: #64748b;
}
.replay-card:not(.disabled) {
  border-color: rgba(251, 191, 36, 0.6);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 16px rgba(251, 191, 36, 0.15);
  animation: replayPulse 2.5s ease-in-out infinite;
}
.replay-card:not(.disabled) #replay-hud-btn {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}
@keyframes replayPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 8px rgba(251, 191, 36, 0.1); }
  50% { box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 20px rgba(251, 191, 36, 0.35); }
}

/* Splat sub-settings collapsible */
.splat-sub {
  border-left: 2px solid rgba(56, 189, 248, 0.25);
  margin-left: 8px;
  padding-left: 10px;
  margin-top: 6px;
}


/* ---------- Graphics Settings Panel ---------- */
#graphics-settings {
  position: fixed;
  top: 90px;
  left: 24px;
  width: 320px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: linear-gradient(160deg, rgba(3, 20, 3, 0.88), rgba(1, 10, 1, 0.94));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 90;
  pointer-events: auto;
  animation: panelFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.settings-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
}

#close-settings-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.2s;
}

#close-settings-btn:hover {
  color: #ef4444;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-divider {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #38bdf8;
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 4px;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.2);
  padding-bottom: 4px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group.checkbox-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.setting-group.checkbox-group label {
  cursor: pointer;
}

.setting-group label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.setting-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #22c55e;
  cursor: pointer;
}

.setting-group input[type="text"] {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.setting-group input[type="text"]:focus {
  border-color: #38bdf8;
}

.slider-group {
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.slider-header span:last-child {
  color: #a7f3d0;
  font-weight: 600;
}

.setting-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  margin: 8px 0;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4ade80;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
  transition: transform 0.1s;
}

.setting-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ---------- Bottom Bar HUD Controls ---------- */
#bottom-bar-hud {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px;
  z-index: 20;
  pointer-events: none; /* Let pointer events through to canvas */
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: rgba(8, 33, 24, 0.75);
  border: 1.5px solid rgba(244, 239, 223, 0.2);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  max-width: 320px;
}

#bottom-bar-hud.hidden {
  display: none !important;
}

#club-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto; /* Catch clicks */
}

.club-btn {
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid rgba(244, 239, 223, 0.3);
  background: rgba(8, 33, 24, 0.82);
  color: var(--cream);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.club-btn:hover {
  border-color: var(--gold);
  background: rgba(8, 33, 24, 0.95);
}

.club-btn.sel {
  background: var(--gold);
  color: var(--club-green-deep);
  border-color: var(--gold-bright);
  box-shadow: 0 0 12px rgba(232, 201, 106, 0.4);
}

.club-btn .yds {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.75;
}

#bottom-bar-hud #action-row {
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: auto; /* Catch clicks */
}

.action-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(244, 239, 223, 0.35);
  background: rgba(8, 33, 24, 0.85);
  color: var(--cream);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.action-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.action-btn:active {
  background: rgba(201, 165, 68, 0.35);
}

#cancel-action-btn.secondary-btn {
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
}

#cancel-action-btn.secondary-btn:hover {
  border-color: #ef4444;
  color: #fff;
  background: rgba(239, 68, 68, 0.18);
}

#cancel-action-btn.secondary-btn:active {
  background: rgba(239, 68, 68, 0.3);
}

#swing-action-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  background: radial-gradient(circle at 35% 30%, #e8c96a, #a8842f);
  color: var(--club-green-deep);
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .08em;
  box-shadow: 0 8px 26px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.1s ease;
}

#swing-action-btn:active {
  transform: scale(.96);
}

/* Adjust layout on mobile devices */
@media (max-width: 640px) {
  .action-btn {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }
  #swing-action-btn {
    width: 80px;
    height: 80px;
    font-size: 15px;
  }
}

/* Landscape phones: keep the bottom bar compact so the course stays visible */
@media (max-height: 480px) and (pointer: coarse) {
  #bottom-bar-hud {
    padding: 6px 10px;
    gap: 4px;
    bottom: max(6px, env(safe-area-inset-bottom));
  }
  #bottom-bar-hud #action-row {
    gap: 10px;
  }
  #swing-action-btn {
    width: 64px;
    height: 64px;
    font-size: 13px;
  }
  .action-btn {
    width: 42px;
    height: 42px;
  }
  .club-btn {
    padding: 4px 9px;
    font-size: 11px;
  }
  #hud {
    transform: scale(0.85);
    transform-origin: top left;
  }
  #swing-ui {
    transform: translateY(-50%) scale(0.85);
  }
}

/* ============================================
   Cinematic Film Overlay — Enhanced Vignette + Grain
   ============================================ */

#film-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  /* Enhanced multi-stop vignette: deeper corners, more gradual falloff */
  background:
    radial-gradient(ellipse 90% 80% at 50% 48%,
      transparent 40%,
      rgba(0, 0, 0, 0.08) 55%,
      rgba(0, 0, 0, 0.22) 70%,
      rgba(0, 0, 0, 0.45) 85%,
      rgba(0, 0, 0, 0.65) 100%);
  mix-blend-mode: multiply;
}

/* Chromatic aberration hint at screen edges */
#film-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 100% at 50% 50%,
      transparent 75%,
      rgba(255, 0, 0, 0.015) 88%,
      rgba(0, 0, 255, 0.02) 95%,
      rgba(0, 0, 128, 0.03) 100%);
  pointer-events: none;
  mix-blend-mode: screen;
}

#grain-canvas {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  opacity: 0.05;
  mix-blend-mode: overlay;
  image-rendering: pixelated;
}

/* Cinematic Realism Additions */

#swing-step-label {
  position: absolute;
  top: -40px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
  pointer-events: none;
  animation: pulseLabel 1s infinite alternate;
}
@keyframes pulseLabel {
  from { opacity: 0.8; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1.02); }
}

#vignette-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}
.flash-green {
  box-shadow: inset 0 0 150px rgba(74, 222, 128, 0.6);
  opacity: 1 !important;
}
.flash-red {
  box-shadow: inset 0 0 150px rgba(239, 68, 68, 0.6);
  opacity: 1 !important;
}

#accuracy-bar .bar-track::before {
  content: '';
  position: absolute;
  top: 48%;
  bottom: 48%;
  left: 0; right: 0;
  background: rgba(251, 191, 36, 0.6);
  box-shadow: 0 0 10px rgba(251, 191, 36, 1.0);
  z-index: 0;
}

#replay-ui {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  pointer-events: none;
}
#replay-watermark {
  position: absolute;
  top: 30px;
  right: 30px;
  font-family: 'Cinzel', serif;
  font-size: 32px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 4px;
}
.replay-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 15px;
  pointer-events: auto;
  background: rgba(10, 31, 10, 0.85);
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.replay-controls button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  transition: all 0.2s;
}
.replay-controls button:hover {
  background: rgba(255, 255, 255, 0.2);
}
.replay-progress-bg {
  width: 200px;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
}
#replay-progress-fill {
  width: 0%;
  height: 100%;
  background: #fbbf24;
}
