:root {
  --bg-body-desktop: #e0e7ff;
  --bg-app: #f8f9fa;
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --primary-btn: #f6993f;
  --primary-btn-hover: #e67e22;

  /* Cores Emoções */
  --c-alegria-bg: #fff9c4;
  --c-alegria-border: #fbc02d;
  --c-tristeza-bg: #e1f5fe;
  --c-tristeza-border: #039be5;
  --c-raiva-bg: #ffebee;
  --c-raiva-border: #e53935;
  --c-medo-bg: #f3e5f5;
  --c-medo-border: #8e24aa;
  --c-nojo-bg: #e8f5e9;
  --c-nojo-border: #43a047;
  --c-surpresa-bg: #e0f7fa;
  --c-surpresa-border: #00acc1;
}

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

body {
  font-family: "Nunito", sans-serif;
  margin: 0;
  padding: 0;
  height: 100vh; /* Fallback */
  height: 100dvh; /* Dynamic viewport height para mobile */
  background-color: var(--bg-body-desktop);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* --- ESTRUTURA DO APP (CONTAINER) --- */
.app-container {
  background-color: var(--bg-app);
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Regras para Desktop (Centralizado com borda) */
@media (min-width: 600px) {
  .app-container {
    max-width: 400px;
    height: 90vh;
    max-height: 850px;
    border-radius: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 8px solid #fff;
  }
}

/* Regras para Mobile (Tela Cheia Real) */
@media (max-width: 599px) {
  body {
    background-color: var(--bg-app);
  }
  .app-container {
    border: none;
    border-radius: 0;
    height: 100dvh;
  }
}

/* --- LAYOUT INTERNO (Flex Column) --- */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.screen.active {
  display: flex;
}

/* 1. Header (Fixo) */
.app-header {
  padding: 20px 20px 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0; /* Não encolhe */
  background: var(--bg-app);
  z-index: 10;
}

.back-btn {
  position: absolute;
  left: 15px;
  background: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

h1 {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
}

/* 2. Conteúdo com Scroll (Meio) */
.scroll-content {
  flex: 1; /* Ocupa todo o espaço sobrando */
  overflow-y: auto; /* Scroll só aqui */
  padding: 10px 20px 20px 20px;
  /* Esconde scrollbar mas mantém funcionalidade */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scroll-content::-webkit-scrollbar {
  display: none;
}

/* 3. Footer de Ação (Fixo embaixo) */
.action-footer {
  padding: 20px;
  background: linear-gradient(
    to top,
    var(--bg-app) 80%,
    rgba(255, 255, 255, 0)
  );
  flex-shrink: 0;
  z-index: 10;
}

/* --- COMPONENTES VISUAIS --- */

/* Avatar Intro */
.intro-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
}

.kid-avatar {
  width: 140px;
  height: 140px;
  margin: 0 auto 30px auto;
  border-radius: 50%;
  background: white;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  padding: 10px;
}

.intro-text {
  text-align: center;
  margin-bottom: 40px;
}
.intro-text h2 {
  font-size: 1.8rem;
  margin: 0 0 10px 0;
  color: var(--text-primary);
}
.intro-text p {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

.mode-card {
  background: white;
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  border: 2px solid transparent;
  transition: 0.2s;
}
.mode-card.selected {
  border-color: var(--primary-btn);
  background: #fff8e1;
}
.icon-box {
  width: 45px;
  height: 45px;
  background: #f1f5f9;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Barra de Progresso */
.progress-container {
  margin-bottom: 20px;
}
.progress-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary-btn);
  width: 0%;
  transition: width 0.3s ease;
}

/* Card Situação */
.situation-card {
  background: white;
  border-radius: 24px;
  padding: 25px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
  text-align: center;
  margin-bottom: 20px;
  border: 1px solid #edf2f7;
}
.situation-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.situation-text {
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.4;
}

/* Grid */
.emotions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.emotion-card {
  background: white;
  border-radius: 18px;
  padding: 15px 10px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  border: 3px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}
.emotion-card h3 {
  margin: 10px 0 0 0;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 700;
}

/* Cores e Estados */
.emotion-card.alegria {
  background: var(--c-alegria-bg);
}
.emotion-card.tristeza {
  background: var(--c-tristeza-bg);
}
.emotion-card.raiva {
  background: var(--c-raiva-bg);
}
.emotion-card.medo {
  background: var(--c-medo-bg);
}
.emotion-card.nojo {
  background: var(--c-nojo-bg);
}
.emotion-card.surpresa {
  background: var(--c-surpresa-bg);
}

.emotion-card.selected {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}
.emotion-card.alegria.selected {
  border-color: var(--c-alegria-border);
}
.emotion-card.tristeza.selected {
  border-color: var(--c-tristeza-border);
}
.emotion-card.raiva.selected {
  border-color: var(--c-raiva-border);
}
.emotion-card.medo.selected {
  border-color: var(--c-medo-border);
}
.emotion-card.nojo.selected {
  border-color: var(--c-nojo-border);
}
.emotion-card.surpresa.selected {
  border-color: var(--c-surpresa-border);
}

/* Botão */
.btn-primary {
  background: var(--primary-btn);
  color: white;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(246, 153, 63, 0.4);
  transition: transform 0.2s;
}
.btn-primary:hover {
  background: var(--primary-btn-hover);
  transform: scale(1.02);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  background: #cbd5e0;
  box-shadow: none;
  color: #718096;
  cursor: default;
}

/* Modal */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-overlay.active {
  display: flex;
}
.modal-content {
  background: white;
  width: 85%;
  max-width: 320px;
  border-radius: 30px;
  padding: 30px 25px;
  text-align: center;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
.shake-anim {
  animation: shake 0.4s ease-in-out;
}
