/* ==========================================================================
   Find Anjaneya's Family - Game Stylesheet
   Theme: Disney-Pixar 3D Warm Golden Forest Storybook
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Curated Color Palette (from Asset Manifest Section 2.3) */
  --color-gold: #F2B84B;
  --color-amber: #E8A92B;
  --color-honey-brown: #7A4A1E;
  --color-dark-brown: #4A2808;
  --color-cream: #FFF3D6;
  --color-cream-soft: rgba(255, 243, 214, 0.85);
  --color-royal-purple: #6B3FA0;
  --color-kiki-blue: #1F3F8F;
  --color-soft-pink: #F4A7B9;
  --color-light-pink: #FFD2DC;
  --color-forest-green: #4F7A3A;

  /* Typography */
  --font-primary: 'Fredoka', 'Comic Sans MS', cursive, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;

  /* Card Geometry & Ratios (Frame: 1126 x 1425 px) */
  --card-aspect-ratio: 1126 / 1425;
  --card-radius: 20px;
  --card-glow-color: rgba(242, 184, 75, 0.95);
  --card-glow-spread: rgba(232, 169, 43, 0.65);

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-normal: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-flip: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   2. Reset & Global Layout
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background-color: #2a1504;
  font-family: var(--font-primary);
  color: var(--color-dark-brown);
}

/* --------------------------------------------------------------------------
   3. Scene System (3 Scenes: Start, Gameplay, Win)
   -------------------------------------------------------------------------- */
.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  z-index: 1;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

/* Scene Backgrounds */
.scene-start {
  background-image: url('asset/bg/bg-start-clean.avif');
}

.scene-gameplay {
  background-image: url('asset/bg/bg-play-clean.avif');
}

.scene-win {
  background-image: url('asset/bg/bg-win-clean.avif');
}

/* Scene Content Wrapper */
.scene-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1440px;
  max-height: 900px;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 32px);
  z-index: 2;
}

/* --------------------------------------------------------------------------
   3.1 PERSISTENT BRAND LOGO: NEO LOGO (Top Left Corner of All Scenes)
   -------------------------------------------------------------------------- */
.neo-logo-container {
  position: fixed;
  top: clamp(10px, 1.8vh, 20px);
  left: clamp(14px, 2.5vw, 32px);
  width: clamp(52px, 6vw, 78px);
  height: clamp(52px, 6vw, 78px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: transform var(--transition-fast, 0.2s ease);
}

.neo-logo-container:hover {
  transform: scale(1.06);
}

.neo-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

/* --------------------------------------------------------------------------
   4. SCENE 1: START SCENE
   -------------------------------------------------------------------------- */
.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

/* Start Main Content: Title & Button centered */
.start-main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3.5vh, 40px);
  width: 100%;
  max-width: 650px;
  margin: auto;
  /* On desktop landscape, center slightly shifted towards the golden opening */
  transform: translateX(5%);
}

@media (max-width: 768px) {
  .start-main-content {
    transform: none;
  }
}

.title-logo-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoGlowFloat 4s ease-in-out infinite alternate;
}

.title-logo-img {
  width: 100%;
  height: auto;
  max-height: 42vh;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 25px rgba(242, 184, 75, 0.4));
}

/* Fallback Title in case title-logo image fails */
.title-logo-fallback {
  text-align: center;
  background: radial-gradient(circle, rgba(255,243,214,0.9) 0%, rgba(242,184,75,0.4) 70%, transparent 100%);
  padding: 24px 36px;
  border-radius: 30px;
}

.fallback-title-find {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  color: var(--color-honey-brown);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.fallback-title-main {
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  font-weight: 700;
  background: linear-gradient(180deg, #FFF9E6 0%, #F2B84B 50%, #C97D18 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 10px rgba(74, 40, 8, 0.8));
  line-height: 1.1;
}

.fallback-title-family {
  font-size: clamp(2rem, 4vw, 3.2rem);
  color: var(--color-amber);
  text-shadow: 0 3px 6px rgba(0,0,0,0.5);
}

/* Start Button */
.start-btn-container {
  display: flex;
  justify-content: center;
}

.btn-start {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  width: clamp(200px, 24vw, 320px);
  min-height: 54px;
  transition: transform var(--transition-fast), filter var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulseButton 2.2s infinite;
}

.btn-start:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 10px 25px rgba(242, 184, 75, 0.8));
}

