/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-top: #E8F4FD;
  --bg-bottom: #F0E6FF;
  --card-bg: #FFFFFF;
  --card-shadow: rgba(0, 0, 0, 0.1);
  --correct: #4CAF50;
  --correct-glow: rgba(76, 175, 80, 0.4);
  --wrong: #FF7043;
  --star-color: #FFD700;
  --star-stroke: #E6A800;
  --text-dark: #333;
  --text-light: #666;
  --bunny-body: #FFF8F0;
  --bunny-pink: #FFB6C1;
  --purple-accent: #7C4DFF;
  --category-animals: #4CAF50;
  --category-food: #FF9800;
  --category-colors: #E91E63;
  --category-numbers: #2196F3;
  --category-body: #9C27B0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: linear-gradient(135deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

/* === SCREENS === */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* === SPLASH === */
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.splash-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--purple-accent);
  text-shadow: 2px 2px 0 rgba(124, 77, 255, 0.15);
  letter-spacing: -1px;
}

.btn-big {
  border: none;
  background: none;
  cursor: pointer;
  padding: 12px;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.btn-big:active {
  transform: scale(0.9);
}

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

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

/* === CATEGORIES === */
.categories-header {
  width: 100%;
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
}

.total-stars-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--star-stroke);
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 16px 24px;
  width: 100%;
  max-width: 600px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 4px 16px var(--card-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

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

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.category-card[data-category="animals"]::before { background: var(--category-animals); }
.category-card[data-category="food"]::before { background: var(--category-food); }
.category-card[data-category="colors"]::before { background: var(--category-colors); }
.category-card[data-category="numbers"]::before { background: var(--category-numbers); }
.category-card[data-category="body"]::before { background: var(--category-body); }

.category-icon {
  font-size: 3rem;
  line-height: 1;
}

.category-progress-ring {
  width: 50px;
  height: 50px;
}

.category-progress-ring .ring-bg {
  fill: none;
  stroke: #eee;
  stroke-width: 4;
}

.category-progress-ring .ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
  transform: rotate(-90deg);
  transform-origin: center;
}

.category-stars {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 600;
}

.category-crown {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 1.4rem;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.2));
}

/* === GAME SCREEN === */
.game-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 10;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(124, 77, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.btn-icon:active {
  transform: scale(0.9);
}

.session-progress {
  display: flex;
  gap: 6px;
  align-items: center;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(124, 77, 255, 0.15);
  transition: background 0.3s ease, transform 0.3s ease;
}

.progress-dot.done {
  background: var(--correct);
  transform: scale(1.1);
}

.progress-dot.current {
  background: var(--purple-accent);
  transform: scale(1.3);
}

.stars-earned {
  display: flex;
  gap: 2px;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--star-stroke);
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 16px 16px;
  gap: 8px;
  overflow: visible;
  min-height: 0;
}

.bunny-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex-shrink: 1;
  min-height: 0;
}

.bunny-container {
  width: 120px;
  height: 130px;
  position: relative;
}

.speech-bubble {
  position: absolute;
  top: -10px;
  background: white;
  border-radius: 20px;
  padding: 10px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 2rem;
  white-space: nowrap;
  z-index: 5;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid white;
}

.speech-bubble.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

/* === CARDS === */
.cards-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 500px;
  padding: 8px;
}

.cards-section.four-cards {
  grid-template-columns: repeat(2, 1fr);
  max-width: 360px;
}

.word-card {
  aspect-ratio: 1;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 4px 16px var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
  position: relative;
  overflow: hidden;
  min-width: 100px;
  min-height: 100px;
}

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

.word-card .card-image {
  width: 75%;
  height: 75%;
  object-fit: contain;
}

.word-card .card-emoji {
  font-size: 3.5rem;
  line-height: 1;
}

.word-card.correct {
  box-shadow: 0 0 0 4px var(--correct), 0 0 20px var(--correct-glow);
  animation: cardCorrect 0.5s ease;
}

.word-card.wrong {
  animation: cardWrong 0.4s ease;
}

.word-card.disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.5);
}

.word-card.hint-glow {
  animation: hintPulse 1s ease-in-out infinite;
}

/* === HINT BUTTON === */
.btn-hint {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: white;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 0.2s ease, opacity 0.3s ease;
}

.btn-hint:active {
  transform: scale(0.9);
}

.btn-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

.hint-flag {
  font-size: 1.8rem;
}

/* === SESSION COMPLETE === */
.complete-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.complete-stars {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.complete-star {
  font-size: 2.5rem;
  animation: starPop 0.4s ease backwards;
}

.complete-message {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--purple-accent);
  text-align: center;
}

.btn-green {
  background: var(--correct);
  border-radius: 50%;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
}

/* === SPARKLE PARTICLES === */
.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 100;
}

/* === RESPONSIVE === */

/* Mobile phones */
@media (max-width: 480px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .game-top-bar {
    padding: 8px 12px;
  }

  .bunny-container {
    width: 100px;
    height: 110px;
  }

  .cards-section {
    gap: 10px;
    padding: 4px;
    max-width: 100%;
  }

  .cards-section.four-cards {
    max-width: 300px;
  }

  .word-card {
    min-width: 80px;
    min-height: 80px;
    border-radius: 16px;
  }

  .word-card .card-emoji {
    font-size: 2.8rem;
  }

  .btn-hint {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .splash-title {
    font-size: 2rem;
  }

  .speech-bubble {
    font-size: 1.5rem;
    padding: 8px 14px;
  }

  .progress-dot {
    width: 8px;
    height: 8px;
  }
}

/* Short phones (iPhone SE, etc.) */
@media (max-height: 600px) {
  .bunny-container {
    width: 80px;
    height: 90px;
  }
  .splash-title {
    font-size: 1.6rem;
  }
  .word-card .card-emoji {
    font-size: 2.2rem;
  }
  .game-area {
    gap: 4px;
    padding: 0 12px 8px;
  }
}

/* Tablets */
@media (min-width: 768px) {
  .cards-section {
    max-width: 560px;
    gap: 18px;
  }
  .cards-section.four-cards {
    max-width: 420px;
  }
  .word-card .card-emoji {
    font-size: 4.5rem;
  }
}

/* Landscape */
@media (orientation: landscape) and (max-height: 500px) {
  .game-area {
    flex-direction: row;
    padding: 0 16px;
  }
  .bunny-section {
    flex: 0 0 auto;
  }
  .bunny-container {
    width: 80px;
    height: 90px;
  }
  .cards-section {
    flex: 1;
  }
}
