/* -------------------- */
/*     BASE E FONTE     */
/* -------------------- */

@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;700&display=swap');

:root {
  --bg: #f3f5f7;
  --text: #1d1d1d;
  --muted: #6d7075;

  --green: #0b7a5b;
  --green-dark: #0e5f49;

  --progress-light: #d9dee3;
  --progress-dark: #0e8576;

  --photo-border: #d4d7dc;

  --orange: #d8832c;
  --red: #c0392b;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  font-family: 'Ubuntu', sans-serif;
  color: var(--text);
  /* margem geral da página */
  padding: 16px 12px 24px;
}

/* global */
.hidden {
  display: none !important;
}

/* -------------------- */
/*       SCREENS        */
/* -------------------- */

.screen {
  width: 100%;
  display: none;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* container principal do game/resultado */
.game-container,
.result-container,
.welcome-container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto 24px;
}

/* -------------------- */
/*   WELCOME OVERLAY    */
/* -------------------- */

.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.75);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-overlay.hidden {
  display: none;
}

.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
}

.welcome-logo {
  max-width: 140px;
  width: 100%;
  height: auto;
  margin-bottom: 8px;
}

.welcome-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px 0;
  background: #ffffff;
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-large {
  padding: 20px 60px;
  font-size: 1.6rem;
  position: relative;
  min-width: 280px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.btn-large.btn-primary {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.btn-large.btn-primary.btn-pulse {
  position: relative;
  overflow: visible;
}

.btn-large.btn-primary.btn-pulse::before,
.btn-large.btn-primary.btn-pulse::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  border: 3px solid rgba(11, 122, 91, 0.6);
  animation: ripple 2s ease-out infinite;
  pointer-events: none;
}

.btn-large.btn-primary.btn-pulse::after {
  animation-delay: 1s;
}

.btn-large.btn-primary:hover:not(:disabled) {
  background-color: #0e5f49 !important;
  background: #0e5f49 !important;
}

.btn-large.btn-primary:active:not(:disabled) {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

.btn-large.btn-primary:disabled {
  opacity: 0.6 !important;
  cursor: not-allowed;
}

.btn-loading {
  display: inline-block;
  margin-left: 8px;
}

.btn-loading.hidden {
  display: none;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes ripple {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.6;
  }
  100% {
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    opacity: 0;
  }
}

/* -------------------- */
/*    PROGRESSO TOPO    */
/* -------------------- */

.top-progress {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-track {
  position: relative;
  flex: 1;
  height: 6px;
  background: var(--progress-light);
  border-radius: 4px;
  margin-right: 12px;
  overflow: visible; /* deixa o boneco sair pra fora da linha */
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--progress-dark);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.runner-icon {
  width: 26px;
  height: 26px;
  position: absolute;
  top: -13px;           /* “sentado” em cima da linha */
  left: 0%;
  transform: translateX(-50%);
  transition: left 0.3s ease;
}

.progress-text {
  font-size: 1.3rem;
  font-weight: 700;
}

/* -------------------- */
/*       FOTO           */
/* -------------------- */

/* wrapper centralizado */
.photo-wrapper {
  width: 100%;
  max-width: 260px;   /* antes era 320px */
  margin: 20px auto 10px;
  position: relative;
}

/* “moldura” da foto com borda fina e fundo branco,
   proporção 4:5 mantida */
.photo-border {
  background: #ffffff;
  border: 2px solid var(--photo-border);
  border-radius: 16px;
  padding: 8px;
  aspect-ratio: 4 / 5;       /* largura : altura = 4:5 */
  overflow: hidden;
  position: relative;
}

/* imagem sempre 4x5, cortando se necessário, mantendo o topo */
#photo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  object-position: center top; /* se cortar na altura, mantém a parte de cima */
  outline: none; /* Remove outline ao receber foco */
}

/* Loading por cima da moldura */
.loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 16px;
}

.loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #ccc;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* -------------------- */
/*        TIMER         */
/* -------------------- */

.timer-display {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;   /* centraliza horizontalmente */
  gap: 8px;
  font-size: 1.8rem;
  font-weight: 700;
}

.clock-icon {
  width: 30px;
}

/* -------------------- */
/*      OPÇÕES          */
/* -------------------- */

.options-grid {
  width: 100%;
  max-width: 520px;
  margin: 20px auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.option-btn {
  padding: 18px 12px;
  font-size: 1rem;
  border-radius: 12px;
  background: #ffffff;
  background-color: #ffffff;
  border: 2px solid var(--photo-border);
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s;
  outline: none;
}

/* Mata qualquer foco visual em botões de opção, em qualquer navegador */
.option-btn,
.option-btn:focus,
.option-btn:focus-visible {
  border: 2px solid var(--photo-border) !important;
  outline: none !important;
}

/* Firefox tem uma borda interna especial de foco em botões */
.option-btn::-moz-focus-inner {
  border: 0 !important;
}

/* 👇 garante que foco NÃO mude visualmente em relação aos outros */
.option-btn:focus,
.option-btn:focus-visible {
  outline: none;
  border-color: var(--photo-border);
}

.option-btn:hover:not(.disabled):not(.selected) {
  border-color: var(--green);
}

.option-btn.selected {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  border-color: #0b7a5b !important;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.option-btn.selected:active,
.option-btn.selected:focus {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

.option-btn.disabled.selected {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  opacity: 1 !important;
  pointer-events: none;
  filter: none !important;
  -webkit-filter: none !important;
}

.option-btn.disabled:not(.selected) {
  opacity: 0.4;
  cursor: not-allowed;
}

/* -------------------- */
/*    BOTÃO ENVIAR      */
/* -------------------- */

.prosseguir-btn {
  margin-top: 10px;
  width: 100%;
  max-width: 520px;
  padding: 18px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  cursor: pointer;
  transition: 0.2s;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
  display: none !important; /* ESCONDIDO: envio automático ao clicar */
}

.prosseguir-btn:active,
.prosseguir-btn:focus {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

.prosseguir-btn:disabled {
  opacity: 0.4 !important;
  cursor: not-allowed;
}

.prosseguir-btn:not(:disabled) {
  opacity: 1 !important;
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
}

.prosseguir-btn:not(:disabled):hover {
  background-color: #0e5f49 !important;
  background: #0e5f49 !important;
}

/* -------------------- */
/*   RESULT SCREEN      */
/* -------------------- */

#result-screen {
  margin-top: 12px;
}

/* card de resultado no mesmo estilo “premium” */
.result-container {
  background: #ffffff;
  border-radius: 18px;
  padding: 24px 20px 28px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
  text-align: center;
}

.result-container h1 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 700;
}

/* bloco principal de score */
.result-score {
  margin-bottom: 20px;
}

.score-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 6px;
}

#feedback-message {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

/* estatísticas (acertos / tempo) */
.stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 22px 0;
}

.stat-item {
  background: #f0f2f5;
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 110px;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green);
}