.btn-start:active {
  transform: scale(0.95);
}

.btn-start img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4));
}

.btn-start-fallback-text {
  display: inline-block;
  background: linear-gradient(180deg, #F2B84B 0%, #E8A92B 60%, #BA7714 100%);
  color: #FFF9E6;
  font-family: var(--font-primary);
  font-size: 2rem;
  font-weight: 700;
  padding: 16px 48px;
  border-radius: 40px;
  border: 4px solid #FFF3D6;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.6);
  text-shadow: 0 2px 4px rgba(74, 40, 8, 0.8);
}

/* --------------------------------------------------------------------------
   5. SCENE 2: GAMEPLAY SCENE (Narrator on Left, Board on Right)
   -------------------------------------------------------------------------- */
.gameplay-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  max-width: 1320px;
  margin: auto;
  gap: clamp(16px, 3.5vw, 48px);
  padding: clamp(8px, 1.5vh, 20px) clamp(12px, 2.5vw, 28px);
}

/* Left Section: Kiki Narrator & Message Bar */
.gameplay-narrator-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  align-self: flex-end;
  width: 230px;
  max-width: 230px;
  min-width: 0;
  min-height: 0;
  flex-shrink: 0;
  gap: 12px;
  margin-bottom: 8px;
  z-index: 10;
}

.kiki-narrator-holder {
  position: relative;
  width: 185px;
  height: 256px;
  max-width: 185px;
  max-height: 256px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}

.kiki-narrator-img,
#kiki-gameplay-avatar {
  width: 100%;
  height: 100%;
  max-width: 185px;
  max-height: 256px;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  transition: transform var(--transition-fast);
}

.kiki-narrator-img.cheer {
  animation: kikiJumpCheer 0.6s ease-in-out infinite alternate;
}

.kiki-narrator-img.encourage {
  animation: kikiNod 0.5s ease-in-out 2;
}

/* Glowing Message Bar (UI-03) */
.message-bar-container {
  position: relative;
  width: 100%;
  max-width: 230px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 26px;
  background: rgba(255, 243, 214, 0.97);
  border: 3px solid var(--color-amber);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 18px rgba(242, 184, 75, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.kiki-message-text {
  position: relative;
  font-family: var(--font-primary);
  font-size: clamp(1.08rem, 1.35vw, 1.25rem);
  font-weight: 800;
  color: #3b1c04;
  text-align: center;
  z-index: 2;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
  line-height: 1.3;
}

/* Right Section: 8 Cards Board (Pushed downward to prevent overlap with top HUD) */
.gameplay-board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 900px;
  margin-top: clamp(32px, 5vh, 52px);
}

/* Top Progress Stars HUD positioned at the far right of the screen */
.gameplay-header {
  position: absolute;
  top: clamp(10px, 1.8vh, 18px);
  right: clamp(16px, 2.8vw, 36px);
  z-index: 25;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.stars-progress-bar {
  display: flex;
  gap: clamp(10px, 2vw, 20px);
  background: rgba(42, 21, 4, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 18px;
  border-radius: 30px;
  border: 2px solid rgba(242, 184, 75, 0.6);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.star-slot {
  width: clamp(32px, 3.8vw, 46px);
  height: clamp(32px, 3.8vw, 46px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.star-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star-slot.filled .star-img {
  animation: starPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  filter: drop-shadow(0 0 10px rgba(242, 184, 75, 0.9));
}

/* Center Cards Board Wrapper */
.cards-board-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 8 Cards Grid: 4 columns x 2 rows on Desktop/Landscape */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(12px, 1.8vw, 22px);
  width: 100%;
  max-width: 900px;
  justify-items: center;
  align-items: center;
}

/* Individual Card (Aspect Ratio 1126:1425) */
.card {
  position: relative;
  width: 100%;
  max-width: 202px;
  aspect-ratio: var(--card-aspect-ratio);
  perspective: 1000px;
  cursor: pointer;
  background: transparent;
  border: none;
  outline: none;
  min-height: 44px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--transition-flip);
  border-radius: var(--card-radius);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}

.card:hover .card-inner {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card:hover.flipped .card-inner,
.card:hover.matched .card-inner {
  transform: rotateY(180deg) translateY(-4px);
}

/* Card Faces (Front & Back) */
.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--card-radius);
  overflow: hidden;
}

/* Card Back (Face-down CARD-01) */
.card-back {
  background-color: #532d10;
  z-index: 2;
  transform: rotateY(0deg);
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Card Front (Face-up CARD-02 Frame + Character/Quality Picture Underneath) */
.card-front {
  transform: rotateY(180deg);
  background-color: transparent;
  z-index: 1;
}

/* Picture Window Container under the frame: 
   Sized precisely to fit the transparent window of CARD-02 */
.card-picture-container {
  position: absolute;
  top: 4.8%;
  left: 9.8%;
  width: 80.4%;
  height: 59.5%;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle, #ffeec7 0%, #e0a34b 100%);
  z-index: 1;
}

.card-picture-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.05);
  display: block;
}

/* Shared Card Front Frame (CARD-02) */
.card-front-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  object-fit: contain;
}

/* HTML Name Banner Text in Card Banner Window: single-line centered in parchment */
.card-name-label {
  position: absolute;
  top: 71.0%;
  left: 9%;
  width: 82%;
  height: 9.2%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: clamp(0.72rem, 1.22vw, 1.04rem);
  white-space: nowrap;
  letter-spacing: -0.1px;
  color: #482305;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.95);
  line-height: 1;
  padding: 0 2px;
  pointer-events: none;
  z-index: 3;
}

/* Matched Card Golden Glow Effect */
.card.matched .card-inner {
  box-shadow: 0 0 20px var(--card-glow-color), 0 0 40px var(--card-glow-spread);
  animation: matchPulse 1.8s infinite alternate ease-in-out;
}

/* Sparkle & Petal Burst Match Effect */
.match-burst-container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 30;
}

