/* ==========================================================================
   1. BASE E CONFIGURAÇÕES GERAIS
   ========================================================================== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030712;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  touch-action: manipulation;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app,
.screen {
  width: 100vw;
  height: 100vh;
}

.screen {
  display: none !important; /* Força sumir por padrão */
  position: fixed;
  inset: 0;
  z-index: 1;
}

.screen.active {
  display: block !important; /* Só aparece quando ganha a classe active */
  z-index: 10; /* Vai para a frente da tela */
}

.screen.active#messageScreen {
  display: flex !important;
}

.screen.active#flowScreen {
  display: flex !important;
}

/* ==========================================================================
   2. TELA DE ANÚNCIOS (AD SCREEN)
   ========================================================================== */
#adScreen {
  background: #020617;
  z-index: 20; /* Garante que fica por cima de resíduos de outras telas */
}

.screen.active#adScreen {
  display: block !important;
}

#adStage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #020617;
}

#adStage img,
#adStage video,
.ad-layer img,
.ad-layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .45s ease;
  z-index: 1;
}

.ad-layer.active {
  opacity: 1;
  z-index: 2;
}

.touchHint {
  position: absolute;
  left: 50%;
  bottom: 5.5vh;
  transform: translateX(-50%);
  background: rgba(2, 6, 23, .72);
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  backdrop-filter: blur(12px);
  padding: 20px 34px;
  border-radius: 999px;
  font-size: clamp(24px, 2.6vw, 46px);
  font-weight: 900;
  text-align: center;
  letter-spacing: .2px;
}

.offline {
  position: fixed !important;
  right: 22px !important;
  top: 22px !important;
  z-index: 99999 !important;
  background: #7f1d1d;
  color: #fecaca;
  border-radius: 999px;
  padding: 10px 18px;
  text-transform: uppercase;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  pointer-events: none;
}


/* ==========================================================================
   3. FALLBACKS E SELETOR DE TOTEM
   ========================================================================== */
.fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #050505;
  color: #fff;
  font-size: clamp(40px, 5vw, 80px);
  text-align: center;
  font-weight: 900;
  padding: 8vw;
}

.fallback .small,
.small {
  display: block;
  margin-top: 18px;
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 400;
  color: #94a3b8;
  opacity: .85;
}

.continue-button {
  margin-top: 22px;
  padding: 16px 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  opacity: .85;
}

.continue-button:active {
  transform: scale(.97);
}

.selector {
  width: 100vw !important;
  max-width: none !important;
  height: 100vh !important;
  padding: 8vh 8vw !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  text-align: center;
}

.selector h1 {
  font-size: clamp(70px, 7vw, 130px) !important;
  margin: 0 0 24px !important;
  text-align: center !important;
}

.selector p {
  font-size: clamp(30px, 3vw, 48px) !important;
  margin: 0 0 50px !important;
  color: #cbd5e1;
  text-align: center !important;
}

#totemList {
  width: min(1400px, 90vw) !important;
}

.totem-choice {
  width: 100% !important;
  display: block !important;
  margin: 24px 0 !important;
  padding: 46px 40px !important;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 32px !important;
  background: rgba(15, 23, 42, .9);
  color: #fff;
  text-align: left !important;
  font-size: clamp(42px, 4vw, 78px) !important;
  font-weight: 900 !important;
}

.totem-choice b {
  display: block !important;
  font-size: 1em !important;
}

.totem-choice span {
  display: block !important;
  margin-top: 12px !important;
  color: #94a3b8;
  font-size: .42em !important;
}


/* ==========================================================================
   4. FLUXO DE PERGUNTAS (FLOW SCREEN)
   ========================================================================== */
#flowScreen {
  align-items: center !important;
  justify-content: center !important;
  padding: clamp(28px, 4vh, 72px) clamp(22px, 4vw, 80px) !important;
  overflow: hidden !important;
}

.screen.active#flowScreen {
  display: flex !important;
}

#flowScreen .panel {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  width: min(92vw, 1080px) !important;
  max-height: 92vh !important;
  padding: clamp(20px, 3.2vh, 54px) clamp(20px, 4vw, 64px) !important;
  overflow: hidden !important;
  background: radial-gradient(circle at top left, rgba(254, 208, 15, .16), transparent 34%), rgba(15, 23, 42, .78) !important;
  border: 1px solid rgba(255, 255, 255, .18) !important;
  border-radius: clamp(28px, 4vh, 52px) !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .48) !important;
  backdrop-filter: blur(14px) !important;
}

#flowScreen .panel h1 {
  font-size: clamp(28px, 4.4vh, 68px) !important;
  line-height: 1.02 !important;
  margin-bottom: clamp(6px, 1vh, 14px) !important;
  color: #ffffff !important;
  font-weight: 950 !important;
  letter-spacing: -0.04em !important;
  text-shadow: 0 8px 30px rgba(0,0,0,.42) !important;
}

#flowScreen .panel p {
  font-size: clamp(16px, 2vh, 30px) !important;
  line-height: 1.2 !important;
  margin-bottom: clamp(12px, 2vh, 28px) !important;
  color: rgba(255,255,255,.78) !important;
  font-weight: 700 !important;
}

#flowScreen .options {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: clamp(8px, 1.3vh, 16px) !important;
}

