:root {
  --bg: #f7fbff;
  --ink: #1f2937;
  --line: #8fa3b8;
  --dino: #39a96b;
  --dino-dark: #1f7a4d;
  --tree: #187447;
  --tree-light: #2fa86b;
  --snow: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #d8f1ff 0%, var(--bg) 72%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game-shell {
  width: min(920px, calc(100vw - 24px));
}

.game {
  position: relative;
  height: clamp(300px, 48vw, 430px);
  overflow: hidden;
  border: 3px solid #334155;
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 22%, var(--snow) 0 2px, transparent 3px),
    radial-gradient(circle at 46% 16%, var(--snow) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 28%, var(--snow) 0 2px, transparent 3px),
    linear-gradient(180deg, #bfe8ff 0%, #edf9ff 68%, #e8f5e9 69%);
  cursor: pointer;
  user-select: none;
}

.hud {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 5;
  display: flex;
  gap: 16px;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 700;
}

.skyline {
  position: absolute;
  right: -20px;
  bottom: 78px;
  width: 52%;
  height: 92px;
  opacity: .55;
}

.skyline span {
  position: absolute;
  bottom: 0;
  width: 120px;
  height: 42px;
  border-radius: 999px 999px 0 0;
  background: #d9edf5;
}

.skyline span:nth-child(1) {
  left: 0;
  width: 150px;
}

.skyline span:nth-child(2) {
  left: 118px;
  height: 70px;
  width: 190px;
}

.skyline span:nth-child(3) {
  right: 0;
  height: 54px;
  width: 170px;
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 58px;
  height: 4px;
  background: var(--line);
}

.ground::after {
  content: "";
  position: absolute;
  inset: 4px 0 auto;
  height: 40px;
  background-image: linear-gradient(90deg, #b7c6d4 0 18px, transparent 18px 42px);
  background-size: 42px 2px;
  animation: groundMove 1.1s linear infinite;
}

.dino {
  position: absolute;
  left: 72px;
  bottom: 62px;
  width: 82px;
  height: 76px;
}

.dino-body,
.dino-head,
.dino-leg,
.dino-tail {
  position: absolute;
  background: var(--dino);
  border: 3px solid var(--dino-dark);
}

.dino-body {
  left: 18px;
  bottom: 18px;
  width: 48px;
  height: 34px;
  border-radius: 17px 20px 14px 14px;
}

.dino-head {
  right: 0;
  top: 6px;
  width: 36px;
  height: 30px;
  border-radius: 12px 14px 10px 8px;
}

.dino-eye {
  position: absolute;
  right: 9px;
  top: 16px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #111827;
}

.dino-tail {
  left: 0;
  bottom: 34px;
  width: 30px;
  height: 16px;
  clip-path: polygon(0 48%, 100% 0, 100% 100%);
}

.dino-leg {
  bottom: 0;
  width: 12px;
  height: 24px;
  border-radius: 0 0 6px 6px;
}

.dino-leg-a {
  left: 28px;
  animation: runA .32s steps(2) infinite;
}

.dino-leg-b {
  left: 50px;
  animation: runB .32s steps(2) infinite;
}

.tree {
  position: absolute;
  right: -90px;
  bottom: 62px;
  width: 64px;
  height: 92px;
}

.tree-star {
  position: absolute;
  top: 0;
  left: 24px;
  width: 16px;
  height: 16px;
  background: #ffd166;
  clip-path: polygon(50% 0, 62% 35%, 98% 35%, 68% 56%, 80% 92%, 50% 70%, 20% 92%, 32% 56%, 2% 35%, 38% 35%);
}

.tree-layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tree);
  border: 3px solid #0f5132;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.tree-layer-top {
  top: 12px;
  width: 42px;
  height: 32px;
  background: var(--tree-light);
}

.tree-layer-mid {
  top: 32px;
  width: 54px;
  height: 38px;
}

.tree-layer-low {
  top: 56px;
  width: 66px;
  height: 38px;
}

.tree-trunk {
  position: absolute;
  left: 25px;
  bottom: 0;
  width: 14px;
  height: 18px;
  background: #8b5a2b;
  border: 3px solid #5f3b1e;
}

.message {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(247, 251, 255, .58);
}

.message.hidden {
  display: none;
}

.message h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 6vw, 54px);
  letter-spacing: 0;
}

.message p {
  margin: 0;
  font-size: clamp(15px, 2.5vw, 20px);
  font-weight: 650;
}

.jump {
  animation: jump .58s cubic-bezier(.2, .72, .32, 1) both;
}

.running .tree {
  animation: treeMove var(--tree-speed, 1.65s) linear infinite;
}

.paused .ground::after,
.paused .dino-leg-a,
.paused .dino-leg-b {
  animation-play-state: paused;
}

@keyframes treeMove {
  from {
    right: -90px;
  }
  to {
    right: calc(100% + 90px);
  }
}

@keyframes groundMove {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -42px;
  }
}

@keyframes jump {
  0%, 100% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(-138px);
  }
}

@keyframes runA {
  0% {
    height: 24px;
  }
  100% {
    height: 14px;
  }
}

@keyframes runB {
  0% {
    height: 14px;
  }
  100% {
    height: 24px;
  }
}

@media (max-width: 560px) {
  .dino {
    left: 42px;
  }

  .hud {
    left: 12px;
    right: 12px;
    justify-content: space-between;
  }
}