/* Central Golden Bloom Halo */
.burst-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle, rgba(255,255,255,0.98) 0%, rgba(255,238,170,0.88) 28%, rgba(242,184,75,0.5) 60%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
  animation: burstGlowAnim 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Radiant Golden 4-Point Sparkle Stars */
.burst-sparkle {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  filter: drop-shadow(0 0 6px #F2B84B) drop-shadow(0 0 12px #E8A92B);
  opacity: 0;
  animation: burstSparkleAnim 1.05s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
  will-change: transform, opacity;
}

/* Fluttering Pink Lotus/Flower Petals */
.burst-petal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 25px;
  background: linear-gradient(135deg, #FFE8F0 0%, #F4A7B9 45%, #E7728B 100%);
  border-radius: 50% 0 50% 50%;
  box-shadow: 0 0 10px rgba(244, 167, 185, 0.85), 0 3px 8px rgba(186, 75, 100, 0.45);
  pointer-events: none;
  opacity: 0;
  animation: burstPetalAnim 1.2s cubic-bezier(0.12, 0.82, 0.32, 1) forwards;
  will-change: transform, opacity;
}


/* --------------------------------------------------------------------------
   6. SCENE 3: WIN SCENE
   -------------------------------------------------------------------------- */
.win-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(14px, 3vh, 32px);
  padding-bottom: clamp(10px, 2vh, 20px);
  gap: clamp(8px, 1.5vh, 18px);
  height: 100%;
  box-sizing: border-box;
  z-index: 10;
}

/* UI-06: Ornate Win Message Panel (Top Centre - Balanced vertical & horizontal ratio) */
.win-panel-container {
  position: relative;
  width: clamp(380px, 64vw, 800px);
  aspect-ratio: 1520 / 780;
  max-height: 42vh;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: panelFloat 3.5s ease-in-out infinite alternate;
  flex-shrink: 0;
}

.win-panel-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.45));
}

.win-panel-content {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 78%;
  height: 64%;
  padding: 0 14px;
  box-sizing: border-box;
  gap: clamp(2px, 0.6vh, 6px);
}

/* Kiki Celebrating Pose (KIKI-05) - Placed directly below the Win Banner */
.kiki-win-container {
  width: clamp(170px, 23vw, 280px);
  height: clamp(170px, 44vh, 320px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: kikiWinDance 1.6s ease-in-out infinite alternate;
}

.kiki-win-img {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.4)) drop-shadow(0 0 35px rgba(242, 184, 75, 0.6));
}

