/* =========================================================
   TAMAN PINTAR - Stylesheet
   Palet: langit cerah, matahari, dan taman bermain
   ========================================================= */

:root {
  /* --- palet warna ceria --- */
  --sky: #4fc3f7;
  --sky-dark: #29a6e0;
  --sun: #ffd54f;
  --sun-dark: #f6b823;
  --coral: #ff7a7a;
  --coral-dark: #f05a5a;
  --grass: #7bd88f;
  --grass-dark: #55c26e;
  --grape: #a684e8;
  --grape-dark: #8c63d9;
  --cream: #fffaf0;
  --ink: #3a3350;
  --ink-soft: #6a6280;
  --white: #ffffff;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-soft: 0 10px 24px rgba(58, 51, 80, 0.14);
  --shadow-pressed: 0 4px 10px rgba(58, 51, 80, 0.18);

  --font-display: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  --font-body: "Nunito", "Comic Sans MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 213, 79, 0.55), transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(123, 216, 143, 0.35), transparent 45%),
    linear-gradient(180deg, #eaf7ff 0%, #fffaf0 55%, #fff6e9 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid var(--sky-dark);
  outline-offset: 3px;
}

img, svg { display: block; }

/* =========================================================
   TOP BAR
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(12px, 3vw, 28px);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(58, 51, 80, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--grape-dark);
}

.brand-mascot { font-size: 1.6rem; }

.brand-title {
  font-size: clamp(1.05rem, 2.4vw, 1.5rem);
  letter-spacing: 0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-soft);
  font-size: 1.4rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.9);
  box-shadow: var(--shadow-pressed);
}

.star-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--sun-dark);
  box-shadow: var(--shadow-soft);
}

/* =========================================================
   LAYOUT / SCREENS
   ========================================================= */
#app {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px) clamp(14px, 4vw, 28px) 60px;
}

.screen {
  animation: screenIn 0.35s ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   HOME SCREEN
   ========================================================= */
.home-hero {
  text-align: center;
  padding: clamp(10px, 3vw, 24px) 0 clamp(18px, 4vw, 30px);
}

.hero-mascot {
  font-size: clamp(3.2rem, 12vw, 5rem);
  margin-bottom: 6px;
}

.floaty {
  animation: floaty 3.2s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-12px) rotate(2deg); }
}

.home-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5.5vw, 2.6rem);
  color: var(--ink);
  margin: 0 0 4px;
}

.home-subtitle {
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  color: var(--ink-soft);
  margin: 0;
  font-weight: 700;
}

.game-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(14px, 3vw, 22px);
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: clamp(22px, 4vw, 30px) 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  text-align: center;
  min-height: 190px;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  color: var(--white);
}

.game-card:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: var(--shadow-pressed);
}

.card-blue   { background: linear-gradient(160deg, var(--sky), var(--sky-dark)); }
.card-green  { background: linear-gradient(160deg, var(--grass), var(--grass-dark)); }
.card-pink   { background: linear-gradient(160deg, var(--coral), var(--coral-dark)); }
.card-purple { background: linear-gradient(160deg, var(--grape), var(--grape-dark)); }

.game-card-icon {
  font-size: clamp(2.2rem, 7vw, 3rem);
  line-height: 1;
}

.game-card-title {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  font-weight: 700;
}

.game-card-desc {
  font-size: clamp(0.85rem, 2.2vw, 0.98rem);
  font-weight: 700;
  opacity: 0.92;
}

/* =========================================================
   GAME HEADER / PROGRESS / QUESTION (shared)
   ========================================================= */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.btn-back {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  background: var(--white);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  color: var(--grape-dark);
  white-space: nowrap;
}

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

.game-title {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.4vw, 1.7rem);
  margin: 0;
  color: var(--ink);
  text-align: center;
  flex: 1;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.progress-track {
  flex: 1;
  height: 16px;
  border-radius: 999px;
  background: rgba(58, 51, 80, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sun), var(--coral));
  transition: width 0.4s ease;
}

