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

body {
  background: #0a0a0a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  image-rendering: pixelated;
}

#game-wrapper {
  position: relative;
  width: 800px;
  height: 480px;
  border: 3px solid #333;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(220, 38, 38, 0.15), 0 0 80px rgba(0,0,0,0.5);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #1a1a2e;
  image-rendering: pixelated;
}

#ui-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#ui-overlay button {
  pointer-events: auto;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10;
}

.screen.active {
  display: flex;
}

.screen.hidden {
  display: none !important;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  font-size: 10px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

#hud.hidden {
  display: none;
}

#hud-left, #hud-center, #hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

#hud-right {
  gap: 8px;
}

.game-title {
  font-size: 42px;
  color: #dc2626;
  text-shadow: 4px 4px 0 #7f1d1d, 0 0 30px rgba(220,38,38,0.3);
  margin-bottom: 8px;
  letter-spacing: 6px;
}

.subtitle {
  font-size: 10px;
  color: #a1a1aa;
  margin-bottom: 32px;
  letter-spacing: 4px;
}

.screen-title {
  font-size: 24px;
  color: #dc2626;
  text-shadow: 3px 3px 0 #7f1d1d;
  margin-bottom: 24px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.menu-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 10px 24px;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-shadow: 1px 1px 0 #991b1b;
  box-shadow: 0 3px 0 #991b1b;
  image-rendering: pixelated;
}

.menu-btn:hover {
  background: #ef4444;
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #991b1b;
}

.menu-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #991b1b;
}

.menu-btn.small {
  font-size: 8px;
  padding: 6px 10px;
}

.menu-btn.back-btn {
  margin-top: 20px;
  background: #555;
  box-shadow: 0 3px 0 #333;
}

.menu-btn.back-btn:hover {
  background: #777;
}

.menu-controls {
  margin-top: 30px;
  font-size: 7px;
  color: #555;
  text-align: center;
  line-height: 1.8;
}

#level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 360px;
  margin-bottom: 12px;
}

.level-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  width: 60px;
  height: 60px;
  background: #333;
  color: #666;
  border: 2px solid #444;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
  image-rendering: pixelated;
}

.level-btn.unlocked {
  background: #1a3a2a;
  border-color: #22c55e;
  color: #22c55e;
}

.level-btn.unlocked:hover {
  background: #2a5a3a;
  border-color: #4ade80;
}

.level-btn.completed {
  background: #1a3a2a;
  border-color: #22c55e;
  color: #22c55e;
}

.level-btn.current {
  border-color: #dc2626;
  box-shadow: 0 0 12px rgba(220,38,38,0.3);
}

.credits-content {
  font-size: 9px;
  color: #a1a1aa;
  text-align: center;
  line-height: 2;
  margin-bottom: 20px;
}

.gameover-sub, .victory-sub {
  font-size: 10px;
  color: #a1a1aa;
  margin-bottom: 20px;
}

#level-complete-stats, #victory-stats {
  font-size: 9px;
  color: #a1a1aa;
  margin-bottom: 16px;
  text-align: center;
  line-height: 2;
}

#toast-container {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  font-size: 8px;
  padding: 6px 14px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  border-radius: 2px;
  text-shadow: 1px 1px 0 #000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}
