:root {
  --app-width: 390px;
  --ink: #253241;
  --muted: #667085;
  --paper: #fffdf8;
  --mint: #70d9c2;
  --sun: #ffd166;
  --coral: #ff6b6b;
  --blue: #4dabf7;
  --shadow: 0 22px 55px rgba(37, 50, 65, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  overflow-y: hidden;
  background:
    radial-gradient(circle at 15% 18%, rgba(112, 217, 194, 0.32), transparent 30%),
    radial-gradient(circle at 86% 82%, rgba(255, 209, 102, 0.38), transparent 28%),
    linear-gradient(135deg, #f7fbff 0%, #fffdf8 52%, #f4fff9 100%);
  background-size: 130% 130%, 140% 140%, 100% 100%;
  animation: skyDrift 12s ease-in-out infinite alternate;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.game-home {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

.alphabet-game {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

.game-stage {
  position: relative;
  width: min(100%, var(--app-width));
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(37, 50, 65, 0.08);
  border-radius: 32px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)),
    radial-gradient(circle at 18% 18%, rgba(255, 209, 102, 0.58), transparent 24%),
    radial-gradient(circle at 84% 22%, rgba(112, 217, 194, 0.6), transparent 25%),
    radial-gradient(circle at 72% 84%, rgba(255, 107, 107, 0.34), transparent 27%),
    radial-gradient(circle at 38% 68%, rgba(255, 255, 255, 0.72), transparent 18%),
    url("../images/playbg.jpg"),
    linear-gradient(145deg, #fff9d8 0%, #e7fff7 42%, #eaf5ff 100%);
  background-position: center, 0% 0%, 100% 10%, 75% 100%, 44% 70%, center, center;
  background-size: 100% 100%, 150% 150%, 145% 145%, 150% 150%, 130% 130%, cover, 100% 100%;
  box-shadow: var(--shadow);
  animation: gameBgMove 14s ease-in-out infinite alternate, gameStageGlow 6s ease-in-out infinite;
}

.game-stage::before,
.game-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 45%;
  pointer-events: none;
}

.game-stage::before {
  width: 420px;
  height: 420px;
  left: -210px;
  top: -120px;
  background: rgba(255, 255, 255, 0.34);
  animation: softWave 11s ease-in-out infinite;
}

.game-stage::after {
  width: 360px;
  height: 360px;
  right: -190px;
  bottom: -150px;
  background: rgba(77, 171, 247, 0.16);
  animation: softWave 13s ease-in-out infinite reverse;
}

.back-button {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 5;
  min-width: 74px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(37, 50, 65, 0.14);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.back-button:active {
  transform: scale(0.95);
  box-shadow: 0 7px 16px rgba(37, 50, 65, 0.12);
}

.back-button:focus-visible,
.alphabet-card:focus-visible {
  outline: 4px solid rgba(255, 209, 102, 0.95);
  outline-offset: 4px;
}

.alphabet-card {
  position: relative;
  z-index: 4;
  width: min(70%, 286px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 42px;
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), transparent 36%),
    linear-gradient(135deg, #ff6b6b 0%, #ff9f43 48%, #4dabf7 100%);
  cursor: pointer;
  font-size: clamp(7rem, 34vw, 13rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 9px 0 rgba(37, 50, 65, 0.12);
  box-shadow: 0 28px 0 rgba(37, 50, 65, 0.12), 0 34px 60px rgba(37, 50, 65, 0.18);
  transform: translateZ(0);
  touch-action: manipulation;
  transition: transform 170ms ease, box-shadow 170ms ease, background 240ms ease;
  animation: alphabetIdle 2.8s ease-in-out infinite;
}

.alphabet-card.is-speaking {
  animation: alphabetDance 620ms ease-in-out infinite;
}

.alphabet-card.is-hidden {
  background: transparent;
  box-shadow: none;
  text-shadow: none;
}

.alphabet-card.is-picture {
  width: min(86vw, 330px);
  padding: 0;
  justify-items: center;
  align-items: center;
}

.alphabet-card.is-locked {
  cursor: default;
  pointer-events: none;
}

.alphabet-letter {
  display: block;
}

.word-picture {
  width: min(100%, 330px);
  height: min(86vw, 330px);
  display: block;
  border-radius: 36px;
  background-image: var(--word-image);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  filter: drop-shadow(0 24px 34px rgba(37, 50, 65, 0.2));
  pointer-events: none;
}

.word-picture[hidden] {
  display: none;
}


.alphabet-card:active {
  transform: translateY(12px) scale(0.98);
  box-shadow: 0 13px 0 rgba(37, 50, 65, 0.12), 0 20px 34px rgba(37, 50, 65, 0.16);
}

.speech-status {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: max(26px, env(safe-area-inset-bottom));
  z-index: 5;
  min-height: 30px;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 0.98rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.game-stage.is-speaking {
  animation: gameBgMove 3.6s ease-in-out infinite alternate, gameStageGlow 1.8s ease-in-out infinite;
}

.game-stage.is-speaking .game-shape {
  animation-duration: 1.6s;
}

.game-stage.is-speaking .game-bubble {
  animation-duration: 3.8s;
}

.game-stage.is-speaking::before {
  animation-duration: 3.2s;
}

.game-stage.is-speaking::after {
  animation-duration: 3.6s;
}

.game-stage.is-speaking .shape-star {
  animation-name: dancingSpin;
}

.game-stage.is-speaking .shape-square {
  animation-name: dancingFloat;
}

.game-stage.is-speaking .shape-circle {
  animation-name: dancingPulse;
}

.alphabet-card.is-changing {
  animation: alphabetPop 260ms ease-out;
}

.game-shape {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.shape-star {
  width: 84px;
  height: 84px;
  top: 15%;
  right: 14%;
  background: var(--sun);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 35%);
  animation: gameSpin 7.5s ease-in-out infinite;
}

.shape-square {
  width: 96px;
  height: 96px;
  left: 9%;
  bottom: 17%;
  border-radius: 26px;
  background: rgba(77, 171, 247, 0.6);
  transform: rotate(16deg);
  animation: gameFloat 6.2s ease-in-out infinite;
}

.shape-circle {
  width: 78px;
  height: 78px;
  right: 12%;
  bottom: 14%;
  border-radius: 50%;
  background: rgba(112, 217, 194, 0.72);
  animation: gamePulse 4.4s ease-in-out infinite;
}

.shape-pill {
  width: 132px;
  height: 42px;
  left: -22px;
  top: 26%;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.56);
  transform: rotate(-17deg);
  animation: gameSlide 6.8s ease-in-out infinite;
}

.shape-ring {
  width: 112px;
  height: 112px;
  right: -32px;
  top: 58%;
  border: 18px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: gameRing 8s ease-in-out infinite;
}

.game-bubble {
  position: absolute;
  z-index: 2;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.5) 38%, rgba(255, 255, 255, 0.16) 72%),
    rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 -7px 14px rgba(77, 171, 247, 0.12), 0 12px 28px rgba(37, 50, 65, 0.08);
  pointer-events: none;
  will-change: transform, opacity;
}

.game-bubble-one {
  width: 22px;
  height: 22px;
  left: 15%;
  bottom: -30px;
  animation: gameBubbleRise 8.5s linear infinite;
}

.game-bubble-two {
  width: 32px;
  height: 32px;
  left: 72%;
  bottom: -42px;
  animation: gameBubbleRise 10.5s linear infinite 1.2s;
}

.game-bubble-three {
  width: 16px;
  height: 16px;
  left: 48%;
  bottom: -24px;
  animation: gameBubbleRise 7.6s linear infinite 2.1s;
}

.game-bubble-four {
  width: 42px;
  height: 42px;
  left: 25%;
  bottom: -54px;
  animation: gameBubbleRise 12s linear infinite 3.4s;
}

.game-bubble-five {
  width: 18px;
  height: 18px;
  left: 84%;
  bottom: -26px;
  animation: gameBubbleRise 8.9s linear infinite 4.2s;
}

.game-bubble-six {
  width: 28px;
  height: 28px;
  left: 6%;
  bottom: -36px;
  animation: gameBubbleRise 11.4s linear infinite 5.1s;
}

.phone-stage {
  position: relative;
  width: min(100%, var(--app-width));
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  overflow: hidden;
  padding: 34px 24px;
  border: 1px solid rgba(37, 50, 65, 0.08);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 253, 248, 0.34)),
    url("../images/homebg.jpg"),
    var(--paper);
  background-position: center, center, center;
  background-size: 100% 100%, cover, 100% 100%;
  box-shadow: var(--shadow);
  animation: homeBgMove 12s ease-in-out infinite alternate, stageGlow 5.8s ease-in-out infinite;
}

.phone-stage::before,
.phone-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
}

