* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #070a12;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f8fafc;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #070a12;
  overflow: hidden;
}

/* --- HUD Header --- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: linear-gradient(180deg, #111827 0%, #080d1a 100%);
  border-bottom: 2px solid #1f293d;
  height: 60px;
  z-index: 10;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#level-badge {
  background: #38bdf8;
  color: #0f172a;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

#song-title {
  font-size: 14px;
  font-weight: 800;
  color: #f1f5f9;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

#score-badge {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fbbf24;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 4px;
}

#combo-pill {
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.6);
  animation: comboPulse 0.3s ease-out;
}

#combo-pill.hidden {
  display: none;
}

@keyframes comboPulse {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #334155;
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

/* Floating Rating Overlay */
#hit-rating {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 0 16px currentColor;
  animation: ratingPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#hit-rating.hidden {
  display: none;
}

#hit-rating.rating-perfect {
  color: #38bdf8;
}

#hit-rating.rating-great {
  color: #10b981;
}

#hit-rating.rating-good {
  color: #f59e0b;
}

@keyframes ratingPop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* --- Main Stage & Canvas --- */
#stage {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* --- Bottom Lane Controls --- */
#lane-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 80px;
  background: #080d1a;
  border-top: 2px solid #1f293d;
  z-index: 10;
}

.lane-btn {
  background: transparent;
  border: none;
  border-right: 1px solid #1a2333;
  color: #64748b;
  font-size: 22px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.08s ease, color 0.08s ease;
  touch-action: manipulation;
}

.lane-btn:last-child {
  border-right: none;
}

.lane-btn.active, .lane-btn:active {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  box-shadow: inset 0 0 20px rgba(56, 189, 248, 0.4);
}

/* --- Modals & Overlays --- */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 20, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #334155;
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.danger-card {
  border-color: #ef4444;
}

.modal-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.hero-tile {
  width: 60px;
  height: 90px;
  filter: drop-shadow(0 6px 14px rgba(56, 189, 248, 0.5));
  transform: rotate(-8deg);
}

.hero-tile-gold {
  width: 60px;
  height: 90px;
  filter: drop-shadow(0 6px 14px rgba(245, 158, 11, 0.6));
  transform: rotate(8deg);
}

.game-title {
  font-size: 26px;
  font-weight: 900;
  color: #f8fafc;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.game-subtitle {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 16px;
}

.rules-box {
  background: #090e1a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  font-size: 12px;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.rule-item b {
  color: #f1f5f9;
}

.action-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.primary-btn {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.6);
}

.secondary-btn {
  background: #334155;
  color: #f8fafc;
  margin-top: 10px;
}

.secondary-btn:hover {
  background: #475569;
}

/* Stars & Level Complete */
.stars-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.star-icon {
  font-size: 38px;
  color: #334155;
}

.star-icon.star-active {
  color: #f59e0b;
  text-shadow: 0 0 16px rgba(245, 158, 11, 0.6);
  animation: starPop 0.4s ease-out;
}

@keyframes starPop {
  0% { transform: scale(0.2); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.modal-title {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
}

.stats-box {
  background: #090e1a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: #94a3b8;
}

.stat-row b {
  color: #f8fafc;
}

.danger-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
