/* ===== Bibi Play — design system estilo YouTube Kids ===== */
:root {
  --bibi-yellow: #F5B940;
  --bibi-red: #E63946;
  --bibi-blue: #4A8FD8;
  --green: #5BBF6B;
  --purple: #9B6BD8;
  --orange: #FF8A3D;
  --pink: #FF6FA5;
  --bg: #FFF9EF;
  --card: #ffffff;
  --ink: #3A3345;
  --ink-soft: #8B8398;
  --radius: 28px;
  --touch: 88px; /* alvo mínimo de toque p/ dedinhos */
  --shadow: 0 6px 0 rgba(58, 51, 69, 0.12);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

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

#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }

/* ===== Header ===== */
.top-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #FFCE5C 0%, var(--bibi-yellow) 100%);
  box-shadow: 0 4px 0 rgba(58, 51, 69, 0.1);
  z-index: 5;
}
.top-bar .logo-char { width: 60px; height: 60px; filter: drop-shadow(0 3px 0 rgba(122, 74, 18, 0.3)); animation: logo-bob 3s ease-in-out infinite; }
@keyframes logo-bob { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-3px); } }
.top-bar h1 { font-size: 28px; margin: 0; letter-spacing: 0.5px; color: #7A4A12; }
.top-bar h1 span { color: var(--bibi-red); }
.top-bar .site-back {
  margin-left: auto; text-decoration: none;
  font-family: inherit; font-weight: 800; font-size: 15px;
  color: #7A4A12; background: rgba(255,255,255,0.55);
  padding: 8px 14px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(122, 74, 18, 0.25);
}
.top-bar .site-back:active { transform: scale(0.95); }

/* ===== Conteúdo / abas ===== */
.tab-panels { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: pop-in 0.25s ease-out; }

@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ===== Cards de jogos ===== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.game-card {
  position: relative;
  border-radius: var(--radius);
  padding: 20px 16px 18px;
  min-height: 230px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
  overflow: hidden;
}
.game-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 18%, rgba(255,255,255,0.35), transparent 55%);
  pointer-events: none;
}
.game-card:active { transform: scale(0.94); }
.game-card .char {
  width: 130px; height: 130px;
  filter: drop-shadow(0 5px 0 rgba(0,0,0,0.18));
  transition: transform 0.15s ease;
}
.game-card:active .char { transform: scale(1.08) rotate(-3deg); }
.game-card .emoji { font-size: 44px; position: absolute; top: 12px; right: 14px; transform: rotate(12deg); }
.game-card .title { font-size: 24px; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,0.18); text-align: center; line-height: 1.1; }

/* ===== Tela de jogo (overlay) ===== */
#game-screen {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: none; flex-direction: column;
}
#game-screen.active { display: flex; }
#game-container { flex: 1; position: relative; overflow: hidden; }
.game-back-btn {
  position: absolute; top: 14px; left: 14px; z-index: 60;
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow);
  font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.game-back-btn:active { transform: scale(0.9); }

/* ===== Vídeos ===== */
.video-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px; max-width: 1100px; margin: 0 auto;
}
.video-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-card iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.video-card .video-title { padding: 12px 16px 14px; font-size: 19px; font-weight: 700; }
.channel-btn {
  display: block; margin: 24px auto 8px; padding: 16px 32px;
  background: var(--bibi-red); color: #fff;
  border-radius: 999px; font-size: 21px; font-weight: 700;
  box-shadow: var(--shadow); text-decoration: none; width: fit-content;
}
.channel-btn:active { transform: scale(0.95); }

/* ===== Lojinha ===== */
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px; max-width: 1100px; margin: 0 auto;
}
.shop-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.shop-card .shop-emoji { font-size: 60px; }
.shop-card .shop-name { font-size: 20px; font-weight: 700; }
.shop-card .shop-price { font-size: 17px; color: var(--ink-soft); }
.shop-badge {
  padding: 8px 22px; border-radius: 999px; font-size: 17px; font-weight: 700; color: #fff;
}
.shop-badge.available { background: var(--green); text-decoration: none; }
.shop-badge.available:active { transform: scale(0.95); }
.shop-badge.soon { background: var(--ink-soft); }
.shop-card.soon { opacity: 0.75; }
.shop-card.soon .shop-emoji { filter: grayscale(0.5); }

/* ===== Portão dos pais ===== */
#parent-gate {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(58, 51, 69, 0.65);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#parent-gate.active { display: flex; }
.gate-box {
  background: #fff; border-radius: var(--radius); padding: 32px 28px;
  max-width: 420px; text-align: center; box-shadow: var(--shadow);
}
.gate-box h2 { margin: 0 0 6px; font-size: 26px; }
.gate-box p { margin: 0 0 20px; font-size: 18px; color: var(--ink-soft); }
.gate-hold-btn {
  width: 130px; height: 130px; border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--gate-progress, 0) * 1%), #EDE7F3 0);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 54px;
  transition: transform 0.1s;
}
.gate-hold-btn:active { transform: scale(0.95); }
.gate-hold-btn .gate-inner {
  width: 104px; height: 104px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.gate-cancel { margin-top: 18px; font-size: 18px; color: var(--ink-soft); padding: 12px; }

/* ===== Navegação inferior ===== */
.bottom-nav {
  display: flex; justify-content: space-around;
  background: #fff; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 0 rgba(58, 51, 69, 0.08);
  z-index: 5;
}
.nav-btn {
  flex: 1; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 20px;
  font-size: 16px; font-weight: 700; color: var(--ink-soft);
}
.nav-btn .nav-icon { font-size: 30px; }
.nav-btn.active { background: #FFEFC9; color: #7A4A12; }
.nav-btn:active { transform: scale(0.93); }

/* ===== Confete (usado pelo SDK) ===== */
.sdk-confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.sdk-confetti {
  position: absolute; top: -20px; width: 14px; height: 14px;
  animation: sdk-confetti-fall 1.6s ease-in forwards;
}
@keyframes sdk-confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}
