@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800&display=swap');

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

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Dynamic viewport height - prevents jumps on mobile */
  background: linear-gradient(to bottom, #87CEEB 0%, #E0F6FF 100%);
  font-family: "Poppins", sans-serif;
  overflow: hidden;
  color: #333;
}

/* --- HUD --- */
#hud {
  width: 90%;
  max-width: 400px;
  margin: 20px auto 0;
  background: rgba(255, 255, 255, 0.95);
  text-align: center;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 1.2em;
  font-weight: 800;
  color: #2c3e50;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border: 2px solid #fff;
  pointer-events: auto; /* Enable clicks on HUD */
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#roll-counter {
  font-size: 0.9em;
  font-weight: 600;
  color: #555;
}

#roll-count {
  color: #e74c3c;
  font-weight: 800;
}

#parachute-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #3498db 0%, #2ecc71 100%);
  border-radius: 12px;
  animation: parachute-pulse 1.5s ease-in-out infinite;
}

.parachute-icon {
  width:32px;
  height: 32px;
  background: url("assets/parachute.png") no-repeat center;
  background-size: contain;
  image-rendering: pixelated;
}

.parachute-text {
  font-size: 0.7em;
  font-weight: 800;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

#parachute-indicator.hidden {
  display: none;
}

@keyframes parachute-pulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.8);
    transform: scale(1.05);
  }
}

#hud-footer {
  width: 100%;
  height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: auto; /* Enable clicks on footer */
}

#roll-instruction {
  margin-top: 15px;
  font-size: 1em;
  font-weight: 600;
  color: #2c3e50;
  background: rgba(255, 255, 255, 0.8);
  padding: 4px 12px;
  border-radius: 12px;
  opacity: 0.8;
}

/* --- 3D Dice --- */
.scene {
  width: 80px;
  height: 80px;
  perspective: 400px;
  pointer-events: auto;
  cursor: pointer;
}

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: translateZ(-40px);
  transition: transform 1s;
}

.cube__face {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 2px solid #ccc;
  line-height: 80px;
  font-size: 40px;
  font-weight: bold;
  color: #333;
  text-align: center;
  background: white;
  border-radius: 12px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
}

.cube__face--1 {
  transform: rotateY(0deg) translateZ(40px);
}

.cube__face--2 {
  transform: rotateY(90deg) translateZ(40px);
}

.cube__face--3 {
  transform: rotateY(180deg) translateZ(40px);
}

.cube__face--4 {
  transform: rotateY(-90deg) translateZ(40px);
}

.cube__face--5 {
  transform: rotateX(90deg) translateZ(40px);
}

.cube__face--6 {
  transform: rotateX(-90deg) translateZ(40px);
}

/* --- Game Stage (Scrollable World Container) --- */
#game-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Dynamic viewport height */
  overflow: hidden;
}

#world-container {
  position: absolute;
  top: 0;
  left: 0;
  /* JS handles all positioning - no CSS centering */
  width: 80vw;
  height: auto;
  aspect-ratio: 1574 / 3939;
  max-width: 800px;
  /* Force minimum width for proper height on mobile */
  /* On narrow screens, this makes the mountain wider than viewport,
     which forces the height to be much taller (~1500px+) for proper scrolling */
  min-width: 600px;
  will-change: transform;
}

/* Props Layer - contains all game entities */
#props-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

/* --- UI Layer (Fixed Overlay) --- */
#ui-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none; /* Allow clicks to pass through to game */
}

#path-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  opacity: 0.5;
   padding-top:35px;
}

#mountain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* --- Character --- */
#character {
  position: absolute;
  --char-size: clamp(80px, 14vw, 120px);
  width: var(--char-size);
  height: var(--char-size);
  background: url("assets/spritesimple.png") no-repeat;
  background-size: 400% 100%;
  background-position: 0 0;
  z-index: 20;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  image-rendering: pixelated;
  overflow: hidden;
}

/* Walking animation */
.walking {
  animation: walk 0.8s steps(4) infinite;
}

@keyframes walk {
  from {
    background-position: 0 0;
  }

  to {
    background-position: calc(var(--char-size) * -4) 0;
  }
}

/* Character falling animation - knocked off mountain */
#character.falling {
  background-image: url("assets/falling.png") !important;
  background-size: contain !important;
  background-position: center !important;
  animation: tumble-fall 1.5s ease-in forwards !important;
  z-index: 25 !important;
}

/* Character swept away by avalanche */
#character.swept-away {
  background-image: url("assets/fall2.png") !important;
  background-size: contain !important;
  background-position: center !important;
  z-index: 25 !important;
}

