/* ==========================================================================
   PETUALANGAN SI KECIL - MAIN STYLES
   Gaya visual 2D kartun ramah anak TK (4-6 tahun)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700;800&family=Nunito:wght@700;800;900&display=swap');

:root {
  /* Palet Warna Ramah Anak */
  --sky-blue: #64C8FF;
  --sky-light: #BFE8FF;
  --sun-yellow: #FFD214;
  --sun-orange: #FFA41C;
  --grass-green: #5CD85A;
  --grass-dark: #38A836;
  --candy-pink: #FF6B9D;
  --candy-purple: #9D65FF;
  --candy-red: #FF4757;
  --cloud-white: #FFFFFF;
  --soft-cream: #FFF9E6;
  --wood-brown: #9E6B38;
  --dark-text: #2C3E50;
  --shadow-color: rgba(0, 0, 0, 0.15);
  
  /* Dimensi & Sudut */
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 36px;
  --radius-full: 999px;
  
  /* Font */
  --font-fun: 'Fredoka', 'Nunito', 'Comic Sans MS', sans-serif;
  --font-round: 'Nunito', 'Fredoka', sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-fun);
  color: var(--dark-text);
  background-color: var(--sky-blue);
}

/* ==========================================================================
   APP CONTAINER & BACKGROUND SCENERY
   ========================================================================== */

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #74d2ff 0%, #b8e9ff 45%, #daf3ff 60%, #a2ea9c 60.1%, #57cf55 75%, #3cb43a 100%);
}

/* Pemandangan Fantasi Animasi */
.scenery-background {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* Matahari Tersenyum */
.animated-sun {
  position: absolute;
  top: 25px;
  right: 5%;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #fff375 20%, #ffd214 70%, #ffa41c 100%);
  border-radius: 50%;
  box-shadow: 0 0 40px #ffd214, inset 0 0 15px rgba(255, 255, 255, 0.8);
  animation: sunGlow 4s ease-in-out infinite alternate;
}

.sun-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sun-eye {
  width: 8px;
  height: 12px;
  background: #5a3800;
  border-radius: 50%;
  margin: 0 8px;
  animation: eyeBlink 3.5s infinite;
}

.sun-smile {
  position: absolute;
  bottom: 22px;
  width: 26px;
  height: 13px;
  border-bottom: 4px solid #5a3800;
  border-radius: 0 0 20px 20px;
}

/* Awan Bergerak Perlahan */
.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 100px;
  filter: drop-shadow(0 8px 12px rgba(100, 180, 240, 0.3));
  opacity: 0.95;
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
}

.cloud-1 {
  width: 170px;
  height: 55px;
  top: 12%;
  left: -200px;
  animation: floatCloud 32s linear infinite;
}
.cloud-1::before { width: 75px; height: 75px; top: -35px; left: 25px; }
.cloud-1::after { width: 90px; height: 90px; top: -45px; right: 25px; }

.cloud-2 {
  width: 220px;
  height: 65px;
  top: 25%;
  left: -250px;
  animation: floatCloud 45s linear infinite 12s;
}
.cloud-2::before { width: 90px; height: 90px; top: -45px; left: 35px; }
.cloud-2::after { width: 110px; height: 110px; top: -55px; right: 35px; }

.cloud-3 {
  width: 140px;
  height: 48px;
  top: 8%;
  left: -180px;
  animation: floatCloud 26s linear infinite 5s;
}
.cloud-3::before { width: 60px; height: 60px; top: -28px; left: 20px; }
.cloud-3::after { width: 70px; height: 70px; top: -35px; right: 20px; }

/* Burung Terbang */
.flying-bird {
  position: absolute;
  top: 18%;
  left: -60px;
  animation: birdFly 20s linear infinite 3s;
}

.bird-wing {
  width: 24px;
  height: 12px;
  border-top: 3px solid #2a527a;
  border-radius: 50% 50% 0 0;
  display: inline-block;
  transform-origin: center;
  animation: flapWing 0.6s ease-in-out infinite alternate;
}

/* Bukit & Daun Melambai */
.hills {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40%;
  pointer-events: none;
}

.hill-back {
  position: absolute;
  bottom: 0;
  left: -10%;
  width: 120%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 100%, #5fd35c 40%, #46bf43 85%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.hill-front {
  position: absolute;
  bottom: -5%;
  right: -10%;
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse at 50% 100%, #6ee26b 40%, #53cc50 85%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.swaying-tree {
  position: absolute;
  bottom: 40px;
  left: 30px;
  transform-origin: bottom center;
  animation: treeSway 4s ease-in-out infinite alternate;
}

.tree-trunk {
  width: 16px;
  height: 50px;
  background: #8b5a2b;
  border-radius: 8px;
  margin: 0 auto;
}

.tree-top {
  width: 70px;
  height: 70px;
  background: #2ebd36;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin-bottom: -15px;
  position: relative;
}

