/* Iron Rebel — pixel shell + landscape touch controls */

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

html, body {
  width: 100%; height: 100%;
  background: radial-gradient(circle at 50% 30%, #1a3a28 0%, #0b1a12 45%, #050a08 100%);
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game-container {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b1a12;
  box-shadow: 0 0 0 2px #2a3a30, 0 12px 40px rgba(0,0,0,0.55);
}

.back-link {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 20;
  color: #cfe8d8;
  text-decoration: none;
  font-size: 12px;
  padding: 6px 10px;
  background: rgba(8,16,12,0.7);
  border: 1px solid #3a5a48;
  border-radius: 4px;
}
.back-link:hover { color: #ffe14d; }

#top-controls {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 20;
  display: flex; gap: 8px;
}
.top-btn {
  width: 40px; height: 32px;
  border: 1px solid #5a6a58;
  background: rgba(10,18,14,0.75);
  color: #cfe8d8;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.top-btn:active { background: #243028; color: #ffe14d; }

#mobile-controls {
  position: absolute; inset: 0;
  pointer-events: none;
  display: none;
  z-index: 10;
}
body.touch-device #mobile-controls { display: block; }

#joystick-zone {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: calc(20px + env(safe-area-inset-left));
  width: 128px; height: 128px;
  pointer-events: auto;
  touch-action: none;
  opacity: 0.55;
}
#joystick-zone:active, #joystick-outer:active { opacity: 0.9; }
#joystick-outer {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255,225,77,0.55);
  background: radial-gradient(circle, rgba(255,255,255,0.08), rgba(0,0,0,0.28));
}
#joystick-inner {
  position: absolute; left: 50%; top: 50%;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(255,225,77,0.55);
  will-change: transform;
}

#dpad {
  display: none; /* joystick primary; dpad kept for fallback accessibility if shown later */
}

.vbtn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  background: rgba(12,20,16,0.35);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  opacity: 0.5;
  display: flex; align-items: center; justify-content: center;
}
.vbtn.active, .vbtn:active { opacity: 0.95; background: rgba(255,80,60,0.35); }
#btn-jump {
  right: calc(28px + env(safe-area-inset-right));
  bottom: calc(36px + env(safe-area-inset-bottom));
  border-color: rgba(77,184,255,0.7);
}
#btn-shoot {
  right: calc(110px + env(safe-area-inset-right));
  bottom: calc(36px + env(safe-area-inset-bottom));
  border-color: rgba(255,80,60,0.7);
}
#btn-weapon {
  right: calc(70px + env(safe-area-inset-right));
  bottom: calc(118px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  font-size: 14px;
  border-color: rgba(255,225,77,0.6);
}
#btn-pause-touch {
  top: calc(56px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 44px; height: 44px;
  font-size: 12px;
}

@media (min-width: 900px) {
  body.touch-device #mobile-controls { opacity: 0.85; }
}
