*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top left, #ffe4f3 0, #e0f2ff 40%, #fefaf1 100%);
  color: #1b2559;
  position: relative;
  overflow-x: hidden;
}

/* Screen-reader only (SEO text visible to crawlers) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Decorative elements */
.decoration {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  font-size: 2.5rem;
  opacity: 0.6;
  animation: gentle-float 6s ease-in-out infinite;
}

.decoration--sun {
  top: 20px;
  right: 30px;
  font-size: 3rem;
  opacity: 0.7;
  animation: sun-rotate 20s linear infinite;
  filter: drop-shadow(0 0 10px rgba(255, 200, 0, 0.5));
}

.decoration--cloud-1 {
  top: 40px;
  left: 20px;
  font-size: 2.2rem;
  animation: cloud-drift 15s ease-in-out infinite;
}

.decoration--cloud-2 {
  top: 80px;
  right: 80px;
  font-size: 2rem;
  animation: cloud-drift 18s ease-in-out infinite 2s;
}

.decoration--cloud-3 {
  top: 60px;
  left: 30%;
  font-size: 1.8rem;
  animation: cloud-drift 20s ease-in-out infinite 4s;
}

.decoration--cloud-4 {
  top: 100px;
  right: 20%;
  font-size: 2.1rem;
  animation: cloud-drift 16s ease-in-out infinite 1s;
}

.decoration--cloud-5 {
  top: 50px;
  left: 60%;
  font-size: 1.9rem;
  animation: cloud-drift 22s ease-in-out infinite 3s;
}

