/* ============================================================
   main.css — Luminous Playground
   ============================================================
   Premium clinic kiosk UI — organic depth, warm glow,
   rich motion. 32-43″ touch panel, 1920×1080 target.
   ============================================================ */

/* ── Reset & Global ───────────────────────────────────────── */

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  color: var(--color-text-primary);
  background: #152535;
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { display: none; }

/* ── App Container ────────────────────────────────────────── */

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ── Screen Base ──────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 700ms var(--ease-out-expo),
    visibility 700ms var(--ease-out-expo);
}

.screen.active {
  opacity: 1;
  visibility: visible;
}


/* ================================================================
   ATTRACT SCREEN
   ================================================================ */

#attract-screen {
  z-index: 100;
  background:
    radial-gradient(ellipse 60% 40% at 50% 70%, rgba(252,227,138,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 90% 60% at 25% 20%, rgba(91,138,114,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 120% 100% at 50% 40%, #1e3340 0%, #182c3a 60%, #122230 100%);
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

/* ── Animated Background Orbs ── */

.attract-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  will-change: transform;
}

.attract-orb--1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(232,168,124,0.40) 0%, transparent 70%);
  top: -10%; left: -5%;
  animation: orb-drift-1 14s var(--ease-breathe) infinite;
}

.attract-orb--2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(91,138,114,0.38) 0%, transparent 70%);
  top: 10%; right: -8%;
  animation: orb-drift-2 18s var(--ease-breathe) infinite;
}

.attract-orb--3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(252,227,138,0.35) 0%, transparent 70%);
  bottom: -5%; left: 30%;
  animation: orb-drift-3 16s var(--ease-breathe) infinite;
}

.attract-orb--4 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(212,165,229,0.25) 0%, transparent 70%);
  top: 50%; left: 60%;
  animation: orb-drift-1 20s var(--ease-breathe) infinite reverse;
}

.attract-orb--5 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(232,168,124,0.28) 0%, transparent 70%);
  bottom: 15%; right: 10%;
  animation: orb-drift-2 22s var(--ease-breathe) infinite reverse;
}

@keyframes orb-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(60px, 30px) scale(1.08); }
  66%      { transform: translate(-30px, -20px) scale(0.95); }
}

@keyframes orb-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-50px, 40px) scale(1.05); }
  66%      { transform: translate(40px, -30px) scale(0.92); }
}

@keyframes orb-drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(30px, -40px) scale(1.1); }
}

/* ── Floating Particles ── */

.attract-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.attract-particles span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  animation: particle-float linear infinite;
  will-change: transform, opacity;
}

/* Particle shape variants */
.attract-particles .particle-circle {
  border-radius: 50%;
}
.attract-particles .particle-diamond {
  border-radius: 1px;
  transform-origin: center;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.attract-particles .particle-star {
  border-radius: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.attract-particles span:nth-child(1)  { left:  8%; animation-duration: 9s;  animation-delay: 0s;    width: 3px; height: 3px; }
.attract-particles span:nth-child(2)  { left: 15%; animation-duration: 12s; animation-delay: -2s;   width: 5px; height: 5px; background: rgba(232,168,124,0.5); }
.attract-particles span:nth-child(3)  { left: 25%; animation-duration: 8s;  animation-delay: -4s;   }
.attract-particles span:nth-child(4)  { left: 35%; animation-duration: 14s; animation-delay: -1s;   width: 6px; height: 6px; background: rgba(91,138,114,0.45); }
.attract-particles span:nth-child(5)  { left: 42%; animation-duration: 10s; animation-delay: -6s;   width: 3px; height: 3px; }
.attract-particles span:nth-child(6)  { left: 50%; animation-duration: 11s; animation-delay: -3s;   width: 5px; height: 5px; background: rgba(252,227,138,0.5); }
.attract-particles span:nth-child(7)  { left: 58%; animation-duration: 13s; animation-delay: -7s;   }
.attract-particles span:nth-child(8)  { left: 65%; animation-duration: 9s;  animation-delay: -5s;   width: 3px; height: 3px; background: rgba(232,168,124,0.5); }
.attract-particles span:nth-child(9)  { left: 72%; animation-duration: 15s; animation-delay: -2s;   width: 5px; height: 5px; }
.attract-particles span:nth-child(10) { left: 78%; animation-duration: 10s; animation-delay: -8s;   background: rgba(212,165,229,0.45); }
.attract-particles span:nth-child(11) { left: 84%; animation-duration: 12s; animation-delay: -1s;   width: 3px; height: 3px; }
.attract-particles span:nth-child(12) { left: 20%; animation-duration: 16s; animation-delay: -4s;   width: 6px; height: 6px; background: rgba(91,138,114,0.4); }
.attract-particles span:nth-child(13) { left: 90%; animation-duration: 11s; animation-delay: -6s;   }
.attract-particles span:nth-child(14) { left: 55%; animation-duration: 14s; animation-delay: -9s;   width: 3px; height: 3px; background: rgba(252,227,138,0.5); }
.attract-particles span:nth-child(15) { left: 95%; animation-duration: 10s; animation-delay: -3s;   width: 5px; height: 5px; }

@keyframes particle-float {
  0% {
    transform: translateY(110vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(95vh) scale(1);
  }
  90% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-10vh) scale(0.5);
    opacity: 0;
  }
}

/* ── Floating Fireflies ── */

.attract-fireflies {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.attract-fireflies span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(252,227,138,0.9) 0%, rgba(252,227,138,0) 70%);
  box-shadow: 0 0 8px rgba(252,227,138,0.4);
  animation: firefly-drift ease-in-out infinite;
  will-change: transform, opacity;
}

