@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&display=swap');

:root {
  --laranja: #ff8a3d;
  --azul-ceu: #a5d8ff;
  --verde: #2ecc71;
  --vermelho: #ff7675;
  --roxo: #a29bfe;
  --azul-escuro: #2196f3;

  /* Alterado para vmin para se adaptar tanto em largura quanto em altura */
  --cell: clamp(60px, 18vmin, 140px);
  --gap: clamp(8px, 2vmin, 16px);
  --board-pad: clamp(10px, 2.5vmin, 20px);
}

html, body { height: 100%; }

body {
  font-family: 'Fredoka', sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

@supports (min-height: 100svh){ body{ min-height: 100svh; } }

.texto-bolha { text-shadow: 0px 4px 0px rgba(0,0,0,0.1), 0px 8px 0px rgba(0,0,0,0.05); font-weight: 900; letter-spacing: 1px; }

.overlay { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 15px; box-sizing: border-box; background: rgba(165, 216, 255, 0.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow-y: auto; }

.card-info { background: white; border-radius: 40px; padding: 22px; max-width: 520px; width: min(95%, 520px); box-shadow: 0 20px 40px rgba(0,0,0,0.15), inset 0 -6px 0 rgba(0,0,0,0.05); animation: entrada 0.35s ease-out; box-sizing: border-box; position: relative; margin: auto; }
.card-info::before { content: ""; position: absolute; top: -20px; left: 30px; width: 70px; height: 70px; background: white; border-radius: 50%; z-index: -1; }
.card-info::after { content: ""; position: absolute; top: -30px; right: 40px; width: 90px; height: 90px; background: white; border-radius: 50%; z-index: -1; }
@keyframes entrada { from { transform: scale(0.92) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

.regras-rapidas { background: #fff9f0; border-radius: 25px; padding: 15px; margin-bottom: 18px; font-size: 0.95rem; text-align: left; color: #666; box-shadow: inset 0 3px 6px rgba(0,0,0,0.05); }
.regras-rapidas h3 { margin: 0 0 8px 0; font-size: 1.1rem; color: var(--laranja); text-align: center; }
.regra-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: bold;}

.btn-modo, .btn-acao { font-family: 'Fredoka'; border-radius: 30px; font-weight: bold; cursor: pointer; width: 100%; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: 0.2s; }
.btn-modo { background: white; border: 4px solid var(--roxo); color: var(--roxo); padding: 14px; margin-bottom: 12px; font-size: 1.15rem; box-shadow: 0 6px 0 rgba(162, 155, 254, 0.2); }
.btn-modo:hover, .btn-modo:active { background: var(--roxo); color: white; transform: translateY(3px); box-shadow: 0 3px 0 rgba(162, 155, 254, 0.2); }

.btn-acao { background: var(--verde); color: white; border: none; padding: 16px; font-size: 1.2rem; margin: 8px 0; box-shadow: 0 6px 0 #27ae60; }
.btn-acao:active { transform: translateY(4px); box-shadow: 0 2px 0 #27ae60; }
.btn-acao:disabled { background: #ccc; box-shadow: 0 6px 0 #999; cursor: not-allowed; transform: none; }

.btn-online { border-color: var(--azul-escuro); color: var(--azul-escuro); box-shadow: 0 6px 0 rgba(33, 150, 243, 0.2); }
.btn-online:hover, .btn-online:active { background: var(--azul-escuro); color: white; box-shadow: 0 3px 0 rgba(33, 150, 243, 0.2); }

.input-nome { width: min(88%, 360px); padding: 14px; border: none; background: #f1f5f9; border-radius: 20px; font-family: 'Fredoka'; font-size: 1.1rem; margin-bottom: 8px; text-align: center; box-sizing: border-box; color: #333; box-shadow: inset 0 3px 6px rgba(0,0,0,0.05); }
.select-dificuldade { appearance: none; cursor: pointer; background: #f1f5f9; font-weight: bold;}

.codigo-sala { font-size: 1.5rem; letter-spacing: 2px; color: var(--roxo); font-weight: bold; background: #f1f5f9; padding: 10px; border-radius: 15px; margin-bottom: 15px; user-select: all; display: inline-block; }

/* ESTILOS DE AVATAR */
.secao-jogador { background: #fffdf5; padding: 12px; border-radius: 20px; margin-bottom: 15px; border: 2px dashed #fcd5ce; }
.lbl-jogador { font-weight: bold; color: var(--laranja); margin-bottom: 5px; font-size: 1.1rem; }
.box-avatares { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.btn-avatar { font-size: 1.6rem; background: white; border: 3px solid transparent; border-radius: 15px; padding: 5px; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.05); user-select: none; -webkit-tap-highlight-color: transparent;}
.btn-avatar.ativo { border-color: var(--roxo); transform: scale(1.15); box-shadow: 0 6px 12px rgba(162, 155, 254, 0.3); background: #f4f2ff; }

.btn-simbolo { width: 88px; height: 88px; border-radius: 25px; border: none; background: #f1f5f9; font-size: 3rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; box-shadow: 0 6px 0 rgba(0,0,0,0.05); }
.btn-simbolo:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.05); }
.btn-simbolo.X { color: var(--vermelho); }
.btn-simbolo.O { color: var(--azul-escuro); }

/* BOTOES TOPO */
.topo { width: 100%; padding: 16px 0; display: flex; justify-content: center; align-items: center; background: rgba(255, 255, 255, 0.85); z-index: 50; position: sticky; top: 0; box-shadow: 0 4px 15px rgba(0,0,0,0.05); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

.botoes-topo-esq { position: absolute; left: 15px; display: flex; gap: 10px; }

.btn-topo { font-family: 'Fredoka', sans-serif; text-decoration: none; color: white; padding: 12px 20px; border-radius: 50px; font-weight: bold; font-size: 1.1rem; border: none; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;}

.btn-topo-sair { background: var(--vermelho); box-shadow: 0 4px 0 #d63031; }
.btn-topo-sair:active { transform: translateY(3px); box-shadow: 0 1px 0 #d63031; }

.btn-topo-menu { background: var(--azul-escuro); box-shadow: 0 4px 0 #1976d2; }
.btn-topo-menu:active { transform: translateY(3px); box-shadow: 0 1px 0 #1976d2; }

/* ======== PLACAR SUPERIOR ======== */
.placar-geral { display: flex; align-items: center; background: rgba(255, 255, 255, 0.6); border-radius: 50px; padding: 8px 15px; gap: 15px; box-shadow: inset 0 2px 10px rgba(255,255,255,0.5); }

.ponto-box { display: flex; align-items: center; gap: 12px; padding: 6px 20px 6px 8px; border-radius: 40px; background: white; min-width: 140px; transition: all 0.3s ease; box-shadow: 0 6px 15px rgba(0,0,0,0.08); }
.ponto-box.invertido { padding: 6px 8px 6px 20px; }

.avatar-placar { font-size: 2.2rem; background: #f1f5f9; border-radius: 50%; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 4px 8px rgba(0,0,0,0.05); line-height: 1; margin-top: -2px;}
.info-placar { text-align: center; display: flex; flex-direction: column; justify-content: center; flex: 1; }

.ponto-box span { font-size: 0.85rem; font-weight: bold; color: #888; text-transform: uppercase; white-space: nowrap; margin-bottom: -2px;}
.ponto-box b { font-size: 2.2rem; color: #555; line-height: 1; }

.placar-vs { font-size: 1.4rem; font-weight: 900; color: var(--roxo); text-shadow: 0 2px 0 rgba(162, 155, 254, 0.3); }

.ponto-box.ativo { background: var(--laranja); color: white; animation: pulsoVez 1.5s infinite ease-in-out; box-shadow: 0 8px 20px rgba(255, 138, 61, 0.4); }
.ponto-box.ativo span, .ponto-box.ativo b { color: white; }
.ponto-box.ativo .avatar-placar { background: rgba(255,255,255,0.25); box-shadow: none; }
.ponto-box:not(.ativo) { opacity: 0.6; transform: scale(0.95); }

@keyframes pulsoVez { 0%, 100% { transform: scale(1.05) rotate(-1deg); } 50% { transform: scale(1.08) rotate(1deg); } }

.painel-jogo { background: white; border-radius: 50px; padding: 30px; margin: 50px 15px 90px 15px; position: relative; z-index: 20; box-shadow: 0 20px 40px rgba(0,0,0,0.08), inset 0 -10px 0 rgba(0,0,0,0.03); }
.painel-jogo::before { content: ""; position: absolute; top: -35px; left: 30px; width: 100px; height: 100px; background: white; border-radius: 50%; z-index: -1; }
.painel-jogo::after { content: ""; position: absolute; top: -45px; right: 40px; width: 130px; height: 130px; background: white; border-radius: 50%; z-index: -1; }
.painel-jogo-extra { content: ""; position: absolute; bottom: -20px; left: 50px; width: 90px; height: 90px; background: white; border-radius: 50%; z-index: -1; }

#tabuleiro { display: grid; grid-template-columns: repeat(3, var(--cell)); grid-template-rows: repeat(3, var(--cell)); gap: var(--gap); background: #a5d8ff; padding: var(--board-pad); border-radius: 35px; box-shadow: inset 0 6px 15px rgba(0,0,0,0.1); }
.casa { width: var(--cell); height: var(--cell); background: white; border-radius: 20px; display: flex; justify-content: center; align-items: center; font-size: clamp(2.5rem, 12vmin, 5.5rem); font-weight: bold; cursor: pointer; box-shadow: 0 8px 15px rgba(0,0,0,0.08); transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease; }
@media (hover: hover) { .casa:empty:hover { transform: scale(1.08); background: #fffdf2; box-shadow: 0 10px 25px rgba(255, 215, 0, 0.4), inset 0 0 15px rgba(255, 230, 0, 0.2); } }
.casa:active { transform: scale(0.95); }

.vitoria-aluno { background: var(--verde) !important; color: white !important; box-shadow: 0 0 30px var(--verde) !important;}
.vitoria-inimigo { background: var(--vermelho) !important; color: white !important; box-shadow: 0 0 30px var(--vermelho) !important;}

.linha-vitoria { position: absolute; left: 0; top: 0; height: 16px; border-radius: 999px; opacity: 0; transform-origin: 0 50%; pointer-events: none; box-shadow: 0 10px 20px rgba(0,0,0,0.2); }

/* EMOJI BAR */
.barra-emojis { position: absolute; bottom: -60px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; background: rgba(255,255,255,0.9); padding: 8px 15px; border-radius: 30px; box-shadow: 0 8px 20px rgba(0,0,0,0.15); z-index: 50; }
.btn-reacao { font-size: 1.6rem; background: none; border: none; cursor: pointer; transition: 0.2s; user-select: none; }
.btn-reacao:active { transform: scale(0.7); }
.emoji-pop { position: fixed; font-size: 3.5rem; pointer-events: none; z-index: 300; animation: floatUp 1.5s ease-out forwards; text-shadow: 0 4px 10px rgba(0,0,0,0.2); left: 50%; top: 50%; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 40px) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.2) rotate(-10deg); } 100% { opacity: 0; transform: translate(-50%, -150px) scale(1) rotate(10deg); } }

/* BOTÕES EMPILHADOS NA LATERAL */
.controles-inferiores { 
  position: fixed; 
  z-index: 100; 
  display: flex; 
  flex-direction: column;
  gap: 12px; 
  right: calc(18px + env(safe-area-inset-right)); 
  bottom: calc(18px + env(safe-area-inset-bottom)); 
}
.btn-circular { width: 60px; height: 60px; border-radius: 50%; border: none; background: var(--verde); color: white; font-size: 1.6rem; box-shadow: 0 8px 20px rgba(0,0,0,0.15), inset 0 -4px 0 rgba(0,0,0,0.1); transition: transform 0.2s ease; cursor: pointer; }
.btn-circular:active { transform: translateY(4px); box-shadow: 0 2px 5px rgba(0,0,0,0.15); }
.btn-circular.inativo { background: #b9c1c8; box-shadow: 0 8px 20px rgba(0,0,0,0.1), inset 0 -4px 0 rgba(0,0,0,0.05);}

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.sparkle { position: fixed; width: 12px; height: 12px; border-radius: 50%; background: white; box-shadow: 0 0 15px white, 0 0 25px gold; opacity: 0; animation: sparkle 0.6s ease-out forwards; }
@keyframes sparkle { 0%{ transform: scale(0.4); opacity: 0; } 40%{ transform: scale(1.2); opacity: 1; } 100%{ transform: scale(0.1) translateY(-30px); opacity: 0; } }
.confetti { position: fixed; width: 12px; height: 16px; border-radius: 4px; opacity: 0.98; animation: confettiFall var(--dur) ease-out forwards; }
@keyframes confettiFall { to { transform: translate(var(--dx), calc(110vh + 40px)) rotate(var(--rot)); opacity: 0; } }

/* RESPONSIVIDADE DO TOPO */
@media (max-width: 600px) {
  .btn-topo { padding: 12px; font-size: 1.4rem; gap: 0; }
  .btn-topo span { display: none; }
  
  .ponto-box { min-width: 110px; padding: 4px 12px 4px 4px; gap: 6px;}
  .ponto-box.invertido { padding: 4px 4px 4px 12px; }
  .avatar-placar { width: 40px; height: 40px; font-size: 1.6rem; }
  .ponto-box b { font-size: 1.8rem; }
  .placar-vs { font-size: 1rem; }
}

/* Ajuste específico para garantir que não corte em telas de notebook (ex: 1366x768) */
@media (max-height: 800px) { 
  :root {
    --cell: clamp(60px, 16vh, 110px);
  }
  .painel-jogo { margin-top: 25px; margin-bottom: 70px; padding: 20px; }
  .casa { font-size: clamp(2.5rem, 10vh, 4.5rem); }
}

@media (max-height: 680px) { 
  .painel-jogo { margin-top: 15px; padding: 15px; } 
  .card-info { padding: 18px; } 
  .topo { padding: 12px 0; } 
  .barra-emojis { bottom: -45px; } 
}