.progress-label {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.question-text {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  text-align: center;
  color: var(--ink);
  margin: 0 0 20px;
  min-height: 2.4em;
}

.feedback-banner {
  min-height: 44px;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: 700;
  margin-top: 16px;
  transition: opacity 0.2s ease;
}

.feedback-banner.correct { color: var(--grass-dark); }
.feedback-banner.wrong   { color: var(--coral-dark); }

/* =========================================================
   GAME 1: COLOR & SHAPE OPTIONS
   ========================================================= */
.options-grid {
  display: grid;
  gap: clamp(12px, 3vw, 20px);
}

.options-grid-shapes {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.shape-option {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.shape-option:active { transform: scale(0.92); }

.shape-option.correct-flash {
  animation: pulseCorrect 0.6s ease;
}

.shape-option.wrong-flash {
  animation: shakeWrong 0.5s ease;
}

@keyframes pulseCorrect {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(123, 216, 143, 0.35); }
  100% { transform: scale(1); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

.shape-svg { width: 70%; height: 70%; }

/* =========================================================
   GAME 2: COUNTING
   ========================================================= */
.animal-stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2vw, 14px);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(16px, 4vw, 26px);
  margin-bottom: 20px;
  min-height: 120px;
}

.animal-emoji {
  font-size: clamp(2rem, 8vw, 3.2rem);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.options-grid-numbers {
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  max-width: 480px;
  margin: 0 auto;
}

.number-option {
  height: 84px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--grape), var(--grape-dark));
  color: var(--white);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease;
}

.number-option:active { transform: scale(0.9); }

.number-option.correct-flash { animation: pulseCorrect 0.6s ease; }
.number-option.wrong-flash   { animation: shakeWrong 0.5s ease; }

/* =========================================================
   GAME 4: DRAG & DROP MATCHING
   ========================================================= */
.drag-play-area {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 5vw, 40px);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(18px, 4vw, 30px) clamp(12px, 4vw, 24px);
}

.basket-row,
.items-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 4vw, 26px);
}

.basket {
  position: relative;
  width: clamp(74px, 18vw, 100px);
  height: clamp(74px, 18vw, 100px);
  border-radius: var(--radius-md);
  border: 4px dashed rgba(58, 51, 80, 0.35);
  background: rgba(58, 51, 80, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.basket-emoji {
  position: absolute;
  bottom: -6px;
  font-size: 1.1rem;
  opacity: 0.55;
}

.basket .shape-svg {
  width: 60%;
  height: 60%;
  opacity: 0.85;
}

.basket.drag-hover {
  transform: scale(1.08);
  background: rgba(58, 51, 80, 0.1);
  border-color: var(--ink);
}

.basket.filled {
  border-style: solid;
  background: rgba(123, 216, 143, 0.18);
  border-color: var(--grass-dark);
}

.basket.wrong-hover {
  border-color: var(--coral-dark);
  background: rgba(255, 122, 122, 0.16);
}

.drag-item {
  width: clamp(58px, 15vw, 76px);
  height: clamp(58px, 15vw, 76px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  will-change: transform;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 6px 8px rgba(58, 51, 80, 0.25));
}

.drag-item.dragging {
  cursor: grabbing;
  transition: none;
  z-index: 20;
}

.drag-item.placed {
  pointer-events: none;
  cursor: default;
  filter: drop-shadow(0 2px 4px rgba(58, 51, 80, 0.18));
}

.drag-item .shape-svg { width: 100%; height: 100%; }

.drag-ball {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.12), inset 4px 6px 0 rgba(255, 255, 255, 0.35);
}

/* =========================================================
   GAME 3: DRAWING BOARD
   ========================================================= */
.drawing-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.draw-canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  touch-action: none;
  cursor: crosshair;
}

.draw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.tool-group-row { gap: 12px; }

.color-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--white);
  box-shadow: 0 0 0 3px rgba(58, 51, 80, 0.12), var(--shadow-soft);
  transition: transform 0.15s ease;
}

.color-swatch.active {
  box-shadow: 0 0 0 3px var(--ink), var(--shadow-soft);
  transform: scale(1.12);
}

.color-swatch:active { transform: scale(0.9); }

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 56px;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: #f2eefc;
  box-shadow: var(--shadow-soft);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}

.tool-btn:active { transform: scale(0.93); }

.tool-btn.active {
  background: var(--grape);
  color: var(--white);
}

.brush-dot {
  border-radius: 50%;
  background: var(--ink);
  display: inline-block;
}

.tool-btn.active .brush-dot { background: var(--white); }

.tool-label { font-size: 0.85rem; }

/* =========================================================
   CELEBRATION OVERLAY
   ========================================================= */
#celebrationCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

.celebration-badge {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -30px) scale(0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--white);
  padding: 20px 34px;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 34px rgba(58, 51, 80, 0.28);
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  font-weight: 700;
  color: var(--sun-dark);
  opacity: 0;
  pointer-events: none;
  z-index: 95;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.celebration-badge.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

#celebrationEmoji { font-size: clamp(2.2rem, 6vw, 3rem); }

/* =========================================================
   RESPONSIVE TWEAKS
   ========================================================= */
@media (min-width: 720px) {
  .drawing-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .draw-canvas { flex: 2; }
  .draw-toolbar {
    flex: 1;
    flex-direction: column;
    align-items: stretch;
  }
  .tool-group-row { justify-content: flex-start; }
}

@media (max-width: 380px) {
  .icon-btn { width: 46px; height: 46px; font-size: 1.2rem; }
  .brand-title { display: none; }
}

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