.attract-fireflies span:nth-child(1)  { left: 10%; top: 25%; animation-duration: 6s;  animation-delay: 0s;   width: 8px; height: 8px; }
.attract-fireflies span:nth-child(2)  { left: 22%; top: 55%; animation-duration: 8s;  animation-delay: -2s;  width: 5px; height: 5px; }
.attract-fireflies span:nth-child(3)  { left: 40%; top: 20%; animation-duration: 7s;  animation-delay: -4s;  width: 7px; height: 7px; }
.attract-fireflies span:nth-child(4)  { left: 60%; top: 50%; animation-duration: 9s;  animation-delay: -1s;  width: 6px; height: 6px; }
.attract-fireflies span:nth-child(5)  { left: 75%; top: 30%; animation-duration: 7s;  animation-delay: -3s;  width: 8px; height: 8px; }
.attract-fireflies span:nth-child(6)  { left: 88%; top: 60%; animation-duration: 8s;  animation-delay: -5s;  width: 5px; height: 5px; }
.attract-fireflies span:nth-child(7)  { left: 32%; top: 72%; animation-duration: 6s;  animation-delay: -2s;  width: 7px; height: 7px; }
.attract-fireflies span:nth-child(8)  { left: 52%; top: 78%; animation-duration: 9s;  animation-delay: -4s;  width: 6px; height: 6px; }
.attract-fireflies span:nth-child(9)  { left: 15%; top: 82%; animation-duration: 7s;  animation-delay: -6s;  width: 5px; height: 5px; }
.attract-fireflies span:nth-child(10) { left: 82%; top: 80%; animation-duration: 8s;  animation-delay: -3s;  width: 7px; height: 7px; }

@keyframes firefly-drift {
  0%, 100% {
    transform: translate(0, 0) scale(0.4);
    opacity: 0.15;
  }
  25% {
    transform: translate(15px, -20px) scale(1);
    opacity: 0.9;
  }
  50% {
    transform: translate(-10px, -10px) scale(0.6);
    opacity: 0.3;
  }
  75% {
    transform: translate(20px, 10px) scale(1);
    opacity: 0.8;
  }
}

/* ── Nature Silhouette ── */

.attract-nature {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18vh;
  pointer-events: none;
  z-index: 1;
}

.attract-nature__hills {
  width: 100%;
  height: 100%;
}

/* ── Attract Content ── */

.attract-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: attract-content-enter 1.2s var(--ease-out-expo) both;
}

@keyframes attract-content-enter {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Logo SVG */
.attract-logo {
  width: 160px;
  height: 160px;
  margin-bottom: 8px;
  animation: logo-breathe 4s var(--ease-breathe) infinite;
}

.attract-logo__icon {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 30px rgba(252,227,138,0.45));
}

@keyframes logo-breathe {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 20px rgba(252,227,138,0.35)); }
  50%      { transform: scale(1.06); filter: drop-shadow(0 0 40px rgba(232,168,124,0.55)); }
}

/* Logo sparkle dots */
.attract-logo__sparkle {
  animation: logo-sparkle 2.4s ease-in-out infinite;
}
@keyframes logo-sparkle {
  0%, 100% { opacity: 0.7; r: 2; }
  50% { opacity: 0.2; r: 1; }
}

/* Title */
.attract-title {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(48px, 6vw, 80px);
  font-weight: 900;
  color: #fff;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-shadow:
    0 0 60px rgba(252,227,138,0.4),
    0 0 120px rgba(232,168,124,0.2),
    0 4px 20px rgba(0,0,0,0.4);
}

/* Subtitle */
.attract-subtitle {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 500;
  color: rgba(255,248,230,0.70);
  letter-spacing: 0.15em;
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(252,227,138,0.15);
}

/* CTA */
.attract-cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}

.attract-cta__ring {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 2px solid rgba(252,227,138,0.15);
  animation: cta-ring-pulse 3s var(--ease-breathe) infinite;
}

.attract-cta__ring--2 {
  width: 200px;
  height: 200px;
  border-color: rgba(232,168,124,0.08);
  animation-delay: 0.8s;
}

@keyframes cta-ring-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.4;
  }
}

.attract-cta__text {
  position: relative;
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 700;
  color: rgba(255,248,230,0.9);
  padding: 18px 48px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(252,227,138,0.15);
  animation: cta-glow 3s var(--ease-breathe) infinite;
  letter-spacing: 0.08em;
}

@keyframes cta-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(252,227,138,0.18), inset 0 0 20px rgba(255,255,255,0.03); }
  50%      { box-shadow: 0 0 40px rgba(232,168,124,0.35),  inset 0 0 30px rgba(255,255,255,0.06); }
}


/* ================================================================
   AGE SELECT SCREEN
   ================================================================ */

#age-select-screen {
  z-index: 10;
  flex-direction: column;
  background:
    radial-gradient(ellipse 130% 90% at 50% 100%, rgba(99,102,241,0.06) 0%, transparent 50%),
    radial-gradient(ellipse 100% 80% at 20% 0%, rgba(255,107,157,0.05) 0%, transparent 40%),
    linear-gradient(170deg, #faf8f5 0%, #f5f0ff 35%, #fff0f5 65%, #f0f8ff 100%);
  padding: 40px 48px;
  gap: 28px;
}

/* ── Ambient Background Orbs ── */

.age-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.age-bg__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
}

