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

html, body {
  width: 100%; height: 100%;
  background: #04060f;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: 'Courier New', monospace;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; /* no pull-to-refresh / double-tap zoom while playing */
}

/* fixed inset box = always exactly the visible viewport (survives phone toolbars) */
#wrap {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  height: 100dvh; /* dynamic viewport unit where supported; the inset fallback covers the rest */
  display: flex; align-items: center; justify-content: center;
}

canvas {
  background: #04060f;
  touch-action: none; /* browser must not hijack touches for scroll/zoom — pointer events drive the ship */
  box-shadow: 0 0 60px rgba(0, 200, 255, 0.15), inset 0 0 80px rgba(0,0,0,0.6);
}

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,10,0.55) 100%);
}

/* ---------- Touch buttons ----------
   Positioned against the safe-area insets so notches and home indicators
   never sit on top of a control. */
.touch-btn {
  position: absolute; z-index: 10;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 76px; height: 76px; border-radius: 50%;
  border: 2px solid rgba(0, 229, 255, 0.6);
  background: rgba(0, 40, 80, 0.35);
  color: #7df9ff; font-family: inherit; font-weight: bold; font-size: 15px;
  letter-spacing: 1px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.touch-btn:active { background: rgba(0, 120, 200, 0.5); transform: scale(0.94); }

/* BOMB — big bottom-left thumb target with live count badge */
#bombBtn {
  left: calc(20px + env(safe-area-inset-left, 0px));
  width: 92px; height: 92px;
  color: #ffd76a; font-size: 17px;
  border-color: rgba(255, 200, 80, 0.7);
  background: rgba(60, 40, 0, 0.35);
  box-shadow: 0 0 18px rgba(255, 200, 80, 0.25), inset 0 0 14px rgba(255, 200, 80, 0.12);
}
#bombBtn:active { background: rgba(160, 110, 10, 0.55); }
#bombBtn .count {
  position: absolute; top: -4px; right: -4px;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 14px;
  background: #ffd76a; color: #3a2500;
  font-size: 15px; line-height: 28px; text-align: center;
  box-shadow: 0 0 8px rgba(255, 215, 106, 0.7);
}

/* PAUSE — small, top-right, clear of the canvas HUD (game.js reserves room for it) */
#pauseBtn {
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: auto;
  width: 52px; height: 52px; font-size: 17px;
}

/* ---------- Menu / game-over stack ----------
   A single flow column, so nothing can overlap however short the viewport is. */
#uiStack {
  position: absolute; left: 0; right: 0; z-index: 11;
  bottom: calc(5% + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 11px;
  pointer-events: none;            /* gaps stay tappable as "launch" */
}
#uiStack > * { pointer-events: auto; }
#uiStack.on-board {                /* the board screen wants it up top */
  bottom: auto;
  top: calc(3% + env(safe-area-inset-top, 0px));
}
#uiStack > .touch-btn,
#uiStack > .name-input {
  position: static;
  left: auto; right: auto; top: auto; bottom: auto;
  transform: none;
}

#startBtn {
  width: auto; height: 54px; padding: 0 40px;
  border-radius: 27px;
  font-size: 19px; letter-spacing: 3px;
  border-color: rgba(125, 249, 255, 0.85);
  background: rgba(0, 60, 110, 0.55);
  box-shadow: 0 0 24px rgba(0, 200, 255, 0.3);
}
#startBtn:active { transform: scale(0.95); }

@media (pointer: coarse) {
  .touch-btn { display: flex; }
}
body.touch-ui .touch-btn { display: flex; }

/* ---------- Landscape prompt (phones only) ---------- */
#rotate {
  position: absolute; inset: 0; z-index: 50;
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #04060f;
  color: #7df9ff; font-size: 18px; letter-spacing: 3px; font-weight: bold;
}
#rotate .rot-icon { font-size: 62px; line-height: 1; }
body.landscape-warn #rotate { display: flex; }
body.landscape-warn .touch-btn { display: none !important; } /* beats the inline style game.js sets */

