@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-5px); }
  30%, 70% { transform: translateX(5px); }
}

@keyframes shakeHard {
  0%, 100% { transform: translateX(0) translateY(0); }
  10% { transform: translateX(-10px) translateY(5px); }
  20% { transform: translateX(10px) translateY(-5px); }
  30% { transform: translateX(-8px) translateY(3px); }
  40% { transform: translateX(8px) translateY(-3px); }
  50% { transform: translateX(-5px) translateY(5px); }
  60% { transform: translateX(5px) translateY(-5px); }
  70% { transform: translateX(-3px) translateY(3px); }
  80% { transform: translateX(3px) translateY(-3px); }
  90% { transform: translateX(-1px) translateY(1px); }
}

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

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px rgba(244,169,0,0.3); }
  50% { box-shadow: 0 0 25px rgba(244,169,0,0.6), 0 0 50px rgba(244,169,0,0.3); }
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-8px, 4px); }
  20% { transform: translate(8px, -4px); }
  30% { transform: translate(-6px, 2px); }
  40% { transform: translate(6px, -2px); }
  50% { transform: translate(-4px, 2px); }
  60% { transform: translate(4px, -2px); }
  70% { transform: translate(-2px, 1px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 0); }
}

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

@keyframes coinSpin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

@keyframes dragonBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02) translateY(-3px); }
}

@keyframes dragonWingFlap {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(5deg); }
}

@keyframes doorCrack {
  0% { transform: scale(1); }
  50% { transform: scale(1.02) rotate(1deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes particlesFloat {
  0% { transform: translateY(0) translateX(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-100px) translateX(30px) scale(0); opacity: 0; }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes victoryCrown {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-15px) rotate(5deg); }
}

@keyframes victoryChest {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes defeatFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.shake { animation: shake 0.5s ease; }
.shake-hard { animation: shakeHard 0.8s ease; }
.pulse-anim { animation: pulse 2s ease-in-out infinite; }
.float-anim { animation: float 3s ease-in-out infinite; }
.glow-anim { animation: glow 2s ease-in-out infinite; }
.screen-shake { animation: screenShake 0.5s ease; }

.screen-transition-enter {
  animation: fadeIn 0.4s ease forwards;
}

.screen-transition-exit {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes dragonBreathing {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.02); }
}

@keyframes dragonWake {
  0% { transform: scale(.92); filter: brightness(.7); }
  50% { transform: scale(1.08); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes dragonRoarAnim {
  0%, 100% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-10px) scale(1.05); }
  50% { transform: translateX(10px) scale(1.08); }
  75% { transform: translateX(-6px) scale(1.05); }
}

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

.dragon-sleeping { animation: dragonBreathing 2.4s ease-in-out infinite; }
.dragon-waking { animation: dragonWake 1s ease; }
.dragon-roaring, .dragon-attacking { animation: dragonRoarAnim .65s ease-in-out; }
.door-changing { animation: doorShake .55s ease-in-out; }

.option-btn.animate-correct .option-letter {
  animation: pulse 0.5s ease 2;
}

.option-btn.animate-incorrect .option-letter {
  animation: shake 0.5s ease;
}

.dragon-breathe-anim {
  animation: dragonBreathe 2s ease-in-out infinite;
}

.door-crack-anim {
  animation: doorCrack 0.6s ease;
}

#intro-screen {
  background: rgba(10,8,19,0.95);
  z-index: 50;
}

.intro-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-scroll {
  background: linear-gradient(145deg, #1B1428, #12101C);
  border: 2px solid #6F2DA8;
  border-radius: 20px;
  padding: 35px 40px;
  max-width: 550px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 50px rgba(111,45,168,0.4);
  animation: scaleIn 0.5s ease;
}

.intro-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(20px, 3vw, 32px);
  color: #F4A900;
  text-shadow: 2px 2px 0 #4C1D78;
  margin-bottom: 20px;
}

.intro-text {
  font-size: clamp(14px, 1.8vw, 18px);
  color: #D8D1E4;
  line-height: 1.8;
  margin-bottom: 20px;
}

.intro-text p {
  margin-bottom: 10px;
}

.intro-errors {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 25px;
}

.intro-error-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intro-error-max {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(28px, 4vw, 40px);
  color: #F4A900;
  text-shadow: 2px 2px 0 #4C1D78;
}

.intro-error-label {
  font-size: clamp(10px, 1.2vw, 13px);
  color: #9B4DDA;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.intro-start-btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(18px, 2.5vw, 24px);
  padding: 14px 50px;
  background: linear-gradient(145deg, #C87A00, #E86A17);
  color: #FFFFFF;
  border: 2px solid #F4A900;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(232,106,23,0.4);
  transition: all 0.3s ease;
  text-transform: uppercase;
}

.intro-start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 30px rgba(232,106,23,0.6);
  background: linear-gradient(145deg, #E86A17, #F4A900);
}

#gameover-screen {
  z-index: 200;
}

.gameover-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10,8,19,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gameover-panel {
  background: linear-gradient(145deg, #1B1428, #12101C);
  border: 2px solid #C91E2E;
  border-radius: 20px;
  padding: 35px 40px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 60px rgba(201,30,46,0.3);
  animation: scaleIn 0.5s ease;
}

.gameover-dragon-container {
  width: 120px;
  height: 120px;
  margin: 0 auto 15px;
}

.gameover-dragon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 30px rgba(255,52,77,0.5));
  animation: shake 1s ease infinite;
}

