/* =============================================
   NUMBER MATCH — simple kids number game
============================================= */

:root {
  --pink: #ff6fb1;
  --yellow: #ffd95a;
  --blue: #62d2ff;
  --green: #63d96c;
  --purple: #7957c8;
  --orange: #ff9f43;
  --text: #334155;
  --panel: rgba(255,255,255,0.84);
}

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

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

body {
  min-height: 100dvh;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, rgba(255, 217, 90, 0.9) 0 8%, transparent 9%),
    radial-gradient(circle at 86% 17%, rgba(98, 210, 255, 0.8) 0 10%, transparent 11%),
    linear-gradient(180deg, #9ee7ff 0%, #dcfaff 52%, #fff2b8 100%);
  touch-action: manipulation;
}

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

.sun {
  position: absolute;
  top: 6%;
  left: 7%;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 14px rgba(255,217,90,.25), 0 0 45px rgba(255,160,60,.32);
  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,.86);
  border-radius: 999px;
  filter: blur(1px);
  opacity: .75;
  animation: cloudDrift linear infinite;
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,.86);
  border-radius: 50%;
}

.c1 {
  width: 160px;
  height: 46px;
  top: 17%;
  left: -200px;
  animation-duration: 25s;
}

.c1::before {
  width: 74px;
  height: 60px;
  top: -30px;
  left: 25px;
}

.c1::after {
  width: 62px;
  height: 48px;
  top: -22px;
  left: 86px;
}

.c2 {
  width: 122px;
  height: 36px;
  top: 48%;
  left: -160px;
  animation-duration: 20s;
  animation-delay: 6s;
  opacity: .52;
}

.c2::before {
  width: 56px;
  height: 46px;
  top: -23px;
  left: 18px;
}

.c2::after {
  width: 46px;
  height: 38px;
  top: -18px;
  left: 64px;
}

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

.bubble {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  color: white;
  font-family: 'Baloo 2', cursive;
  font-size: 1.7rem;
  font-weight: 800;
  opacity: .55;
  animation: float 5s ease-in-out infinite;
}

.b1 { right: 12%; top: 18%; background: var(--pink); }
.b2 { left: 10%; bottom: 18%; background: var(--green); animation-delay: 1s; }
.b3 { right: 20%; bottom: 18%; background: var(--purple); animation-delay: 2s; }
.b4 { left: 24%; top: 30%; background: var(--orange); animation-delay: 1.6s; }

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

.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.86);
  border: 3px solid rgba(255,255,255,0.96);
  color: var(--purple);
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 7px 24px rgba(50,90,80,0.18);
  backdrop-filter: blur(10px);
  touch-action: manipulation;
}

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

.game {
  position: relative;
  z-index: 1;
  width: min(880px, calc(100% - 18px));
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
}

.hud {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 6px auto 12px;
  padding-right: 112px;
}

.hud-block {
  min-width: 92px;
  padding: 8px 18px;
  border-radius: 22px;
  background: var(--panel);
  border: 3px solid rgba(255,255,255,.95);
  text-align: center;
  box-shadow: 0 8px 24px rgba(40,80,80,.13);
  backdrop-filter: blur(10px);
}

.hud-block.target {
  background: rgba(255,217,90,.86);
}

.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.8rem;
  line-height: 1;
  font-weight: 800;
  color: #334155;
}

.question-card {
  margin: 0 auto 14px;
  width: min(560px, 100%);
  padding: 18px 18px 16px;
  border-radius: 34px;
  background: rgba(255,255,255,.88);
  border: 5px solid white;
  box-shadow: 0 16px 42px rgba(40,80,80,.16);
  text-align: center;
}

.question-small {
  font-family: 'Baloo 2', cursive;
  color: #64748b;
  font-weight: 800;
  letter-spacing: 1px;
}

.question-number {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(4rem, 15vw, 7rem);
  line-height: .9;
  color: var(--pink);
  text-shadow: 4px 4px 0 #ffe45e, 7px 7px 0 rgba(98,210,255,.65);
  font-weight: 800;
}

.question-msg {
  min-height: 28px;
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  color: var(--purple);
  font-size: 1.15rem;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 13px;
  max-width: 680px;
  margin: 0 auto;
}

.num-btn {
  aspect-ratio: 1;
  border: 5px solid white;
  border-radius: 28px;
  background: linear-gradient(160deg, #ffb3d9, #62d2ff);
  color: white;
  font-family: 'Baloo 2', cursive;
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 800;
  text-shadow: 2px 3px 0 rgba(0,0,0,.18);
  box-shadow: 0 10px 22px rgba(50,70,100,.16);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.num-btn:nth-child(2n) { background: linear-gradient(160deg, #a7f3d0, #7ee081); }
.num-btn:nth-child(3n) { background: linear-gradient(160deg, #ffd36f, #ff9f43); }
.num-btn:nth-child(4n) { background: linear-gradient(160deg, #b8f7ff, #a78bfa); }

.num-btn:active,
.num-btn.pop {
  transform: scale(.9) rotate(-2deg);
  box-shadow: 0 5px 12px rgba(50,70,100,.14);
}

.num-btn.wrong {
  animation: shake .28s ease-in-out;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.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,.93);
  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-icon {
  font-size: 4rem;
  line-height: 1;
  animation: iconBop 1.1s ease-in-out infinite;
}

@keyframes iconBop {
  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;
}

.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);
}

@media (max-width: 760px) {
  .hud {
    gap: 8px;
    padding-right: 66px;
  }

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

  .number-grid {
    grid-template-columns: repeat(3, minmax(78px, 1fr));
    gap: 10px;
  }

  .num-btn {
    border-radius: 24px;
  }
}

@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 {
    justify-content: flex-start;
  }
}
