:root {
  --card-bg: #2f1208;
  --ink: #fff3e8;
  --accent: #ffb347;
  --accent-2: #ff7043;
  --ground: #6f3a1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #5c200f, #1f0b06 70%);
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  width: min(920px, 100%);
  background: linear-gradient(180deg, #3b170b, #2a1007);
  border: 2px solid #7a3f1d;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}

.header h1 { margin: 0; color: var(--accent); }
.header p { margin: 6px 0 10px; color: #ffd8a8; }

.hud {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
}

.game {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 430px;
  border: 2px solid #8f4f2f;
  border-radius: 14px;
  background: linear-gradient(#b8deff, #e8f6ff 62%, #d9ecff 100%);
  touch-action: manipulation;
}

.background-track {
  position: absolute;
  inset: 0;
  width: 200%;
  display: flex;
  pointer-events: none;
}

.background {
  width: 50%;
  height: 100%;
  object-fit: cover;
  opacity: .5;
  will-change: transform;
}

.background-b {
  transform: scaleX(-1);
}

.cloud-layer, .obstacle-layer {
  position: absolute;
  inset: 0;
}

.cloud {
  position: absolute;
  width: 62px;
  opacity: .34;
  filter: saturate(0.72);
  pointer-events: none;
}


.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10%;
  background: linear-gradient(180deg, #855232, #6a3d24);
  border-top: 2px solid #4f2f1d;
  box-shadow: inset 0 3px 0 rgba(255, 197, 135, 0.17), 0 -1px 7px rgba(66, 30, 12, 0.2);
}

.player {
  position: absolute;
  left: 11%;
  bottom: 10%;
  height: 102px;
  width: auto;
  transform-origin: bottom center;
}

.player.running {
  animation: bob .24s ease-in-out infinite alternate;
}

.player-shadow {
  position: absolute;
  left: calc(11% + 16px);
  bottom: calc(10% - 7px);
  width: 70px;
  height: 12px;
  border-radius: 999px;
  background: rgba(40, 18, 8, .35);
  filter: blur(1px);
  animation: shadowPulse .24s ease-in-out infinite alternate;
}

@keyframes bob {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@keyframes shadowPulse {
  from { transform: scaleX(1); opacity: .38; }
  to { transform: scaleX(.92); opacity: .28; }
}

.obstacle {
  position: absolute;
  bottom: 10%;
  object-fit: contain;
}

.obstacle.sheep {
  width: 74px;
  height: 64px;
}

.obstacle.daffodil {
  width: 52px;
  height: 52px;
}

.tankard {
  position: absolute;
  width: 42px;
  height: 42px;
  object-fit: contain;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  background: rgba(29, 8, 3, .35);
  z-index: 8;
}

.overlay:not(.visible) { display: none; }

#restartBtn {
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  background: linear-gradient(180deg, #ffcb66, #ff934f);
  color: #3c1808;
}

.controls { margin: 10px 0 0; color: #ffd2a1; }



@media (max-width: 800px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .page {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    display: block;
    min-height: auto;
  }

  .card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 10px;
    border-radius: 16px;
  }

  .header h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .header p,
  .controls {
    font-size: 1rem;
  }

  .hud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    font-size: 0.95rem;
  }

  .game {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    aspect-ratio: 9 / 14;
    min-height: 420px;
    max-height: none;
    overflow: hidden;
  }

  .background-track {
    width: 200%;
    max-width: none;
  }

  .player {
    height: 84px;
  }

  .player-shadow {
    width: 56px;
    left: calc(11% + 11px);
    bottom: calc(10% - 6px);
  }

  .obstacle.sheep { width: 62px; height: 54px; }
  .obstacle.daffodil { width: 46px; height: 42px; }
  .tankard { width: 36px; height: 36px; }
}
