@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Bubblegum+Sans&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

:root {
  --theme-bg: linear-gradient(180deg, #1a0533 0%, #2d1b69 30%, #5b2d8e 60%, #8b5fbf 80%, #c4a6e0 100%);
  --theme-font: 'Fredoka One', 'Bubblegum Sans', cursive;
  --theme-text-shadow:
    0 0 20px rgba(255, 150, 200, 0.8),
    0 0 40px rgba(150, 200, 255, 0.6),
    0 0 80px rgba(200, 150, 255, 0.4),
    4px 4px 0 rgba(100, 50, 150, 0.5);
  --theme-hint-bg: linear-gradient(135deg, rgba(255, 150, 200, 0.3), rgba(150, 200, 255, 0.3));
  --theme-hint-border: rgba(255, 255, 255, 0.3);
  --theme-overlay: rgba(0, 0, 0, 0.85);
  --theme-parent-btn: linear-gradient(135deg, #ff69b4, #9b59b6);
  --theme-parent-zone: rgba(255,255,255,0);
  --theme-ambient-top: transparent;
  --theme-ambient-mid-1: rgba(100, 200, 255, 0.05);
  --theme-ambient-mid-2: rgba(150, 100, 255, 0.08);
  --theme-ambient-mid-3: rgba(200, 150, 255, 0.05);
  --theme-ambient-bottom: transparent;
  --theme-glass: rgba(255,255,255,0.12);
  --theme-glass-border: rgba(255,255,255,0.18);
  --theme-vignette: radial-gradient(circle at center, transparent 45%, rgba(3, 8, 20, 0.26) 100%);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

body {
  background: var(--theme-bg);
  font-family: var(--theme-font);
  cursor: none;
  color: white;
  transition: background 0.8s ease, color 0.4s ease;
}

#backdrop-gradient,
#backdrop-vignette,
#backdrop-stars,
#backdrop-orbs,
#theme-scene,
.snowflakes,
.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#backdrop-gradient {
  z-index: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.12), transparent 28%),
    radial-gradient(circle at 80% 25%, rgba(255,255,255,0.08), transparent 22%),
    radial-gradient(circle at 50% 80%, rgba(255,255,255,0.08), transparent 25%);
  mix-blend-mode: screen;
}

#backdrop-vignette {
  z-index: 1;
  background: var(--theme-vignette);
}

#backdrop-stars {
  z-index: 1;
  overflow: hidden;
}

.backdrop-star {
  position: absolute;
  color: rgba(255,255,255,0.6);
  animation: twinkle 4s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.18));
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 0.75; transform: scale(1.1); }
}

#backdrop-orbs {
  z-index: 1;
  overflow: hidden;
}

.backdrop-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.22;
  animation: orb-drift linear infinite alternate;
}

@keyframes orb-drift {
  from { transform: translate3d(-2vw, -1vh, 0) scale(0.95); }
  to { transform: translate3d(2vw, 2vh, 0) scale(1.08); }
}

#theme-scene {
  z-index: 2;
  overflow: hidden;
}

.scene-layer {
  position: absolute;
  inset: auto 0 0 0;
  pointer-events: none;
  background-repeat: repeat-x;
  background-position: bottom center;
  transform-origin: center bottom;
  opacity: 0.72;
}

.scene-layer.layer-back {
  height: 45%;
  opacity: 0.3;
}

.scene-layer.layer-mid {
  height: 34%;
  opacity: 0.45;
}

.scene-layer.layer-front {
  height: 24%;
  opacity: 0.75;
}

.scene-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.06) 100%);
  mix-blend-mode: screen;
}

.snowflakes {
  z-index: 3;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -20px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.2em;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(360deg);
  }
}

.aurora {
  z-index: 3;
  background: linear-gradient(
    180deg,
    var(--theme-ambient-top) 0%,
    var(--theme-ambient-mid-1) 20%,
    var(--theme-ambient-mid-2) 40%,
    var(--theme-ambient-mid-3) 60%,
    var(--theme-ambient-bottom) 100%
  );
  animation: aurora-shift 8s ease-in-out infinite alternate;
}

@keyframes aurora-shift {
  0% { opacity: 0.3; transform: translateX(-5%); }
  100% { opacity: 0.7; transform: translateX(5%); }
}

#display {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.letter-display {
  font-size: min(45vw, 45vh);
  color: white;
  text-shadow: var(--theme-text-shadow);
  animation: letter-appear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
  text-align: center;
  line-height: 1.1;
  position: relative;
  padding: 0.08em 0.18em;
}

.letter-display.word {
  font-size: min(18vw, 18vh);
}

.letter-display.word-long {
  font-size: min(12vw, 12vh);
}

.output-card {
  padding: 18px 24px;
  border-radius: 28px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 24px 70px rgba(0,0,0,0.24);
  backdrop-filter: blur(12px);
}

.output-caption {
  display: none;
}

.letter-display.emoji {
  font-size: min(35vw, 35vh);
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255, 200, 255, 0.5));
}

.scattered-emoji {
  position: fixed;
  pointer-events: none;
  z-index: 18;
  animation: scatter-appear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
             scatter-fade 3s ease-in 1s forwards;
}

@keyframes scatter-appear {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(var(--rot)); opacity: 1; }
}

@keyframes scatter-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.bubble {
  position: fixed;
  pointer-events: none;
  z-index: 28;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.7), rgba(200, 170, 255, 0.24) 50%, rgba(150, 200, 255, 0.12) 80%, transparent);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  animation: bubble-rise ease-out forwards;
}