#flowScreen .options button {
  width: 100% !important;
  min-height: clamp(84px, 11vh, 150px) !important;
  padding: clamp(14px, 2.2vh, 26px) clamp(16px, 3vw, 30px) !important;
  border: 0 !important;
  border-radius: clamp(20px, 2.8vh, 36px) !important;
  background: linear-gradient(135deg, #FED00F 0%, #facc15 55%, #f59e0b 100%) !important;
  color: #111827 !important;
  font-size: clamp(20px, 3vh, 44px) !important;
  line-height: 1.05 !important;
  font-weight: 950 !important;
  text-align: center !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255,255,255,.45) !important;
  cursor: pointer !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

#flowScreen .options button:active {
  transform: scale(.985) !important;
}

.option-title {
  font-size: 1em;
  font-weight: 950;
  line-height: 1.05;
}

.option-subtitle {
  margin-top: 8px;
  font-size: .52em;
  line-height: 1.15;
  font-weight: 700;
  opacity: .72;
  max-width: 90%;
}


/* ==========================================================================
   5. TELA DE MENSAGENS - EXPANSÃO DO CARD E FLUXO NATURAL
   ========================================================================== */
#messageScreen {
  width: 100vw;
  height: 100vh;
  padding: 3vh 4vw !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
    align-items: center;
  justify-content: center;
}

#messageScreen .messageBox {
  width: min(92vw, 1080px) !important;
  max-width: 94% !important;
  height: auto !important;
  max-height: 82vh !important; /* Aumentado para dar margem de cálculo ao JS */
  
  padding: clamp(24px, 4vh, 48px) !important;
  box-sizing: border-box !important;
  background: rgba(15, 23, 42, .88) !important; 
  border: 1px solid rgba(255, 255, 255, .2) !important;
  border-radius: 44px !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6) !important;
  
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: center !important;
  overflow: hidden !important; 
}

#messageTitle {
  width: 100% !important;
  flex-shrink: 0 !important;
  margin: 0 0 16px 0 !important;
  color: #fef3c7 !important;
  font-size: var(--message-title-size, 38px) !important;
  line-height: 1.15 !important;
  text-align: center !important;
  font-weight: 900 !important;
}

#messageText {
  width: 100% !important;
  height: auto !important;
  margin: 0 auto 12px auto !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: var(--message-text-size, 32px) !important;
line-height: var(--message-text-line, 1.08) !important;
  text-align: center !important;
  overflow: hidden !important;
  display: block !important;
  max-height: none !important;
  flex-grow: 1 !important;
}

/* Formatações internas */
#messageText .msg-main { font-size: 1.1em; line-height: 1.3; }
#messageText .msg-footer { margin-top: 12px; text-align: center; opacity: .9; }
#messageText .msg-divider { width: 50%; margin: 12px auto; border: none; border-top: 2px solid rgba(255, 255, 255, .25); }


/* ==========================================================================
   6. RODAPÉ COMPACTO E CONTROLES CORRIGIDOS
   ========================================================================== */
#messageQrBox {
  width: 100% !important;
  margin-top: auto !important; /* Empurra o rodapé sempre para a base do card */
  flex-shrink: 0 !important;
  transform-origin: bottom center !important;
  overflow: hidden !important;
}

.messageFooterCompact {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: 22px;
  background: rgba(0,0,0,.3);
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 16px;
  align-items: center;
  box-sizing: border-box;
}

.messageSponsorCompact {
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.supportText {
  font-size: 13px;
  line-height: 1.1;
  opacity: .75;
  margin-bottom: 6px;
}

.sponsorNameCompact {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
}

.sponsorLogoCompact {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255,255,255,.05);
  padding: 4px;
}

.messageQrCompact {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qrTitleCompact {
  color: #FED00F;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 6px;
  white-space: nowrap;
}

#localQrCanvas {
  width: 84px !important;
  height: 84px !important;
  padding: 4px !important;
  border-radius: 10px !important;
  background: #fff !important;
}


/* ==========================================================================
   7. TEMAS DINÂMICOS POR CAMPANHA
   ========================================================================== */
#flowScreen.campaign-themed,
#messageScreen.campaign-themed {
  background-color: #030712;
}

#flowScreen.campaign-themed .panel,
#messageScreen.campaign-themed .messageBox {
  background: rgba(15, 23, 42, .92) !important;
  backdrop-filter: blur(8px);
  border-color: var(--campaign-primary, #FED00F) !important;
}

#flowScreen.campaign-themed .panel h1 {
  color: var(--campaign-primary, #FED00F) !important;
}


/* ==========================================================================
   8. AJUSTES ESPECÍFICOS - REMOVIDO CONFLITOS DE ALTURA
   ========================================================================== */
@media (max-height: 850px) {
  #messageScreen .messageBox {
    max-height: 85vh !important; /* Mantém área limpa sem achatar o fluxo */
    padding: 20px !important;
  }
  #flowScreen .options button {
    min-height: clamp(60px, 9vh, 110px) !important;
  }
}

.messageFooterCompact {
  grid-template-columns: 1fr 130px !important;
  max-width: 500px !important;
  gap: 10px !important;
}

.messageSponsorCompact {
  max-width: 180px !important;
}

.supportText,
.sponsorNameCompact {
  font-size: 11px !important;
  line-height: 1.05 !important;
}

.qrTitleCompact {
  font-size: 13px !important;
  line-height: 1.05 !important;
  white-space: normal !important;
  max-width: 120px !important;
  text-align: center !important;
}

.sponsorLogoCompact {
  width: 58px !important;
  height: 58px !important;
}

#localQrCanvas {
  width: 76px !important;
  height: 76px !important;
}