.gameover-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(28px, 5vw, 48px);
  color: #FF344D;
  text-shadow: 3px 3px 0 #4C1D78, 0 0 30px rgba(255,52,77,0.4);
  margin-bottom: 10px;
}

.gameover-text {
  font-size: clamp(13px, 1.5vw, 16px);
  color: #D8D1E4;
  margin-bottom: 15px;
  line-height: 1.5;
}

.gameover-stats {
  margin: 10px 0;
  font-size: clamp(12px, 1.3vw, 15px);
  color: #D8D1E4;
}

.gameover-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.gameover-btn {
  padding: 12px 30px;
  background: linear-gradient(145deg, #2A1E3C, #1B1428);
  border: 2px solid #6F2DA8;
  border-radius: 14px;
  color: #FFFFFF;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(14px, 1.8vw, 18px);
  transition: all 0.3s ease;
}

.gameover-btn:hover {
  transform: translateY(-2px);
  border-color: #9B4DDA;
  box-shadow: 0 4px 20px rgba(111,45,168,0.4);
}

.gameover-btn-retry {
  background: linear-gradient(145deg, #4C1D78, #6F2DA8) !important;
  border-color: #9B4DDA !important;
}

#victory-screen {
  z-index: 200;
}

.victory-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10,8,19,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.victory-panel {
  background: linear-gradient(145deg, #1B1428, #12101C);
  border: 2px solid #F4A900;
  border-radius: 20px;
  padding: 35px 40px;
  text-align: center;
  max-width: 550px;
  width: 90%;
  box-shadow: 0 0 60px rgba(244,169,0,0.3);
  animation: scaleIn 0.6s ease;
}

.victory-crown {
  font-size: 64px;
  color: #F4A900;
  margin-bottom: 10px;
  animation: victoryCrown 2s ease-in-out infinite;
  text-shadow: 0 0 30px rgba(244,169,0,0.5);
}

.victory-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(28px, 5vw, 48px);
  color: #79C528;
  text-shadow: 3px 3px 0 #4C1D78, 0 0 30px rgba(121,197,40,0.4);
  margin-bottom: 10px;
}

.victory-text {
  font-size: clamp(13px, 1.5vw, 17px);
  color: #D8D1E4;
  margin-bottom: 15px;
  line-height: 1.5;
}

.victory-chest {
  font-size: 48px;
  color: #F4A900;
  margin-bottom: 15px;
  animation: victoryChest 1s ease forwards;
  text-shadow: 0 0 20px rgba(244,169,0,0.5);
}

.victory-stats {
  margin: 15px 0;
  font-size: clamp(12px, 1.3vw, 15px);
  color: #D8D1E4;
  line-height: 2;
}

.victory-stats span {
  display: inline-block;
  min-width: 100px;
}

.victory-stats .stat-label { color: #9B4DDA; }
.victory-stats .stat-value { color: #F4A900; font-family: 'Luckiest Guy', cursive; }

.victory-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.victory-btn {
  padding: 12px 30px;
  background: linear-gradient(145deg, #2A1E3C, #1B1428);
  border: 2px solid #6F2DA8;
  border-radius: 14px;
  color: #FFFFFF;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(14px, 1.8vw, 18px);
  transition: all 0.3s ease;
}

.victory-btn:hover {
  transform: translateY(-2px);
  border-color: #9B4DDA;
  box-shadow: 0 4px 20px rgba(111,45,168,0.4);
}

.victory-btn-primary {
  background: linear-gradient(145deg, #4A8F16, #2A5A15) !important;
  border-color: #79C528 !important;
}
