/* Estilos Gerais */
body {
  background-image: url('https://i.imgur.com/rlwBK6p.jpeg');
  background-size: cover;
  font-family: 'Arial Black', sans-serif;
  text-align: center;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  line-height: 1.4;
}

h1 { color: #333333; margin: 20px 0; }

/* Overlay de loading global */
#global-loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#global-loading .global-loading-box {
  background: #111;
  color: #fff;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 20px 24px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Layout principal */
#layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px 24px;
}

/* Pontuação */
#score { font-size: 24px; margin: 10px 0; color: #000; font-weight: 700; display: none; }

/* Dificuldade */
#difficulty-select {
  padding: 10px; font-size: 18px; border: 2px solid #000; border-radius: 5px;
  background-color: #fff; color: #333; transition: border-color .3s;
}
#difficulty-select:hover { border-color: #000000; }
#difficulty-selection { margin: 20px 0; }
#difficulty-select:focus,
#difficulty-select:active {
  outline: none;
  border-color: #000000;
  background-color: #ffffff;
  color: #000000;
}

/* Categorias */
.category-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px; margin: 20px 0;
}
.category-grid label {
  background-color: #fff;
  border: 2px solid #000000;
  border-radius: 5px;
  padding: 15px;
  cursor: pointer;
  transition: background-color .3s, transform .2s, color .3s;
  text-align: center;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-grid input[type="checkbox"] { display: none; }
.category-grid label:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}
.category-grid label:has(input[type="checkbox"]:checked) {
  background-color: #151715 !important;
  color: #fff !important;
  border-color: #333 !important;
}

/* Botões base */
.button, .game-button {
  background-color: #000;
  color: #fff;
  padding: 15px 50px;
  font-size: 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px;
  width: 80%;
  max-width: 200px;
  transition: background-color .3s, color .3s;
}
.button.disabled { opacity: 1.0; pointer-events: none; }
.button:hover, .game-button:hover { background-color: #333; color: #f1f1f1; }
.button:active { transform: scale(.95); }

/* Botões de prêmios */
#stop-prize { cursor: pointer; }
#stop-prize:hover { background-color: #e40303; transform: scale(1.05); transition: background-color .3s, transform .2s; }
#lose-prize, #win-prize {
  cursor: default; background-color: #000; color: #fff; padding: 15px 50px; font-size: 20px;
  border: none; border-radius: 5px; margin: 10px; width: 80%; max-width: 200px; transition: none;
}
#lose-prize:hover, #win-prize:hover { background-color: #000; color: #fff; }

/* Spinner reutilizado */
.spinner {
  border: 8px solid #f3f3f3; border-top: 8px solid #000; border-radius: 50%;
  width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 10px auto;
}
@keyframes spin { 0% {transform: rotate(0)} 100% {transform: rotate(360deg)} }

/* Power-ups (container) */
#power-ups {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  display: none;                /* aparece ao iniciar o jogo */
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Placeholder quando todos os poderes foram usados (somente mobile/tablet) */
.power-ups-empty {
  display: none;
  font-size: 14px;
  color: #555;
  padding: 8px 12px;
  background: #fff;
  border: 1px dashed #ccc;
  border-radius: 8px;
}