/* Small screens: trim the controls so they don't eat the playfield */
@media (max-height: 640px) {
  #bombBtn { width: 74px; height: 74px; font-size: 15px; }
  #pauseBtn { width: 44px; height: 44px; font-size: 15px; }
  #startBtn { height: 50px; font-size: 17px; padding: 0 32px; }
}

/* MUTE — stacked under pause so the HUD's right column reserve is unchanged */
#muteBtn {
  top: calc(76px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: auto;
  width: 52px; height: 52px;
  color: #7df9ff;
}
#muteBtn .slash { opacity: 0; }
#muteBtn.off { color: #5f7d9c; border-color: rgba(95, 125, 156, 0.6); }
#muteBtn.off .wave { opacity: 0; }
#muteBtn.off .slash { opacity: 1; }

/* FOCUS — held with the free thumb; bottom-right mirrors BOMB */
#focusBtn {
  right: calc(20px + env(safe-area-inset-right, 0px));
  width: 84px; height: 84px;
  font-size: 14px;
  color: #bfe9ff;
  border-color: rgba(191, 233, 255, 0.55);
  background: rgba(0, 40, 80, 0.3);
}
#focusBtn.held {                 /* slow motion is running */
  background: rgba(0, 150, 220, 0.6);
  border-color: rgba(191, 233, 255, 1);
  box-shadow: 0 0 22px rgba(120, 220, 255, 0.7);
}
#focusBtn.cooling {              /* recharging — visibly unavailable */
  opacity: 0.4;
  color: #5f7d9c;
  border-color: rgba(95, 125, 156, 0.5);
  background: rgba(10, 22, 36, 0.35);
}
#focusBtn:not(.cooling):not(.held) {   /* charged and waiting */
  animation: focusReady 2s ease-in-out infinite;
}
@keyframes focusReady {
  0%, 100% { box-shadow: 0 0 8px rgba(191, 233, 255, 0.25); }
  50%      { box-shadow: 0 0 20px rgba(191, 233, 255, 0.6); }
}

/* SAVE CARD — game-over only */
#cardBtn {
  width: auto; height: 42px; padding: 0 26px;
  border-radius: 21px;
  font-size: 14px; letter-spacing: 2px;
  color: #ffd76a;
  border-color: rgba(255, 215, 106, 0.7);
  background: rgba(60, 40, 0, 0.4);
}
#cardBtn:active { transform: scale(0.95); }

@media (max-height: 640px) {
  #focusBtn { width: 68px; height: 68px; font-size: 12px; }
  #muteBtn { width: 44px; height: 44px; top: calc(64px + env(safe-area-inset-top, 0px)); }
}

/* SCORES & BADGES — menu and game-over only */
#boardBtn {
  width: auto; height: 40px; padding: 0 22px;
  border-radius: 20px;
  font-size: 13px; letter-spacing: 2px;
  color: #8fb4d9;
  border-color: rgba(143, 180, 217, 0.5);
  background: rgba(10, 24, 40, 0.5);
}
#boardBtn:active { transform: scale(0.95); }


/* ---------- Pilot name ---------- */
.name-input {
  display: none;
  width: 210px; height: 38px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid rgba(125, 249, 255, 0.45);
  background: rgba(6, 16, 30, 0.75);
  color: #cfeaff;
  font-family: inherit; font-size: 15px; font-weight: bold;
  letter-spacing: 3px; text-align: center; text-transform: uppercase;
  outline: none;
  touch-action: manipulation;
  -webkit-appearance: none; appearance: none;
}
.name-input::placeholder { color: #46607a; letter-spacing: 2px; font-weight: normal; }
.name-input:focus {
  border-color: rgba(125, 249, 255, 0.95);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.3);
  color: #ffffff;
}

