@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;800;900&display=swap');

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Fredoka One', 'Nunito', sans-serif;
}

#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
}

#game-container canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===== MOBILE CONTROLS ===== */
#mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 20px;
  pointer-events: none;
  z-index: 100;
}

#mobile-controls.hidden {
  display: none;
}

.control-group {
  display: flex;
  gap: 10px;
  pointer-events: all;
}

.ctrl-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  touch-action: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ctrl-btn:active,
.ctrl-btn.pressed {
  transform: scale(0.88);
  background: rgba(255, 200, 50, 0.45);
  border-color: rgba(255, 220, 80, 0.8);
  box-shadow: 0 2px 10px rgba(255,200,50,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ctrl-btn svg {
  width: 32px;
  height: 32px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

#btn-jump {
  width: 78px;
  height: 78px;
  background: rgba(100, 220, 100, 0.25);
  border-color: rgba(100, 255, 100, 0.5);
  box-shadow: 0 4px 24px rgba(50,200,50,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

#btn-jump:active,
#btn-jump.pressed {
  background: rgba(100, 255, 100, 0.5);
  transform: scale(0.88);
}

/* ===== HUD OVERLAY ===== */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  pointer-events: none;
  z-index: 99;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
}

#hud.hidden {
  display: none;
}

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

.hud-label {
  font-family: 'Fredoka One', sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hud-value {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8), 0 0 20px rgba(255,220,50,0.5);
}

/* Hearts */
.hearts-container {
  display: flex;
  gap: 4px;
}

.heart {
  font-size: 22px;
  transition: transform 0.2s, opacity 0.3s;
  filter: drop-shadow(0 2px 4px rgba(255,50,50,0.6));
}

.heart.empty {
  opacity: 0.25;
  filter: none;
}

.heart.pulse {
  animation: heartPulse 0.3s ease;
}

@keyframes heartPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Key indicator */
#key-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  transition: all 0.3s;
}

#key-indicator.has-key {
  background: rgba(255, 215, 0, 0.25);
  border-color: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 12px rgba(255,215,0,0.4);
}

#key-icon {
  font-size: 18px;
  opacity: 0.4;
  transition: opacity 0.3s;
}

#key-indicator.has-key #key-icon {
  opacity: 1;
  animation: spin 0.5s ease;
}

@keyframes spin {
  from { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.3); }
  to { transform: rotate(360deg) scale(1); }
}

/* Score */
#score-display {
  font-family: 'Fredoka One', sans-serif;
  font-size: 22px;
  color: #FFD700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8), 0 0 20px rgba(255,215,0,0.4);
}

/* Level indicator */
#level-indicator {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
  color: #a0c8ff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  background: rgba(20,40,100,0.5);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1.5px solid rgba(100,160,255,0.3);
}

/* ===== DIALOG BOX ===== */
#dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 160px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#dialog-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

#dialog-box {
  background: linear-gradient(135deg, rgba(15,15,40,0.96), rgba(30,20,60,0.96));
  border: 2px solid rgba(140,100,255,0.6);
  border-radius: 20px;
  padding: 20px 28px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(100,50,255,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}

#dialog-speaker {
  font-family: 'Fredoka One', sans-serif;
  font-size: 18px;
  color: #c084fc;
  margin-bottom: 8px;
  text-shadow: 0 0 15px rgba(192,132,252,0.6);
}

#dialog-text {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  color: #e8e8ff;
  line-height: 1.6;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#dialog-continue {
  display: block;
  margin-top: 14px;
  font-family: 'Fredoka One', sans-serif;
  font-size: 13px;
  color: rgba(200,180,255,0.6);
  text-align: right;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.1; }
}

/* ===== WIN SCREEN ===== */
#win-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f0528, #1a0a4a, #0a1a3a);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s;
}

#win-screen.visible {
  opacity: 1;
  pointer-events: all;
}

#win-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: clamp(28px, 6vw, 52px);
  color: #FFD700;
  text-align: center;
  text-shadow: 0 0 30px rgba(255,215,0,0.8), 0 4px 20px rgba(0,0,0,0.8);
  animation: winPulse 2s ease-in-out infinite;
  margin-bottom: 16px;
  padding: 0 20px;
}

#win-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(16px, 3vw, 22px);
  color: #c0e0ff;
  text-align: center;
  padding: 0 20px;
  margin-bottom: 40px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

#win-love-message {
  font-family: 'Fredoka One', sans-serif;
  font-size: clamp(20px, 4.2vw, 34px);
  color: #FFD700;
  text-align: center;
  padding: 0 20px;
  margin-bottom: 34px;
  text-shadow: 0 0 25px rgba(255,215,0,0.9), 0 4px 16px rgba(0,0,0,0.8);
  animation: winPulse 2s ease-in-out infinite;
}

