* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  user-select: none;
}

/* ===== MENU ===== */
#menu {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 70%);
  position: relative;
  overflow: hidden;
}

.stars {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: twinkle ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.5); }
}

.title-container { text-align: center; margin-bottom: 40px; z-index: 1; }

.game-title {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #c62828, #ff6d00, #c62828);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 8px;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1rem;
  letter-spacing: 12px;
  color: #888;
  font-weight: 300;
}

.divider {
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c62828, transparent);
  margin: 20px auto;
}

.description { font-size: 0.95rem; color: #999; line-height: 1.8; }

.btn-container { display: flex; flex-direction: column; gap: 14px; z-index: 1; }

.menu-btn {
  padding: 14px 48px;
  font-size: 1.1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  letter-spacing: 2px;
}

.start-btn {
  background: linear-gradient(135deg, #c62828, #e53935);
  color: white;
  box-shadow: 0 4px 20px rgba(198, 40, 40, 0.4);
}
.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(198, 40, 40, 0.6);
}

.how-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.how-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.how-to {
  display: none;
  margin-top: 20px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  max-width: 500px;
  z-index: 1;
}

.how-to h3 { margin: 16px 0 8px; color: #e53935; font-size: 1rem; }
.how-to h3:first-child { margin-top: 0; }
.how-to p { color: #aaa; font-size: 0.85rem; line-height: 1.7; }

.how-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin-bottom: 8px;
}

.how-item { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.how-item .key {
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  min-width: 80px;
  text-align: center;
}
.how-item .desc { color: #999; }

.footer { margin-top: 30px; color: #555; font-size: 0.75rem; letter-spacing: 1px; z-index: 1; }

/* ===== GAME ===== */
#gameCanvas { display: block; width: 100vw; height: 100vh; }

#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
}

#health-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.6);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

#health-bar .bar-bg {
  width: 140px; height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
}

#health-bar .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e53935, #66bb6a);
  border-radius: 5px;
  transition: width 0.3s ease;
}

#healthText { font-size: 0.8rem; font-weight: 600; min-width: 28px; }

#floor-display, #score-display {
  background: rgba(0,0,0,0.6);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.9rem;
  font-weight: 600;
}

#hud-bottom {
  position: absolute;
  bottom: 16px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 24px;
}

#inventory {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.6);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}

.inv-title { color: #888; font-size: 0.75rem; }
.inv-key { font-size: 1rem; opacity: 0.3; transition: all 0.3s; }
.inv-key.has { opacity: 1; animation: keyGlow 1s ease-in-out infinite; }

@keyframes keyGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5) drop-shadow(0 0 4px currentColor); }
}

.inv-sep { color: #444; margin: 0 4px; }
.inv-potion { font-size: 0.85rem; }

#message {
  background: rgba(0,0,0,0.7);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  max-width: 400px;
  opacity: 0;
  transition: opacity 0.3s;
}
#message.show { opacity: 1; }

#minimap-container {
  position: absolute;
  top: 70px;
  right: 24px;
  width: 140px;
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.8);
}
#minimap { width: 100%; height: 100%; }

#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.4);
  font-size: 1.2rem;
  font-weight: 200;
}

#interact-hint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.9rem;
  display: none;
}

/* Screens */
#pauseScreen, #gameOverScreen, #winScreen, #nextFloorScreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  gap: 16px;
}

#pauseScreen h2, #gameOverScreen h2, #winScreen h2, #nextFloorScreen h2 {
  font-size: 2rem;
  color: #e53935;
}

#pauseScreen button, #gameOverScreen button, #winScreen button, #nextFloorScreen button {
  padding: 12px 32px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #c62828;
  color: white;
  font-weight: 600;
  transition: all 0.2s;
}

#pauseScreen button:hover, #gameOverScreen button:hover, #winScreen button:hover, #nextFloorScreen button:hover {
  background: #e53935;
  transform: scale(1.05);
}

/* ===== 增强版加载界面 ===== */
#loadingScreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0f 70%);
  z-index: 200;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 520px;
  width: 90%;
}

.loading-icon {
  font-size: 4rem;
  animation: loadingBounce 1.5s ease-in-out infinite;
}

@keyframes loadingBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-10px) rotate(-5deg); }
  75% { transform: translateY(-5px) rotate(5deg); }
}

#loadingScreen h2 {
  font-size: 1.6rem;
  color: #ff6d00;
  text-align: center;
}

#loadingStep {
  font-size: 0.9rem;
  color: #888;
  text-align: center;
  min-height: 1.4em;
}

.loading-progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loading-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}

.loading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c62828, #ff6d00, #ffc107);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(255, 109, 0, 0.5);
}

.loading-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #888;
}

#loadPercent {
  color: #ff6d00;
  font-weight: 700;
  font-size: 1rem;
}

.loading-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 20px;
  width: 100%;
  padding: 16px 20px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  color: #666;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: #ddd;
  font-family: 'Courier New', monospace;
}

/* ===== 阶梯加载界面 ===== */
#nextFloorScreen { z-index: 100; }