@keyframes tumble-fall {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(150px, 800px) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* Character parachuting - saved by parachute */
#character.parachuting {
  --parachute-size: clamp(80px, 15vw, 150px);
  background-image: url("assets/parachute.png") !important;
  width: var(--parachute-size) !important;
  height: var(--parachute-size) !important;
  background-size: contain !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  z-index: 25 !important;
}

/* --- Eagle --- */
#eagle {
  position: fixed;
  --eagle-size: clamp(50px, 9vw, 90px);
  top: 80px;
  left: 40px;
  width: var(--eagle-size);
  height: var(--eagle-size);
  background: url("assets/sprite-eagle-soaring.png") no-repeat;
  background-size: 400% 100%;
  background-position: 0 0;
  z-index: 15;
  pointer-events: none;
  image-rendering: pixelated;
  animation: eagle-soar 1.5s steps(4) infinite,
    eagle-float 3s ease-in-out infinite;
}

@keyframes eagle-soar {
  from {
    background-position: 0 0;
  }

  to {
    background-position: calc(var(--eagle-size) * -4) 0;
  }
}

@keyframes eagle-float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-15px);
  }
}

/* Eagle attacking state */
#eagle.attacking {
  animation: eagle-dive 1s ease-in forwards;
}

@keyframes eagle-dive {
  0% {
    transform: translateY(0) scale(1);
  }

  100% {
    transform: translate(var(--dive-x), var(--dive-y)) scale(1.3);
  }
}

/* Eagle soaring state - dramatic circling animation */
#eagle.soaring {
  animation: eagle-soar 1.5s steps(4) infinite,
    eagle-circle 4s ease-in-out infinite;
}

@keyframes eagle-circle {
  0% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(100px, -30px) scale(1.1);
  }
  50% {
    transform: translate(200px, 0) scale(1);
  }
  75% {
    transform: translate(100px, 30px) scale(0.9);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

/* --- Ram Character --- */
#ram {
  position: absolute;
  --ram-size: clamp(65px, 13vw, 130px);
  width: var(--ram-size);
  height: var(--ram-size);
  background: url("assets/ram.png") no-repeat;
  background-size: contain;
  background-position: center;
  z-index: 19;
  top: 0;
  left: 0;
  visibility: visible;
  pointer-events: none;
  image-rendering: pixelated;
}

#ram.ram-animated {
  background: url("assets/sprite-ram.png") no-repeat;
  background-size: 400% 100%;
  background-position: 0 0;
}

#ram.ram-animated.ram-idle {
  animation: ram-breathe 1.2s steps(4) infinite;
}

@keyframes ram-breathe {
  from {
    background-position: 0 0;
  }

  to {
    background-position: calc(var(--ram-size) * -4) 0;
  }
}

/* --- Yeti Character --- */
#yeti {
  position: absolute;
  --yeti-size: clamp(100px, 19vw, 190px);
  width: var(--yeti-size);
  height: var(--yeti-size);
  background: url("assets/sprite-yetti.png") no-repeat;
  background-size: 300% 100%;
  background-position: 0 0;
  z-index: 19;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  image-rendering: pixelated;
}

#yeti.yeti-idle {
  animation: yeti-idle 1.5s steps(3) infinite;
}

#yeti.yeti-attacking {
  animation: yeti-attack 0.6s steps(3) forwards;
}

@keyframes yeti-idle {
  from {
    background-position: 0 0;
  }
  to {
    background-position: calc(var(--yeti-size) * -3) 0;
  }
}

@keyframes yeti-attack {
  0% {
    background-position: 0 0;
  }
  50% {
    background-position: calc(var(--yeti-size) * -1) 0;
  }
  100% {
    background-position: calc(var(--yeti-size) * -2) 0;
  }
}

/* --- Treasure Chest --- */
#treasure-chest {
  position: absolute;
  --chest-size: clamp(55px, 10vw, 100px);
  width: var(--chest-size);
  height: var(--chest-size);
  background: url("assets/treasurechest.png") no-repeat;
  background-size: contain;
  background-position: center;
  z-index: 19;
  top: 0;
  left: 0;
  visibility: visible;
  pointer-events: none;
  image-rendering: pixelated;
}

#treasure-chest.opening {
  background: url("assets/sprite-treasurechest.png") no-repeat;
  background-size: 300% 100%;
  background-position: 0 0;
  animation: chest-open 0.8s steps(3) forwards;
}

@keyframes chest-open {
  from {
    background-position: 0 0;
  }

  to {
    background-position: calc(var(--chest-size) * -3) 0;
  }
}

/* --- Keg (Goal) --- */
#keg {
  position: absolute;
  width: 60px;
  height: 60px;
  background: url("assets/keg.png") no-repeat;
  background-size: contain;
  background-position: center;
  z-index: 18;
  top: 0;
  left: 70%;
  visibility: visible;
  pointer-events: none;
  image-rendering: pixelated;
}

