@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', monospace;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

#game-container {
  position: relative;
  width: 768px;
  height: 720px;
  background: #000;
  border: 8px solid #444;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  position: relative;
  z-index: 1;
}

@media (min-width: 769px) {
  canvas {
    width: 768px;
    height: 720px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  #container {
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 220px;
  }
  
  canvas {
    width: 100vw;
    height: auto;
  }
}

.mobile-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100vw;
  height: 200px;
  background: rgba(0, 0, 0, 0.95);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1000;
}

.mobile-controls.active {
  display: block;
}

.dpad {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 120px;
  height: 120px;
}

.dpad-btn {
  position: absolute;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  font-weight: bold;
  touch-action: none;
  z-index: 1001;
}

.dpad-arrow {
  display: block;
  line-height: 1;
  transform-origin: center;
}

.dpad-left .dpad-arrow {
  transform: rotate(-90deg);
}

.dpad-right .dpad-arrow {
  transform: rotate(90deg);
}

.dpad-btn:active {
  background: rgba(255, 255, 255, 0.6);
}

.dpad-up { top: 0; left: 40px; }
.dpad-down { bottom: 0; left: 40px; }
.dpad-left { top: 40px; left: 0; }
.dpad-right { top: 40px; right: 0; }

.action-buttons {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 140px;
  height: 80px;
  z-index: 1001;
}

.action-btn {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255, 200, 0, 0.4);
  border: 2px solid rgba(255, 200, 0, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
  font-weight: bold;
  touch-action: none;
  font-family: 'Press Start 2P', monospace;
  z-index: 1002;
}

.action-btn:active {
  background: rgba(255, 200, 0, 0.7);
}

.btn-action { top: 10px; right: 0; }
.btn-menu { top: 10px; right: 80px; }

#title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1e 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  z-index: 10;
  animation: fadeIn 1s;
}

#title-screen.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.title {
  font-size: 32px;
  color: #ffd700;
  text-shadow: 4px 4px #8b4513;
  margin-bottom: 40px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.subtitle {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 60px;
}

.start-text {
  font-size: 14px;
  color: #fff;
  animation: blink 1.5s infinite;
}

.controls {
  position: absolute;
  bottom: 20px;
  font-size: 8px;
  color: #666;
  text-align: center;
}