.age-bg__orb--1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,107,157,0.08) 0%, transparent 70%);
  top: -20%; left: -10%;
  animation: orb-drift-1 20s var(--ease-breathe) infinite;
}

.age-bg__orb--2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(99,102,241,0.07) 0%, transparent 70%);
  bottom: -15%; right: -5%;
  animation: orb-drift-2 24s var(--ease-breathe) infinite;
}

.age-bg__orb--3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,200,100,0.06) 0%, transparent 70%);
  top: 30%; right: 20%;
  animation: orb-drift-3 18s var(--ease-breathe) infinite;
}

/* ── Header ── */

.age-select-header {
  text-align: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.age-select-title {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 900;
  color: var(--color-text-primary);
  letter-spacing: 0.04em;
  opacity: 0;
  animation: age-title-in 800ms var(--ease-out-expo) 200ms forwards;
}

@keyframes age-title-in {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card Grid ── */

.age-card-container {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
  align-content: center;
}

/* ── Age Card ── */

.age-card {
  position: relative;
  border: none;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.06),
    0 1px 3px rgba(0,0,0,0.04);
  transition:
    transform 500ms var(--ease-overshoot),
    box-shadow 500ms var(--ease-out-expo);
  cursor: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

/* Per-card accent glow */
.age-card__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 500ms ease;
  pointer-events: none;
  z-index: 0;
}

.age-card[data-age-group="toddler"] .age-card__glow {
  box-shadow: inset 0 0 60px rgba(255,107,157,0.12), 0 8px 40px rgba(255,107,157,0.15);
}
.age-card[data-age-group="child"] .age-card__glow {
  box-shadow: inset 0 0 60px rgba(56,216,120,0.12), 0 8px 40px rgba(56,216,120,0.15);
}
.age-card[data-age-group="teen"] .age-card__glow {
  box-shadow: inset 0 0 60px rgba(99,102,241,0.12), 0 8px 40px rgba(99,102,241,0.15);
}
.age-card[data-age-group="adult"] .age-card__glow {
  box-shadow: inset 0 0 60px rgba(197,95,252,0.12), 0 8px 40px rgba(197,95,252,0.15);
}

/* Card scene (illustration area) */
.age-card__scene {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

/* Per-card scene backgrounds */
.age-card[data-age-group="toddler"] .age-card__scene {
  background: linear-gradient(160deg, #FFF0F5 0%, #FFE4EE 50%, #FFD6E4 100%);
}
.age-card[data-age-group="child"] .age-card__scene {
  background: linear-gradient(160deg, #EFFFEF 0%, #D4F5D4 50%, #C4EDCC 100%);
}
.age-card[data-age-group="teen"] .age-card__scene {
  background: linear-gradient(160deg, #1a1033 0%, #1e1445 50%, #15102e 100%);
}
.age-card[data-age-group="adult"] .age-card__scene {
  background: linear-gradient(160deg, #F5F0FF 0%, #EDE4FF 50%, #E4D8FF 100%);
}

.age-card__illustration {
  width: 85%;
  height: 85%;
  max-height: 140px;
  transition: transform 600ms var(--ease-overshoot);
}

/* Age card SVG micro-animations */
.age-svg-float {
  animation: age-svg-float 3.5s ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
}
.age-svg-pulse {
  animation: age-svg-pulse 2.8s ease-in-out infinite;
  animation-delay: var(--pulse-delay, 0s);
}
.age-svg-twinkle {
  animation: age-svg-twinkle 2s ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}
.age-svg-peek {
  animation: age-svg-peek 4s ease-in-out infinite;
}
.age-svg-blink {
  animation: age-svg-blink 3s ease-in-out infinite;
}

@keyframes age-svg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes age-svg-pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 0.7; }
}
@keyframes age-svg-twinkle {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.2; }
}
@keyframes age-svg-peek {
  0%, 80%, 100% { transform: translateY(0); }
  10% { transform: translateY(-8px); }
  20% { transform: translateY(-4px); }
}
@keyframes age-svg-blink {
  0%, 42%, 46%, 100% { transform: scaleY(1); }
  44% { transform: scaleY(0.1); }
}

/* Age card floating particles */
.age-card__particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.age-card__particles span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0;
  animation: age-particle-drift 4s ease-in-out infinite;
}
.age-card[data-age-group="toddler"] .age-card__particles span { background: #FF6B9D; }
.age-card[data-age-group="child"] .age-card__particles span   { background: #38D878; }
.age-card[data-age-group="teen"] .age-card__particles span    { background: #818CF8; }
.age-card[data-age-group="adult"] .age-card__particles span   { background: #C55FFC; }

.age-card__particles span:nth-child(1) { left: 15%; top: 60%; animation-delay: 0s;   width: 3px; height: 3px; }
.age-card__particles span:nth-child(2) { left: 35%; top: 70%; animation-delay: 0.8s; width: 5px; height: 5px; }
.age-card__particles span:nth-child(3) { left: 55%; top: 50%; animation-delay: 1.6s; }
.age-card__particles span:nth-child(4) { left: 75%; top: 65%; animation-delay: 2.4s; width: 3px; height: 3px; }
.age-card__particles span:nth-child(5) { left: 90%; top: 55%; animation-delay: 3.2s; width: 5px; height: 5px; }

@keyframes age-particle-drift {
  0%   { transform: translateY(0) scale(0); opacity: 0; }
  20%  { transform: translateY(-10px) scale(1); opacity: 0.6; }
  80%  { transform: translateY(-40px) scale(0.8); opacity: 0.3; }
  100% { transform: translateY(-60px) scale(0); opacity: 0; }
}

/* Card info area */
.age-card__info {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 16px 20px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.age-card__age-badge {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 14px;
  border-radius: 9999px;
  color: rgba(255,255,255,0.95);
}

.age-card[data-age-group="toddler"] .age-card__age-badge {
  background: linear-gradient(135deg, #FF6B9D, #FF8BBF);
}
.age-card[data-age-group="child"] .age-card__age-badge {
  background: linear-gradient(135deg, #38D878, #5CE88E);
}
.age-card[data-age-group="teen"] .age-card__age-badge {
  background: linear-gradient(135deg, #6366F1, #818CF8);
}
.age-card[data-age-group="adult"] .age-card__age-badge {
  background: linear-gradient(135deg, #A66BFF, #C55FFC);
}

.age-card__name {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 900;
  color: var(--color-text-primary);
  letter-spacing: 0.03em;
}

.age-card__desc {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

/* ── Card Interactions ── */

/* Touch feedback */
.age-card:active {
  transform: scale(0.94);
  transition-duration: 120ms;
}

.age-card:active .age-card__glow {
  opacity: 1;
}

/* Hover (debug with mouse) */
@media (hover: hover) {
  .age-card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow:
      0 16px 48px rgba(0,0,0,0.10),
      0 4px 12px rgba(0,0,0,0.06);
  }
  .age-card:hover .age-card__glow {
    opacity: 1;
  }
  .age-card:hover .age-card__illustration {
    transform: scale(1.08);
  }
}

/* Card entrance animation */
.age-enter .age-card {
  animation: card-bounce-in 800ms var(--ease-overshoot) both;
}
.age-enter .age-card:nth-child(1) { animation-delay: 100ms; }
.age-enter .age-card:nth-child(2) { animation-delay: 200ms; }
.age-enter .age-card:nth-child(3) { animation-delay: 300ms; }
.age-enter .age-card:nth-child(4) { animation-delay: 400ms; }

@keyframes card-bounce-in {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.85);
  }
  60% {
    opacity: 1;
    transform: translateY(-8px) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Card select bounce */
.age-card.card-selected {
  animation: card-select-bounce 500ms var(--ease-bounce) forwards;
}
@keyframes card-select-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(0.90); }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1.04); opacity: 0.7; }
}

/* ── Shared Play Banner ── */

.shared-play-banner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  border: none;
  border-radius: 20px;
  overflow: hidden;
  cursor: none;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(135deg, rgba(91,138,114,0.08) 0%, rgba(232,168,124,0.08) 50%, rgba(212,165,229,0.08) 100%);
  border: 1px solid rgba(91,138,114,0.12);
  transition: transform 400ms var(--ease-overshoot), box-shadow 400ms ease;
  flex-shrink: 0;
}

.shared-play-banner__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(252,227,138,0.1), 0 4px 24px rgba(91,138,114,0.12);
}

.shared-play-banner:active .shared-play-banner__glow,
.shared-play-banner:hover .shared-play-banner__glow {
  opacity: 1;
}

.shared-play-banner:active {
  transform: scale(0.97);
}

.shared-play-banner__content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
}

.shared-play-banner__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(91,138,114,0.08);
}

.shared-play-banner__text {
  flex: 1;
}

.shared-play-banner__title {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 900;
  color: var(--color-text-primary);
  letter-spacing: 0.04em;
}

.shared-play-banner__desc {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.shared-play-banner__arrow {
  flex-shrink: 0;
  color: var(--color-text-subtle);
  transition: transform 300ms var(--ease-overshoot);
}

.shared-play-banner:active .shared-play-banner__arrow {
  transform: translateX(4px);
}

@media (hover: hover) {
  .shared-play-banner:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(91,138,114,0.12);
  }
  .shared-play-banner:hover .shared-play-banner__arrow {
    transform: translateX(4px);
  }
}


/* ================================================================
   GAME SELECT SCREEN
   ================================================================ */

#game-select-screen {
  z-index: 8;
  flex-direction: column;
  background:
    radial-gradient(ellipse 130% 90% at 50% 100%, rgba(99,102,241,0.06) 0%, transparent 50%),
    radial-gradient(ellipse 100% 80% at 20% 0%, rgba(255,107,157,0.05) 0%, transparent 40%),
    linear-gradient(170deg, #faf8f5 0%, #f5f0ff 35%, #fff0f5 65%, #f0f8ff 100%);
  padding: 40px 48px;
  gap: 28px;
}

/* ── Game Select Header ── */

.game-select-header {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.game-select-title {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 900;
  color: var(--color-text-primary);
  letter-spacing: 0.04em;
}

.game-select-back-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  transition:
    transform 300ms var(--ease-overshoot),
    background 300ms ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.game-select-back-btn:active {
  transform: scale(0.85);
  background: rgba(0,0,0,0.12);
}

.game-select-back-btn svg {
  width: 24px;
  height: 24px;
  color: var(--color-text-primary);
}

/* ── Game Card Grid ── */

.game-card-container {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
  align-content: center;
}

/* ── Game Card ── */

.game-card {
  position: relative;
  border: none;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.06),
    0 1px 3px rgba(0,0,0,0.04);
  transition:
    transform 500ms var(--ease-overshoot),
    box-shadow 500ms var(--ease-out-expo);
  cursor: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.game-card__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 500ms ease;
  pointer-events: none;
  z-index: 0;
}

/* Per-age-group glow colors */
.game-card[data-age-group="toddler"] .game-card__glow {
  box-shadow: inset 0 0 60px rgba(255,107,157,0.12), 0 8px 40px rgba(255,107,157,0.15);
}
.game-card[data-age-group="child"] .game-card__glow {
  box-shadow: inset 0 0 60px rgba(56,216,120,0.12), 0 8px 40px rgba(56,216,120,0.15);
}
.game-card[data-age-group="teen"] .game-card__glow {
  box-shadow: inset 0 0 60px rgba(99,102,241,0.12), 0 8px 40px rgba(99,102,241,0.15);
}
.game-card[data-age-group="adult"] .game-card__glow {
  box-shadow: inset 0 0 60px rgba(197,95,252,0.12), 0 8px 40px rgba(197,95,252,0.15);
}
.game-card[data-age-group="shared"] .game-card__glow {
  box-shadow: inset 0 0 60px rgba(252,227,138,0.12), 0 8px 40px rgba(91,138,114,0.15);
}

/* Card scene (icon area) */
.game-card__scene {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

/* Per-age-group scene backgrounds */
.game-card[data-age-group="toddler"] .game-card__scene {
  background: linear-gradient(160deg, #FFF0F5 0%, #FFE4EE 50%, #FFD6E4 100%);
}
.game-card[data-age-group="child"] .game-card__scene {
  background: linear-gradient(160deg, #EFFFEF 0%, #D4F5D4 50%, #C4EDCC 100%);
}
.game-card[data-age-group="teen"] .game-card__scene {
  background: linear-gradient(160deg, #1a1033 0%, #1e1445 50%, #15102e 100%);
}
.game-card[data-age-group="adult"] .game-card__scene {
  background: linear-gradient(160deg, #F5F0FF 0%, #EDE4FF 50%, #E4D8FF 100%);
}
.game-card[data-age-group="shared"] .game-card__scene {
  background: linear-gradient(160deg, #F5F8F0 0%, #EFF5E8 50%, #FFF8F0 100%);
}

.game-card__icon {
  font-size: clamp(48px, 6vw, 80px);
  line-height: 1;
  transition: transform 600ms var(--ease-overshoot);
}

/* SVG Illustration wrapper (replaces emoji icon) */
.game-card__illustration-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  transition: transform 600ms var(--ease-overshoot);
}

.game-card__illustration-wrap svg {
  width: 100%;
  height: 100%;
  max-width: 200px;
  max-height: 160px;
  display: block;
}

/* SVG micro-animations */
.gc-float {
  animation: gc-float 3s ease-in-out infinite;
}
.gc-pulse {
  animation: gc-pulse 2.4s ease-in-out infinite;
}
.gc-twinkle {
  animation: gc-twinkle 1.8s ease-in-out infinite;
}

@keyframes gc-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes gc-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes gc-twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Card info area */
.game-card__info {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 16px 20px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.game-card__name {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 900;
  color: var(--color-text-primary);
  letter-spacing: 0.03em;
}

.game-card__desc {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

/* ── Game Card Interactions ── */

.game-card:active {
  transform: scale(0.94);
  transition-duration: 120ms;
}

.game-card:active .game-card__glow {
  opacity: 1;
}

.game-card.card-selected {
  animation: card-select-bounce 500ms var(--ease-bounce) forwards;
}

@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow:
      0 16px 48px rgba(0,0,0,0.10),
      0 4px 12px rgba(0,0,0,0.06);
  }
  .game-card:hover .game-card__glow {
    opacity: 1;
  }
  .game-card:hover .game-card__icon {
    transform: scale(1.15);
  }
  .game-card:hover .game-card__illustration-wrap {
    transform: scale(1.08);
  }
}


/* ================================================================
   GAME SCREEN
   ================================================================ */

#game-screen {
  z-index: 1;
  background: #152535;
}

#canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}


/* ── Game HUD ── */

#game-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 400ms ease, visibility 400ms ease;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 100%);
}

#game-hud.visible {
  opacity: 1;
  visibility: visible;
}

/* Shared game mode: hide score/combo/timer, only show back button */
#game-hud.shared-mode #hud-score,
#game-hud.shared-mode #hud-combo,
#game-hud.shared-mode #hud-timer {
  display: none;
}

#game-hud > * {
  pointer-events: auto;
}

/* Back button */
#back-button {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  transition:
    transform 300ms var(--ease-overshoot),
    background 300ms ease;
  flex-shrink: 0;
}

#back-button:active {
  transform: scale(0.85);
  background: rgba(255,255,255,0.25);
}

#back-button svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

/* HUD mini icons */
.hud-mini-icon {
  width: 18px;
  height: 18px;
  margin-bottom: 2px;
  opacity: 0.7;
}
.hud-timer-icon {
  opacity: 0.8;
}

/* HUD common pill style */
#hud-score,
#hud-combo,
#hud-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  min-width: 100px;
}