/* --- Cow --- */
#cow {
  position: absolute;
  width: 100px;
  height: 100px;
  background: url("assets/sprite-cow.png") no-repeat;
  background-size: 300% auto;
  background-position: 0 center;
  z-index: 18;
  left: 8%;
  /* Position from top instead of bottom for consistent placement */
  top: 75%;
  pointer-events: none;
  image-rendering: pixelated;
  animation: cow-graze 1.2s steps(3) infinite;
}

@keyframes cow-graze {
  from {
    background-position: 0 center;
  }
  to {
    background-position: -300px center;
  }
}

/* --- Avalanche --- */
/* --- Avalanche Canvas --- */
#avalanche-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Dynamic viewport height */
  z-index: 50;
  pointer-events: none;
  display: none;
}

/* --- Path Steps --- */
.step-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  /* background-color: rgba(255, 255, 255, 0.6); 
    border: 1px solid rgba(0, 0, 0, 0.2); */
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
}

/* --- Debug Controls --- */
#debug-controls {
  position: fixed;
  bottom: 100px;
  right: 10px;
  z-index: 100;
  display: none; /* Hidden by default - change to 'flex' to show */
  flex-direction: column;
  gap: 5px;
}

#debug-controls button {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: monospace;
}

#debug-controls button:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* --- Victory Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Dynamic viewport height */
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: linear-gradient(135deg, #1a2a6c 0%, #b21f1f 50%, #fdbb2d 100%);
  padding: 40px 50px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 0 50px rgba(253, 187, 45, 0.6),
              0 0 100px rgba(253, 187, 45, 0.3);
  border: 3px solid #fdbb2d;
  transform: scale(0.8);
  animation: modal-pop 0.5s ease forwards;
}

@keyframes modal-pop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.victory-title {
  font-size: 2.5em;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
               0 0 20px rgba(253, 187, 45, 0.8);
  margin-bottom: 20px;
  animation: title-glow 1.5s ease-in-out infinite alternate;
}

@keyframes title-glow {
  from {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                 0 0 20px rgba(253, 187, 45, 0.8);
  }
  to {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
                 0 0 40px rgba(253, 187, 45, 1),
                 0 0 60px rgba(253, 187, 45, 0.6);
  }
}

.victory-sprites {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: -20px;
  margin: 30px 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
}

.victory-drinking {
  margin-right: -30px;
  z-index: 2;
}

.victory-keg {
  width: 80px;
  height: 80px;
  background: url("assets/sprite-keg.png") no-repeat;
  background-size: 300% 100%;
  background-position: 0 0;
  image-rendering: pixelated;
  animation: keg-pour 0.8s steps(3) infinite;
  z-index: 1;
}

@keyframes keg-pour {
  from {
    background-position: 0 0;
  }
  to {
    background-position: calc(80px * -3) 0;
  }
}

.victory-drinking {
  width: 80px;
  height: 80px;
  background: url("assets/sprite-drinnking.png") no-repeat;
  background-size: 300% 100%;
  background-position: 0 0;
  image-rendering: pixelated;
  animation: drinking 0.8s steps(3) infinite;
}

@keyframes drinking {
  from {
    background-position: 0 0;
  }
  to {
    background-position: calc(80px * -3) 0;
  }
}

.victory-text {
  font-size: 1.5em;
  color: #fff;
  font-weight: 600;
  margin: 20px 0;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.play-again-btn {
  padding: 15px 40px;
  font-size: 1.2em;
  font-weight: 700;
  color: #1a2a6c;
  background: linear-gradient(135deg, #fdbb2d 0%, #f9f622 100%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(253, 187, 45, 0.4);
}

.play-again-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(253, 187, 45, 0.6);
}

/* --- Victory Score Display --- */
#victory-score {
  font-size: 1.3em;
  color: #fff;
  margin: 15px 0;
  font-weight: 600;
}

#victory-score span {
  color: #fdbb2d;
  font-size: 1.4em;
  font-weight: 800;
}

/* --- High Score Entry --- */
#new-highscore {
  background: rgba(253, 187, 45, 0.2);
  padding: 20px;
  border-radius: 15px;
  margin: 15px 0;
  border: 2px solid #fdbb2d;
}

#new-highscore.hidden {
  display: none;
}

.highscore-message {
  font-size: 1.5em;
  color: #fdbb2d;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(253, 187, 45, 0.8);
  animation: highscore-flash 0.5s ease-in-out infinite alternate;
  margin-bottom: 15px;
}