#win-characters {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-end;
  margin-bottom: 40px;
  flex-wrap: wrap;
  padding: 0 20px;
}

.win-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: float 3s ease-in-out infinite;
}

.win-char:nth-child(2) { animation-delay: 0.5s; }
.win-char:nth-child(3) { animation-delay: 1s; }
.win-char:nth-child(4) { animation-delay: 1.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

.win-char-label {
  font-family: 'Fredoka One', sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.win-char-icon {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  border: 3px solid rgba(255,255,255,0.3);
  overflow: hidden;
  background: rgba(255,255,255,0.1);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

@keyframes winPulse {
  0%, 100% { transform: scale(1); text-shadow: 0 0 30px rgba(255,215,0,0.8); }
  50% { transform: scale(1.04); text-shadow: 0 0 60px rgba(255,215,0,1), 0 0 100px rgba(255,150,0,0.5); }
}

#play-again-btn {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px;
  color: #0a0a20;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  border: none;
  border-radius: 50px;
  padding: 14px 48px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(255,165,0,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

#play-again-btn:hover, #play-again-btn:active {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 10px 40px rgba(255,165,0,0.7);
}

/* Confetti */
.confetti-piece {
  position: fixed;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  pointer-events: none;
  z-index: 301;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
    opacity: 1;
  }
  80% { opacity: 1; }
  100% {
    transform: translateY(110vh) rotate(720deg) translateX(var(--drift));
    opacity: 0;
  }
}

/* ===== GAME OVER SCREEN ===== */
#gameover-screen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

#gameover-screen.visible {
  opacity: 1;
  pointer-events: all;
}

#gameover-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: clamp(36px, 8vw, 64px);
  color: #ff4444;
  text-shadow: 0 0 40px rgba(255,50,50,0.8), 0 4px 20px rgba(0,0,0,0.8);
  margin-bottom: 12px;
  animation: shake 0.5s ease 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

#gameover-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  color: rgba(255,200,200,0.8);
  margin-bottom: 40px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

#retry-btn {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px;
  color: white;
  background: linear-gradient(135deg, #e44d, #c33);
  border: 2px solid rgba(255,100,100,0.5);
  border-radius: 50px;
  padding: 14px 48px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(200,50,50,0.5);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
}

#retry-btn:hover, #retry-btn:active {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 10px 40px rgba(200,50,50,0.7);
}

#menu-btn {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px;
  color: rgba(200,200,255,0.8);
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  padding: 10px 36px;
  cursor: pointer;
  transition: all 0.15s;
}

#menu-btn:hover, #menu-btn:active {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* ===== LEVEL TRANSITION ===== */
#level-transition {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#level-transition.active {
  opacity: 1;
}

#level-transition-text {
  font-family: 'Fredoka One', sans-serif;
  font-size: clamp(24px, 5vw, 40px);
  color: white;
  text-align: center;
  text-shadow: 0 0 30px rgba(100,150,255,0.8);
  padding: 0 20px;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.4s 0.2s;
}

#level-transition.active #level-transition-text {
  opacity: 1;
  transform: scale(1);
}

/* ===== BOSS HEALTH BAR ===== */
#boss-health-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, 80vw);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

#boss-health-container.visible {
  opacity: 1;
}

#boss-name {
  font-family: 'Fredoka One', sans-serif;
  font-size: 14px;
  color: #ff8888;
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 0 0 10px rgba(255,100,100,0.6);
  text-transform: uppercase;
  letter-spacing: 2px;
}

#boss-health-bar {
  width: 100%;
  height: 16px;
  background: rgba(0,0,0,0.5);
  border-radius: 8px;
  border: 2px solid rgba(255,100,100,0.4);
  overflow: hidden;
  box-shadow: 0 0 15px rgba(255,50,50,0.3);
}

#boss-health-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff4444, #ff8800);
  border-radius: 6px;
  transition: width 0.4s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ===== PAUSE BUTTON ===== */
#pause-btn {
  position: fixed;
  top: 14px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  transition: all 0.15s;
  font-size: 16px;
}

#pause-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Notifications / floating text */
.floating-text {
  position: fixed;
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px;
  color: #FFD700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8), 0 0 20px rgba(255,200,50,0.5);
  pointer-events: none;
  z-index: 150;
  animation: floatUp 1.2s ease forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .ctrl-btn { width: 58px; height: 58px; }
  #btn-jump { width: 66px; height: 66px; }
  .ctrl-btn svg { width: 26px; height: 26px; }
  #mobile-controls { height: 120px; padding: 10px 14px; }
}
