/* =============================================
   DINOSAUR DASH — style.css
   Kid-friendly dinosaur runner
============================================= */

:root {
  --sky-top: #9ee7ff;
  --sky-bot: #fff1b8;
  --grass: #5fd36a;
  --grass-dark: #2f9b44;
  --dino: #67d66e;
  --dino-dark: #2f9b44;
  --text: #334155;
  --purple: #6b4ba3;
  --panel: rgba(255,255,255,0.78);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Nunito', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bot));
  touch-action: none;
  color: var(--text);
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.sun {
  position: absolute;
  top: 7%;
  left: 8%;
  width: 88px;
  height: 88px;
  background: #ffd95a;
  border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(255,217,90,0.25), 0 0 50px rgba(255,160,60,0.35);
  animation: sunBop 3s ease-in-out infinite;
}

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

.cloud {
  position: absolute;
  background: rgba(255,255,255,0.86);
  border-radius: 999px;
  filter: blur(1px);
  opacity: 0.8;
  animation: cloudDrift linear infinite;
}
.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.86);
  border-radius: 50%;
}

.c1 { width: 160px; height: 46px; top: 14%; left: -190px; animation-duration: 24s; }
.c1::before { width: 76px; height: 62px; top: -31px; left: 24px; }
.c1::after { width: 62px; height: 48px; top: -22px; left: 86px; }

.c2 { width: 118px; height: 36px; top: 33%; left: -150px; animation-duration: 19s; animation-delay: 5s; opacity: .55; }
.c2::before { width: 58px; height: 48px; top: -24px; left: 18px; }
.c2::after { width: 46px; height: 38px; top: -18px; left: 64px; }

.c3 { width: 190px; height: 54px; top: 55%; left: -230px; animation-duration: 31s; animation-delay: 2s; opacity: .42; }
.c3::before { width: 90px; height: 70px; top: -34px; left: 30px; }
.c3::after { width: 78px; height: 56px; top: -25px; left: 105px; }

@keyframes cloudDrift {
  to { transform: translateX(calc(100vw + 280px)); }
}

.leaf {
  position: absolute;
  font-size: 2rem;
  opacity: .45;
  animation: leafFloat 4s ease-in-out infinite;
}
.l1 { right: 10%; top: 17%; }
.l2 { left: 8%; bottom: 18%; animation-delay: 1.2s; }
.l3 { right: 18%; bottom: 24%; animation-delay: 2.4s; }

@keyframes leafFloat {
  0%,100% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-12px); }
}

.home-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(255,255,255,0.84);
  border: 3px solid rgba(255,255,255,0.95);
  color: var(--purple);
  font-family: 'Baloo 2', cursive;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 7px 24px rgba(50,90,80,0.18);
  backdrop-filter: blur(10px);
}

.home-btn:active {
  transform: scale(.94);
}

.hud {
  position: relative;
  z-index: 10;
  display: flex;
  gap: 12px;
  padding-top: max(14px, env(safe-area-inset-top));
  margin-bottom: 8px;
  flex-shrink: 0;
}

.hud-block {
  min-width: 88px;
  padding: 7px 15px;
  border-radius: 22px;
  background: var(--panel);
  border: 2px solid rgba(255,255,255,.9);
  text-align: center;
  box-shadow: 0 5px 20px rgba(50,100,80,.12);
  backdrop-filter: blur(10px);
}

.hud-block.level {
  background: rgba(255,225,108,.76);
}

.hud-label {
  display: block;
  font-family: 'Baloo 2', cursive;
  font-size: .58rem;
  letter-spacing: 2px;
  font-weight: 800;
  color: #64748b;
}

.hud-val {
  display: block;
  font-family: 'Baloo 2', cursive;
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 800;
  color: #334155;
}

canvas {
  position: relative;
  z-index: 5;
  display: block;
  border-radius: 22px;
  box-shadow: 0 10px 38px rgba(40,80,70,.18), inset 0 2px 0 rgba(255,255,255,.45);
  touch-action: none;
  flex-shrink: 0;
}

.touch-controls {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.touch-controls.hidden {
  opacity: 0;
  pointer-events: none;
}

.touch-btn {
  width: 142px;
  height: 82px;
  border-radius: 24px;
  border: 3px solid rgba(255,255,255,.92);
  background: rgba(255,255,255,.65);
  box-shadow: 0 6px 20px rgba(50,90,80,.18);
  font-family: 'Baloo 2', cursive;
  color: var(--purple);
  cursor: pointer;
  touch-action: none;
}

.touch-btn.duck {
  background: rgba(255,227,118,.68);
}

.touch-btn.pressed {
  transform: scale(.91);
  background: rgba(255,255,255,.9);
}

.btn-icon {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.btn-label {
  display: block;
  margin-top: 4px;
  font-size: .62rem;
  letter-spacing: 2px;
  font-weight: 800;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(145,220,255,.52);
  backdrop-filter: blur(12px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(410px, 88vw);
  padding: 28px 28px 25px;
  border-radius: 34px;
  background: rgba(255,255,255,.92);
  text-align: center;
  box-shadow: 0 22px 70px rgba(40,90,80,.25);
  animation: popIn .38s cubic-bezier(.34,1.56,.64,1);
}

@keyframes popIn {
  from { transform: scale(.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.title-dino {
  font-size: 4rem;
  line-height: 1;
  animation: dinoBop 1.1s ease-in-out infinite;
}

@keyframes dinoBop {
  0%,100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-8px); }
}

.overlay-card h1 {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: .92;
  color: var(--purple);
  margin: 7px 0 14px;
}

.overlay-card p {
  color: #64748b;
  font-size: .94rem;
  line-height: 1.75;
  margin-bottom: 21px;
}

.overlay-card b {
  color: #334155;
}

.play-btn {
  border: 0;
  border-radius: 999px;
  padding: 15px 34px;
  background: linear-gradient(135deg, #63d96c, #2fb6ff);
  color: white;
  font-family: 'Baloo 2', cursive;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47,182,255,.32);
}

.play-btn:active {
  transform: scale(.94);
}

.hint {
  margin-top: 13px;
  color: #94a3b8;
  font-size: .72rem;
}

@media (max-width: 520px) {
  .home-btn {
    min-width: 52px;
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
  }

  .home-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
  }

  .hud {
    gap: 8px;
  }

  .hud-block {
    min-width: 76px;
    padding-inline: 10px;
  }

  .touch-btn {
    width: 130px;
    height: 76px;
  }
}