@keyframes highscore-flash {
  from {
    opacity: 0.8;
  }
  to {
    opacity: 1;
    text-shadow: 0 0 20px rgba(253, 187, 45, 1);
  }
}

#initials-entry label {
  display: block;
  color: #fff;
  font-size: 1em;
  margin-bottom: 10px;
}

#initials-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}

.initial-input {
  width: 50px;
  height: 60px;
  font-size: 2em;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  border: 3px solid #fdbb2d;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #1a2a6c;
  outline: none;
}

.initial-input:focus {
  border-color: #fff;
  box-shadow: 0 0 15px rgba(253, 187, 45, 0.8);
}

.submit-score-btn {
  padding: 10px 30px;
  font-size: 1em;
  font-weight: 700;
  color: #1a2a6c;
  background: linear-gradient(135deg, #fdbb2d 0%, #f9f622 100%);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.submit-score-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(253, 187, 45, 0.6);
}

.leaderboard-btn {
  padding: 12px 30px;
  font-size: 1em;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px;
}

.leaderboard-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.6);
}

/* --- Leaderboard Modal --- */
.leaderboard-content {
  min-width: 320px;
}

.leaderboard-title {
  font-size: 2em;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  margin-bottom: 20px;
}

#leaderboard-list {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 20px;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
}

.leaderboard-entry:first-child {
  background: linear-gradient(135deg, rgba(253, 187, 45, 0.4) 0%, rgba(249, 246, 34, 0.4) 100%);
  border: 2px solid #fdbb2d;
}

.leaderboard-entry:nth-child(2) {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.3) 0%, rgba(169, 169, 169, 0.3) 100%);
  border: 2px solid #c0c0c0;
}

.leaderboard-entry:nth-child(3) {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.3) 0%, rgba(184, 115, 51, 0.3) 100%);
  border: 2px solid #cd7f32;
}

.leaderboard-rank {
  font-size: 1.2em;
  font-weight: 800;
  min-width: 30px;
}

.leaderboard-initials {
  font-size: 1.3em;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.leaderboard-rolls {
  font-size: 1.1em;
  color: #fdbb2d;
}

.leaderboard-empty {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  padding: 20px;
}

.close-leaderboard-btn {
  padding: 12px 40px;
  font-size: 1em;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.close-leaderboard-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.6);
}

/* --- Welcome Modal --- */
.welcome-content {
  max-width: 350px;
  text-align: center;
}

.welcome-character {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  background: url("assets/spritesimple.png") no-repeat;
  background-size: 400% 100%;
  background-position: 0 0;
  image-rendering: pixelated;
  animation: welcome-walk 0.8s steps(4) infinite;
}

@keyframes welcome-walk {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -480px 0;
  }
}

.welcome-title {
  font-size: 1.8em;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5),
               0 0 20px rgba(253, 187, 45, 0.8);
  margin-bottom: 15px;
}

.welcome-text {
  font-size: 1.1em;
  color: #fff;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 25px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.begin-btn {
  display: block;
  width: 100%;
  padding: 15px 40px;
  font-size: 1.3em;
  font-weight: 700;
  color: #1a2a6c;
  background: linear-gradient(135deg, #fdbb2d 0%, #f9f622 100%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(253, 187, 45, 0.4);
  margin-bottom: 15px;
}

.begin-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(253, 187, 45, 0.6);
}

/* --- Game Over Modal --- */
.gameover-content {
  max-width: 350px;
  text-align: center;
  background: linear-gradient(135deg, #2c3e50 0%, #4a6741 50%, #8b4513 100%);
}

.gameover-character {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  background: url("assets/falling.png") no-repeat center;
  background-size: contain;
  image-rendering: pixelated;
  animation: gameover-tumble 2s ease-in-out infinite;
}

@keyframes gameover-tumble {
  0%, 100% {
    transform: rotate(-10deg) scale(1);
  }
  50% {
    transform: rotate(10deg) scale(1.05);
  }
}

.gameover-title {
  font-size: 1.6em;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  margin-bottom: 15px;
}

.gameover-text {
  font-size: 1.1em;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  margin-bottom: 25px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* --- Loading Screen --- */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Dynamic viewport height */
  background: linear-gradient(to bottom, #87CEEB 0%, #E0F6FF 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  padding: 40px;
}

.loading-spinner {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border: 6px solid rgba(44, 62, 80, 0.2);
  border-top: 6px solid #2c3e50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 1.5em;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 20px;
  animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.loading-bar {
  width: 200px;
  height: 10px;
  background: rgba(44, 62, 80, 0.2);
  border-radius: 5px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3498db 0%, #2ecc71 100%);
  border-radius: 5px;
  transition: width 0.3s ease;
}