@import url("https://fonts.googleapis.com/css2?family=Fredoka+One&family=Poppins:wght@400;600;800&display=swap");

:root {
  --bg: #0f172a;
  --card: #1e293b;
  --accent: #3b82f6;
  --text: #f1f5f9;
  --green: #10b981;
  --red: #ef4444;
  --gray: #64748b;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--text);
  font-family: "Poppins", sans-serif;
  overflow-x: hidden;
}

/* Layout Geral */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 15px;
  padding-bottom: calc(
    60px + var(--safe-bottom)
  ); /* Espaço para o botão fixo */
}

.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}

.center-content {
  margin-top: auto;
  margin-bottom: auto;
}

/* Título */
h1 {
  font-family: "Fredoka One", cursive;
  font-size: clamp(2.5rem, 8vw, 4rem);
  color: #60a5fa;
  margin-bottom: 25px;
  text-shadow: 0 4px 15px rgba(96, 165, 250, 0.4);
}

/* Setup Box */
.setup-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 30px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.setup-box label {
  font-size: 1.25rem;
  margin-bottom: 5px;
  display: block;
}

.setup-box input {
  width: 100%;
  padding: 10px;
  font-size: 1.25rem;
  text-align: center;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  margin-bottom: 25px;
  font-weight: bold;
}

/* Isso fará com que todos os placeholders fiquem brancos */
.setup-box input::placeholder {
  color: white;
  opacity: 0.7; /* Recomendado para não confundir com o texto já digitado */
}

/* Se quiser branco total (sem transparência) */
.setup-box input::placeholder {
  color: #ffffff;
  opacity: 1;
}

#startBtn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

#joinRoomBtn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

/* Jogo Layout */
.header {
  margin-bottom: 15px;
}

.current-team {
  font-size: 1rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.current-team strong {
  display: block;
  font-size: 1rem;
  color: white;
  margin-top: 5px;
}

/* Placar Compacto */
.scoreboard {
  display: flex;
  gap: 10px;
  margin: 25px;
}

.team-score {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid transparent;
  transition: all 0.3s;
}

.team-score.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
}

.team-score .label {
  font-size: 0.8rem;
  opacity: 0.7;
}

.team-score strong {
  font-size: 1.8rem;
  line-height: 1;
}

/* Dado e Roleta */
.wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 10px 0 25px;
}

.dice {
  width: 80px;
  height: 80px;
  background: white;
  color: var(--bg);
  border-radius: 16px;
  font-size: 3.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  animation: diceJump 1.8s ease-out;
}

.wheel {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 6px solid var(--card);
  box-shadow: var(--shadow);
  animation: spin 3s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.wheel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: conic-gradient(
    #ef4444 0deg 60deg,
    #10b981 60deg 120deg,
    #3b82f6 120deg 180deg,
    #8b5cf6 180deg 240deg,
    #f59e0b 240deg 300deg,
    #ec4899 300deg 360deg
  );
}

.wheel::after {
  content: attr(data-cat);
  position: absolute;
  inset: 12px;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  text-align: center;
  padding: 5px;
  line-height: 1.1;
}

/* Palavra e Dica */
.info {
  font-size: 1.1rem;
  color: #94a3b8;
  min-height: 1.5rem;
}

.word {
  font-size: 1.5rem;
  background: rgb(0 0 0 / 7%);
  color: var(--text);
  border-radius: 16px;
  margin: 10px 0 30px;
  padding: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  word-wrap: break-word;
  transition: opacity 0.3s;
}

.word.loading {
  opacity: 0.6;
  font-style: italic;
}

/* Área de Ações */
.actions-area {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Botão Próxima Rodada (Grande) */
#playRound {
  width: 100%;
  padding: 20px;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 18px;
  border: none;
  background: linear-gradient(45deg, #3b82f6, #2563eb);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s;
}

#playRound:active {
  transform: scale(0.98);
}

/* Ajuste para caber 3 botões */
.decision-buttons {
  display: flex;
  gap: 8px; /* Reduzi levemente o gap */
  width: 100%;
}