/* HUD Score */
#hud-score {
  padding: 6px 24px 8px;
}

#hud-score-value {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  line-height: 1.1;
  transition: transform 200ms var(--ease-overshoot);
}

#hud-score-value.score-pop {
  animation: score-pop 300ms var(--ease-bounce);
}

@keyframes score-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* HUD Combo */
#hud-combo {
  padding: 6px 18px 8px;
  min-width: 80px;
  background: rgba(255,215,0,0.12);
  border-color: rgba(255,215,0,0.15);
  transition: opacity 300ms ease, transform 300ms ease;
}

#hud-combo.hud-hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

#hud-combo-value {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 28px;
  font-weight: 900;
  color: #FFD700;
  text-shadow: 0 0 16px rgba(255,215,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  line-height: 1.1;
}

/* HUD Timer */
#hud-timer {
  padding: 6px 24px 8px;
  margin-left: auto;
}

#hud-timer-value {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  line-height: 1.1;
}

#hud-timer.timer-warning #hud-timer-value {
  color: #FF5252;
  animation: timer-flash 0.5s ease-in-out infinite alternate;
}

@keyframes timer-flash {
  from { opacity: 1; }
  to   { opacity: 0.4; }
}

.hud-label {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}


/* ── Combo Popup ── */

#combo-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 64px;
  font-weight: 900;
  color: #FFD700;
  text-shadow:
    0 0 30px rgba(255,215,0,0.6),
    0 0 60px rgba(255,215,0,0.3),
    0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
  white-space: nowrap;
}