.phone-stage::before {
  width: 260px;
  height: 260px;
  left: -140px;
  bottom: 8%;
  background: rgba(77, 171, 247, 0.12);
  animation: homeOrbDrift 9s ease-in-out infinite;
}

.phone-stage::after {
  width: 230px;
  height: 230px;
  right: -128px;
  top: 16%;
  background: rgba(255, 209, 102, 0.18);
  animation: homeOrbDrift 10.5s ease-in-out infinite reverse;
}

.music-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(37, 50, 65, 0.14);
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.game-music-toggle {
  left: auto;
  right: 18px;
}

.music-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(37, 50, 65, 0.16);
}

.music-toggle:active {
  transform: translateY(1px);
}

.music-toggle:focus-visible {
  outline: 4px solid rgba(255, 209, 102, 0.92);
  outline-offset: 3px;
}

.music-toggle[aria-pressed="true"] {
  background: var(--sun);
}

.music-icon {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.music-toggle[aria-pressed="true"] .music-icon {
  animation: musicBounce 720ms ease-in-out infinite;
}

.mascot {
  position: relative;
  z-index: 2;
  width: clamp(132px, 42vw, 188px);
  height: auto;
  display: block;
  border-radius: 28px;
  filter: drop-shadow(0 16px 24px rgba(37, 50, 65, 0.14));
  animation: floaty 4.6s ease-in-out infinite, mascotPop 6.2s ease-in-out infinite;
}

.button-stack {
  position: relative;
  z-index: 2;
  width: min(100%, 280px);
  display: grid;
  gap: 16px;
}

.start-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  color: #ffffff;
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  box-shadow: 0 12px 0 rgba(37, 50, 65, 0.12), 0 18px 28px rgba(37, 50, 65, 0.12);
  animation: buttonBreathe 3.4s ease-in-out infinite;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.bangla-button {
  background: linear-gradient(135deg, var(--coral), #ff8c61);
}

.english-button {
  background: linear-gradient(135deg, var(--blue), var(--mint));
  animation-delay: 420ms;
}

.start-button:hover {
  transform: translateY(-3px);
  filter: saturate(1.08);
  box-shadow: 0 15px 0 rgba(37, 50, 65, 0.11), 0 22px 34px rgba(37, 50, 65, 0.14);
}

.start-button:active {
  transform: translateY(4px);
  box-shadow: 0 6px 0 rgba(37, 50, 65, 0.12), 0 12px 18px rgba(37, 50, 65, 0.12);
}

.start-button:focus-visible {
  outline: 4px solid rgba(255, 209, 102, 0.92);
  outline-offset: 4px;
}

.decor {
  position: absolute;
  z-index: 1;
  opacity: 0.78;
  pointer-events: none;
}

.home-spark {
  position: absolute;
  z-index: 1;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.24);
  pointer-events: none;
}

.spark-one {
  top: 23%;
  left: 28%;
  animation: sparkleFloat 4.8s ease-in-out infinite;
}

.spark-two {
  top: 48%;
  right: 18%;
  animation: sparkleFloat 5.6s ease-in-out infinite 1.1s;
}

.spark-three {
  bottom: 25%;
  left: 17%;
  animation: sparkleFloat 6.1s ease-in-out infinite 2s;
}

.decor-one {
  width: 78px;
  height: 78px;
  top: 12%;
  left: 9%;
  border-radius: 26px;
  background: var(--sun);
  transform: rotate(18deg);
  animation: spinFloat 7s ease-in-out infinite;
}

.decor-two {
  width: 68px;
  height: 68px;
  right: 11%;
  bottom: 15%;
  border-radius: 50%;
  background: var(--mint);
  animation: softPulse 4.6s ease-in-out infinite;
}

.decor-three {
  width: 92px;
  height: 34px;
  right: -18px;
  top: 30%;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.82);
  transform: rotate(-18deg);
  animation: slideFloat 6s ease-in-out infinite;
}

