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

body {
  background: #0a0a12;
  color: #e0e0e0;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 960px;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  font-size: 9px;
  color: #8888aa;
  z-index: 10;
}

#hud-left, #hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#hud-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#level-name {
  color: #ccccee;
  font-size: 10px;
  letter-spacing: 2px;
}

#move-counter {
  color: #6a6a8a;
}

button {
  font-family: 'Press Start 2P', monospace;
  background: #1a1a2e;
  color: #8888cc;
  border: 1px solid #333355;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

button:hover {
  background: #2a2a4e;
  color: #aaaaee;
  border-color: #5555aa;
}

button:active {
  transform: scale(0.95);
}

#canvas {
  border: 2px solid #1a1a3a;
  border-radius: 4px;
  image-rendering: pixelated;
  display: block;
}

#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 20;
}

#controls-hint {
  font-size: 7px;
  color: #444466;
  margin-top: 8px;
  letter-spacing: 1px;
}

#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
  gap: 4px;
  z-index: 10;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #12122a;
  border: 2px solid #2a2a55;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: #3a3a6e;
}

.dpad-row {
  display: flex;
  gap: 4px;
}

.mobile-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.action-btn {
  width: 44px;
  height: 44px;
  font-size: 16px;
  padding: 0;
  border-radius: 50%;
  background: #1a0a1a;
  border: 2px solid #442244;
}

/* Level Select */
#level-select {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(5,5,15,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#level-select.hidden, #win-overlay.hidden {
  display: none;
}

#level-select-inner {
  text-align: center;
}

#level-select-inner h2 {
  font-size: 14px;
  color: #aaaadd;
  margin-bottom: 24px;
  letter-spacing: 3px;
}

#level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.level-btn {
  width: 64px;
  height: 64px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
}

.level-btn.completed {
  border-color: #33aa55;
  color: #55dd77;
}

.level-btn.locked {
  opacity: 0.3;
  cursor: not-allowed;
}

.level-btn .checkmark {
  color: #44dd66;
  font-size: 14px;
}

#btn-close-levels {
  font-size: 8px;
  padding: 8px 20px;
}

/* Win Overlay */
#win-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(5,5,15,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#win-inner {
  text-align: center;
}

#win-inner h2 {
  font-size: 20px;
  color: #ffdd44;
  margin-bottom: 16px;
  letter-spacing: 4px;
  animation: pulse-glow 1s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  from { text-shadow: 0 0 10px #ffdd44; }
  to { text-shadow: 0 0 30px #ffaa00, 0 0 60px #ff6600; }
}

#win-moves {
  font-size: 8px;
  color: #888;
  margin-bottom: 20px;
}

#btn-next-level {
  font-size: 10px;
  padding: 12px 24px;
  background: #1a2a1a;
  border-color: #33aa55;
  color: #55dd77;
}

footer {
  position: fixed;
  bottom: 8px;
  font-size: 8px;
  z-index: 5;
}

footer a {
  color: #333355;
  text-decoration: none;
  font-family: 'Press Start 2P', monospace;
}

footer a:hover {
  color: #6666aa;
}

@media (max-width: 700px) {
  #controls-hint { display: none; }
  #mobile-controls { display: flex; }
  #hud { font-size: 7px; }
  #level-name { font-size: 8px; }
  .level-btn { width: 54px; height: 54px; font-size: 8px; }
}

@media (max-width: 400px) {
  #level-grid { grid-template-columns: repeat(3, 1fr); }
}