:root {
  --fundo: #cfe8ff;
  --painel: rgba(255, 255, 255, 0.92);
  --texto: #2d2440;
  --suave: #6b5f84;
  --botao: #8f6fd8;
  --botao-texto: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--fundo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#tela { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#placar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 22px;
  text-shadow: 0 1px 0 #fff, 0 0 6px rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.painel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  padding: 24px 20px;
  border-radius: 20px;
  background: var(--painel);
  box-shadow: 0 10px 40px rgba(45, 36, 64, 0.25);
  text-align: center;
}

.painel[hidden], #placar[hidden], #barra[hidden], button[hidden], #poder[hidden] { display: none; }

h1 { margin: 0; font-size: 44px; letter-spacing: 2px; color: var(--botao); }
h2 { margin: 0 0 8px; font-size: 26px; }
.sub { margin: 0 0 16px; color: var(--suave); }
.dica { margin: 16px 0 0; font-size: 14px; color: var(--suave); line-height: 1.4; }

.botoes { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

button {
  min-width: 140px;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--botao);
  color: var(--botao-texto);
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
}

button.secundario { background: #e6def8; color: var(--texto); }
button:focus-visible { outline: 3px solid var(--texto); outline-offset: 2px; }

#placar { flex-wrap: wrap; }
#barra {
  flex-basis: 100%;
  height: 8px;
  margin-top: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}
#barra-cheia { height: 100%; width: 0; background: var(--botao); }

.fases { display: grid; gap: 8px; margin: 0 0 16px; }
button.fase {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #f1ecfd;
  color: var(--texto);
  min-height: 52px;
}
button.fase .num {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--botao); color: #fff;
}
button.fase .estrelas { color: #e0a800; letter-spacing: 2px; }
button.fase:disabled { opacity: 0.45; cursor: default; }

.painel { max-height: calc(100% - 24px); overflow-y: auto; }
.rotulo { margin: 4px 0 8px; font-weight: 700; text-align: left; color: var(--suave); font-size: 14px; }
.personagens { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
button.personagem {
  min-width: 0; min-height: 56px; padding: 6px;
  display: grid; gap: 2px; align-content: center;
  background: color-mix(in srgb, var(--cor) 35%, white);
  color: var(--texto);
  border: 3px solid transparent;
  font-size: 14px; line-height: 1.15;
}
button.personagem .poder { font-weight: 500; font-size: 12px; color: var(--suave); }
button.personagem[aria-pressed="true"] { border-color: var(--botao); }

#poder {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 84px; height: 84px; min-width: 0; padding: 0;
  border-radius: 50%;
  background: conic-gradient(var(--cor, #b48cff) var(--carga, 0%), rgba(255, 255, 255, 0.55) 0);
  box-shadow: 0 4px 14px rgba(45, 36, 64, 0.3);
  display: grid; place-items: center;
}
#poder span {
  width: 66px; height: 66px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.92); color: var(--texto);
  font-size: 12px; line-height: 1.1; padding: 4px; text-align: center;
}
#poder.cheio { animation: pulsar 0.8s ease-in-out infinite; }
#poder.ativo span { background: var(--cor); color: #2d2440; }
@keyframes pulsar { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { #poder.cheio { animation: none; outline: 3px solid var(--botao); } }

.novo-perfil { display: flex; gap: 8px; margin-top: 12px; }
.novo-perfil input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 2px solid #e6def8; border-radius: 14px; font: inherit; font-size: 17px; color: var(--texto);
}
.novo-perfil button { min-width: 96px; }
.elenco { margin-bottom: 8px; }
.elenco button { min-width: 0; flex: 1; }
.elenco button[aria-pressed="true"] { background: var(--botao); color: #fff; }
.diario { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.parada {
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  background: #eeeaf5; color: var(--suave);
}
.parada.alcancada { background: color-mix(in srgb, var(--cor) 45%, white); color: var(--texto); font-weight: 600; }

#aviso {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.9); color: var(--texto);
  font-weight: 800; font-size: 22px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 6px 20px rgba(45, 36, 64, 0.2);
}
#aviso[hidden] { display: none; }
#aviso.some { animation: aviso 2.6s ease forwards; }
@keyframes aviso { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #aviso.some { animation: none; } }

.metas { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; text-align: left; }
.metas li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  padding: 8px 10px; border-radius: 12px; background: #f6f3fc; font-size: 14px;
}
.metas .conta { font-weight: 700; color: var(--suave); font-size: 13px; }
.metas .trilho { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #e6def8; overflow: hidden; }
.metas .trilho .cheio { display: block; height: 100%; background: var(--botao); }
.metas li.cumprida { background: #e5f7e9; }
.metas li.cumprida .conta { color: #2f8a46; }
#metas-fim li { grid-template-columns: 1fr; font-weight: 700; }
.subiu { font-weight: 800; color: var(--botao); }
.subiu[hidden] { display: none; }

.erro { color: #b3261e; min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.pequeno { font-size: 13px; color: var(--suave); margin: 4px 0 8px; }
.turma[hidden] { display: none; }
.turma .rotulo { display: flex; justify-content: space-between; align-items: center; }
button.mini { min-width: 0; min-height: 32px; padding: 4px 10px; font-size: 13px; }
.placar { list-style: none; margin: 0 0 8px; padding: 0; text-align: left; font-size: 14px; }
.placar li { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; padding: 5px 8px; border-radius: 8px; }
.placar li:nth-child(odd) { background: #f6f3fc; }
.placar li.eu { background: #e6def8; font-weight: 800; }
.placar li.vazio { display: block; color: var(--suave); }
.placar .pos { color: var(--suave); }
.festival { height: 10px; border-radius: 5px; background: #eeeaf5; overflow: hidden; }
#festival-cheio { height: 100%; width: 0; background: linear-gradient(90deg, #ff6b6b, #ffa94d, #ffe066, #8ce99a, #74c0fc, #b197fc); }
.dupla { display: grid; gap: 8px; margin: 8px 0; }
.dupla p { margin: 0; font-size: 14px; }
.dupla select { min-height: 44px; border-radius: 12px; border: 2px solid #e6def8; font: inherit; padding: 0 10px; background: #fff; color: var(--texto); }
.turma-resultado { font-weight: 700; color: var(--botao); min-height: 1.2em; }
.rotulo-3d {
  position: fixed; transform: translate(-50%, -100%); pointer-events: none;
  padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.85);
  font-size: 13px; font-weight: 700; color: var(--texto); white-space: nowrap;
}
.rotulo-3d[hidden] { display: none; }
.rotulo-3d.placa { background: #ff8fc8; color: #fff; }
