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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #ddd;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* --- FPS Counter --- */

#fps-counter {
  position: fixed;
  top: 4px;
  right: 4px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #0f0;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 4px;
  z-index: 200;
  pointer-events: none;
  white-space: pre;
}

/* --- HUD --- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  padding: 16px 24px;
  z-index: 50;
  pointer-events: none;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-timer {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.hud-hp {
  display: flex;
  gap: 4px;
}

.heart::before {
  content: '\2665';
  font-size: 22px;
}

.heart.filled {
  color: #ff4444;
  text-shadow: 0 0 6px #ff2222;
}

.heart.empty {
  color: #442222;
}

.hud-keys {
  display: flex;
  gap: 6px;
}

.key-indicator {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.key-gold { background: #ffd700; }
.key-red { background: #ff4444; }
.key-blue { background: #4488ff; }
.key-green { background: #44ff44; }
.key-purple { background: #aa44ff; }

.hud-stars {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.star-icon::before {
  content: '\2605';
  font-size: 20px;
  color: #ffd700;
  text-shadow: 0 0 4px #ffd700;
}

/* --- Overlays --- */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
}

.overlay-content {
  text-align: center;
  max-width: 400px;
  padding: 40px;
}

.game-title {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 12px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  margin-bottom: 8px;
}

.game-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 32px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.overlay h2 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 4px;
}

.death-title {
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.4);
}

.overlay-hint {
  color: #888;
  font-size: 14px;
}

/* --- Loading --- */

.loading-bar-track {
  width: 100%;
  height: 8px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: #ffd700;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
  transition: width 0.15s ease-out;
}

.loading-text {
  color: #888;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* --- Level select --- */

#level-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.level-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #ddd;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.level-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 215, 0, 0.5);
}

.level-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.level-stars {
  color: #ffd700;
  font-size: 18px;
  letter-spacing: 2px;
}

/* --- Complete screen --- */

.complete-stars {
  font-size: 48px;
  color: #ffd700;
  letter-spacing: 8px;
  margin-bottom: 20px;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.complete-stat {
  font-size: 16px;
  color: #aaa;
  margin-bottom: 6px;
}

.complete-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.btn {
  padding: 10px 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ddd;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: rgba(255, 215, 0, 0.2);
  border-color: rgba(255, 215, 0, 0.4);
  color: #ffd700;
}

.btn-primary:hover {
  background: rgba(255, 215, 0, 0.3);
}

/* --- Touch Controls --- */

#touch-controls {
  pointer-events: none;
  z-index: 60;
}

.joystick-base {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(24px + env(safe-area-inset-left, 0px));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  z-index: 60;
}

.joystick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: none;
}

.attack-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 200, 50, 0.25);
  border: 2px solid rgba(255, 200, 50, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: rgba(255, 215, 0, 0.9);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  z-index: 60;
}

.attack-btn-active {
  background: rgba(255, 200, 50, 0.45);
  border-color: rgba(255, 200, 50, 0.8);
}