.tree-top::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 12px;
  width: 45px;
  height: 45px;
  background: #39d343;
  border-radius: 50%;
}

/* ==========================================================================
   TOP APP BAR & HUD (Koin, Bintang, Navigasi)
   ========================================================================== */

.top-bar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  width: 100%;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 16px 6px 10px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  border: 3px solid #ffde59;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dark-text);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hud-pill.coins {
  border-color: #ffd214;
}

.hud-pill.stars {
  border-color: #ff9f1a;
}

.pill-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  animation: pulseScale 2s infinite ease-in-out;
}

/* ==========================================================================
   BUTTONS (Bouncy, Ramah Anak, Mudah Ditekan)
   ========================================================================== */

.btn-game {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-fun);
  font-weight: 800;
  font-size: 1.35rem;
  color: #ffffff;
  border: none;
  cursor: pointer;
  outline: none;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
  min-height: 56px;
  touch-action: manipulation;
}

.btn-game:active {
  transform: translateY(4px) scale(0.96) !important;
}

/* Varian Warna Tombol */
.btn-primary {
  background: linear-gradient(180deg, #ffc837 0%, #ff8008 100%);
  box-shadow: 0 8px 0 #c25e00, 0 12px 18px rgba(0, 0, 0, 0.2);
}
.btn-primary:active {
  box-shadow: 0 3px 0 #c25e00, 0 6px 10px rgba(0, 0, 0, 0.15);
}

.btn-green {
  background: linear-gradient(180deg, #6ee26b 0%, #2ebd36 100%);
  box-shadow: 0 8px 0 #1b8523, 0 12px 18px rgba(0, 0, 0, 0.2);
}
.btn-green:active {
  box-shadow: 0 3px 0 #1b8523, 0 6px 10px rgba(0, 0, 0, 0.15);
}

.btn-blue {
  background: linear-gradient(180deg, #56ccf2 0%, #2f80ed 100%);
  box-shadow: 0 8px 0 #1c54a3, 0 12px 18px rgba(0, 0, 0, 0.2);
}
.btn-blue:active {
  box-shadow: 0 3px 0 #1c54a3, 0 6px 10px rgba(0, 0, 0, 0.15);
}

.btn-pink {
  background: linear-gradient(180deg, #ff758c 0%, #ff4b6b 100%);
  box-shadow: 0 8px 0 #b31b37, 0 12px 18px rgba(0, 0, 0, 0.2);
}
.btn-pink:active {
  box-shadow: 0 3px 0 #b31b37, 0 6px 10px rgba(0, 0, 0, 0.15);
}

.btn-purple {
  background: linear-gradient(180deg, #b06ab3 0%, #7b2cbf 100%);
  box-shadow: 0 8px 0 #521882, 0 12px 18px rgba(0, 0, 0, 0.2);
}
.btn-purple:active {
  box-shadow: 0 3px 0 #521882, 0 6px 10px rgba(0, 0, 0, 0.15);
}

/* Tombol Ikon Bundar */
.btn-circle {
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
}

.btn-icon-pulse {
  animation: bounceSmall 2s infinite ease-in-out;
}

/* ==========================================================================
   SCREEN MANAGEMENT & TRANSITIONS
   ========================================================================== */

.screen-container {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2);
  pointer-events: none;
}

.screen.active {
  display: flex;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* ==========================================================================
   SPLASH SCREEN
   ========================================================================== */

#screen-splash {
  background: radial-gradient(circle, #ffeaa7 0%, #74d2ff 80%);
  text-align: center;
  z-index: 500;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.game-logo-large {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 900;
  color: #ff4757;
  text-shadow: 
    3px 3px 0 #ffd214,
    -3px -3px 0 #ffd214,
    3px -3px 0 #ffd214,
    -3px 3px 0 #ffd214,
    0 8px 16px rgba(0,0,0,0.25);
  letter-spacing: 2px;
  animation: logoBounce 2s infinite ease-in-out;
}

.game-sublogo {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700;
  color: #2f80ed;
  background: #ffffff;
  padding: 6px 24px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.splash-loader {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.loader-dot {
  width: 18px;
  height: 18px;
  background: #ff4757;
  border-radius: 50%;
  animation: loaderBounce 1.2s infinite ease-in-out;
}
.loader-dot:nth-child(2) { background: #ffd214; animation-delay: 0.2s; }
.loader-dot:nth-child(3) { background: #2ebd36; animation-delay: 0.4s; }

/* ==========================================================================
   HOME SCREEN
   ========================================================================== */

#screen-home .home-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 900px;
  height: 100%;
  padding-bottom: 20px;
}

.home-header {
  text-align: center;
  margin-top: 5px;
}

.home-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  color: #ff3366;
  text-shadow: 
    3px 3px 0 #ffe066,
    -3px -3px 0 #ffe066,
    3px -3px 0 #ffe066,
    -3px 3px 0 #ffe066,
    0 6px 12px rgba(0,0,0,0.18);
}

.home-momo-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
  cursor: pointer;
}

.speech-bubble-momo {
  position: absolute;
  top: -20px;
  right: -50px;
  background: #ffffff;
  color: var(--dark-text);
  font-size: 1.1rem;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 20px;
  border: 3px solid #ffd214;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  animation: floatSmall 2.5s infinite ease-in-out;
  white-space: nowrap;
}

.speech-bubble-momo::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: #ffffff transparent;
}

.home-menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 440px;
}

.home-menu-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.btn-large-play {
  width: 100%;
  font-size: 1.6rem;
  padding: 18px 36px;
  border-radius: var(--radius-full);
  animation: playPulse 2.2s infinite ease-in-out;
}

/* ==========================================================================
   GAME MENU / PILIH PERMAINAN
   ========================================================================== */

.menu-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1100px;
  height: 100%;
  overflow-y: auto;
  padding: 10px 10px 30px;
}

.menu-header-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 4px 8px rgba(0,0,0,0.25);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
}

.game-card {
  position: relative;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  cursor: pointer;
  border: 4px solid #ffffff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12), inset 0 2px 4px rgba(255,255,255,0.8);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 16px 30px rgba(0,0,0,0.18);
}

.game-card:active {
  transform: scale(0.95);
}

.card-icon-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
  transition: transform 0.3s ease;
}

.game-card:hover .card-icon-wrapper {
  transform: rotate(10deg) scale(1.1);
}

.card-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--dark-text);
}