.bubble {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 -8px 14px rgba(77, 171, 247, 0.12);
  pointer-events: none;
}

.bubble-one {
  width: 18px;
  height: 18px;
  left: 22%;
  bottom: 20%;
  animation: bubbleRise 7.5s linear infinite;
}

.bubble-two {
  width: 24px;
  height: 24px;
  right: 24%;
  bottom: 9%;
  animation: bubbleRise 8.8s linear infinite 1.4s;
}

.bubble-three {
  width: 14px;
  height: 14px;
  right: 18%;
  top: 19%;
  animation: bubbleWiggle 5s ease-in-out infinite;
}

.is-live .button-stack {
  animation: stackFloat 4.2s ease-in-out infinite;
}

@keyframes skyDrift {
  0% {
    background-position: 0% 0%, 100% 100%, center;
  }

  100% {
    background-position: 12% 6%, 88% 92%, center;
  }
}

@keyframes homeBgMove {
  0% {
    background-position: center, 50% 48%, center;
  }

  100% {
    background-position: center, 50% 52%, center;
  }
}

@keyframes homeOrbDrift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(24px, -18px) scale(1.08);
  }
}

@keyframes gameBgMove {
  0% {
    background-position: center, 0% 0%, 100% 10%, 75% 100%, 44% 70%, center, center;
  }

  100% {
    background-position: center, 12% 9%, 88% 24%, 62% 88%, 50% 62%, center, center;
  }
}

