/* ==========================================================================
   POPMAGIC KIDS - DESIGN SYSTEM & INFANT UX/UI (3 ANOS)
   ========================================================================== */

:root {
  --color-bg-start: #a8edea;
  --color-bg-end: #fed6e3;
  --color-shadow: rgba(45, 52, 54, 0.15);
  --safe-min-touch: 80px;
}

/* Reset Global e Bloqueio Total de Gestos Nativos */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  touch-action: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
}

/* Canvas Principal de Jogos em Tela Cheia */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
  cursor: pointer;
}

/* ==========================================================================
   HOME HUB (TELA INICIAL 100% VISUAL)
   ========================================================================== */
#hubOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at center, #ffffff 0%, #fed6e3 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#hubOverlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Grade Flexível de Jogos com Alvos Gigantes e Rolagem Suave */
.hub-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  max-width: 860px;
  max-height: 88vh;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none; /* Firefox */
}

.hub-grid::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

/* Cards dos Jogos (100% Visual, Sem Texto) */
.hub-game-card {
  width: 118px;
  height: 118px;
  min-width: 90px;
  min-height: 90px;
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12), 0 0 0 6px rgba(255, 255, 255, 0.85);
  cursor: pointer;
  border: none;
  outline: none;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
  animation: floatCard 4s ease-in-out infinite alternate;
}

/* Gradientes Vibrantes para os 10 Jogos */
.hub-game-card:nth-child(1) { background: linear-gradient(135deg, #ff6584, #ff758c); animation-delay: 0s; }
.hub-game-card:nth-child(2) { background: linear-gradient(135deg, #ffeaa7, #fdcb6e); animation-delay: 0.3s; }
.hub-game-card:nth-child(3) { background: linear-gradient(135deg, #a29bfe, #6c5ce7); animation-delay: 0.6s; }
.hub-game-card:nth-child(4) { background: linear-gradient(135deg, #74b9ff, #0984e3); animation-delay: 0.9s; }
.hub-game-card:nth-child(5) { background: linear-gradient(135deg, #55efc4, #00b894); animation-delay: 1.2s; }
.hub-game-card:nth-child(6) { background: linear-gradient(135deg, #e0c3fc, #8ec5fc); animation-delay: 1.5s; }
.hub-game-card:nth-child(7) { background: linear-gradient(135deg, #fd79a8, #e84393); animation-delay: 1.8s; }
.hub-game-card:nth-child(8) { background: linear-gradient(135deg, #6c5ce7, #4834d4); animation-delay: 2.1s; }
.hub-game-card:nth-child(9) { background: linear-gradient(135deg, #81ecec, #00cec9); animation-delay: 2.4s; }
.hub-game-card:nth-child(10) { background: linear-gradient(135deg, #ffeaa7, #fab1a0); animation-delay: 2.7s; }
.hub-game-card:nth-child(11) { background: linear-gradient(135deg, #ff7675, #6c5ce7); animation-delay: 3.0s; }
.hub-game-card:nth-child(12) { background: linear-gradient(135deg, #fdcb6e, #e17055); animation-delay: 3.3s; }

.hub-game-card svg {
  width: 76px;
  height: 76px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
}

.hub-game-card:active,
.hub-game-card.selected {
  transform: scale(0.9) !important;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15), 0 0 0 14px rgba(255, 255, 255, 0.9);
}

@keyframes floatCard {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-2deg); }
  100% { transform: translateY(0px) rotate(2deg); }
}

/* ==========================================================================
   CONTROLES SUPERIORES (HOME & SOM)
   ========================================================================== */
.top-nav {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.nav-btn {
  width: 60px;
  height: 60px;
  min-width: 60px;
  min-height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 20px var(--color-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-btn:active {
  transform: scale(0.88);
}

.nav-btn svg {
  width: 32px;
  height: 32px;
  fill: #2d3436;
}

/* Botão Casinha (Home) com cor alegre */
#homeBtn {
  background: linear-gradient(135deg, #ffeaa7, #fab1a0);
  border-color: #ffffff;
}

#homeBtn svg {
  fill: #ff6584;
}

/* Barra de Progresso Visual Estrelada (Zero Texto) */
.star-progress-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 30px;
  box-shadow: 0 6px 14px var(--color-shadow);
  border: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: auto;
}

.star-icon {
  width: 26px;
  height: 26px;
  fill: #ffe600;
  filter: drop-shadow(0 2px 4px rgba(255, 179, 0, 0.4));
  animation: starWiggle 3s infinite ease-in-out;
}

.meter-track {
  width: 80px;
  height: 12px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, #ffe600, #ff6584, #00cec9);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes starWiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-8deg) scale(1.1); }
  75% { transform: rotate(8deg) scale(1.1); }
}

/* Flash comemorativo */
#celebrationFlash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 230, 0, 0.3) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#celebrationFlash.active {
  opacity: 1;
}

/* Responsividade Avançada para Telas Pequenas, Paisagem e Tablets */
@media (max-width: 480px) {
  .hub-grid {
    gap: 12px;
    padding: 6px;
    max-height: 86vh;
  }
  .hub-game-card {
    width: 98px;
    height: 98px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 26px;
  }
  .hub-game-card svg {
    width: 58px;
    height: 58px;
  }
}

@media (max-height: 520px) {
  .hub-grid {
    gap: 10px;
    padding: 6px;
    max-height: 82vh;
  }
  .hub-game-card {
    width: 82px;
    height: 82px;
    min-width: 75px;
    min-height: 75px;
    border-radius: 22px;
  }
  .hub-game-card svg {
    width: 48px;
    height: 48px;
  }
}

@media (min-width: 768px) and (min-height: 600px) {
  .hub-grid {
    max-width: 880px;
    gap: 22px;
    max-height: 88vh;
  }
  .hub-game-card {
    width: 135px;
    height: 135px;
    border-radius: 36px;
  }
  .hub-game-card svg {
    width: 82px;
    height: 82px;
  }
}