#combo-popup.combo-popup-hidden {
  opacity: 0;
  visibility: hidden;
}

#combo-popup.combo-popup-show {
  animation: combo-popup-anim 900ms var(--ease-overshoot) forwards;
}

@keyframes combo-popup-anim {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-10deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3) rotate(3deg);
  }
  60% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(0.9);
  }
}


/* ── Game Over Overlay ── */

#game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14,10,26,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 500ms ease, visibility 500ms ease;
}

#game-over-overlay.game-over-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#game-over-overlay.game-over-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.game-over-card {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(197,95,252,0.06) 0%, transparent 50%),
    linear-gradient(160deg, #ffffff 0%, #faf5ff 50%, #fff5f8 100%);
  border-radius: 32px;
  padding: 48px 64px;
  text-align: center;
  box-shadow:
    0 32px 80px rgba(0,0,0,0.25),
    0 0 0 1px rgba(255,255,255,0.1);
  min-width: 420px;
  animation: game-over-card-in 600ms var(--ease-overshoot);
  overflow: hidden;
}

/* Confetti */
.game-over-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.game-over-confetti span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
  opacity: 0;
}

/* Confetti shape variants: ribbons (wide), squares, stars */
.game-over-confetti span:nth-child(3n+1) { border-radius: 1px; } /* ribbon */
.game-over-confetti span:nth-child(3n+2) { border-radius: 50%; } /* circle */
.game-over-confetti span:nth-child(3n)   { clip-path: polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%); border-radius: 0; } /* star */