@keyframes bubble-rise {
  0% {
    transform: scale(0.3) translateY(0);
    opacity: 0.9;
  }
  50% {
    transform: scale(1) translateY(var(--rise-y));
    opacity: 0.7;
  }
  100% {
    transform: scale(0.6) translateY(calc(var(--rise-y) * 2));
    opacity: 0;
  }
}

@keyframes letter-appear {
  0% {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.3) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.word-hint {
  position: absolute;
  bottom: 15%;
  font-size: min(8vw, 8vh);
  color: rgba(255, 255, 255, 0.88);
  background: var(--theme-hint-bg);
  padding: 10px 30px;
  border-radius: 50px;
  border: 2px solid var(--theme-hint-border);
  backdrop-filter: blur(12px);
  animation: hint-appear 0.5s ease-out;
  text-align: center;
  z-index: 10;
  box-shadow: 0 16px 40px rgba(0,0,0,0.16);
}

@keyframes hint-appear {
  0% { transform: translateY(20px) scale(0.8); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 30;
  animation: sparkle-fly linear forwards;
}

@keyframes sparkle-fly {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0) rotate(720deg);
    opacity: 0;
  }
}

.frozen-burst {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 25;
  animation: burst-out 0.8s ease-out forwards;
}

@keyframes burst-out {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--bx), var(--by)) scale(0);
    opacity: 0;
  }
}

.ripple {
  position: fixed;
  border-radius: 50%;
  border: 3px solid rgba(255, 200, 255, 0.6);
  pointer-events: none;
  z-index: 25;
  animation: ripple-expand 0.8s ease-out forwards;
}

@keyframes ripple-expand {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

.float-emoji {
  position: fixed;
  font-size: 3em;
  pointer-events: none;
  z-index: 30;
  animation: float-up 2s ease-out forwards;
}

@keyframes float-up {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: translateY(-100px) scale(1.2) rotate(15deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-250px) scale(0.8) rotate(-10deg);
    opacity: 0;
  }
}

.idle-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  animation: idle-bounce 3s ease-in-out infinite;
}

.idle-prompt .emoji-row {
  font-size: min(18vw, 18vh);
  margin-bottom: 20px;
}

.idle-prompt .text {
  font-size: min(6vw, 6vh);
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 0 20px rgba(200, 150, 255, 0.5);
}

.idle-prompt .subtext {
  margin-top: 12px;
  font-size: min(2.8vw, 18px);
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes idle-bounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -53%) scale(1.05); }
}

#parent-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--theme-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

#parent-overlay.visible {
  display: flex;
}

#parent-overlay h2 {
  color: white;
  font-size: 2.2em;
  margin-bottom: 10px;
}

#parent-overlay p {
  color: rgba(255, 255, 255, 0.78);
  font-size: 1.1em;
  margin-bottom: 6px;
  text-align: center;
}

#parent-panel {
  width: min(92vw, 760px);
  padding: 28px;
  border-radius: 28px;
  background: rgba(10, 14, 28, 0.42);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 30px 90px rgba(0,0,0,0.3);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.parent-subtitle {
  max-width: 560px;
}

#parent-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

#parent-notes {
  width: 100%;
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.parent-note {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.84);
  font-size: 0.95rem;
  line-height: 1.45;
}

.parent-note strong {
  display: block;
  margin-bottom: 4px;
  color: white;
}

.parent-btn {
  padding: 15px 40px;
  font-size: 1.08em;
  font-family: var(--theme-font);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  margin: 6px;
  transition: transform 0.2s, opacity 0.2s;
  min-width: 260px;
}

.parent-btn:hover {
  transform: scale(1.05);
}

.parent-btn.fullscreen {
  background: var(--theme-parent-btn);
  color: white;
}

.parent-btn.exit {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.24);
}

#parent-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 72px;
  height: 72px;
  z-index: 500;
  cursor: none;
  background: var(--theme-parent-zone);
}

.edge-blocker {
  position: fixed;
  z-index: 100;
  background: transparent;
}

.edge-blocker.top { top: 0; left: 0; right: 0; height: 15px; }
.edge-blocker.bottom { bottom: 0; left: 0; right: 0; height: 15px; }
.edge-blocker.left { top: 0; left: 0; bottom: 0; width: 15px; }
.edge-blocker.right { top: 0; right: 0; bottom: 0; width: 15px; }

#cursor-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  font-size: 2em;
  transition: left 0.05s, top 0.05s;
}

#theme-banner {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  pointer-events: none;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(10, 15, 35, 0.35);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,0.9);
  font-size: min(3vw, 18px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center;
}

#theme-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#theme-banner .sub {
  display: block;
  font-size: 0.72em;
  opacity: 0.8;
  letter-spacing: 0.12em;
  margin-top: 3px;
}

#theme-banner.pulse {
  box-shadow: 0 18px 50px rgba(0,0,0,0.24), 0 0 24px rgba(255,255,255,0.08);
}

#mode-hud {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 650;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#mode-chip,
#math-chip {
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(8, 12, 24, 0.34);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(10px);
  color: rgba(255,255,255,0.82);
  font-size: min(2.4vw, 14px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#math-chip {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#math-chip.visible {
  opacity: 1;
  transform: translateY(0);
}

#demo-chip {
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.82);
  font-size: min(2.4vw, 14px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#demo-chip.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  #mode-hud {
    display: none;
  }

  #parent-panel,
  #parent-grid,
  #parent-notes {
    display: block;
  }

  .parent-btn {
    width: 100%;
    min-width: 220px;
    padding: 14px 24px;
  }

  .parent-note {
    margin-top: 10px;
  }
}
