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

html, body {
  height: 100%;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e0e0e0;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-wrap {
  position: relative;
  width: 800px;
  height: 600px;
  flex-shrink: 0;
  transform-origin: center center;
}

canvas {
  display: block;
  background: #121212;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.08);
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(3px);
  border-radius: 8px;
  text-align: center;
}

.overlay.visible { display: flex; }

.overlay h1 {
  font-size: 52px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.overlay p { font-size: 18px; color: #9e9e9e; max-width: 480px; line-height: 1.5; }

.overlay.gameover h1 { color: #ff1744; text-shadow: 0 0 24px rgba(255, 23, 68, 0.7); }
.overlay.victory h1 { color: #ffd740; text-shadow: 0 0 24px rgba(255, 215, 64, 0.7); }
.overlay.intro h1 { color: #00e5ff; text-shadow: 0 0 24px rgba(0, 229, 255, 0.7); }

.overlay.intro p { max-width: 560px; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font-size: 15px;
  color: #bdbdbd;
}

.controls > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.controls .icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-size: 16px;
}

kbd {
  display: inline-block;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 13px;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.overlay button {
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 14px 36px;
  color: #00e5ff;
  background: transparent;
  border: 2px solid #00e5ff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.25), inset 0 0 16px rgba(0, 229, 255, 0.08);
}

.overlay button:hover {
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.5), inset 0 0 20px rgba(0, 229, 255, 0.15);
}

#level-banner {
  position: absolute;
  top: 45%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 40px;
  letter-spacing: 8px;
  text-transform: uppercase;
  color: #00e5ff;
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#level-banner.show { opacity: 1; }

/* ---------- Touch Controls ---------- */
.touch-only { display: none; }
body.touch .touch-only { display: flex; }

#fire-btn {
  display: none;
  position: fixed;
  right: 28px;
  bottom: 32px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #76ff03;
  background: rgba(118, 255, 3, 0.08);
  border: 2px solid rgba(118, 255, 3, 0.6);
  box-shadow: 0 0 18px rgba(118, 255, 3, 0.25), inset 0 0 14px rgba(118, 255, 3, 0.08);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}
body.touch #fire-btn { display: block; }

#fire-btn:active {
  background: rgba(118, 255, 3, 0.22);
  box-shadow: 0 0 28px rgba(118, 255, 3, 0.5);
}

#joy-base, #joy-stick {
  display: none;
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 10;
}

#joy-base.visible, #joy-stick.visible { display: block; }

#joy-base {
  width: 110px;
  height: 110px;
  border: 2px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.05);
}

#joy-stick {
  width: 48px;
  height: 48px;
  background: rgba(0, 229, 255, 0.3);
  border: 2px solid rgba(0, 229, 255, 0.7);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
}

#rotate-hint {
  display: none;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  font-size: 14px;
  color: #ffd740;
  background: rgba(18, 18, 18, 0.85);
  border: 1px solid rgba(255, 215, 64, 0.4);
  border-radius: 20px;
  box-shadow: 0 0 14px rgba(255, 215, 64, 0.2);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}

@media (orientation: portrait) {
  body.touch #rotate-hint { display: block; }
}