.win-heading {
  font-family: 'Pacifico', 'Lobster', 'Kalam', cursive, sans-serif;
  font-size: clamp(2.2rem, 3.9vw, 3.4rem);
  font-weight: 400;
  color: #C62828;
  background: linear-gradient(180deg, #E53935 0%, #B71C1C 60%, #880E4F 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  transform: scaleX(1.18);
  transform-origin: center;
  letter-spacing: 1.2px;
  line-height: 1.2;
  filter: drop-shadow(0 2px 0 rgba(255, 235, 180, 0.9)) drop-shadow(0 4px 10px rgba(183, 28, 28, 0.3));
  margin: 0;
}

.win-line1 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: clamp(1rem, 1.65vw, 1.35rem);
  font-weight: 700;
  color: #4A1E04;
  line-height: 1.35;
  letter-spacing: 0.6px;
  display: inline-block;
  transform: scaleX(1.06);
  transform-origin: center;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
  text-shadow: 0 1px 1px rgba(255, 235, 180, 0.7);
  margin: 0;
}

/* Fallback Win Panel Styling if image fails */
.win-panel-fallback {
  background: radial-gradient(circle, #FFF8E7 0%, #FBE5B5 75%, #F2B84B 100%);
  border: 6px solid #E8A92B;
  border-radius: 36px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 35px rgba(242, 184, 75, 0.7);
}

/* --------------------------------------------------------------------------
   7. WIN EFFECTS: Sparkling Golden Dust & Drifting Pink Petals (Pure Code)
   -------------------------------------------------------------------------- */
.win-effects-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

/* Golden Dust Particle */
.gold-dust {
  position: absolute;
  bottom: -30px;
  left: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #FFFFFF 0%, #FFF3D6 40%, #F2B84B 100%);
  box-shadow: 0 0 8px #F2B84B, 0 0 16px #E8A92B;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  animation: floatUpDust linear infinite;
  animation-fill-mode: both;
}

/* Pink Petal Particle */
.pink-petal {
  position: absolute;
  top: -40px;
  left: 0;
  width: 16px;
  height: 22px;
  background: linear-gradient(135deg, #FFD2DC 0%, #F4A7B9 60%, #E78BA0 100%);
  border-radius: 50% 0 50% 50%;
  box-shadow: 0 2px 6px rgba(186, 75, 100, 0.25);
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  animation: driftPetal linear infinite;
  animation-fill-mode: both;
}

/* --------------------------------------------------------------------------
   8. MISSING ASSET & PLACEHOLDER SYSTEM
   -------------------------------------------------------------------------- */
.img-placeholder {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7A4A1E 0%, #4A2808 100%);
  border: 2px dashed #F2B84B;
  border-radius: 12px;
  color: #FFF3D6;
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 8px;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.img-placeholder .placeholder-tag {
  color: #F2B84B;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   9. KEYFRAME ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes branchSway {
  0% { transform: rotate(-2deg); }
  100% { transform: rotate(2deg); }
}

@keyframes bubbleFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

@keyframes logoGlowFloat {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35)) drop-shadow(0 0 20px rgba(242, 184, 75, 0.3)); }
  100% { transform: translateY(-8px) scale(1.02); filter: drop-shadow(0 14px 28px rgba(0,0,0,0.4)) drop-shadow(0 0 35px rgba(242, 184, 75, 0.6)); }
}

@keyframes pulseButton {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes matchPulse {
  0% {
    box-shadow: 0 0 15px rgba(242, 184, 75, 0.8), 0 0 30px rgba(232, 169, 43, 0.5);
  }
  100% {
    box-shadow: 0 0 30px rgba(242, 184, 75, 1), 0 0 60px rgba(232, 169, 43, 0.85);
  }
}

@keyframes starPop {
  0% { transform: scale(0.6) rotate(-20deg); }
  50% { transform: scale(1.35) rotate(15deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes burstGlowAnim {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.55);
  }
}

@keyframes burstSparkleAnim {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 0) scale(0.2) rotate(0deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(calc(var(--tx) * 0.45), calc(var(--ty) * 0.45)) scale(1.35) rotate(60deg);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot));
  }
}

@keyframes burstPetalAnim {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 0) scale(0.2) rotate(0deg);
  }
  18% {
    opacity: 1;
  }
  75% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(var(--scale)) rotate(var(--rot));
  }
}

@keyframes kikiJumpCheer {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-14px) scale(1.08); }
}

@keyframes kikiNod {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-8deg); }
}

@keyframes kikiWinDance {
  0% { transform: translateY(0) scale(1) rotate(-3deg); }
  100% { transform: translateY(-18px) scale(1.05) rotate(3deg); }
}

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

