/* Make sure the root and body take full viewport height */
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #111;
  overflow: hidden; /* hide scrollbars */
}
.hidden {
  display: none !important;
}
/* Body flex center but relative for UI */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;  /* viewport height */
  position: relative;
  -webkit-overflow-scrolling: touch;
  background: #111;
}

/* Wrapper to fill viewport */
#canvasWrapper {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 0;
  /* Add safe area padding to prevent notch cutoffs */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-sizing: border-box;
  touch-action: none;
}

/* Fullscreen canvas */
canvas {
  background: #000;
  border: 3px solid #66ffff;
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  display: block;
  max-width: 100%;
  max-height: 100%;
  /* Disable default iOS touch zoom */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* UI elements fixed on top */
#hud, #healthBarContainer, #healthText, #controls, #waveScreen {
  position: fixed;
  z-index: 10;
  user-select: none;
}

/* Example: hud top-left */
#hud {
  top: 20px;
  left: 20px;
  color: #009999;
  font-family: monospace;
  font-size: clamp(14px, 2vw, 20px);
}
#gameCanvas, body, html {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -moz-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* Controls bottom-left */
#controls {
  bottom: 20px;
  left: 20px;
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: clamp(12px, 2vw, 16px);
  max-width: 90vw;
  overflow-wrap: break-word;
  color: #009999;
}

/* Health bar */
#healthBarContainer {
  top: 60px;
  left: 20px;
  width: 200px;
  height: 20px;
  border: 2px solid #00ffff;
  border-radius: 5px;
  background: #222;
}

#healthBarFill {
  height: 100%;
  background: #00ffff;
  width: 100%;
  border-radius: 3px;
  transition: width 0.2s ease;
}

#healthText {
  top: 60px;
  left: 230px;
  color: #00ffff;
  font-family: monospace;
  font-size: clamp(12px, 1.8vw, 18px);
}

/* Wave screen full overlay */
#waveScreen {
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.9);
  color: #00ffff;
  font-family: monospace;
  font-size: clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  visibility: hidden;
  z-index: 20;
}

/* Mobile portrait canvas flip */
@media (max-width: 768px) and (orientation: portrait) {
  canvas {
    aspect-ratio: 9 / 16;
    width: auto;
    height: 100vh;
  }
}

/* Prevent body from resizing on input focus (Safari fix) */
input, textarea, select, button {
  font-size: 16px;
}

#radioUI {
  background: #111;
  border: 2px solid #44ffcc;
  padding: 20px;
  border-radius: 8px;
  width: 300px;
  text-align: center;
}

#stationList li {
  margin: 8px 0;
  cursor: pointer;
}

#stationList li.locked {
  opacity: 0.3;
  pointer-events: none;
}

#radioPanel {
  position: fixed;
  top: 0;
  right: 0;
  width: 350px;
  max-width: 80vw;
  height: 100vh;
  background: rgba(15,15,15,0.95);
  color: #eee;
  box-shadow: -4px 0 12px rgba(0,0,0,0.8);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1050;
  overflow-y: auto;
  overflow-x: hidden; /* add this */
  padding: 20px;
  font-family: monospace, monospace;
}

#radioPanel.visible {
  transform: translateX(0);
}

#radioUI h2 {
  margin-top: 0;
  margin-bottom: 16px;
}

#stationList {
  list-style: none;
  padding: 0;
  margin-bottom: 20px;
}

#stationList li {
  padding: 8px 12px;
  background: #333;
  margin-bottom: 8px;
  border-radius: 4px;
  cursor: pointer;
}

#stationList li.active {
  background: #5599ff;
  font-weight: bold;
}

#closeRadio {
  background: #5599ff;
  border: none;
  color: white;
  padding: 10px 16px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
}

#radioControls button {
  margin-right: 10px;
  padding: 8px 12px;
  font-size: 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background-color: #5599ff;
  color: white;
  user-select: none;
}

#radioControls button:hover {
  background-color: #3377cc;
}