/* grade interna dos botões */
.grid { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.power-up {
  width: 200px; padding: 15px; font-size: 18px; cursor: pointer; background-color: #000; color: #fff;
  border: none; border-radius: 8px; transition: background-color .3s, color .3s, opacity .3s, transform .3s;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}
.power-up:hover { background-color: #7b7676; color: #000; }

/* Estado "usado": mantém o espaço do botão para não colapsar layout e mostra etiqueta clara */
.power-up.used {
  position: relative;
  color: transparent;
  cursor: not-allowed;
  opacity: .85;
  background: #e9ecef;
  border: 1px solid #d0d7de;
}
.power-up.used::after {
  content: "✔ Usado";
  color: #111;
  font-weight: 700;
  letter-spacing: .3px;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

/* animação de flip */
@keyframes powerFlip {
  0%   { transform: rotateY(0deg); }
  40%  { transform: rotateY(90deg); }
  60%  { transform: rotateY(90deg); }
  100% { transform: rotateY(180deg); }
}
.power-up.animating {
  animation: powerFlip 800ms cubic-bezier(.4,.0,.2,1) forwards;
  pointer-events: none;
}
.power-up.animating::before {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  transform: translateZ(1px);
}

/* Próxima */
#next-button {
  margin-top: 10px; padding: 10px 20px; font-size: 18px; cursor: pointer; background-color: #000; color: #fff;
  border: none; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,.3); transition: background-color .3s, color .3s;
  display: none;
}
#next-button:hover { background-color: #007BFF; color: #fff; }

/* Quiz container */
#quiz-container {
  margin: 20px auto; padding: 20px; background-color: #fff; border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,.2); max-width: 700px; width: 100%; opacity: 0;
  transition: opacity .5s ease; display: none;
}

/* Cartão de prêmios */
.card-like {
  margin: 20px auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
  max-width: 700px;
  width: 100%;
}
.prizes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px 16px;
  place-items: center;
}

/* Pergunta e opções */
#question { font-size: 24px; margin-bottom: 20px; color: #000; min-height: 56px; }
#options button {
  display: block; margin: 10px auto; padding: 15px 30px; font-size: 20px; cursor: pointer;
  background-color: #060606; color: #fff; border: none; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,.3);
  transition: background-color .3s, transform .2s;
}
#options button:hover { background-color: #7b7676; color: #000; }

/* Estados de resposta */
.correct { background-color: #4CAF50 !important; color: #fff !important; }
.incorrect { background-color: #F44336 !important; color: #fff !important; }

/* Modal: Ajuda do Público */
#audience-help {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #111;
  color: #fff;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
#audience-help .modal-content {
  width: min(680px, 92vw);
  max-height: min(84vh, 720px);
  background: #1b1b1b;
  color: #fff;
  border: 1px solid #333;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  padding: 20px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
#audience-help h2 { margin: 0 0 8px 0; color: #fff; }
#audience-votes { text-align: left; font-size: 16px; line-height: 1.5; }
.audience-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 16px;
  height: 240px;
  width: 100%;
}
#audience-help .modal-content .audience-chart canvas {
  width: 100% !important;
  height: 100% !important;
}
#close-audience-help {
  align-self: center;
  margin-top: 4px;
  padding: 10px 20px;
  font-size: 18px;
  cursor: pointer;
  background-color: #27ae60;
  color: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,.3);
  transition: background-color .3s, transform .2s;
}
#close-audience-help:hover { background-color: #1e8449; transform: scale(1.05); }

/* Modal: Cartas */
#card-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0,0,0,.7);
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
#card-modal .modal-content {
  background: #ffffff;
  color: #111;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  padding: 20px;
  width: min(640px, 92vw);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: auto;
}
#card-modal h2 { margin: 0 0 8px 0; }
#card-container {
  display: flex;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
  gap: 10px;
  padding: 10px;
  flex-wrap: wrap;
}
.card { width: 100px; height: 150px; perspective: 1000px; cursor: pointer; flex: 0 0 auto; }
.card-inner { width: 100%; height: 100%; position: relative; transition: transform .6s; transform-style: preserve-3d; }
.card-front, .card-back {
  width: 100%; height: 100%; position: absolute; backface-visibility: hidden; display: flex; align-items: center;
  justify-content: center; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,.3);
}
.card-front { background-image: url('imagens/prabaixo.png'); background-size: cover; background-position: center; }
.card-back { background-size: 101%; background-repeat: no-repeat; background-position: center; transform: rotateY(180deg); }
.card.flipped .card-inner { transform: rotateY(180deg); }

