* { touch-action: manipulation; }
html, body {
  margin: 0;
  height: 100%;
  background: #0b0f14;
  overflow: hidden;
}
canvas { display: block; }
/* Gameplay HUD hidden by default — play-session shows it */
#hud {
  position: fixed;
  left: 16px;
  top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-family: monospace;
  font-size: 13px;
  display: none;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}
.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.hud-label {
  flex: 1;
}
.hud-value {
  min-width: 50px;
  text-align: center;
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}
.hud-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.hud-btn:hover {
  background: rgba(255,255,255,0.2);
}
.hud-btn:active {
  background: rgba(255,255,255,0.3);
}
.hud-input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
.hud-unit {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}
.hud-divider {
  height: 1px;
  background: rgba(255,255,255,0.2);
  margin: 4px 0;
}
.hud-readonly {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  flex: 1;
  text-align: right;
}
.debug-section {
  /* Stage-specific debug UI sections */
}
#hud-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px 0;
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  letter-spacing: 2px;
  transition: color 0.15s;
}
#hud-toggle:hover {
  color: rgba(255,255,255,0.7);
}
#hud-collapsible.collapsed {
  display: none;
}

/* Scoring panel - top right, hidden until play-session */
#scoring-panel {
  position: fixed;
  right: 16px;
  top: 16px;
  padding: 16px 24px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-family: monospace;
  text-align: center;
  min-width: 140px;
  display: none;
}
#scoring-shots {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 6px;
}
#scoring-shots .shots-current {
  color: #fc8;
}
#scoring-hole {
  font-size: 18px;
  color: rgba(255,255,255,0.8);
}
#scoring-hole .hole-current {
  color: #8cf;
}
#scoring-shots .shots-par {
  color: rgba(255,255,255,0.5);
}
#scoring-fps {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  text-align: left;
}
#scoring-fps .fps-value {
  color: #8f8;
  font-weight: bold;
}
#scoring-fps .fps-low {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
}

/* Vehicle debug panel */
#vehicle-debug {
  position: fixed;
  right: 16px;
  top: 120px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(100,200,255,0.3);
  color: #fff;
  font-family: monospace;
  font-size: 11px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 100;
}
#vehicle-debug.visible { display: flex; }
#vehicle-debug .bd-title {
  font-size: 13px;
  font-weight: bold;
  color: #8cf;
  margin-bottom: 2px;
}
#vehicle-debug .bd-section {
  color: rgba(100,200,255,0.7);
  font-size: 10px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#vehicle-debug .bd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
#vehicle-debug .bd-row label { flex: 1; }
#vehicle-debug .bd-row input {
  width: 55px;
  padding: 2px 4px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
}
#vehicle-debug .bd-row .bd-unit {
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  width: 24px;
}
#vehicle-debug .bd-readout {
  color: #8f8;
  font-weight: bold;
}
#vehicle-debug .bd-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 2px 0;
}

/* Range debug panel */
#range-debug {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255,200,50,0.3);
  color: #fff;
  font-family: monospace;
  font-size: 11px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 260px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 100;
}
#range-debug.visible { display: flex; }
#range-debug .bd-title { font-size: 13px; font-weight: bold; color: #fd8; margin-bottom: 2px; }
#range-debug .bd-section { color: rgba(255,200,80,0.7); font-size: 10px; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
#range-debug .bd-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#range-debug .bd-row label { flex: 1; }
#range-debug .bd-row input { width: 55px; padding: 2px 4px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #fff; border-radius: 3px; font-family: monospace; font-size: 11px; }
#range-debug .bd-readout { color: #fd8; font-weight: bold; }
#range-debug .bd-readout.estimate { color: #8f8; font-size: 13px; }
#range-debug .bd-divider { height: 1px; background: rgba(255,200,80,0.15); margin: 2px 0; }
#range-debug .bd-unit { font-size: 9px; color: rgba(255,255,255,0.4); width: 24px; }

/* Screen fade overlay for transitions */
#screen-fade {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.4s ease-in-out;
}
#screen-fade.active {
  opacity: 1;
}

/* Mobile styles */
@media (max-width: 768px), (pointer: coarse) {
  #hud {
    left: 10px;
    transform: none;
    top: 70px;
    padding: 8px 10px;
    font-size: 10px;
    min-width: auto;
    max-width: 160px;
    gap: 3px;
  }
  .hud-row {
    gap: 3px;
  }
  .hud-input {
    width: 45px;
    padding: 2px 3px;
    font-size: 10px;
  }
  .hud-btn {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .hud-value {
    min-width: 35px;
    font-size: 9px;
  }
  .hud-unit {
    font-size: 8px;
  }
  .hud-label {
    font-size: 9px;
  }
  /* Hide verbose debug info on mobile */
  .hud-row:has(#camPosValue),
  .hud-row:has(#camRotValue),
  .hud-row:has(#stageValue) {
    display: none;
  }
  /* Hide divider after stage row */
  .hud-row:has(#stageValue) + .hud-divider {
    display: none;
  }
  /* Mobile scoring panel */
  #scoring-panel {
    right: 10px;
    top: 10px;
    padding: 8px 12px;
    min-width: 80px;
  }
  #scoring-shots {
    font-size: 14px;
  }
  #scoring-hole {
    font-size: 11px;
  }
  #scoring-fps {
    font-size: 10px;
  }
  #scoring-fps .fps-low {
    font-size: 9px;
  }
}

/* Main menu — defined in HTML so title + art are visible from first paint */
#screen-main-menu {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  color: #fff;
  font-family: monospace;
  text-align: center;
  overflow-y: auto;
  padding: clamp(36px, 8vh, 120px) 24px 24px;
  box-sizing: border-box;
}
#screen-main-menu .menu-title {
  font-size: clamp(52px, 8vw, 72px);
  font-weight: bold;
  letter-spacing: 8px;
  margin-bottom: clamp(28px, 4vh, 48px);
  color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.55);
}
#screen-main-menu .menu-subtitle {
  font-size: clamp(16px, 2.2vw, 18px);
  color: rgba(255,255,255,0.5);
  margin-top: -34px;
  margin-bottom: clamp(56px, 14vh, 146px);
  letter-spacing: 4px;
  text-shadow: 0 2px 18px rgba(0,0,0,0.45);
}
#screen-main-menu .menu-play {
  padding: clamp(12px, 2vh, 16px) clamp(44px, 7vw, 64px);
  font-size: clamp(20px, 3vw, 24px);
  font-family: monospace;
  font-weight: bold;
  background: rgba(9,14,20,0.42);
  border: 2px solid rgba(255,255,255,0.36);
  backdrop-filter: blur(8px);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 4px;
  transition: background 0.2s, border-color 0.2s;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  /* Hidden until JS wires the click handler */
  visibility: hidden;
}
#screen-main-menu .menu-play:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}
#screen-main-menu .menu-debug {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: clamp(16px, 3vh, 32px);
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  /* Hidden until JS wires the change handler */
  visibility: hidden;
}

/* Prevent text selection and callouts on mobile */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
