@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700;900&display=swap');

:root{
  --laranja:#ff9f43;
  --laranja-sombra:#e67e22;
  --azul-ceu:#74b9ff;
  --azul-claro:#c8d6e5;
  --verde:#1dd1a1;
  --verde-sombra:#10ac84;
  --vermelho:#ff6b6b;
  --vermelho-sombra:#ee5253;
  --azul-tile:#5f27cd;
  --fundo-tabuleiro:#121b2b;
  --parede:#0abde3;
  --areia:#feca57;

  --pac-step:360ms;
  --ghost-step:980ms;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:'Fredoka',sans-serif;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  align-items:center;
  min-height:100vh;
  min-height:100svh;
  min-height:100dvh;
  position:relative;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}


header{
  width:100%;
  align-self:stretch;
  padding:10px 18px;
  padding-left:calc(env(safe-area-inset-left) + 18px);
  padding-right:calc(env(safe-area-inset-right) + 18px);
  background:rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 4px solid rgba(255,255,255,0.5);
  z-index:20;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.grupo-esq{display:flex;gap:12px;align-items:center;flex:1 1 auto; justify-content: flex-start;}

.btn-sair, .btn-menu, .btn-grande, .btn-circular, .btn-d, .btn-rep-inline {
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-sair:active, .btn-menu:active, .btn-grande:active, .btn-circular:active, .btn-d:active, .btn-rep-inline:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 rgba(0,0,0,0) !important;
}

.btn-sair{
  text-decoration:none;background:var(--vermelho);color:#fff;padding:8px 18px;border-radius:999px;
  font-weight:900; font-size:.95rem;display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;
  border: 2px solid #fff; box-shadow: 0 4px 0 var(--vermelho-sombra);
}
.btn-menu{
  border:none;cursor:pointer;background:var(--azul-tile);color:#fff;padding:8px 18px;border-radius:999px;
  font-weight:900; font-family:'Fredoka',sans-serif;font-size:.95rem;white-space:nowrap;
  border: 2px solid #fff; box-shadow: 0 4px 0 #341f97;
}

/* --- Corações centralizados perfeitamente --- */
.status-centro{
  display:flex; justify-content:center; align-items:center; 
}
@media (min-width: 481px) {
  header { position: relative; }
  .status-centro {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}

#vidas-ui{
  font-size:1.6rem; letter-spacing:4px; white-space:nowrap;
  animation: heartbeat 2s infinite;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.15));
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.melhor-ranking{
  flex: 1 1 auto; text-align:right; font-weight:900; color:#2d3436; font-size:1.4rem;
  white-space:nowrap; display: flex; justify-content: flex-end; align-items: center; gap: 6px;
}
.melhor-ranking span{
  color:var(--laranja); font-size:2.4rem; vertical-align:middle;
  text-shadow: 2px 3px 0px rgba(0,0,0,0.1);
}

.wrap{
  width:100%;z-index:10;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:8px;
  padding:12px 12px;flex:1;min-height:0;
}
.card-jogo{
  width:min(94vw,650px);
  background:#fff;
  border: 8px solid #fff;
  border-radius: 40px;
  box-shadow: 0 16px 40px rgba(0,0,0,.15), inset 0 -6px 0 rgba(0,0,0,0.05);
  padding:14px 16px 16px;
  display:flex; flex-direction:column; align-items:center; gap:10px; min-height:0;
}
.linha-topo-card{width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px}

