* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── Body ── */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(145deg, #0b1a2e, #1b3a5c 50%, #3a7ca5);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  padding: 16px;
}

/* ── Preloader ── */
.preloader {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.12);
  border-top: 8px solid #f9d976;
  border-right: 8px solid #f39c12;
  animation: spin 0.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  box-shadow: 0 0 40px rgba(243, 156, 18, 0.2);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ── Game Container ── */
.game {
  position: relative;
  width: 700px;
  max-width: 100%;
  height: 350px;
  background: linear-gradient(180deg, #7ec8e0 0%, #b5dff5 55%, #d4eef9 100%);
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  overflow: hidden;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

/* ── Sun ── */
.sun {
  position: absolute;
  width: 48px;
  height: 48px;
  top: 28px;
  right: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff9c4, #fdd835);
  box-shadow:
    0 0 50px rgba(253, 216, 53, 0.5),
    0 0 90px rgba(253, 216, 53, 0.25),
    0 0 130px rgba(253, 216, 53, 0.1);
  z-index: 5;
}

/* ── Road ── */
.road {
  position: absolute;
  width: 100%;
  height: 60px;
  top: 80%;
  left: 0;
  background: #2c3e50;
  z-index: 10;
  border-top: 4px solid #1a2a38;
}

.road::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 6px;
  background: #27ae60;
  top: -6px;
  z-index: 10;
}

.road::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 45%,
    #ecf0f1 45%,
    #ecf0f1 55%,
    transparent 55%,
    transparent 100%
  );
  background-size: 30px;
  animation: roadMove 0.25s linear infinite;
  z-index: 10;
}

@keyframes roadMove {
  0% {
    background-position: 0;
  }
  100% {
    background-position-x: -30px;
  }
}

/* ── Clouds & Trees ── */
.cloud {
  position: absolute;
  top: 30px;
  left: 20px;
  z-index: 8;
  pointer-events: none;
}

.fa-cloud {
  position: absolute;
  top: calc(5px * var(--i));
  left: calc(15px * var(--i));
  font-size: 3em;
  color: rgba(255, 255, 255, 0.85);
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: cloudDrift 4s linear infinite;
  animation-delay: calc(1s * var(--i));
}

.fa-tree {
  position: absolute;
  font-size: 4.2em;
  color: #1e7e34;
  top: 120px;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  animation: cloudDrift 8s linear infinite;
  animation-delay: calc(-0.8s * var(--i));
}

@keyframes cloudDrift {
  0% {
    transform: translateX(720px);
    opacity: 0.5;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(-720px);
    opacity: 0.5;
  }
}

/* ── Character ── */
.char {
  position: absolute;
  bottom: 0px;
  left: 30px;
  z-index: 90;
  transition: bottom 0.05s linear;
}

.char img {
  height: auto;
  width: 60px;
  display: block;
  image-rendering: pixelated;
}

/* ── Jump Animation (smoother) ── */
.jump {
  animation: jumpSmooth 0.9s cubic-bezier(0.22, 0.68, 0.35, 1.1) forwards;
}

@keyframes jumpSmooth {
  0% {
    bottom: 0px;
  }
  40% {
    bottom: 100px;
  }
  60% {
    bottom: 100px;
  }
  100% {
    bottom: 0px;
  }
}

/* ── Obstacle ── */
.block {
  width: 22px;
  height: 75px;
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  border-radius: 6px 6px 0 0;
  position: absolute;
  bottom: 0px;
  left: 700px;
  z-index: 100;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.15);
}

.block_run {
  animation: blockSlide 2.8s linear infinite;
}

@keyframes blockSlide {
  0% {
    left: 700px;
  }
  100% {
    left: -30px;
  }
}

/* ── Score ── */
.score-display {
  position: absolute;
  top: 16px;
  left: 24px;
  z-index: 50;
  font-size: 1.3rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 16px;
  border-radius: 40px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-display .score {
  color: #ffe066;
  font-weight: 700;
}

/* ── Start Button Overlay ── */
.button-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(3px);
  border-radius: 24px;
  transition: opacity 0.4s ease;
}

.button-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-btn {
  padding: 14px 48px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #f39c12, #e67e22);
  border: none;
  border-radius: 60px;
  cursor: pointer;
  box-shadow:
    0 8px 28px rgba(243, 156, 18, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.start-btn:hover {
  transform: scale(1.04);
  background: linear-gradient(145deg, #f1c40f, #e67e22);
  box-shadow: 0 12px 36px rgba(243, 156, 18, 0.55);
}

.start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 16px rgba(243, 156, 18, 0.3);
}

/* ── Game Over Override (injected via JS) ── */
.game-over {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
  min-height: 100vh;
  background: linear-gradient(145deg, #0b1a2e, #1b3a5c 50%, #3a7ca5);
  color: #fff;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  text-align: center;
  padding: 24px;
}

.game-over h1 {
  font-size: 2.6rem;
  font-weight: 700;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.25);
  padding: 16px 40px;
  border-radius: 60px;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-over button {
  padding: 14px 48px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #27ae60, #1e8449);
  border: none;
  border-radius: 60px;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(39, 174, 96, 0.35);
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease;
  letter-spacing: 1px;
}

.game-over button:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 36px rgba(39, 174, 96, 0.5);
}

.game-over button:active {
  transform: scale(0.96);
}