/* bloco de ranking */
.ranking-info {
  background: #f0f2f5;
  border-radius: 12px;
  padding: 14px 14px 16px;
  margin-bottom: 18px;
}

.ranking-info p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.ranking-cta {
  font-weight: 600;
  color: var(--text);
}

.btn-ranking {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 18px;
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: 0.2s;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
  border: none;
}

.btn-ranking:hover {
  background-color: #0e5f49 !important;
  background: #0e5f49 !important;
}

.btn-ranking:active,
.btn-ranking:focus {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

/* botões de ação final */
.actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: 0.2s;
}

.btn-primary {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.btn-primary:hover {
  background-color: #0e5f49 !important;
  background: #0e5f49 !important;
}

.btn-primary:active,
.btn-primary:focus {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

.btn-ghost {
  background: transparent;
  color: var(--green-dark);
  border: 2px solid var(--photo-border);
}

.btn-ghost:hover {
  background: #f0f2f5;
}

/* -------------------- */
/*   PAYMENT SCREEN     */
/* -------------------- */

.ranking-revealed {
  background: linear-gradient(135deg, #e8f5f1 0%, #d9e9f7 100%);
  border-radius: 16px;
  padding: 14px 14px 16px;
  margin-bottom: 12px;
}

.ranking-revealed h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
  text-align: center;
}

.ranking-position {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.position-badge,
.percentile-badge {
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  text-align: center;
  min-width: 100px;
}

.position-number,
.percentile-text {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
}

.ranking-country {
  background: linear-gradient(135deg, #fff8e8 0%, #f7f0d9 100%);
}

.ranking-country.hidden {
  display: none;
}

.congratulations {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.5;
}

/* -------------------- */
/*   COMPARTILHAMENTO   */
/* -------------------- */

.share-section {
  margin: 20px 0;
  padding: 16px;
  background: #f9fafb;
  border-radius: 12px;
  text-align: center;
}

.share-cta {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-secondary {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  color: #ffffff !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.btn-secondary:hover {
  background-color: #0e5f49 !important;
  background: #0e5f49 !important;
}

.btn-secondary:active,
.btn-secondary:focus {
  background-color: #0b7a5b !important;
  background: #0b7a5b !important;
  opacity: 1 !important;
}

/* -------------------- */
/*        MODAL         */
/* -------------------- */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#history-modal {
  z-index: 99999;
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.3s ease;
  box-sizing: border-box;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green-dark);
}

.btn-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  transition: 0.2s;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.share-description {
  margin: 0 0 20px;
  color: var(--muted);
  text-align: center;
}

.share-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.share-option-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.share-option-btn.whatsapp {
  background: #25D366;
  color: #ffffff;
}

.share-option-btn.whatsapp:hover {
  background: #1da851;
}

.share-option-btn.instagram {
  background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: #ffffff;
}

.share-option-btn.instagram:hover {
  opacity: 0.9;
}

.share-option-btn.copy {
  background: #6366f1;
  color: #ffffff;
}

.share-option-btn.copy:hover {
  background: #4f46e5;
}

.share-link-preview {
  position: relative;
  margin-top: 20px;
}

.share-link-preview input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: monospace;
  color: var(--muted);
  background: #f9fafb;
}

.link-copiado {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--green);
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* -------------------- */
/*      RESPONSIVO      */
/* -------------------- */

@media (max-width: 600px) {
  .timer-display {
    font-size: 1.5rem;
  }

  .photo-border {
    padding: 8px;
  }

  .option-btn {
    font-size: 0.95rem;
    padding: 16px 8px;
  }

  .score-big {
    font-size: 2.5rem;
  }
}

/* -------------------- */
/*   CHECKOUT MODAL     */
/* -------------------- */

.benefits-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 30px;
}

.benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 10px;
  transition: 0.2s;
}