.btn-decision {
  flex: 1;
  padding: 12px 5px; /* Padding lateral menor para telas pequenas */
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: white;
  font-weight: 700;
  font-size: 0.8rem; /* Fonte levemente menor */
  transition: transform 0.2s, opacity 0.3s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-decision svg {
  width: 24px;
  height: 24px;
}

.btn-decision.correct {
  background: var(--green);
}
.btn-decision.skip {
  background: var(--red);
}

/* Estilo do botão Trocar */
.btn-decision.reroll {
  background: #f59e0b; /* Âmbar/Laranja */
  color: white;
}

/* Estado desabilitado para quando acabarem as chances */
.btn-decision:disabled {
  background: #475569;
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

/* Botão Novo Jogo Fixo (Rodapé) */
.floating-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 15px;
  padding-bottom: max(15px, var(--safe-bottom));
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  z-index: 100;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-mini {
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.3s;
}

.btn-mini:hover,
.btn-mini:active {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Tela de Vitória */
.winner-screen h1 {
  font-size: 3rem;
  margin-top: 20px;
}
.winner-text {
  font-size: 1.5rem;
  margin-bottom: 20px;
}
.end.big {
  background: var(--green);
  color: white;
  padding: 15px 30px;
  border-radius: 15px;
  border: none;
  font-weight: bold;
  font-size: 1.2rem;
  width: 100%;
}

/* Animações */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  80% {
    transform: rotate(1100deg);
  }
  100% {
    transform: rotate(1080deg);
  }
}

@keyframes diceJump {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Media Queries */

/* Tablet (iPad Landscape) e Desktop */
@media (min-width: 768px) {
  .game-layout {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Divide em duas colunas */
    grid-template-rows: auto 1fr auto;
    gap: 20px 40px;
    text-align: left;
    max-width: 900px;
    align-items: center;
  }

  .header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 0;
  }
  .scoreboard {
    grid-column: 1 / -1;
  }

  /* Lado Esquerdo: Ferramentas */
  .wrapper {
    grid-column: 1;
    grid-row: 3;
    margin: 0;
    justify-content: flex-end;
  }

  /* Lado Direito: Conteúdo */
  .game-content {
    grid-column: 2;
    grid-row: 3;
    text-align: center;
  }

  .actions-area {
    grid-column: 1 / -1;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .timer-card {
    grid-column: 1 / -1;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }

  .wheel {
    width: 180px;
    height: 180px;
  }
  .dice {
    width: 100px;
    height: 100px;
    font-size: 4rem;
  }

  /* Ajuste do botão fixo no desktop para não ficar "flutuando" estranho */
  .floating-footer {
    position: relative;
    background: transparent;
    border: none;
    padding: 20px;
    margin-top: 20px;
  }
  .screen {
    padding-bottom: 20px;
  }
}

/* Celulares Pequenos */
@media (max-width: 380px) {
  .wheel {
    width: 120px;
    height: 120px;
  }
  .dice {
    width: 70px;
    height: 70px;
    font-size: 3rem;
  }
  h1 {
    font-size: 2.5rem;
  }
  .word {
    font-size: 1.4rem;
    padding: 15px 10px;
  }
}

/* Container do Anúncio */
.ad-box {
  width: 100%;
  max-width: 100%; /* Garante que não estoure a tela no celular */
  margin: 25px auto 10px auto; /* Margem superior generosa para segurança */
  min-height: 100px; /* Altura mínima para evitar CLS (pulo de layout) */
  text-align: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.1); /* Fundo sutil caso o ad demore carregar */
  border-radius: 8px;
  padding: 10px;
}

/* Texto pequeno escrito "Publicidade" (Regra de boa prática) */
.ad-label {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

/* Ajuste para telas maiores (Desktop) */
@media (min-width: 768px) {
  .ad-box {
    grid-column: 1 / -1; /* Ocupa toda a largura na grid do desktop */
    max-width: 728px; /* Tamanho padrão de leaderboard */
  }
}

.tutorial-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.tutorial-screen.active {
  opacity: 1;
  pointer-events: all;
}
.tutorial-content {
  text-align: center;
  margin-top: auto;
  margin-bottom: auto;
}
.tutorial-slide {
  display: none;
  animation: fadeIn 0.6s ease forwards;
}
.tutorial-slide.active {
  display: block;
}
.tutorial-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  display: block;
}
.tutorial-title {
  font-family: "Fredoka One", cursive;
  font-size: 2.2rem;
  color: #60a5fa;
  margin: 20px 0;
}
.tutorial-text {
  font-size: 1.2rem;
  line-height: 1.6;
  color: #cbd5e1;
  max-width: 90%;
  margin: 0 auto;
}
.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 30px 0;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  transition: all 0.3s;
}
.dot.active {
  background: var(--accent);
  transform: scale(1.4);
}
.tutorial-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}
.btn-tutorial {
  padding: 14px 30px;
  border-radius: 15px;
  font-weight: 700;
  font-size: 1.1rem;
  border: none;
  cursor: pointer;
}
.btn-skip {
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-next {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.welcome-subtitle {
  font-size: 1.3rem;
  color: #94a3b8;
  margin: 10px 0 40px;
  font-weight: 500;
}
#timerDisplay {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  margin: 10px 0;
  font-family: "Fredoka One", cursive;
}

#startTimerBtn {
  background: var(--green);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  margin: 0 auto 15px auto;
}
.timer-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}
.history-list-modal {
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 15px;
  padding: 15px;
  margin: 20px 0;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-entry {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
  color: #cbd5e1;
}

.history-entry strong {
  color: var(--accent);
}

.history-entry .points-tag {
  float: right;
  background: var(--green);
  color: white;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: bold;
}
/* Feedback de Copiar */
.copy-feedback {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: bold;
  z-index: 2000;
  animation: fadeInOut 2s forwards;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#displayRoomCode {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

#displayRoomCode:hover {
  background: rgba(59, 130, 246, 0.2);
}