/* Voltar/Recomeçar */
#back-button {
  margin-top: 20px; padding: 10px 20px; font-size: 18px; cursor: pointer; background-color: #27ae60; color: #fff;
  border: none; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,.3); transition: background-color .3s, transform .2s;
}
#back-button:hover { background-color: #218c54; transform: scale(1.05); }
#restart-inline { margin-top: 12px; }

/* Card Final: garantir centralização perfeita */
#final-result {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  max-width: 700px;
  width: 100%;
}

/* Quando a tela final estiver visível, centralizar o layout verticalmente no desktop */
body.final-state main#layout {
  min-height: calc(100vh - 120px); /* compensar header/footer */
  display: grid;
  align-items: center;   /* vertical */
  justify-items: center; /* horizontal */
}

/* Em estado final, manter o card no centro e a coluna central ocupando a largura do card */
body.final-state #center-pane {
  width: 100%;
  display: grid;
  justify-items: center;
}

body.final-state #final-result {
  display: block !important;
}

/* Rodapé */
footer { background-color: #424242; color: #fff; font-size: 14px; padding: 10px 0; width: 100%; text-align: center; }

/* Respostas em duas colunas em telas médias */
@media (min-width: 560px) {
  #options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  #options button { width: 100%; margin: 0; }
}

/* Ajuste mobile: padroniza os três botões (Errar, Parar, Acertar) */
@media (max-width: 900px) {
  /* Garante uma única coluna já existente */
  .prizes-grid { grid-template-columns: 1fr; }

  /* Contêiner de cada “bloco” de prêmio ocupa 100% */
  #prizes > div {
    width: 100%;
  }

  /* Botões com largura 100%, mesma altura e tipografia consistente */
  #prizes .game-button {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 48px;         /* altura consistente */
    padding: 12px 16px;       /* padding uniforme */
    font-size: 18px;          /* tipografia uniforme */
    line-height: 1.2;
    box-sizing: border-box;   /* inclui padding na largura */
    border-radius: 10px;      /* mesmo raio nos três */
  }

  /* Remove diferenças visuais no hover em mobile (opcional) */
  #prizes .game-button:hover {
    background-color: #000;
    color: #fff;
    transform: none;
  }

  /* Mantém o botão de Parar com a mesma basex1, mas sem “crescer” no hover */
  #stop-prize {
    cursor: pointer;
    background-color: #000;   /* mesma cor base dos demais para igualdade */
  }
  #stop-prize:hover { background-color: #e40303; transform: scale(1.05); transition: background-color .3s, transform .2s; }
}

/* Desktop (>= 901px) */
@media (min-width: 901px) {
  body.game-started #layout {
    grid-template-columns: 320px 1fr;
    align-items: start;
    gap: 32px;
    padding: 0 24px 40px;
  }

  /* Sidebar fixa dos power-ups */
  #power-ups {
    display: none;
    position: sticky;
    top: 20px;
    z-index: 2;
    max-height: calc(100vh - 40px);
    overflow: auto;
  }

  #difficulty-selection,
  #category-selection.category-grid {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    justify-content: center;
  }
  #quiz-container { max-width: 860px; margin-left: auto; margin-right: auto; }
  .card-like { max-width: 860px; margin-left: auto; margin-right: auto; }
  #question { font-size: 26px; }

  /* Centralizar ainda mais o card final em telas grandes */
  #final-result {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Estado final no desktop: ocupar largura total e centralizar completamente */
  body.final-state #layout {
    grid-template-columns: 1fr !important;   /* remove coluna da sidebar */
    padding: 0 24px 40px;
  }
  body.final-state #power-ups { display: none !important; } /* esconde a coluna vazia */
}

/* Ultra-wide */
@media (min-width: 1200px) {
  #quiz-container { max-width: 900px; }
  .card-like { max-width: 900px; }
  #options button { font-size: 20px; padding: 16px 28px; }
}