.benefit-item:hover {
  background: #f3f5f7;
  transform: translateY(-2px);
}

.benefit-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.benefit-text {
  flex: 1;
}

.benefit-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.benefit-text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Container geral do bloco de pagamento (texto + spinner + botão) */
.checkout-ui {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center; /* centraliza tudo horizontalmente */
}

/* Label de preço acima do spinner/botão */
.checkout-price-label {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  color: var(--green-dark);
}

/* Área que representa exatamente o “retângulo do botão” */
.checkout-slot {
  position: relative;       /* pai do spinner */
  width: 100%;
  max-width: 320px;         /* pode ajustar conforme o botão do Stripe */
}

/* Área do elemento da Stripe */
#express-checkout-element {
  display: block;
  min-height: 52px;         /* altura típica do botão */
}

/* Spinner SOBRE a área do botão, sem empurrar nada pra baixo */
.checkout-loading {
  position: absolute;
  inset: 0;                 /* ocupa todo o espaço da .checkout-slot */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;     /* não bloqueia clique no botão se atrasar */
  z-index: 2;               /* por cima do botão */
}

/* Spinner menorzinho para o checkout */
.checkout-loading .spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* Quando “hidden”, some de vez */
.checkout-loading.hidden {
  display: none;
}

/* -------------------- */
/*   LINK HISTÓRICO     */
/* -------------------- */

.link-historico {
  display: block;
  margin-top: 40px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.link-historico:hover {
  opacity: 1;
  text-decoration: underline;
}

/* -------------------- */
/* LOADING RESULT OVERLAY */
/* -------------------- */

.loading-result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-result-overlay.hidden {
  display: none;
}

.loading-result-content {
  text-align: center;
}

.loading-result-content .spinner {
  margin: 0 auto 16px;
}

.loading-result-content p {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green-dark);
  margin: 0;
}

/* -------------------- */
/*   HISTORY MODAL      */
/* -------------------- */

.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.history-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.history-item:last-child {
  margin-bottom: 0;
}

.history-score {
  font-weight: 700;
  color: var(--green-dark);
}

.history-date {
  font-size: 0.85rem;
  color: var(--muted);
}
