html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #10142a, #02030a);
  color: #f0f4ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100%;
  overflow: hidden;
}

#ui {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  z-index: 2;
  opacity: 0.85;
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 2px;
}

#hud {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  justify-content: center;
}

#message {
  margin-bottom: 10px;
  min-height: 20px;
}

#startButton {
  padding: 6px 12px;
  background: #2b5cff;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-weight: 600;
}

#startButton:hover {
  opacity: 0.9;
}

#gameCanvas {
  display: block;
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,0.1);
  background: radial-gradient(circle at center, #050816, #02030a);
  box-shadow: 0 0 40px rgba(0,0,0,0.7);
}

/* === Mobile controls (hidden on desktop by default) === */

#mobile-controls {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  left: max(12px, env(safe-area-inset-left, 12px));
  right: max(12px, env(safe-area-inset-right, 12px));
  display: none; /* shown only on touch devices via JS */
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none; /* children re-enable this */
  z-index: 5;
}

#mobile-controls * {
  pointer-events: auto;
}

#btnShoot {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: none;
  font-size: 16px;
  font-weight: 600;
  background: rgba(255, 80, 80, 0.8);
  color: #f5f5ff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
  margin-right: 10px;
  touch-action: none;
}

/* Slightly bigger on phones */
@media (max-width: 900px) {
  #joystick {
    width: 140px;
    height: 140px;
  }
  #btnShoot {
    width: 100px;
    height: 100px;
  }
}

#joystick {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.7));
  border: 2px solid rgba(255, 255, 255, 0.2);
}

#joystick-handle {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
}

/* === High score overlay === */
#high-scores {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(5, 10, 30, 0.94);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 14px 22px 18px;
  z-index: 20;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
  min-width: 240px;
  max-width: 340px;
  pointer-events: none;
}

#high-scores h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #93c5fd;
  text-transform: uppercase;
}

.hs-table {
  margin: 0 auto;
  border-collapse: collapse;
  width: 100%;
}

.hs-table th,
.hs-table td {
  padding: 3px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}

.hs-table th {
  color: #b0c4ff;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.hs-current td {
  color: #fbbf24;
  font-weight: 700;
}

.hs-date {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
}

@media (max-width: 360px) {
  .hs-col-date { display: none; }
}

/* === Name entry modal === */
#name-entry {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(5, 10, 30, 0.96);
  border: 1px solid rgba(255, 180, 0, 0.45);
  border-radius: 10px;
  padding: 20px 28px 22px;
  z-index: 30;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
  min-width: 240px;
  max-width: 300px;
}

.ne-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: #fbbf24;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ne-score {
  margin: 0 0 12px;
  font-size: 13px;
  color: #b0c4ff;
}

.ne-hint {
  margin: -6px 0 10px;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}

#ne-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  color: #f0f4ff;
  font-size: 16px;
  padding: 8px 10px;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 6px;
  outline: none;
  text-transform: uppercase;
  font-family: inherit;
}

#ne-input:focus {
  border-color: rgba(255, 180, 0, 0.6);
  background: rgba(255,255,255,0.1);
}

#ne-submit {
  padding: 8px 22px;
  background: #2b5cff;
  border: none;
  border-radius: 5px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-top: 4px;
}

#ne-submit:hover {
  opacity: 0.9;
}

/* === Orientation banner (portrait phones — slim suggestion strip) === */
#orientation-prompt {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(8, 14, 40, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 7px 16px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #b0c4ff;
}

#orientation-prompt p {
  margin: 0;
}

.rotate-icon {
  font-size: 18px;
  display: inline-block;
  animation: spin 3s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Portrait phones: show rotation banner and push HUD below it */
@media (orientation: portrait) and (max-width: 600px) {
  #orientation-prompt {
    display: flex;
  }
  #ui {
    top: 42px;
  }
}

/* Compact HUD on short landscape screens (phones in landscape) */
@media (max-height: 450px) {
  h1 {
    display: none;
  }
  #hud {
    font-size: 12px;
    gap: 10px;
  }
  #joystick {
    width: 90px;
    height: 90px;
  }
  #btnShoot {
    width: 72px;
    height: 72px;
    font-size: 13px;
  }
}

/* Larger controls for tablets (touch + wide screen) */
@media (min-width: 768px) and (pointer: coarse) {
  #joystick {
    width: 150px;
    height: 150px;
  }
  #btnShoot {
    width: 110px;
    height: 110px;
  }
}