.dica{
  display:flex;align-items:center;gap:12px;background:#fef9e7;
  border: 4px dashed #ffeaa7; padding:8px 16px;border-radius:24px;
  font-weight:800;color:#2d3436;min-width:0;flex:1;
}
#emoji-dica{font-size:2.2rem; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.1));}
#txt-categoria{font-size:.9rem;opacity:.75;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; text-transform: uppercase; font-weight: 900; color:var(--laranja)}
#txt-instrucao{font-size:1.1rem;color:#2d3436;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.placar{display:flex;gap:10px}
.placar .box{
  background:#f1f2f6;border:3px solid #dfe4ea;border-radius:20px;padding:8px 12px;text-align:center;
  box-shadow:inset 0 4px 0 #fff; min-width:90px;
}
.placar .box b{display:block;font-size:1.3rem;color:var(--azul-tile); line-height: 1;}
.placar .box span{display:block;font-size:.75rem;font-weight:900;color:#747d8c; margin-top: 2px;}

.palavra-wrap{width:100%;display:flex;flex-direction:column;gap:8px}
.palavra-bar{display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap}
.palavra{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.slot{
  width:44px;height:50px;border-radius:16px;background:#f8f9fa;
  border: 4px solid #dfe4ea; box-shadow: 0 4px 0 #ced6e0;
  display:flex;align-items:center;justify-content:center;
  font-weight:900;font-size:1.6rem;color:#2f3542;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.slot.ok{
  background:var(--verde); border-color:#fff; color:#fff;
  box-shadow: 0 4px 0 var(--verde-sombra);
  transform: translateY(-2px);
}
.slot.next{
  outline: 4px solid var(--laranja); outline-offset: 2px;
  animation: pulseSlot 1s infinite alternate;
}
@keyframes pulseSlot {
  from { outline-color: var(--laranja); transform: scale(1); }
  to { outline-color: #ffda79; transform: scale(1.05); }
}

.btn-rep-inline{
  width:52px;height:52px;border-radius:18px;border:4px solid #fff;
  background:#feca57; color: #fff;
  box-shadow: 0 6px 0 #e1b12c;
  font-size:1.4rem;font-weight:900;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;user-select:none;touch-action:manipulation;
}

.barra{width:100%;height:14px;background:#f1f2f6;border-radius:999px;overflow:hidden;border:3px solid #fff; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);}
#barra-prog{height:100%;width:0%;background:linear-gradient(90deg, var(--verde), #55efc4);transition:.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); border-radius: 999px;}

.tabuleiro-box{width:100%;display:flex;justify-content:center;margin-top:4px;}
#mundo{
  --tile:25px;--sprite:22px;--font:18px;
  --mundo-border:8px;
  box-sizing:content-box; 
  position:relative;
  background:var(--fundo-tabuleiro);
  border:var(--mundo-border) solid #576574;
  border-radius:24px;
  box-shadow:0 12px 35px rgba(0,0,0,.25), inset 0 0 20px rgba(0,0,0,0.5);
  overflow:hidden;
  touch-action:none;
  user-select:none;
  display:block;
}

#grid{position:absolute;inset:0;display:grid;z-index:1}
.bloco{width:var(--tile);height:var(--tile);display:flex;align-items:center;justify-content:center}

.parede{
  background: linear-gradient(135deg, #48dbfb 0%, var(--parede) 100%);
  border-radius: 6px;
  box-shadow: inset 2px 2px 4px rgba(255,255,255,0.4), inset -2px -2px 4px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.3);
  margin: 1px;
  width: calc(var(--tile) - 2px);
  height: calc(var(--tile) - 2px);
}

.caminho{
  position:relative;
  color:#feca57;font-weight:900;font-size:var(--font);
  text-shadow: 0px 2px 0px #b33939;
}
.caminho[data-pellet="1"]::after{
  content:"";
  width:max(5px, calc(var(--tile)*0.25));
  height:max(5px, calc(var(--tile)*0.25));
  border-radius:999px;
  background:#ffda79;
  box-shadow: 0 0 8px #ffda79, 0 2px 0 #ccae62;
  display:block;
}

.caminho.next{
  background: #ffffff;
  color: var(--vermelho) !important;
  border-radius: 8px;
  text-shadow: none !important;
  z-index: 5;
  animation: nextPulseBoard 500ms ease-in-out infinite alternate;
}
@keyframes nextPulseBoard{
  from{
    transform:scale(1); 
    box-shadow: 0 0 0 3px var(--laranja), 0 0 10px rgba(255,159,67,0.6);
  }
  to{
    transform:scale(1.2); 
    box-shadow: 0 0 0 4px var(--laranja), 0 0 25px rgba(255,255,255,0.9), 0 5px 15px rgba(255,159,67,0.9);
  }
}

.status-inferior{
  display:flex; width:100%; justify-content:center; gap:32px;
  padding-top:12px; border-top:4px dashed #f1f2f6; margin-top:4px;
}
.box-status{ font-size:1.3rem; font-weight:900; color:#576574; }
.box-status span{ color:var(--laranja); font-size:1.8rem; vertical-align:bottom; text-shadow: 1px 2px 0 #d1ccc0;}

#pacman{
  width:var(--sprite);height:var(--sprite);
  position:absolute;z-index:10;
  transition:left var(--pac-step) linear, top var(--pac-step) linear, transform 0.1s;
  will-change:transform,left,top;
  margin:1.5px;
  background:#ffda79;
  border-radius:50%;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.15), 0 4px 6px rgba(0,0,0,0.3);
}
#pacman::after{
  content:""; position:absolute; inset:-1px;
  background:var(--fundo-tabuleiro);
  border-radius:50%;
  animation: chomp 300ms infinite alternate;
}
@keyframes chomp {
  0% { clip-path:polygon(50% 50%, 100% 15%, 100% 85%); }
  100% { clip-path:polygon(50% 50%, 100% 45%, 100% 55%); }
}

.fantasma{
  width:var(--sprite);height:var(--sprite);
  position:absolute;z-index:10;
  border-radius:50% 50% 10% 10%;
  transition:left var(--ghost-step) linear, top var(--ghost-step) linear;
  box-shadow:inset -3px -3px 0 rgba(0,0,0,.2), 0 6px 8px rgba(0,0,0,0.4);
  margin:1.5px;
  animation: bobbing 1s ease-in-out infinite alternate;
}
@keyframes bobbing {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}
.fantasma::before, .fantasma::after{
  content:""; position:absolute; top:24%; width:28%; height:32%;
  background:#fff; border-radius:50%; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.fantasma::before{left:20%}
.fantasma::after{right:20%}
.fantasma .pupila{
  position:absolute; top:36%; width:14%; height:14%;
  background:#2f3542; border-radius:50%; left:26%;
  box-shadow: calc(var(--sprite)*0.32) 0 0 0 #2f3542;
}
.f1{background:var(--vermelho);}
.f2{background:#00d2d3;}
.f3{background:var(--laranja);}

#fx-layer{position:absolute;inset:0;pointer-events:none;z-index:9}
.popup{
  position:absolute;font-weight:900;font-size:18px;color:#fff;
  text-shadow:0 3px 6px rgba(0,0,0,.5), 0 0 10px #ff9f43;
  transform:translate(-50%,-50%);
  animation:popUp 750ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  will-change:transform,opacity;
}
@keyframes popUp{
  0%{transform:translate(-50%,-50%) scale(.5);opacity:0}
  30%{opacity:1; transform:translate(-50%, calc(-50% - 20px)) scale(1.2)}
  100%{transform:translate(-50%, calc(-50% - 40px)) scale(1);opacity:0}
}
.spark{
  position:absolute;width:8px;height:8px;border-radius:50%;
  background:#fff; box-shadow:0 0 15px 5px #ffda79;
  animation:spark 600ms ease-out forwards;
}
@keyframes spark{
  0%{transform:translate(-50%,-50%) scale(1);opacity:1}
  100%{transform:translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.1);opacity:0}
}
.flash{position:absolute;inset:0;background:rgba(255,107,107,.4);pointer-events:none;animation:flashOut 350ms ease-out}
@keyframes flashOut{from{opacity:1}to{opacity:0}}

.controles-fixos{
  position:fixed; right:14px; bottom:14px;
  right:calc(env(safe-area-inset-right) + 14px);
  bottom:calc(env(safe-area-inset-bottom) + 14px);
  display:flex;flex-direction:column;gap:12px; z-index:2500;
}
.btn-circular{
  width:64px;height:64px;border-radius:24px;border:4px solid #fff;
  background:#f1f2f6; color:#2f3542;
  box-shadow:0 8px 0 #dfe4ea, 0 15px 20px rgba(0,0,0,0.2);
  font-size:1.6rem;font-weight:900;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;user-select:none;touch-action:manipulation;
}
.btn-circular.ativo{background:var(--verde);color:#fff; border-color:#fff; box-shadow: 0 8px 0 var(--verde-sombra), 0 15px 20px rgba(0,0,0,0.2);}

.dpad{
  position:fixed; left:14px; bottom:14px;
  left:calc(env(safe-area-inset-left) + 14px);
  bottom:calc(env(safe-area-inset-bottom) + 14px);
  z-index:2000; display:none;
}
.dpad-grid{ display:grid; grid-template-columns:70px 70px 70px; grid-template-rows:70px 70px 70px; gap:8px; }
.btn-d{
  width:100%;height:100%;border-radius:20px;border:4px solid rgba(255,255,255,0.8);
  background:rgba(255,255,255,.6); backdrop-filter: blur(5px);
  box-shadow:0 6px 0 rgba(0,0,0,0.1);
  font-size:1.8rem;font-weight:900; color:#2d3436;
  cursor:pointer;display:flex;align-items:center;justify-content:center;
  user-select:none;touch-action:manipulation;
}
.btn-d.center{opacity:.0;pointer-events:none}

.overlay{
  position:fixed;inset:0;background:rgba(18, 27, 43, 0.7);
  display:none;align-items:center;justify-content:center;
  padding:18px;z-index:5000; backdrop-filter:blur(8px);
}
.menu-caixa{
  /* --- MUDANÇA DA LARGURA DO MODAL --- */
  width:min(92vw, 800px); 
  background:#fff; border:8px solid #fff;
  border-radius:40px; box-shadow:0 25px 60px rgba(0,0,0,.4);
  padding:24px; text-align:center;
  animation: popMenu 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popMenu {
  from { transform: scale(0.8) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.menu-caixa h1{margin:0 0 10px;color:var(--laranja);font-size:2.2rem; text-shadow: 2px 2px 0 #ffeaa7;}
.menu-caixa p{margin:0 0 16px;color:#576574;font-weight:700; font-size: 1.2rem;}
.regras{
  margin:10px 0 20px; background:#fef9e7; border:4px dashed #feca57;
  border-radius:24px; padding:16px; text-align:left; font-weight:700; color:#2d3436; line-height:1.4; font-size: 1.1rem;
}
.linha-botoes{display:flex;flex-direction:column;gap:16px}
.btn-grande{
  border:4px solid #fff; cursor:pointer; padding:16px 20px;border-radius:24px;
  font-weight:900;font-size:1.2rem; font-family:'Fredoka',sans-serif; text-transform: uppercase; letter-spacing: 1px;
}
.btn-verde{background:var(--verde);color:#fff; box-shadow: 0 8px 0 var(--verde-sombra);}
.btn-laranja{background:var(--laranja);color:#fff; box-shadow: 0 8px 0 var(--laranja-sombra);}
.btn-cinza{background:#f1f2f6;color:#2f3542; box-shadow: 0 8px 0 #ced6e0;}


@media (max-width:720px){
  header{padding:8px 12px;}
  .melhor-ranking{font-size: 1.1rem; flex: 1 1 auto; text-align: right;}
  .melhor-ranking span{font-size: 1.8rem;}
  #vidas-ui{font-size:1.3rem;}
  .card-jogo{width:min(96vw,600px);border-width:6px;border-radius:32px; padding:12px;}
  .slot{width:36px;height:44px; font-size: 1.3rem;}
  .btn-rep-inline{width:46px;height:46px; font-size:1.2rem;}
  .box-status{font-size: 1.1rem;}
  .box-status span{font-size: 1.5rem;}
}
@media (max-width:480px){
  header { flex-direction: column; align-items: center; gap: 8px; }
  /* No celular ele volta a ocupar a linha de forma natural pra não bagunçar */
  .status-centro { position: static; transform: none; width: 100%; }
  .grupo-esq, .melhor-ranking { justify-content: center; text-align: center; width: 100%; }
  .dpad-grid{ grid-template-columns:60px 60px 60px; grid-template-rows:60px 60px 60px; }
  .btn-circular{ width: 54px; height: 54px; font-size: 1.3rem;}
}