.card-subtitle {
  font-size: 0.95rem;
  color: #6c7a89;
  font-weight: 600;
}

.card-stars-earned {
  display: flex;
  gap: 4px;
  font-size: 1.3rem;
}

.card-star {
  color: #d1d8e0;
  transition: color 0.3s ease;
}
.card-star.earned {
  color: #ff9f1a;
  filter: drop-shadow(0 2px 4px rgba(255,159,26,0.5));
}

/* Warna Khusus Game Card */
.card-counting { border-color: #ff9f1a; }
.card-counting .card-icon-wrapper { background: linear-gradient(135deg, #ffd32a, #ff9f1a); }

.card-letters { border-color: #00d2d3; }
.card-letters .card-icon-wrapper { background: linear-gradient(135deg, #48dbfb, #0abde3); }

.card-colors { border-color: #ff6b81; }
.card-colors .card-icon-wrapper { background: linear-gradient(135deg, #ff758c, #ff4757); }

.card-shapes { border-color: #9c88ff; }
.card-shapes .card-icon-wrapper { background: linear-gradient(135deg, #c56cf0, #8c7ae6); }

.card-puzzle { border-color: #2ed573; }
.card-puzzle .card-icon-wrapper { background: linear-gradient(135deg, #7bed9f, #2ed573); }

/* ==========================================================================
   RESULT MODAL / POPUP SCREEN
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  width: 100%;
  max-width: 500px;
  text-align: center;
  border: 6px solid #ffd214;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  position: relative;
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.result-momo {
  width: 140px;
  height: 140px;
  margin: -80px auto 10px;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.2));
}

.result-title {
  font-size: 2.5rem;
  font-weight: 900;
  color: #ff4757;
  text-shadow: 2px 2px 0 #ffd214;
  margin-bottom: 5px;
}

.result-stars-row {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 15px 0;
}

.result-star-item {
  font-size: 3.5rem;
  color: #dcdde1;
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.4), color 0.3s ease;
}

.result-star-item.active {
  transform: scale(1);
  color: #ffd214;
  filter: drop-shadow(0 4px 10px rgba(255, 210, 20, 0.6));
}

.result-rewards-pill {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  background: #fff9e6;
  padding: 8px 24px;
  border-radius: var(--radius-full);
  border: 2px dashed #ffd214;
  margin-bottom: 20px;
  font-size: 1.2rem;
  font-weight: 800;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

/* ==========================================================================
   PARTICLE CANVAS (Confetti & Sparkles)
   ========================================================================== */

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes sunGlow {
  0% { transform: scale(1) rotate(0deg); box-shadow: 0 0 35px #ffd214; }
  100% { transform: scale(1.06) rotate(6deg); box-shadow: 0 0 55px #ffa41c; }
}

@keyframes eyeBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 350px)); }
}

@keyframes birdFly {
  0% { transform: translate(0, 0); }
  50% { transform: translate(calc(50vw), -25px); }
  100% { transform: translate(calc(100vw + 100px), 10px); }
}

@keyframes flapWing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(-35deg); }
}

@keyframes treeSway {
  0% { transform: rotate(-2deg); }
  100% { transform: rotate(3deg); }
}

@keyframes logoBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.03); }
}

@keyframes loaderBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0; }
  80% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes playPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

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

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

@keyframes sparkleSpin {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}