/* Particle Keyframes */
@keyframes floatUpDust {
  0% {
    transform: translateY(0) translateX(0) scale(0.6);
    opacity: 0;
  }
  15% {
    opacity: 0.9;
  }
  85% {
    opacity: 0.9;
  }
  100% {
    transform: translateY(-115vh) translateX(30px) scale(1.1);
    opacity: 0;
  }
}

@keyframes driftPetal {
  0% {
    transform: translateY(0) translateX(0) scale(var(--scale, 1)) rotate(0deg);
    opacity: 0;
  }
  6% {
    opacity: 0.95;
  }
  50% {
    transform: translateY(55vh) translateX(var(--drift, 40px)) scale(var(--scale, 1)) rotate(180deg);
  }
  90% {
    opacity: 0.95;
  }
  100% {
    transform: translateY(115vh) translateX(calc(var(--drift, 40px) * -0.5)) scale(var(--scale, 1)) rotate(360deg);
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   10. RESPONSIVE ADAPTATION (Desktop, Tablets, Mobile Portrait/Landscape)
   -------------------------------------------------------------------------- */

/* Tablet & Smaller Desktops (<= 1024px) */
@media (max-width: 1024px) {
  .gameplay-container {
    gap: 20px;
    padding: 12px;
  }

  .gameplay-narrator-section {
    width: 220px;
  }

  .kiki-narrator-holder {
    height: 240px;
  }

  .cards-grid {
    max-width: 640px;
    gap: 12px;
  }

  .card {
    max-width: 145px;
  }
}

/* Mobile Portrait Mode (<= 768px or orientation: portrait) */
@media (max-width: 768px), (orientation: portrait) and (max-width: 900px) {
  .scene-container {
    padding: 10px 12px;
  }

  /* Neo Logo Mobile */
  .neo-logo-container {
    top: clamp(8px, 1.5vh, 14px);
    left: clamp(8px, 2vw, 16px);
    width: clamp(38px, 8.5vw, 50px);
    height: clamp(38px, 8.5vw, 50px);
  }

  /* Start Screen Mobile */
  .start-container {
    justify-content: center;
  }

  .start-main-content {
    transform: none;
    gap: 24px;
    max-width: 90%;
  }

  .btn-start {
    width: clamp(180px, 50vw, 260px);
    min-height: 48px;
  }

  /* Gameplay Container on Mobile Portrait: Board on Top, Narrator Bar at Bottom */
  .gameplay-container {
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .gameplay-board-section {
    order: 1;
    width: 100%;
    gap: 8px;
  }

  /* 2 columns x 4 rows on Mobile Portrait */
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: clamp(8px, 2.2vw, 14px);
    max-width: 350px;
    width: 100%;
    margin: 0 auto;
  }

  .card {
    max-width: 160px;
  }

  .card-name-label {
    font-size: clamp(0.78rem, 3.4vw, 1.05rem);
  }

  /* Narrator Section on Mobile Portrait: Compact row at bottom */
  .gameplay-narrator-section {
    order: 2;
    flex-direction: row;
    width: 100%;
    max-width: 420px;
    gap: 10px;
  }

  .kiki-narrator-holder {
    width: 78px;
    height: 78px;
    flex-shrink: 0;
  }

  .message-bar-container {
    min-height: 54px;
    padding: 10px 18px;
    border-radius: 26px;
  }

  .kiki-message-text {
    font-size: 1.12rem;
    font-weight: 800;
  }

  /* Win Screen Mobile */
  .win-container {
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 12px;
    gap: 10px;
  }

  .win-panel-container {
    width: 96%;
    max-width: 480px;
    aspect-ratio: 1520 / 780;
    max-height: 35vh;
  }

  .win-panel-content {
    width: 80%;
    height: 66%;
    padding: 0 10px;
    gap: 3px;
  }

  .win-heading {
    font-size: clamp(1.5rem, 4.6vw, 2rem);
    margin: 0;
    transform: scaleX(1.15);
  }

  .win-line1 {
    font-size: clamp(0.85rem, 2.7vw, 1.05rem);
    line-height: 1.25;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    transform: scaleX(1.04);
    margin: 0;
  }

  .kiki-win-container {
    height: 48vh;
    max-height: 290px;
    width: clamp(150px, 48vw, 240px);
  }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .win-effects-container {
    display: none !important;
  }
}