@keyframes gameStageGlow {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 28px 68px rgba(37, 50, 65, 0.17), 0 0 0 8px rgba(112, 217, 194, 0.13);
  }
}

@keyframes softWave {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  50% {
    transform: translate(28px, 24px) rotate(18deg) scale(1.08);
  }
}

@keyframes alphabetIdle {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-10px) rotate(1deg);
  }
}

@keyframes alphabetDance {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg) scale(1);
  }

  50% {
    transform: translateY(-14px) rotate(3deg) scale(1.04);
  }
}

@keyframes alphabetPop {
  0% {
    transform: scale(0.86) rotate(-4deg);
  }

  70% {
    transform: scale(1.08) rotate(3deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes gameSpin {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(18px) rotate(28deg);
  }
}

@keyframes gameFloat {
  0%,
  100% {
    transform: translate(0, 0) rotate(16deg);
  }

  50% {
    transform: translate(12px, -18px) rotate(28deg);
  }
}

@keyframes gamePulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.16);
  }
}

@keyframes dancingSpin {
  0%,
  100% {
    transform: translateY(0) rotate(-10deg) scale(1);
  }

  50% {
    transform: translateY(26px) rotate(30deg) scale(1.08);
  }
}

@keyframes dancingFloat {
  0%,
  100% {
    transform: translate(-6px, 4px) rotate(8deg);
  }

  50% {
    transform: translate(18px, -24px) rotate(34deg);
  }
}

@keyframes dancingPulse {
  0%,
  100% {
    transform: scale(0.92);
  }

  50% {
    transform: scale(1.26);
  }
}

@keyframes gameSlide {
  0%,
  100% {
    transform: translateX(0) rotate(-17deg);
  }

  50% {
    transform: translateX(20px) rotate(-8deg);
  }
}

@keyframes gameRing {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  50% {
    transform: translate(-18px, -10px) scale(1.08);
  }
}

@keyframes gameBubbleRise {
  0% {
    opacity: 0;
    transform: translate3d(0, 36px, 0) scale(0.76);
  }

  12% {
    opacity: 0.72;
  }

  45% {
    transform: translate3d(18px, -42vh, 0) scale(1);
  }

  78% {
    opacity: 0.58;
  }

  100% {
    opacity: 0;
    transform: translate3d(-16px, -88vh, 0) scale(1.22);
  }
}

@keyframes stageGlow {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 26px 65px rgba(37, 50, 65, 0.18), 0 0 0 7px rgba(255, 209, 102, 0.12);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes mascotPop {
  0%,
  100% {
    filter: drop-shadow(0 16px 24px rgba(37, 50, 65, 0.14));
  }

  50% {
    filter: drop-shadow(0 22px 30px rgba(37, 50, 65, 0.18)) saturate(1.08);
  }
}

@keyframes stackFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(5px);
  }
}

@keyframes buttonBreathe {
  0%,
  100% {
    filter: saturate(1);
  }

  50% {
    filter: saturate(1.12) brightness(1.03);
  }
}

@keyframes musicBounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-3px) rotate(-8deg);
  }
}

@keyframes sparkleFloat {
  0%,
  100% {
    opacity: 0.42;
    transform: translateY(0) scale(0.85);
  }

  50% {
    opacity: 1;
    transform: translateY(-18px) scale(1.18);
  }
}

@keyframes spinFloat {
  0%,
  100% {
    transform: translateY(0) rotate(18deg);
  }

  50% {
    transform: translateY(12px) rotate(32deg);
  }
}

@keyframes softPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

@keyframes slideFloat {
  0%,
  100% {
    transform: translateX(0) rotate(-18deg);
  }

  50% {
    transform: translateX(-16px) rotate(-10deg);
  }
}

@keyframes bubbleRise {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.85);
  }

  15%,
  75% {
    opacity: 0.78;
  }

  100% {
    opacity: 0;
    transform: translateY(-210px) scale(1.18);
  }
}

@keyframes bubbleWiggle {
  0%,
  100% {
    transform: translate(0, 0);
  }

  50% {
    transform: translate(-10px, 12px);
  }
}

@media (min-width: 760px) {
  .game-stage,
  .phone-stage {
    height: 100vh;
    height: 100dvh;
  }
}

@media (max-width: 430px) {
  .phone-stage {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 28px 18px;
    border-radius: 0;
  }

  .game-stage {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .button-stack {
    width: 100%;
  }

  .start-button {
    min-height: 54px;
    font-size: 1rem;
  }

  .music-toggle {
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
  }

  .alphabet-card {
    width: min(78vw, 270px);
    border-radius: 34px;
  }

  .back-button {
    min-width: 66px;
    height: 40px;
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