.decoration--balloon-1 {
  top: 150px;
  left: 15px;
  font-size: 2.5rem;
  opacity: 0.8;
  animation: balloon-rise 12s ease-in-out infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.decoration--balloon-2 {
  top: 180px;
  right: 25px;
  font-size: 2.2rem;
  opacity: 0.8;
  animation: balloon-rise 14s ease-in-out infinite 2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.decoration--balloon-3 {
  top: 200px;
  left: 25%;
  font-size: 2rem;
  opacity: 0.8;
  animation: balloon-rise 13s ease-in-out infinite 1s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.decoration--balloon-4 {
  top: 160px;
  right: 15%;
  font-size: 2.3rem;
  opacity: 0.8;
  animation: balloon-rise 15s ease-in-out infinite 3s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.decoration--balloon-5 {
  top: 190px;
  left: 70%;
  font-size: 2.1rem;
  opacity: 0.8;
  animation: balloon-rise 11s ease-in-out infinite 2.5s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.balloon-shape {
  width: 1.2em;
  height: 1.5em;
  background: linear-gradient(135deg, #4ade80, #22c55e, #16a34a);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.balloon-shape::before {
  content: "";
  position: absolute;
  bottom: -0.15em;
  left: 50%;
  transform: translateX(-50%);
  width: 0.3em;
  height: 0.2em;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border-radius: 0 0 50% 50%;
}

.balloon-string {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 1.5em;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.1));
  border-radius: 2px;
}

.decoration--bird-1 {
  top: 120px;
  left: -50px;
  font-size: 1.8rem;
  opacity: 0.7;
  animation: bird-fly-1 25s linear infinite;
}

.decoration--bird-2 {
  top: 160px;
  left: -50px;
  font-size: 1.6rem;
  opacity: 0.7;
  animation: bird-fly-2 30s linear infinite 5s;
}

.decoration--bird-3 {
  top: 220px;
  left: -50px;
  font-size: 1.7rem;
  opacity: 0.7;
  animation: bird-fly-3 28s linear infinite 10s;
}

.decoration--bird-4 {
  top: 100px;
  right: -50px;
  font-size: 1.8rem;
  opacity: 0.7;
  animation: bird-fly-4 27s linear infinite 3s;
  transform: scaleX(-1);
}

.decoration--tree-1 {
  bottom: 20px;
  left: 10px;
  font-size: 3rem;
  opacity: 0.65;
  animation: tree-sway 8s ease-in-out infinite;
}

.decoration--tree-2 {
  bottom: 20px;
  right: 15px;
  font-size: 2.8rem;
  opacity: 0.65;
  animation: tree-sway 7s ease-in-out infinite 1s;
}

.decoration--flower-1 {
  bottom: 100px;
  left: 50px;
  font-size: 2rem;
  opacity: 0.7;
  animation: flower-bloom 5s ease-in-out infinite;
}

.decoration--flower-2 {
  bottom: 120px;
  right: 60px;
  font-size: 1.8rem;
  opacity: 0.7;
  animation: flower-bloom 6s ease-in-out infinite 1.5s;
}

.decoration--flower-3 {
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.9rem;
  opacity: 0.7;
  animation: flower-bloom 5.5s ease-in-out infinite 0.8s;
}

.decoration--flower-4 {
  bottom: 90px;
  left: 15%;
  font-size: 2rem;
  opacity: 0.75;
  animation: flower-bloom 5.8s ease-in-out infinite 1.2s;
}

.decoration--flower-5 {
  bottom: 110px;
  right: 20%;
  font-size: 1.9rem;
  opacity: 0.75;
  animation: flower-bloom 6.2s ease-in-out infinite 0.5s;
}

.decoration--flower-6 {
  bottom: 95px;
  left: 35%;
  font-size: 2.1rem;
  opacity: 0.75;
  animation: flower-bloom 5.3s ease-in-out infinite 1.8s;
}

.decoration--flower-7 {
  bottom: 105px;
  right: 35%;
  font-size: 1.8rem;
  opacity: 0.75;
  animation: flower-bloom 6s ease-in-out infinite 2.2s;
}

.decoration--flower-8 {
  bottom: 85px;
  left: 70%;
  font-size: 2rem;
  opacity: 0.75;
  animation: flower-bloom 5.7s ease-in-out infinite 1.5s;
}

/* Grass elements */
.grass {
  position: fixed;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
  transform-origin: bottom center;
}

.grass::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 2px;
  background: #15803d;
  border-radius: 2px;
}

.grass--1 {
  left: 5%;
  width: 8px;
  height: 40px;
  background: linear-gradient(to top, #22c55e, #16a34a, #15803d);
  border-radius: 4px 4px 0 0;
  animation: grass-sway 4s ease-in-out infinite;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--2 {
  left: 12%;
  width: 6px;
  height: 35px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3px 3px 0 0;
  animation: grass-sway 4.5s ease-in-out infinite 0.5s;
  box-shadow: 0 0 2px rgba(34, 197, 94, 0.3);
}

.grass--3 {
  left: 18%;
  width: 7px;
  height: 45px;
  background: linear-gradient(to top, #22c55e, #16a34a, #15803d);
  border-radius: 3.5px 3.5px 0 0;
  animation: grass-sway 3.8s ease-in-out infinite 1s;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--4 {
  left: 25%;
  width: 6px;
  height: 38px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3px 3px 0 0;
  animation: grass-sway 4.2s ease-in-out infinite 0.3s;
  box-shadow: 0 0 2px rgba(34, 197, 94, 0.3);
}

.grass--5 {
  left: 32%;
  width: 8px;
  height: 42px;
  background: linear-gradient(to top, #22c55e, #16a34a, #15803d);
  border-radius: 4px 4px 0 0;
  animation: grass-sway 4.7s ease-in-out infinite 0.8s;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--6 {
  left: 50%;
  width: 7px;
  height: 40px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3.5px 3.5px 0 0;
  animation: grass-sway 4.3s ease-in-out infinite 1.2s;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--7 {
  left: 58%;
  width: 6px;
  height: 36px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3px 3px 0 0;
  animation: grass-sway 4.6s ease-in-out infinite 0.6s;
  box-shadow: 0 0 2px rgba(34, 197, 94, 0.3);
}

.grass--8 {
  left: 65%;
  width: 8px;
  height: 44px;
  background: linear-gradient(to top, #22c55e, #16a34a, #15803d);
  border-radius: 4px 4px 0 0;
  animation: grass-sway 3.9s ease-in-out infinite 1.5s;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--9 {
  left: 72%;
  width: 7px;
  height: 39px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3.5px 3.5px 0 0;
  animation: grass-sway 4.4s ease-in-out infinite 0.9s;
  box-shadow: 0 0 3px rgba(34, 197, 94, 0.3);
}

.grass--10 {
  left: 80%;
  width: 6px;
  height: 37px;
  background: linear-gradient(to top, #22c55e, #16a34a);
  border-radius: 3px 3px 0 0;
  animation: grass-sway 4.1s ease-in-out infinite 0.4s;
  box-shadow: 0 0 2px rgba(34, 197, 94, 0.3);
}

@keyframes gentle-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes sun-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes cloud-drift {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  33% {
    transform: translateX(15px) translateY(-5px);
  }
  66% {
    transform: translateX(-10px) translateY(5px);
  }
}

@keyframes tree-sway {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(2deg);
  }
  75% {
    transform: rotate(-2deg);
  }
}

@keyframes flower-bloom {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.15) rotate(5deg);
  }
}

@keyframes grass-sway {
  0%, 100% {
    transform: rotate(0deg) translateX(0);
  }
  25% {
    transform: rotate(3deg) translateX(2px);
  }
  50% {
    transform: rotate(0deg) translateX(0);
  }
  75% {
    transform: rotate(-3deg) translateX(-2px);
  }
}

@keyframes balloon-rise {
  0%, 100% {
    transform: translateY(0) translateX(0);
  }
  25% {
    transform: translateY(-15px) translateX(5px);
  }
  50% {
    transform: translateY(-25px) translateX(-3px);
  }
  75% {
    transform: translateY(-15px) translateX(3px);
  }
}

@keyframes bird-fly-1 {
  0% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(calc(100vw + 100px)) translateY(-20px);
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(-20px);
  }
}

@keyframes bird-fly-2 {
  0% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(calc(100vw + 100px)) translateY(15px);
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(15px);
  }
}

@keyframes bird-fly-3 {
  0% {
    transform: translateX(0) translateY(0);
  }
  50% {
    transform: translateX(calc(100vw + 100px)) translateY(-10px);
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(-10px);
  }
}

@keyframes bird-fly-4 {
  0% {
    transform: scaleX(-1) translateX(0) translateY(0);
  }
  50% {
    transform: scaleX(-1) translateX(calc(-100vw - 100px)) translateY(-15px);
  }
  100% {
    transform: scaleX(-1) translateX(calc(-100vw - 100px)) translateY(-15px);
  }
}

@media (max-width: 640px) {
  .decoration {
    font-size: 1.8rem;
  }
  
  .decoration--sun {
    font-size: 2.2rem;
    top: 10px;
    right: 15px;
  }
  
  .decoration--cloud-1,
  .decoration--cloud-2,
  .decoration--cloud-3,
  .decoration--cloud-4,
  .decoration--cloud-5 {
    font-size: 1.5rem;
  }
  
  .decoration--balloon-1,
  .decoration--balloon-2,
  .decoration--balloon-3,
  .decoration--balloon-4,
  .decoration--balloon-5 {
    font-size: 1.6rem;
  }
  
  .decoration--bird-1,
  .decoration--bird-2,
  .decoration--bird-3,
  .decoration--bird-4 {
    font-size: 1.3rem;
  }
  
  .decoration--tree-1,
  .decoration--tree-2 {
    font-size: 2rem;
  }
  
  .decoration--flower-1,
  .decoration--flower-2,
  .decoration--flower-3,
  .decoration--flower-4,
  .decoration--flower-5,
  .decoration--flower-6,
  .decoration--flower-7,
  .decoration--flower-8 {
    font-size: 1.5rem;
  }
  
  .grass--1,
  .grass--2,
  .grass--3,
  .grass--4,
  .grass--5,
  .grass--6,
  .grass--7,
  .grass--8,
  .grass--9,
  .grass--10 {
    width: 4px;
    height: 25px;
  }
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  z-index: 2;
}

.login__card,
.home {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(40, 80, 160, 0.18);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  position: relative;
  overflow: hidden;
  z-index: 2;
}

.home::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 0 0, rgba(255, 214, 165, 0.35), transparent 55%),
    radial-gradient(circle at 100% 0, rgba(197, 255, 214, 0.3), transparent 55%),
    radial-gradient(circle at 0 100%, rgba(186, 201, 255, 0.45), transparent 55%);
  opacity: 0.7;
  pointer-events: none;
}

.home > * {
  position: relative;
}

.login__title,
.home__title {
  font-size: 1.8rem;
  margin: 0 0 8px;
}

.home__name {
  color: #ff7a59;
}

.login__subtitle,
.home__subtitle {
  margin: 0 0 24px;
  color: #52608f;
}

.login__buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn--google {
  background: #ffffff;
  color: #1b2559;
  box-shadow: 0 8px 20px rgba(15, 52, 96, 0.1);
}

.btn--facebook {
  background: #1877f2;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(24, 119, 242, 0.35);
}

.btn--primary {
  background: #ff7a59;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(255, 122, 89, 0.45);
}

.btn--secondary {
  background: #ffffff;
  color: #ff7a59;
  box-shadow: 0 8px 20px rgba(27, 37, 89, 0.08);
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(27, 37, 89, 0.16);
}

.home__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.home__header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.home__language-selector {
  position: relative;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffffff;
  color: #1b2559;
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(27, 37, 89, 0.08);
}

.logout-link:hover {
  background: #fff5f0;
}

.language-select {
  appearance: none;
  background: #ffffff;
  border: 1px solid #d0d6ff;
  border-radius: 999px;
  padding: 6px 32px 6px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1b2559;
  cursor: pointer;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231b2559' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

.language-select:hover {
  border-color: #ff7a59;
  box-shadow: 0 2px 8px rgba(255, 122, 89, 0.15);
}

.language-select:focus {
  outline: none;
  border-color: #ff7a59;
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.1);
}

.home__content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.voice-panel {
  background: linear-gradient(135deg, #ffcfdf, #b0f3f1);
  border-radius: 24px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(255, 122, 89, 0.35);
  position: relative;
  overflow: hidden;
}

.voice-panel::after {
  content: "🎈";
  position: absolute;
  font-size: 2.2rem;
  right: 10px;
  top: 10px;
  opacity: 0.8;
  animation: float 4s ease-in-out infinite;
}

.voice-panel__status {
  margin-top: 12px;
  color: #1b2559;
}

.voice-panel__timer {
  margin: 8px 0 0;
  font-weight: 600;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.avatar-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff7b2, #ff9a9e);
  box-shadow: 0 8px 20px rgba(255, 154, 158, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  animation: avatar-bob 3s ease-in-out infinite;
}

.avatar-face {
  width: 70%;
  height: 70%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-eye {
  position: absolute;
  width: 6px;
  height: 8px;
  border-radius: 999px;
  background: #29346b;
  top: 40%;
}

.avatar-eye--left {
  left: 32%;
}

.avatar-eye--right {
  right: 32%;
}

.avatar-mouth {
  position: absolute;
  width: 40%;
  height: 10px;
  border-radius: 999px;
  border-bottom: 3px solid #ff7a59;
  bottom: 26%;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.dialog-backdrop.hidden {
  display: none;
}

.dialog {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
}

.dialog__close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: #52608f;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.dialog__close:hover,
.dialog__close:focus-visible {
  background: rgba(82, 96, 143, 0.12);
  color: #1b2559;
  outline: none;
}

.dialog__title {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.dialog__text {
  margin: 0 0 16px;
  color: #52608f;
}

.dialog__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field__label {
  font-size: 0.9rem;
}

.field__input {
  border-radius: 999px;
  border: 1px solid #d0d6ff;
  padding: 8px 12px;
  font-size: 1rem;
}

.voice-panel__animation {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  position: relative;
  filter: drop-shadow(0 10px 25px rgba(255, 255, 255, 0.6));
}

.mic-circle {
  position: absolute;
  inset: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  opacity: 0.7;
}

.mic-circle--1 {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.9);
}

.mic-circle--2 {
  width: 70px;
  height: 70px;
  animation: pulse 1.6s infinite;
}

.mic-circle--3 {
  width: 100px;
  height: 100px;
  animation: pulse 1.6s infinite 0.3s;
}

.voice-panel__animation--active .mic-circle--2,
.voice-panel__animation--active .mic-circle--3 {
  animation-play-state: running;
  border-color: rgba(255, 255, 255, 0.9);
}

/* Red when listening to the child */
.voice-panel__animation--listening .mic-circle--1 {
  background: #ff4b5c;
  box-shadow: 0 0 20px rgba(255, 75, 92, 0.9);
}

.voice-panel__animation--listening .mic-circle--2,
.voice-panel__animation--listening .mic-circle--3 {
  border-color: rgba(255, 75, 92, 0.85);
}

/* Green when AI is responding */
.voice-panel__animation--ai .mic-circle--1 {
  background: #00c982;
  box-shadow: 0 0 20px rgba(0, 201, 130, 0.9);
}

.voice-panel__animation--ai .mic-circle--2,
.voice-panel__animation--ai .mic-circle--3 {
  border-color: rgba(0, 201, 130, 0.85);
}

.voice-panel__animation:not(.voice-panel__animation--active)
  .mic-circle--2,
.voice-panel__animation:not(.voice-panel__animation--active)
  .mic-circle--3 {
  animation-play-state: paused;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.5;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0.1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.5;
  }
}

@keyframes float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes avatar-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (min-width: 640px) {
  .login__card,
  .home {
    padding: 32px;
  }
}

/* Dialog steps */
.dialog-step {
  display: block;
}

.dialog-step.hidden {
  display: none;
}

/* Topics grid */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.topic-card {
  background: #f8f9ff;
  border: 2px solid #d0d6ff;
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.topic-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 122, 89, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(27, 37, 89, 0.15);
  border-color: #a8b4ff;
  background: #ffffff;
}

/* Selected topic state (multi-select) */
.topic-card--selected {
  border-color: #ff7a59;
  background: #fff5f0;
  box-shadow: 0 0 0 2px rgba(255, 122, 89, 0.25),
    0 10px 25px rgba(255, 122, 89, 0.35);
  transform: translateY(-3px) scale(1.05);
  animation: topic-select 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.topic-card--selected::before {
  width: 200px;
  height: 200px;
}

.topic-card--deselecting {
  animation: topic-deselect 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes topic-select {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.08);
  }
  100% {
    transform: translateY(-3px) scale(1.05);
  }
}

@keyframes topic-deselect {
  0% {
    transform: translateY(-3px) scale(1.05);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.topic-thumbnail {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 12px;
  background: #e8ebff;
}

.topic-title {
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
  color: #1b2559;
  font-weight: 600;
}

.topics-loading,
.topics-error {
  text-align: center;
  padding: 20px;
  color: #52608f;
  grid-column: 1 / -1;
}

.topics-confirm-btn {
  display: block;
  margin: 8px auto 16px;
  width: auto;
  min-width: 200px;
}

@media (max-width: 640px) {
  .topics-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
  
  .topic-thumbnail {
    height: 80px;
  }
  
  .topic-title {
    font-size: 0.85rem;
  }
}

/* Dialog subtitle */
.dialog__subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: #1b2559;
  margin: 16px 0 4px;
}

/* Level selection */
.levels-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.level-card {
  background: #f8f9ff;
  border: 2px solid #d0d6ff;
  border-radius: 12px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.level-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(27, 37, 89, 0.12);
  border-color: #a8b4ff;
  background: #ffffff;
}

.level-card--selected {
  border-color: #ff7a59;
  background: linear-gradient(135deg, #ff7a59, #ff5a36);
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.35),
    0 8px 20px rgba(255, 90, 54, 0.4);
  transform: translateY(-3px) scale(1.08);
  animation: level-select-pulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-card--selected .level-title {
  color: #ffffff;
  font-weight: 700;
}

@keyframes level-select-pulse {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.12);
  }
  100% {
    transform: translateY(-3px) scale(1.08);
  }
}

.level-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1b2559;
}

.levels-loading,
.levels-error {
  text-align: center;
  padding: 12px;
  color: #52608f;
  width: 100%;
}

/* Subscription Page Styles */
.page--subscription,
.page--payment {
  min-height: 100vh;
  padding: 20px 16px;
}

.subscription,
.payment {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.subscription__header,
.payment__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.subscription__back {
  color: #52608f;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.subscription__back:hover {
  color: #ff7a59;
}

.subscription__card,
.payment__card {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(40, 80, 160, 0.18);
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.subscription__title,
.payment__title {
  font-size: 1.8rem;
  margin: 0 0 8px;
  text-align: center;
}

.subscription__subtitle {
  margin: 0 0 32px;
  color: #52608f;
  text-align: center;
}

.subscription__section-title {
  font-size: 1.2rem;
  margin: 0 0 16px;
  color: #1b2559;
  font-weight: 600;
}

.subscription__packages {
  margin-bottom: 32px;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.package-card {
  background: #ffffff;
  border: 2px solid #e8ebff;
  border-radius: 16px;
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.package-card:hover {
  border-color: #ff7a59;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 122, 89, 0.2);
}

.package-card--selected {
  border-color: #ff7a59;
  background: #fff5f3;
  box-shadow: 0 4px 12px rgba(255, 122, 89, 0.3);
}

.package-card__minutes {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff7a59;
}

.package-card__label {
  font-size: 0.875rem;
  color: #52608f;
}

.package-card__price {
  font-size: 0.75rem;
  color: #1b2559;
  font-weight: 600;
  margin-top: 4px;
}

.subscription__custom {
  margin-bottom: 32px;
}

.custom-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.custom-input-group .field__input {
  flex: 1;
  max-width: 200px;
}

.custom-input-group__label {
  color: #52608f;
  font-weight: 500;
}

.subscription__pricing-note {
  font-size: 0.875rem;
  color: #52608f;
  margin: 0;
}

.subscription__buyer-info {
  margin-bottom: 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field__label {
  font-weight: 600;
  color: #1b2559;
  font-size: 0.95rem;
}

.field__input {
  padding: 12px 16px;
  border: 2px solid #e8ebff;
  border-radius: 12px;
  font-size: 1rem;
  color: #1b2559;
  transition: all 0.2s ease;
  background: #ffffff;
}

.field__input:focus {
  outline: none;
  border-color: #ff7a59;
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.1);
}

.field__error {
  color: #ff4444;
  font-size: 0.875rem;
  display: none;
}

.field__error[style*="block"] {
  display: block;
}

.subscription__summary {
  background: #f8f9ff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #52608f;
}

.summary-item:last-child {
  margin-bottom: 0;
}

.summary-item--total {
  padding-top: 12px;
  border-top: 2px solid #e8ebff;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1b2559;
}

.summary-item strong {
  color: #ff7a59;
  font-size: 1.2rem;
}

.btn--large {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Payment Page Styles */
.payment__card {
  text-align: center;
}

.payment__icon {
  margin-bottom: 16px;
}

.payment__icon img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.payment__order-summary {
  margin: 20px 0;
}

.payment__amount {
  font-size: 2rem;
  font-weight: 700;
  color: #ff7a59;
  margin-bottom: 8px;
}

.payment__order-detail {
  font-size: 1rem;
  color: #52608f;
}

.payment__message {
  background: #fff5f3;
  border-left: 4px solid #ff7a59;
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
}

.payment__message-text {
  font-size: 1.1rem;
  color: #52608f;
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 640px) {
  .subscription__card,
  .payment__card {
    padding: 24px;
  }

  .subscription__title,
  .payment__title {
    font-size: 1.5rem;
  }

  .packages-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }

  .package-card {
    padding: 12px 8px;
  }

  .package-card__minutes {
    font-size: 1.2rem;
  }

  .package-card__price {
    font-size: 0.7rem;
  }

  .custom-input-group .field__input {
    max-width: 100%;
  }

  .payment__icon img {
    max-width: 220px;
  }

  .payment__message-text {
    font-size: 1rem;
  }
}

/* Time up message */
.time-up-message {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  border: 1px dashed rgba(154, 165, 250, 0.7);
}

.time-up-message p {
  margin: 0 0 16px;
  color: #3f4a7f;
}

.time-up-message p strong {
  color: #e53935;
}

.time-up-message.hidden {
  display: none;
}

/* ===== Admin Dashboard ===== */
.page--admin {
  background: #f4f6fb;
  min-height: 100vh;
}

.admin {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.admin__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.admin__title {
  font-size: 1.75rem;
  color: #1b2559;
  margin: 0;
}

.admin__back {
  color: #4a6cf7;
  text-decoration: none;
}

.admin__back:hover {
  text-decoration: underline;
}

.admin__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.admin__cell {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.admin__cell-title {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
  color: #1b2559;
}

.admin__cell-content {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.admin__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin__table th,
.admin__table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.admin__table th {
  font-weight: 600;
  color: #666;
  position: sticky;
  top: 0;
  background: #fff;
}

.admin__table tbody tr:hover {
  background: #f8f9fd;
}

.admin__placeholder {
  color: #999;
  text-align: center;
  margin-top: 4rem;
}

/* Full-width admin cell (user detail page) */
.admin__cell--full {
  margin-bottom: 1.5rem;
}

/* User link in admin table */
.admin__user-link {
  color: #4a6cf7;
  text-decoration: none;
  font-weight: 500;
}

.admin__user-link:hover {
  text-decoration: underline;
  color: #3451c7;
}

/* User info grid */
.admin__user-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.admin__info-row {
  display: flex;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.admin__info-label {
  font-weight: 600;
  color: #666;
  min-width: 130px;
  font-size: 0.85rem;
}

.admin__info-value {
  color: #1b2559;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .admin__user-info {
    grid-template-columns: 1fr;
  }
}

.admin__delete-btn {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s;
}

.admin__delete-btn:hover {
  background: #fde8e8;
}

.admin__cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.admin__edit-btn {
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.admin__edit-btn:hover {
  background: #3554d1;
}

.admin__user-edit .admin__info-row {
  align-items: center;
}

.admin__input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d4d8e2;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
}

.admin__input:focus {
  outline: none;
  border-color: #4a6cf7;
  box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.15);
}

.admin__input-group {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.admin__quick-add {
  background: #f0f2f8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: #1b2559;
  transition: background 0.15s;
}

.admin__quick-add:hover {
  background: #e2e7f5;
}

.admin__form-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid #eef0f5;
}

.admin__btn {
  background: #f0f2f8;
  color: #1b2559;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.admin__btn:hover:not(:disabled) {
  background: #e2e7f5;
}

.admin__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin__btn--primary {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
}

.admin__btn--primary:hover:not(:disabled) {
  background: #3554d1;
  border-color: #3554d1;
}

.admin__form-error {
  color: #e74c3c;
  font-size: 0.85rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0 0;
  justify-content: center;
}

.pagination__btn {
  background: #f0f2f8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #1b2559;
  transition: background 0.15s;
}

.pagination__btn:hover:not(:disabled) {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
}

.pagination__btn--active {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
  font-weight: 600;
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination__info {
  font-size: 0.75rem;
  color: #999;
  margin-left: 0.5rem;
}

@media (max-width: 768px) {
  .admin__grid {
    grid-template-columns: 1fr;
  }
}

/* =============================================================
   Kid-friendly homepage v2: mascot stage, time ring, giant button
   ============================================================= */

/* Stage: the hero area containing mascot + time ring */
.stage {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 8px auto 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@media (min-width: 640px) {
  .stage {
    width: 300px;
    height: 300px;
  }
}

.time-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 6px 18px rgba(255, 122, 89, 0.35));
}

.time-ring__bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 10;
}

.time-ring__progress {
  fill: none;
  stroke: #4ade80;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 641; /* 2 * PI * 102 ≈ 640.88 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.6s ease, stroke 0.6s ease;
}

.time-ring__progress--warn { stroke: #fbbf24; }
.time-ring__progress--danger { stroke: #ef4444; }

/* Mascot (Buddy) — big animated character */
.mascot {
  position: relative;
  width: 62%;
  height: 62%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mascot-bob 3s ease-in-out infinite;
  transform-origin: center 80%;
}

.mascot__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 20px rgba(255, 122, 89, 0.4));
}

.mascot__ear {
  transform-origin: center 90%;
  transition: transform 0.3s ease;
}
.mascot__ear--left { transform-origin: 42px 80px; }
.mascot__ear--right { transform-origin: 158px 80px; }

/* eyes — closed using scaleY(0.1) on blink */
.mascot__eye {
  transform-origin: center;
  animation: mascot-blink 5.5s infinite;
}
.mascot__eye--right { animation-delay: 0.1s; }

.mascot__mouth {
  transform-box: fill-box;
  transform-origin: center;
  /* Fast morph between phoneme shapes set by MascotManager */
  transition: d 80ms linear;
}

/* Sparkles around the mascot — shown on celebrate */
.mascot__sparkles {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  opacity: 0;
}
.mascot__sparkles span {
  position: absolute;
  font-size: 1.4rem;
  opacity: 0;
}
.mascot__sparkles span:nth-child(1) { top: 0;    left: 10%; }
.mascot__sparkles span:nth-child(2) { top: 10%;  right: 0;  }
.mascot__sparkles span:nth-child(3) { bottom: 10%; left: 0; }
.mascot__sparkles span:nth-child(4) { bottom: 0;  right: 10%; }
.mascot__sparkles span:nth-child(5) { top: 50%;   left: -5%; }

/* ---------- Mascot states ---------- */

/* Listening — ears perk up, glowing ring */
.mascot[data-state="listening"] .mascot__ear--left { transform: rotate(-12deg) translateY(-4px); }
.mascot[data-state="listening"] .mascot__ear--right { transform: rotate(12deg) translateY(-4px); }
.mascot[data-state="listening"] .mascot__svg {
  filter: drop-shadow(0 0 18px rgba(239, 68, 68, 0.55))
          drop-shadow(0 10px 20px rgba(255, 122, 89, 0.4));
}

/* Speaking — phoneme shapes are swapped by MascotManager via the `d` attribute.
   A subtle jaw bob runs alongside for added liveliness, and the head gives a
   gentle nod to sell the talking motion. */
.mascot[data-state="speaking"] .mascot__mouth {
  animation: mascot-jaw-bob 0.42s ease-in-out infinite;
}
.mascot[data-state="speaking"] .mascot__svg {
  animation: mascot-head-nod 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(74, 222, 128, 0.6))
          drop-shadow(0 10px 20px rgba(255, 122, 89, 0.4));
}

/* Live lip-sync: mouth `d` is updated every animation frame from the AI's
   voice waveform, so the CSS path `transition` and the canned jaw-bob would
   both fight the real motion. Turn them off when the analyser is driving. */
.mascot--live-mouth .mascot__mouth {
  transition: none;
  animation: none !important;
}

/* Celebrating — bounce and show sparkles */
.mascot[data-state="celebrate"] {
  animation: mascot-celebrate 0.8s ease-in-out 2;
}
.mascot[data-state="celebrate"] .mascot__sparkles { opacity: 1; }
.mascot[data-state="celebrate"] .mascot__sparkles span {
  animation: sparkle-pop 1s ease-out infinite;
}
.mascot[data-state="celebrate"] .mascot__sparkles span:nth-child(2) { animation-delay: 0.15s; }
.mascot[data-state="celebrate"] .mascot__sparkles span:nth-child(3) { animation-delay: 0.3s; }
.mascot[data-state="celebrate"] .mascot__sparkles span:nth-child(4) { animation-delay: 0.45s; }
.mascot[data-state="celebrate"] .mascot__sparkles span:nth-child(5) { animation-delay: 0.6s; }

/* Error — droopy mouth, sad eyes */
.mascot[data-state="error"] .mascot__mouth {
  d: path("M 82 142 Q 100 128 118 142");
}

/* Amplitude scaling driven by JS */
.mascot.mascot--amp {
  transform: scale(var(--mascot-amp, 1));
  transition: transform 0.08s ease-out;
}

@keyframes mascot-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes mascot-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98%      { transform: scaleY(0.1); }
}

/* Subtle jaw bob underneath the phoneme path swaps */
@keyframes mascot-jaw-bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(-1.5px) scale(1.04, 1.08); }
}

/* Tiny head nod to reinforce talking */
@keyframes mascot-head-nod {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-2px) rotate(-1deg); }
}

@keyframes mascot-celebrate {
  0%   { transform: translateY(0) rotate(0); }
  25%  { transform: translateY(-20px) rotate(-6deg); }
  50%  { transform: translateY(0) rotate(0); }
  75%  { transform: translateY(-14px) rotate(6deg); }
  100% { transform: translateY(0) rotate(0); }
}

@keyframes sparkle-pop {
  0%   { opacity: 0; transform: scale(0.5) translateY(0); }
  50%  { opacity: 1; transform: scale(1.3) translateY(-6px); }
  100% { opacity: 0; transform: scale(0.7) translateY(-12px); }
}

/* Turn-taking badge — speech-bubble near the mascot */
.turn-badge {
  position: absolute;
  top: -6px;
  right: -12px;
  background: #ffffff;
  color: #1b2559;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(27, 37, 89, 0.2);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 3;
  animation: badge-wobble 2s ease-in-out infinite;
}
.turn-badge::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(27, 37, 89, 0.1);
}
.turn-badge--hidden {
  opacity: 0;
  transform: translateY(-6px) scale(0.85);
  pointer-events: none;
}
.turn-badge--kid { background: #fff0c2; }
.turn-badge--kid::after { background: #fff0c2; }
.turn-badge--ai  { background: #d8f9e4; }
.turn-badge--ai::after  { background: #d8f9e4; }

@keyframes badge-wobble {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}

/* Status & timer on stage */
.stage__status {
  position: absolute;
  bottom: -42px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #1b2559;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  font-size: 0.95rem;
}
.stage__timer {
  position: absolute;
  bottom: -68px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #52608f;
  font-size: 0.8rem;
  opacity: 0.75;
}

/* Controls row — giant talk button center, small pause/stop on sides */
.controls {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  margin-top: 80px;
}

.btn--talk {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff9a7a, #ff5a36);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(255, 90, 54, 0.45),
    inset 0 -6px 12px rgba(0, 0, 0, 0.12),
    inset 0 6px 10px rgba(255, 255, 255, 0.25);
  border: 4px solid #ffffff;
  position: relative;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 800;
  font-size: 0.9rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.btn--talk:active:not(:disabled) {
  transform: scale(0.95);
  box-shadow: 0 8px 18px rgba(255, 90, 54, 0.35),
    inset 0 -2px 6px rgba(0, 0, 0, 0.15);
}
.btn--talk:not(:disabled):hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 18px 32px rgba(255, 90, 54, 0.5),
    inset 0 -6px 12px rgba(0, 0, 0, 0.12),
    inset 0 6px 10px rgba(255, 255, 255, 0.25);
}
.btn--talk__icon {
  font-size: 2.4rem;
  line-height: 1;
  animation: talk-wiggle 2.5s ease-in-out infinite;
}
.btn--talk__label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.btn--talk__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(255, 122, 89, 0.55);
  opacity: 0;
  pointer-events: none;
}
.btn--talk.recording .btn--talk__ring,
.btn--talk.btn--talk--active .btn--talk__ring {
  animation: talk-ring-pulse 1.4s ease-out infinite;
  opacity: 1;
}
.btn--talk.recording,
.btn--talk.btn--talk--active {
  width: 96px;
  height: 96px;
  background: linear-gradient(145deg, #7ef1b1, #2ecc71);
  box-shadow: 0 14px 28px rgba(46, 204, 113, 0.45),
    inset 0 -6px 12px rgba(0, 0, 0, 0.12),
    inset 0 6px 10px rgba(255, 255, 255, 0.25);
}
.btn--talk.recording .btn--talk__icon,
.btn--talk.btn--talk--active .btn--talk__icon {
  font-size: 1.8rem;
}
.btn--talk.recording .btn--talk__label,
.btn--talk.btn--talk--active .btn--talk__label {
  font-size: 0.68rem;
}

@keyframes talk-wiggle {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-6deg); }
  75%      { transform: rotate(6deg); }
}

@keyframes talk-ring-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Small icon buttons (pause/stop) */
.btn--icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #ffffff;
  color: #1b2559;
  box-shadow: 0 8px 16px rgba(27, 37, 89, 0.12);
  border: 2px solid #eef0ff;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.3s ease;
}
.btn--icon:disabled {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}
.btn--icon:not(:disabled):hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 20px rgba(27, 37, 89, 0.2);
}

/* Help button — image fits inside the 76px circle. Pre-session it inherits
   .btn--icon:disabled (opacity:0 on desktop, display:none on mobile), which
   keeps it symmetric with pause-btn so start-btn stays centered. */
.btn--help {
  background: #fff7e6;
  border-color: #ffd479;
  position: relative;
  overflow: hidden;
}
.btn--help .btn__img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
}
/* Reveal alongside pause-btn while a conversation is active. The explicit
   display overrides the mobile .btn--icon:disabled { display: none } rule. */
body.session-active .btn--help {
  display: inline-flex;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
/* Greyed appearance when temporarily disabled mid-session */
body.session-active .btn--help:disabled {
  pointer-events: none;
  cursor: not-allowed;
}
body.session-active .btn--help:disabled::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(120, 120, 120, 0.55);
}
.btn--help--pulse {
  animation: help-pulse 0.6s ease-out;
}

@keyframes help-pulse {
  0%   { transform: scale(1);    box-shadow: 0 8px 16px rgba(27, 37, 89, 0.12); }
  40%  { transform: scale(1.18); box-shadow: 0 0 0 12px rgba(255, 196, 87, 0.45); }
  100% { transform: scale(1);    box-shadow: 0 8px 16px rgba(27, 37, 89, 0.12); }
}

/* Sticker strip */
.sticker-strip {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  padding: 10px 14px;
  border: 1px dashed rgba(154, 165, 250, 0.7);
}
.sticker-strip__title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #3f4a7f;
  margin-bottom: 6px;
}
.sticker-strip__list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 32px;
  align-items: center;
}
.sticker {
  font-size: 1.4rem;
  line-height: 1;
  animation: sticker-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}
.sticker-strip__empty {
  color: #7a85c0;
  font-size: 0.8rem;
  font-style: italic;
}

@keyframes sticker-pop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Confetti */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translate3d(0, 0, 0) rotate(0);    opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(720deg); opacity: 0.85; }
}

/* Fade decorations when in active session */
body.session-active .decoration,
body.session-active .grass {
  opacity: 0.25 !important;
  transition: opacity 0.6s ease;
}
body .decoration,
body .grass {
  transition: opacity 0.6s ease;
}

/* Topic card stagger-in */
.topic-card--enter {
  animation: topic-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes topic-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Level card with emoji */
.level-card {
  gap: 6px;
}
.level-emoji {
  font-size: 1.2rem;
  line-height: 1;
}

/* Reduce-motion support */
@media (prefers-reduced-motion: reduce) {
  .mascot,
  .mascot__eye,
  .mascot__sparkles span,
  .btn--talk__icon,
  .turn-badge,
  .confetti-piece,
  .topic-card--enter {
    animation: none !important;
  }
}

/* =============================================================
   Mobile-friendly tweaks (≤ 640px)
   ============================================================= */
@media (max-width: 640px) {
  /* Use viewport units that respect notches/safe areas */
  .page {
    padding: 10px 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .home,
  .login__card {
    padding: 16px;
    border-radius: 20px;
  }

  /* Header — keep horizontal but allow shrinking */
  .home__header {
    gap: 8px;
    margin-bottom: 16px;
    align-items: flex-start;
  }
  .home__title {
    font-size: 1.5rem;
    line-height: 1.2;
  }
  .home__subtitle {
    font-size: 0.85rem;
    margin: 0 0 4px;
  }
  .home__header-right {
    gap: 6px;
    flex-shrink: 0;
  }

  .language-select {
    padding: 8px 28px 8px 10px;
    font-size: 0.85rem;
  }

  /* Stage scales down so big talk button still fits the viewport vertically */
  .stage {
    width: 220px;
    height: 220px;
    margin: 4px auto 4px;
  }
  .stage__status {
    bottom: -38px;
    font-size: 0.85rem;
    white-space: normal;
    max-width: 90vw;
    line-height: 1.25;
  }
  .stage__timer {
    bottom: -62px;
    font-size: 0.75rem;
  }

  /* Turn badge — keep on the bubble corner but shrink */
  .turn-badge {
    font-size: 0.78rem;
    padding: 6px 10px;
    top: -2px;
    right: -8px;
  }

  /* Talk button stays prominent but a bit smaller; icon buttons keep a touch-friendly 52px */
  .controls {
    gap: 14px;
    margin-top: 70px;
  }
  .btn--talk {
    width: 116px;
    height: 116px;
  }
  .btn--talk__icon { font-size: 2.1rem; }
  .btn--talk__label { font-size: 0.72rem; }
  .btn--talk.recording,
  .btn--talk.btn--talk--active {
    width: 84px;
    height: 84px;
  }
  .btn--talk.recording .btn--talk__icon,
  .btn--talk.btn--talk--active .btn--talk__icon { font-size: 1.6rem; }
  .btn--talk.recording .btn--talk__label,
  .btn--talk.btn--talk--active .btn--talk__label { font-size: 0.62rem; }
  .btn--icon {
    width: 68px;
    height: 68px;
    font-size: 1.6rem;
  }

  /* Sticker strip more compact */
  .sticker-strip {
    padding: 8px 12px;
  }
  .sticker-strip__title { font-size: 0.8rem; }
  .sticker { font-size: 1.25rem; }

  /* Dialog: full-height, scrollable content, sticky confirm button at the top */
  .dialog-backdrop { padding: 8px; }
  .dialog {
    border-radius: 18px;
    padding: 16px 14px 14px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .dialog__title {
    font-size: 1.15rem;
  }
  .dialog__text {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }
  .dialog__subtitle {
    margin: 12px 0 4px;
  }

  /* Sticky confirm button at the top of step 2 so it's always reachable */
  #dialog-step-2 .topics-confirm-btn {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 4px auto 12px;
    padding: 12px 22px;
    font-size: 1rem;
    box-shadow: 0 6px 16px rgba(255, 122, 89, 0.4);
  }

  /* Form fields — use larger inputs to avoid iOS auto-zoom on focus (≥ 16px) */
  .field__input,
  .language-select {
    font-size: 16px;
  }
  .btn--primary,
  .btn--secondary,
  .btn--google,
  .btn--facebook {
    padding: 12px 16px;
    font-size: 0.95rem;
  }

  /* Level cards row should wrap nicely */
  .levels-grid { gap: 8px; }
  .level-card {
    padding: 8px 14px;
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Topics: tighter grid, smaller thumbnails (existing rule already addresses this) */
  .topics-grid {
    max-height: 300px;
  }

  /* Avoid pause/help buttons being missed near the talk button — vertical hit
     area. body.session-active rules override this for help-btn mid-session. */
  .btn--icon:disabled { display: none; }
}

/* Very small phones (≤ 360px) */
@media (max-width: 360px) {
  .stage {
    width: 200px;
    height: 200px;
  }
  .btn--talk {
    width: 104px;
    height: 104px;
  }
  .btn--talk.recording,
  .btn--talk.btn--talk--active {
    width: 76px;
    height: 76px;
  }
  .btn--icon {
    width: 60px;
    height: 60px;
    font-size: 1.4rem;
  }
  .controls { gap: 10px; }
  .home__title { font-size: 1.3rem; }
}

/* Landscape phones — collapse vertical-heavy stage so controls remain visible */
@media (max-height: 520px) and (orientation: landscape) {
  .stage {
    width: 180px;
    height: 180px;
  }
  .controls { margin-top: 56px; }
  .btn--talk { width: 96px; height: 96px; }
  .btn--talk__icon { font-size: 1.7rem; }
  .home__subtitle { display: none; }
}



.install-dialog {
  text-align: center;
  max-width: 380px;
}

.install-dialog__icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}

.install-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.install-dialog__steps {
  margin: 0 0 16px;
  padding-left: 0;
  list-style: none;
  text-align: left;
  color: #52608f;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.install-dialog__steps li {
  background: #fff5f0;
  border-radius: 12px;
  padding: 10px 12px;
}

#install-dialog.dialog-backdrop { z-index: 20; }