.game-over-confetti span:nth-child(1)  { left:  5%; background: #FF6B9D; animation-duration: 2.5s; animation-delay: 0.1s;  width: 10px; height: 5px; }
.game-over-confetti span:nth-child(2)  { left: 10%; background: #FFD700; animation-duration: 2.8s; animation-delay: 0.3s;  width: 6px;  height: 6px; }
.game-over-confetti span:nth-child(3)  { left: 15%; background: #6366F1; animation-duration: 2.2s; animation-delay: 0.0s;  width: 10px; height: 10px; }
.game-over-confetti span:nth-child(4)  { left: 20%; background: #38D878; animation-duration: 3.0s; animation-delay: 0.2s;  width: 10px; height: 5px; }
.game-over-confetti span:nth-child(5)  { left: 25%; background: #C55FFC; animation-duration: 2.6s; animation-delay: 0.15s; width: 7px;  height: 7px; }
.game-over-confetti span:nth-child(6)  { left: 30%; background: #FF8C42; animation-duration: 2.4s; animation-delay: 0.4s;  width: 9px;  height: 9px; }
.game-over-confetti span:nth-child(7)  { left: 35%; background: #4ECDC4; animation-duration: 2.7s; animation-delay: 0.25s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(8)  { left: 40%; background: #FF6B9D; animation-duration: 2.3s; animation-delay: 0.35s; width: 6px;  height: 6px; }
.game-over-confetti span:nth-child(9)  { left: 45%; background: #FFD700; animation-duration: 2.9s; animation-delay: 0.05s; width: 10px; height: 10px; }
.game-over-confetti span:nth-child(10) { left: 50%; background: #6366F1; animation-duration: 2.5s; animation-delay: 0.2s;  width: 10px; height: 5px; }
.game-over-confetti span:nth-child(11) { left: 55%; background: #38D878; animation-duration: 2.4s; animation-delay: 0.12s; width: 7px;  height: 7px; }
.game-over-confetti span:nth-child(12) { left: 60%; background: #C55FFC; animation-duration: 3.1s; animation-delay: 0.28s; width: 9px;  height: 9px; }
.game-over-confetti span:nth-child(13) { left: 65%; background: #FF8C42; animation-duration: 2.3s; animation-delay: 0.08s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(14) { left: 70%; background: #4ECDC4; animation-duration: 2.7s; animation-delay: 0.32s; width: 6px;  height: 6px; }
.game-over-confetti span:nth-child(15) { left: 75%; background: #FFD700; animation-duration: 2.6s; animation-delay: 0.18s; width: 10px; height: 10px; }
.game-over-confetti span:nth-child(16) { left: 80%; background: #FF6B9D; animation-duration: 2.8s; animation-delay: 0.22s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(17) { left: 85%; background: #6366F1; animation-duration: 2.2s; animation-delay: 0.38s; width: 7px;  height: 7px; }
.game-over-confetti span:nth-child(18) { left: 90%; background: #38D878; animation-duration: 3.0s; animation-delay: 0.1s;  width: 9px;  height: 9px; }
.game-over-confetti span:nth-child(19) { left: 95%; background: #C55FFC; animation-duration: 2.5s; animation-delay: 0.26s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(20) { left:  8%; background: #FF8C42; animation-duration: 2.9s; animation-delay: 0.14s; width: 6px;  height: 6px; }
.game-over-confetti span:nth-child(21) { left: 18%; background: #4ECDC4; animation-duration: 2.4s; animation-delay: 0.36s; width: 10px; height: 10px; }
.game-over-confetti span:nth-child(22) { left: 28%; background: #FFD700; animation-duration: 2.6s; animation-delay: 0.06s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(23) { left: 38%; background: #FF6B9D; animation-duration: 3.2s; animation-delay: 0.3s;  width: 7px;  height: 7px; }
.game-over-confetti span:nth-child(24) { left: 48%; background: #6366F1; animation-duration: 2.3s; animation-delay: 0.16s; width: 9px;  height: 9px; }
.game-over-confetti span:nth-child(25) { left: 58%; background: #38D878; animation-duration: 2.7s; animation-delay: 0.34s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(26) { left: 68%; background: #C55FFC; animation-duration: 2.5s; animation-delay: 0.04s; width: 6px;  height: 6px; }
.game-over-confetti span:nth-child(27) { left: 78%; background: #FF8C42; animation-duration: 3.0s; animation-delay: 0.24s; width: 10px; height: 10px; }
.game-over-confetti span:nth-child(28) { left: 88%; background: #4ECDC4; animation-duration: 2.4s; animation-delay: 0.42s; width: 10px; height: 5px; }
.game-over-confetti span:nth-child(29) { left: 12%; background: #FFD700; animation-duration: 2.8s; animation-delay: 0.2s;  width: 7px;  height: 7px; }
.game-over-confetti span:nth-child(30) { left: 52%; background: #FF6B9D; animation-duration: 2.6s; animation-delay: 0.08s; width: 9px;  height: 9px; }

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(400px) rotate(720deg);
    opacity: 0;
  }
}

@keyframes game-over-card-in {
  from {
    opacity: 0;
    transform: scale(0.75) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game-over-title {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 900;
  color: var(--color-text-primary);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

/* Rank Badge */
.game-over-rank {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
}
.game-over-rank.rank-visible {
  opacity: 1;
  transform: scale(1);
  animation: rank-bounce 600ms var(--ease-overshoot);
}
.game-over-rank__letter {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
}

/* Rank colors */
.game-over-rank[data-rank="S"] {
  background: linear-gradient(135deg, #FFD700, #FFAA00);
  box-shadow: 0 0 30px rgba(255,215,0,0.5), 0 4px 16px rgba(0,0,0,0.15);
}
.game-over-rank[data-rank="S"] .game-over-rank__letter { color: #fff; text-shadow: 0 1px 4px rgba(180,120,0,0.5); }

.game-over-rank[data-rank="A"] {
  background: linear-gradient(135deg, #C55FFC, #A66BFF);
  box-shadow: 0 0 24px rgba(197,95,252,0.4), 0 4px 16px rgba(0,0,0,0.15);
}
.game-over-rank[data-rank="A"] .game-over-rank__letter { color: #fff; text-shadow: 0 1px 4px rgba(120,50,180,0.5); }

.game-over-rank[data-rank="B"] {
  background: linear-gradient(135deg, #6366F1, #818CF8);
  box-shadow: 0 0 20px rgba(99,102,241,0.3), 0 4px 16px rgba(0,0,0,0.15);
}
.game-over-rank[data-rank="B"] .game-over-rank__letter { color: #fff; }

.game-over-rank[data-rank="C"] {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.game-over-rank[data-rank="C"] .game-over-rank__letter { color: #475569; }

@keyframes rank-bounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Star Rating */
.game-over-stars {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  opacity: 0;
}
.game-over-stars.stars-visible {
  opacity: 1;
}
.game-over-star {
  width: 32px;
  height: 32px;
  transition: transform 400ms var(--ease-overshoot);
}
.game-over-star.star-earned path {
  fill: #FFD700;
  stroke: #FFAA00;
  filter: drop-shadow(0 0 6px rgba(255,215,0,0.5));
}
.game-over-star.star-earned {
  animation: star-pop 500ms var(--ease-overshoot);
}
@keyframes star-pop {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.game-over-score-wrap {
  position: relative;
  z-index: 1;
  margin-bottom: 28px;
}

.game-over-score-label {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.game-over-score {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: clamp(56px, 8vw, 80px);
  font-weight: 900;
  background: linear-gradient(135deg, #FF6B9D 0%, #C55FFC 40%, #6366F1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  animation: score-count-up 800ms var(--ease-out-expo);
}

@keyframes score-count-up {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.game-over-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 16px;
  justify-content: center;
}

.game-over-btn {
  font-family: 'Zen Maru Gothic', var(--font-family-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  border: none;
  border-radius: 9999px;
  padding: 14px 36px;
  cursor: none;
  transition:
    transform 300ms var(--ease-overshoot),
    box-shadow 300ms ease;
  min-width: 180px;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.game-over-btn:active {
  transform: scale(0.92);
}

.game-over-btn--replay {
  background: linear-gradient(135deg, #6366F1 0%, #C55FFC 100%);
  color: #fff;
  box-shadow: 0 6px 28px rgba(99,102,241,0.35);
}

.game-over-btn--replay:active {
  box-shadow: 0 2px 12px rgba(99,102,241,0.25);
}

.game-over-btn--replay svg {
  flex-shrink: 0;
}

.game-over-btn--menu {
  background: rgba(0,0,0,0.05);
  color: var(--color-text-primary);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
}

.game-over-btn--menu:active {
  background: rgba(0,0,0,0.1);
}

@media (hover: hover) {
  .game-over-btn:hover {
    transform: translateY(-3px);
  }
  .game-over-btn--replay:hover {
    box-shadow: 0 10px 36px rgba(99,102,241,0.45);
  }
}


/* ================================================================
   IDLE INDICATOR
   ================================================================ */

#idle-indicator {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-success);
  opacity: 0;
  transition: opacity 700ms;
}

#idle-indicator.warning {
  opacity: 0.6;
  background: var(--color-warning);
  animation: idle-blink 1s ease-in-out infinite;
}

@keyframes idle-blink {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.8; }
}


/* ================================================================
   SCREEN TRANSITIONS
   ================================================================ */

.fade-out {
  animation: fade-out 700ms var(--ease-out-expo) forwards;
}
.fade-in {
  animation: fade-in 700ms var(--ease-out-expo) forwards;
}


/* ================================================================
   RESPONSIVE
   ================================================================ */

/* 4K displays */
@media (min-width: 2560px) {
  .game-card {
    border-radius: 36px;
  }
  .game-card__scene {
    min-height: 220px;
  }
  .game-card__icon {
    font-size: 96px;
  }
  .game-card__illustration-wrap svg {
    max-width: 260px;
    max-height: 200px;
  }
  .game-card__info {
    padding: 20px 28px 28px;
    gap: 8px;
  }
  .game-card__name {
    font-size: 30px;
  }
  .game-card__desc {
    font-size: 16px;
  }
  .game-card-container {
    gap: 40px;
    max-width: 1600px;
  }
  .game-select-back-btn {
    width: 68px;
    height: 68px;
  }
  .game-select-back-btn svg {
    width: 32px;
    height: 32px;
  }
  .age-card {
    border-radius: 36px;
  }
  .age-card__scene {
    min-height: 220px;
  }
  .age-card__illustration {
    max-height: 200px;
  }
  .age-card__info {
    padding: 20px 28px 28px;
    gap: 8px;
  }
  .age-card__name {
    font-size: 30px;
  }
  .age-card__desc {
    font-size: 16px;
  }
  .age-card__age-badge {
    font-size: 14px;
    padding: 4px 18px;
  }
  .age-card-container {
    gap: 40px;
    max-width: 1900px;
  }
  #back-button {
    width: 68px;
    height: 68px;
  }
  #back-button svg {
    width: 32px;
    height: 32px;
  }
  #hud-score-value,
  #hud-timer-value {
    font-size: 44px;
  }
  .game-over-card {
    padding: 64px 96px;
    min-width: 560px;
    border-radius: 40px;
  }
}

/* HD / smaller monitors */
@media (max-width: 1440px) {
  #game-select-screen {
    padding: 32px 36px;
    gap: 20px;
  }
  .game-card-container {
    gap: 20px;
  }
  .game-card {
    border-radius: 22px;
  }
  .game-card__scene {
    min-height: 130px;
  }
  .game-card__info {
    padding: 12px 16px 16px;
  }
  .game-card__name {
    font-size: 18px;
  }
  .game-card__desc {
    font-size: 12px;
  }
  #age-select-screen {
    padding: 32px 36px;
    gap: 20px;
  }
  .age-card-container {
    gap: 20px;
  }
  .age-card {
    border-radius: 22px;
  }
  .age-card__scene {
    min-height: 130px;
  }
  .age-card__illustration {
    max-height: 110px;
  }
  .age-card__info {
    padding: 12px 16px 16px;
  }
  .age-card__name {
    font-size: 18px;
  }
  .age-card__desc {
    font-size: 12px;
  }
  .attract-logo {
    width: 120px;
    height: 120px;
  }
}

/* Portrait orientation */
@media (orientation: portrait) {
  .game-card-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    max-width: 600px;
  }
  .game-card__scene {
    min-height: 100px;
  }

  .age-card-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .age-card__scene {
    min-height: 120px;
  }

  #game-hud {
    padding: 12px 16px;
    gap: 12px;
  }

  #hud-score-value,
  #hud-timer-value {
    font-size: 26px;
  }

  .game-over-card {
    min-width: 320px;
    padding: 36px 40px;
  }

  .game-over-buttons {
    flex-direction: column;
    gap: 12px;
  }

  .attract-logo {
    width: 110px;
    height: 110px;
  }
}


/* ================================================================
   THREE.JS ACTIVE — Override CSS-only effects
   ================================================================ */

/* Hide CSS orbs & particles when Three.js canvas is active (fireflies stay visible) */
#app.has-threejs .attract-orb,
#app.has-threejs .attract-particles {
  display: none;
}

/* Transparent attract background to show WebGL scene */
#app.has-threejs #attract-screen {
  background: transparent;
}

/* Semi-transparent age-select / game-select to let WebGL bleed through subtly */
#app.has-threejs #game-select-screen {
  background:
    linear-gradient(170deg,
      rgba(250,248,245,0.93) 0%,
      rgba(245,240,255,0.93) 35%,
      rgba(255,240,245,0.93) 65%,
      rgba(240,248,255,0.93) 100%);
}

#app.has-threejs #age-select-screen {
  background:
    linear-gradient(170deg,
      rgba(250,248,245,0.93) 0%,
      rgba(245,240,255,0.93) 35%,
      rgba(255,240,245,0.93) 65%,
      rgba(240,248,255,0.93) 100%);
}

/* Hide age-select CSS ambient orbs when Three.js is rendering */
#app.has-threejs .age-bg {
  display: none;
}
