html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* a página nunca rola: tudo cabe na tela */
  background: #faf8ef;
  color: #776e65;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
}

body {
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input {
  font-family: inherit;
}

:root {
  /* Tema Default (verde) */
  --t2-bg: #E5F3DF; --t2-fg: #45613D;
  --t4-bg: #C7E5B9; --t4-fg: #355C2C;
  --t8-bg: #A4D58D; --t8-fg: #FFFFFF;
  --t16-bg: #78BD65; --t16-fg: #FFFFFF;
  --t32-bg: #4CA94B; --t32-fg: #FFFFFF;
  --t64-bg: #298C3A; --t64-fg: #FFFFFF;
  --t128-bg: #19732E; --t128-fg: #FFFFFF;
  --t256-bg: #125A27; --t256-fg: #FFFFFF;
  --t512-bg: #104820; --t512-fg: #FFFFFF;
  --t1024-bg: #0B371A; --t1024-fg: #FFFFFF;
  --t2048-bg: #072A15; --t2048-fg: #FFFFFF;
  --t4096-bg: #052014; --t4096-fg: #FFFFFF;
  --tsuper-bg: #03150D; --tsuper-fg: #FFFFFF;
  --accent: #4CA94B;
  --accent-rgb: 76, 169, 75;
  --glow-rgb: 120, 189, 101;
  --tile-font: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  --tile-weight: 700;
  --font-scale: 1;
}

/* Celular: jogo, ranking e instruções empilhados.
   Tela larga: ranking na lateral. */
.layout {
  display: grid;
  grid-template-columns: min(500px, 100%);
  grid-template-areas: "head" "side" "game";
  justify-content: center;
  align-items: start;
  column-gap: 40px;
  row-gap: 14px;
  height: 100%;
  box-sizing: border-box;
  padding: 20px 16px;
}

.container { grid-area: game; min-width: 0; }
.heading   { grid-area: head; }

/* Coluna do placar + ranking */
.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.side .scores-container {
  justify-content: center;
}

.side .score-container,
.side .best-container {
  flex: 1;
  max-width: 160px;
}

/* Tela larga: ranking na lateral, com rolagem própria se precisar. */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .layout {
    grid-template-columns: 500px 320px;
    grid-template-areas: "head head" "game side";
    grid-template-rows: auto minmax(0, 1fr);
  }
  .side {
    max-height: 100%;
  }
  .side .score-container,
  .side .best-container {
    max-width: none;
  }
  .ranking {
    margin-top: 0 !important;
    min-height: 0;
    box-sizing: border-box;
    overflow-y: auto;
  }
  .ranking-button,
  .ranking-close {
    display: none !important;
  }
}

/* Celular / tela estreita: ranking abre numa janela pelo botão. */
@media (max-width: 899px), (max-aspect-ratio: 1/1) {
  .ranking {
    display: none;
  }
  .ranking.open {
    display: block;
    position: fixed;
    z-index: 1001;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    box-sizing: border-box;
    overflow-y: auto;
    margin: 0 !important;
    box-shadow: 0 20px 50px rgba(60, 58, 50, 0.3);
    animation: fade-in 150ms ease;
  }
}

.ranking-button {
  display: flex;
}

.ranking-close {
  margin-left: 10px;
  width: 32px;
  height: 32px;
  font-size: 22px;
}

.ranking-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(119, 110, 101, 0.45);
}

.ranking-backdrop[hidden] {
  display: none;
}

/* ---------- Cabeçalho ---------- */

.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1.title {
  font-size: 80px;
  font-weight: bold;
  margin: 0;
  line-height: 1;
}

.scores-container {
  display: flex;
  gap: 6px;
}

.score-container,
.best-container {
  position: relative;
  background: #bbada0;
  border-radius: 10px;
  color: white;
  text-align: center;
  padding: 10px 24px 8px;
  min-width: 52px;
  font-weight: bold;
}

.scores-container .label {
  font-size: 13px;
  line-height: 13px;
  text-transform: uppercase;
  color: #eee4da;
}

.scores-container .value {
  font-size: 25px;
  line-height: 32px;
}

.score-addition {
  position: absolute;
  right: 30px;
  bottom: 10px;
  color: rgba(119, 110, 101, 0.9);
  font-size: 25px;
  font-weight: bold;
  z-index: 100;
  pointer-events: none;
  animation: move-up 600ms ease-in forwards;
}

@keyframes move-up {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-150px); opacity: 0; }
}

.restart-button,
.pause-button,
.game-message button,
.rank-form button {
  background: #8f7a66;
  border-radius: 10px;
  padding: 0 22px;
  color: #f9f6f2;
  height: 44px;
  line-height: 44px;
  font-size: 18px;
  font-weight: bold;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Barra: colunas, altura, novo jogo, pausa ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 12px;
  margin: 18px 0 16px;
}

.mode-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-label {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  padding-left: 4px;
}

.segmented {
  display: flex;
  background: #bbada0;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: #eee4da;
  font-weight: bold;
  font-size: 16px;
  width: 28px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.segmented button.active {
  background: var(--accent);
  color: #f9f6f2;
}

.actions {
  display: flex;
  gap: 6px;
}

.toolbar .restart-button,
.toolbar .pause-button {
  height: 38px;
  line-height: 38px;
  font-size: 16px;
  padding: 0 16px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #8f7a66;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: #f9f6f2;
}

.icon-button svg.stroke {
  fill: none;
  stroke: #f9f6f2;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* ---------- Tabuleiro ---------- */

.play-area {
  position: relative;
  margin: 0 auto;
  width: var(--board-w);
  height: var(--area-h);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.grid-container {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--board-w);
  height: var(--area-h);
  background: #bbada0;
  border-radius: 16px;
}

.grid-cell {
  position: absolute;
  /* 1px menor de cada lado: o bloco cobre a casa por inteiro
     e a borda clara da casa não "vaza" em volta dele. */
  width: calc(var(--cell) - 2px);
  height: calc(var(--cell) - 2px);
  border-radius: var(--radius);
  background: rgba(238, 228, 218, 0.35);
}

.tile-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tile {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cell);
  height: var(--cell);
  transition-property: transform;
  transition-duration: 100ms;
  transition-timing-function: ease-in-out;
  will-change: transform;
  z-index: 2;
}

.tile.merging {
  z-index: 1;
}

.tile.falling {
  z-index: 3;
  transition: none;
}

.tile.falling .tile-inner {
  box-shadow: 0 5px 0 rgba(119, 110, 101, 0.2);
}

.tile-inner {
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  text-align: center;
  font-weight: bold;
  line-height: var(--cell);
  font-family: var(--tile-font);
  font-weight: var(--tile-weight);
  font-size: calc(var(--cell) * 0.55 * var(--font-scale));
  white-space: nowrap;
  background: #eee4da;
  color: #776e65;
}

.tile-inner[data-d="3"] { font-size: calc(var(--cell) * 0.45 * var(--font-scale)); }
.tile-inner[data-d="4"] { font-size: calc(var(--cell) * 0.35 * var(--font-scale)); }
.tile-inner[data-d="5"] { font-size: calc(var(--cell) * 0.29 * var(--font-scale)); }
.tile-inner[data-d="6"] { font-size: calc(var(--cell) * 0.24 * var(--font-scale)); }
.tile-inner[data-d="7"] { font-size: calc(var(--cell) * 0.2 * var(--font-scale)); }

.tile-inner.appear { animation: appear 200ms ease 100ms backwards; }
.tile-inner.pop    { animation: pop 200ms ease 0ms backwards; }

@keyframes appear {
  0%   { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ---------- Cores dos blocos ---------- */

/* As cores vêm de variáveis (--t2-bg, --t2-fg...) que o tema escolhido nas
   configurações define; os valores abaixo em :root são o tema Default (verde). */

[data-v="2"]      { background: var(--t2-bg); color: var(--t2-fg); }
[data-v="4"]      { background: var(--t4-bg); color: var(--t4-fg); }
[data-v="8"]      { background: var(--t8-bg); color: var(--t8-fg); }
[data-v="16"]     { background: var(--t16-bg); color: var(--t16-fg); }
[data-v="32"]     { background: var(--t32-bg); color: var(--t32-fg); }
[data-v="64"]     { background: var(--t64-bg); color: var(--t64-fg); }
[data-v="128"]    { background: var(--t128-bg); color: var(--t128-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.144); }
[data-v="256"]    { background: var(--t256-bg); color: var(--t256-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.192); }
[data-v="512"]    { background: var(--t512-bg); color: var(--t512-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.24); }
[data-v="1024"]   { background: var(--t1024-bg); color: var(--t1024-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.48), inset 0 0 0 1px rgba(255, 255, 255, 0.288); }
[data-v="2048"]   { background: var(--t2048-bg); color: var(--t2048-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.56), inset 0 0 0 1px rgba(255, 255, 255, 0.336); }
[data-v="4096"]   { background: var(--t4096-bg); color: var(--t4096-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.62), inset 0 0 0 1px rgba(255, 255, 255, 0.372); }
[data-v="super"]  { background: var(--tsuper-bg); color: var(--tsuper-fg);
  box-shadow: 0 0 30px 10px rgba(var(--glow-rgb), 0.62), inset 0 0 0 1px rgba(255, 255, 255, 0.372); }

/* ---------- Mensagens ---------- */

.game-message {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--area-h);
  border-radius: 16px;
  background: rgba(238, 228, 218, 0.73);
  z-index: 100;
  text-align: center;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  padding: 0 16px;
  box-sizing: border-box;
  animation: fade-in 500ms ease 300ms backwards;
}

.game-message p {
  font-size: 54px;
  font-weight: bold;
  margin: 0 0 24px;
  line-height: 1.1;
}

.game-message .lower {
  display: flex;
  gap: 10px;
}

.game-message.game-over,
.game-message.game-won,
.game-message.game-paused {
  display: flex;
}

.game-message.game-paused {
  animation: none;
}

.game-message.game-won {
  background: rgba(var(--accent-rgb), 0.5);
  color: #f9f6f2;
}

.game-message .keep-playing-button { display: none; }
.game-message.game-won .keep-playing-button,
.game-message.game-paused .keep-playing-button { display: inline-block; }

.rank-form,
.rank-result {
  display: none;
  margin-bottom: 20px;
}

.game-message.ask-name .rank-form { display: block; }
.game-message.show-result .rank-result { display: block; }

.rank-form-title {
  font-weight: bold;
  margin-bottom: 10px;
}

.rank-form-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.rank-form input {
  width: 160px;
  max-width: 45vw;
  height: 44px;
  box-sizing: border-box;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 17px;
  font-weight: bold;
  color: #776e65;
  background: #f9f6f2;
  outline: none;
}

.rank-form input:focus {
  box-shadow: 0 0 0 3px #edc22e;
}

.rank-result {
  font-weight: bold;
  font-size: 20px;
}

@keyframes fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ---------- Ranking ---------- */

.ranking {
  margin-top: 30px;
  background: #bbada0;
  border-radius: 16px;
  padding: 16px;
}

.ranking-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #f9f6f2;
}

.ranking-head h2 {
  margin: 0 auto 0 0;
  font-size: 24px;
}

.ranking-mode {
  font-weight: bold;
  font-size: 15px;
  color: #eee4da;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ranking-list li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(238, 228, 218, 0.55);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: bold;
}

.ranking-list li.me {
  background: #f9f6f2;
  box-shadow: 0 0 0 2px #edc22e;
}

.ranking-list .pos {
  width: 26px;
  text-align: center;
  color: #8f7a66;
}

.ranking-list li:nth-child(1) .pos { color: #edc22e; }
.ranking-list li:nth-child(2) .pos { color: #a39b92; }
.ranking-list li:nth-child(3) .pos { color: #f2b179; }

.ranking-list .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-list li.live {
  background: var(--accent);
  color: #f9f6f2;
  z-index: 1;
}

.ranking-list li.live .pos { color: #f9f6f2; }

.ranking-list li.live .name::after {
  content: "ao vivo";
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 10px;
  text-transform: uppercase;
  vertical-align: 2px;
}

.ranking-list li.climb {
  animation: climb 450ms ease;
}

@keyframes climb {
  0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.9); }
  100% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
}

.ranking-list .mini-tile {
  font-family: var(--tile-font);
  font-weight: var(--tile-weight);
  min-width: 34px;
  height: 26px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 7px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ranking-list .pts {
  min-width: 64px;
  text-align: right;
}

.ranking-empty {
  justify-content: center;
  color: #8f7a66;
  font-weight: normal !important;
}

/* ---------- Rodapé ---------- */

.game-explanation {
  margin-top: 28px;
  line-height: 1.65;
}

.important {
  text-transform: uppercase;
}

hr {
  border: none;
  border-bottom: 1px solid #e6ddd3;
  margin: 20px 0;
}

.footnote {
  font-size: 14px;
  margin: 0;
}

@media (max-width: 520px) {
  .layout { padding-top: 14px; }
  h1.title { font-size: 54px; }
  .score-container, .best-container { padding: 8px 14px 6px; min-width: 40px; }
  .scores-container .value { font-size: 20px; line-height: 26px; }
  .toolbar .restart-button { padding: 0 12px; font-size: 15px; }
  .game-message p { font-size: 36px; margin-bottom: 16px; }
  .game-message button { font-size: 15px; padding: 0 14px; }
}

/* ---------- Configurações ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(119, 110, 101, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 150ms ease;
}

/* O display:flex acima sobrescreve o atributo hidden; isto garante que ele feche. */
.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-sizing: border-box;
  background: #faf8ef;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(60, 58, 50, 0.3);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 26px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #eee4da;
  color: #776e65;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.preview {
  --cell: 58px;
  --radius: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #bbada0;
  border-radius: 14px;
  margin-bottom: 18px;
}

.preview .tile-inner {
  width: var(--cell);
  height: var(--cell);
  flex: none;
}

.setting {
  margin-bottom: 18px;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 8px;
}

.setting-value {
  color: var(--accent);
}

.setting input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.font-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}

.font-options button {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #eee4da;
  color: #776e65;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.font-options button.active {
  background: var(--accent);
  color: #f9f6f2;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.link-button {
  border: 0;
  background: none;
  color: #8f7a66;
  font-weight: bold;
  font-size: 15px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* ---------- Poderes ---------- */

/* Bloco "Câmera lenta": branco com número azul. */
.tile-inner[data-power="slow"] {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(30, 64, 175, 0.5);
  box-shadow: 0 0 0 3px #93c5fd inset, 0 0 22px 4px rgba(59, 130, 246, 0.35);
  animation: power-glow 1.4s ease-in-out infinite;
}

@keyframes power-glow {
  0%, 100% { box-shadow: 0 0 0 3px #93c5fd inset, 0 0 14px 2px rgba(59, 130, 246, 0.25); }
  50%      { box-shadow: 0 0 0 3px #60a5fa inset, 0 0 26px 6px rgba(59, 130, 246, 0.45); }
}

.effects {
  position: absolute;
  top: calc(var(--gap) + 18px);
  right: var(--gap);
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

.effect-pill {
  background: #ffffff;
  color: #3b82f6;
  font-weight: bold;
  font-size: 13px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.effect-pill.fresh {
  animation: pop 300ms ease;
}

.toast {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  color: #3b82f6;
  font-weight: bold;
  font-size: 26px;
  padding: 10px 22px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.3);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.toast.show {
  animation: toast 1.4s ease forwards;
}

@keyframes toast {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  25%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

/* Abas do ranking */
.ranking-tabs {
  display: flex;
  gap: 4px;
  background: rgba(238, 228, 218, 0.35);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 12px;
}

.ranking-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #f9f6f2;
  font-weight: bold;
  font-size: 14px;
  height: 32px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 120ms;
}

.ranking-tabs button.active {
  background: var(--accent);
}

/* Interruptor nas configurações */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.setting-title {
  display: block;
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 4px;
}

.setting-help {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: #cdc1b4;
  position: relative;
  cursor: pointer;
  transition: background 150ms;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 150ms;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

/* Barra de carga dos poderes (faixa de entrada no topo) */
.power-bar {
  position: absolute;
  top: calc(var(--gap) / 2 - 2px);
  left: var(--gap);
  right: var(--gap);
  height: 4px;
  border-radius: 2px;
  background: rgba(238, 228, 218, 0.35);
  overflow: hidden;
  z-index: 5;
  pointer-events: none;
}

.power-bar[hidden] {
  display: none;
}

.power-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: #f9f6f2;
  transition: width 300ms ease, background 300ms;
}

.power-bar.full .power-bar-fill {
  background: linear-gradient(90deg, #bfdbfe, #ffffff, #93c5fd, #ffffff, #bfdbfe);
  background-size: 200% 100%;
  animation: ice-shimmer 1.2s linear infinite;
  box-shadow: 0 0 8px rgba(147, 197, 253, 0.9);
}

@keyframes ice-shimmer {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ---------- Efeito na borda (para fora do tabuleiro) ---------- */

.aura {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  pointer-events: none;
  transition: box-shadow 500ms ease;
  box-shadow: 0 0 0 0 transparent;
}

.aura[data-theme="ice"] {
  animation: aura-ice 2.4s ease-in-out infinite;
}

.aura[data-theme="joker"] {
  animation: aura-joker 0.9s ease-in-out infinite;
}

.aura[data-theme="fire"] {
  animation: aura-fire 0.9s ease-in-out infinite;
}

@keyframes aura-ice {
  0%, 100% { box-shadow: 0 0 0 3px #e0f2fe, 0 0 16px 5px rgba(147, 197, 253, 0.8), 0 0 40px 12px rgba(191, 219, 254, 0.55); }
  50%      { box-shadow: 0 0 0 4px #ffffff, 0 0 22px 7px rgba(147, 197, 253, 0.95), 0 0 54px 18px rgba(191, 219, 254, 0.7); }
}

@keyframes aura-joker {
  0%, 100% { box-shadow: 0 0 0 3px #f0abfc, 0 0 16px 5px rgba(192, 38, 211, 0.8), 0 -6px 40px 12px rgba(147, 51, 234, 0.45); }
  35%      { box-shadow: 0 0 0 3px #e879f9, 0 0 22px 8px rgba(217, 70, 239, 0.95), 0 -10px 52px 16px rgba(147, 51, 234, 0.6); }
  70%      { box-shadow: 0 0 0 3px #c026d3, 0 0 14px 4px rgba(192, 38, 211, 0.75), 0 -4px 36px 10px rgba(147, 51, 234, 0.4); }
}

@keyframes aura-fire {
  0%, 100% { box-shadow: 0 0 0 3px #fdba74, 0 0 16px 5px rgba(249, 115, 22, 0.8), 0 -6px 40px 12px rgba(239, 68, 68, 0.45); }
  35%      { box-shadow: 0 0 0 3px #fde047, 0 0 22px 8px rgba(251, 146, 60, 0.95), 0 -10px 52px 16px rgba(239, 68, 68, 0.6); }
  70%      { box-shadow: 0 0 0 3px #fb923c, 0 0 14px 4px rgba(249, 115, 22, 0.75), 0 -4px 36px 10px rgba(239, 68, 68, 0.4); }
}

.fx {
  position: absolute;
  top: -44px;
  left: -44px;
  pointer-events: none;
  z-index: 6;
}

/* Cor da barra cheia conforme o poder que vem */
.power-bar.full[data-theme="joker"] .power-bar-fill {
  background: linear-gradient(90deg, #f0abfc, #c026d3, #a855f7, #c026d3, #f0abfc);
  background-size: 200% 100%;
  box-shadow: 0 0 8px rgba(192, 38, 211, 0.9);
}

.power-bar.full[data-theme="fire"] .power-bar-fill {
  background: linear-gradient(90deg, #fde047, #fb923c, #ef4444, #fb923c, #fde047);
  background-size: 200% 100%;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.9);
}

/* Bloco Coringa: rosa com "?" verde */
.tile-inner[data-power="joker"] {
  background: radial-gradient(circle at 50% 85%, #f0abfc 0%, #d946ef 45%, #a21caf 80%, #701a75 100%);
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(74, 4, 78, 0.55);
  animation: joker-flicker 0.8s ease-in-out infinite;
}

@keyframes joker-flicker {
  0%, 100% { box-shadow: 0 0 14px 3px rgba(192, 38, 211, 0.55); filter: brightness(1); }
  50%      { box-shadow: 0 0 24px 7px rgba(168, 85, 247, 0.7); filter: brightness(1.12); }
}

/* Bloco Fogo: "X" sobre chamas */
.tile-inner[data-power="fire"] {
  background: radial-gradient(circle at 50% 85%, #fde047 0%, #fb923c 40%, #ef4444 75%, #b91c1c 100%);
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(127, 29, 29, 0.6);
  animation: fire-flicker 0.8s ease-in-out infinite;
}

@keyframes fire-flicker {
  0%, 100% { box-shadow: 0 0 14px 3px rgba(249, 115, 22, 0.55); filter: brightness(1); }
  50%      { box-shadow: 0 0 24px 7px rgba(239, 68, 68, 0.7); filter: brightness(1.12); }
}

/* Bloco destruído pelo fogo */
.tile-inner.burn {
  animation: burn 320ms ease-in forwards;
}

@keyframes burn {
  0%   { transform: scale(1); filter: brightness(1); opacity: 1; }
  40%  { transform: scale(1.12); filter: brightness(1.6) saturate(2); box-shadow: 0 0 24px 8px rgba(249, 115, 22, 0.8); }
  100% { transform: scale(0.2); opacity: 0; filter: brightness(2); }
}

/* Poderes guardados (carga acumulada) */
.power-stock {
  position: absolute;
  top: calc(var(--gap) + 18px);
  left: var(--gap);
  z-index: 5;
  pointer-events: none;
  background: var(--accent);
  color: #f9f6f2;
  font-weight: bold;
  font-size: 13px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.35);
}

.power-stock[hidden] {
  display: none;
}

/* "+N" de carga, no canto inferior direito da barra de poder */
.charge-gain {
  position: absolute;
  top: calc(var(--gap) / 2 + 4px);
  right: var(--gap);
  z-index: 5;
  pointer-events: none;
  color: #f9f6f2;
  font-weight: bold;
  font-size: 13px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(119, 110, 101, 0.6);
  opacity: 0;
}

.charge-gain.show {
  animation: charge-gain 900ms ease-out forwards;
}

@keyframes charge-gain {
  0%   { opacity: 0; transform: translateY(-4px) scale(0.8); }
  15%  { opacity: 1; transform: translateY(0) scale(1.15); }
  30%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(3px); }
}

/* A queima vence a animação contínua dos blocos especiais */
.tile .tile-inner.burn {
  animation: burn 320ms ease-in forwards;
}

/* ---------- Barra superior: modo atual ---------- */

.toolbar {
  align-items: center;
}

.mode-badge {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: #bbada0;
  color: #f9f6f2;
  font-weight: bold;
  font-size: 15px;
  padding: 0 14px;
  cursor: pointer;
}

/* Primeiro acesso: botão de configurações piscando */
.icon-button.attention {
  animation: attention 1.4s ease-in-out infinite;
}

@keyframes attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
  50%      { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.45), 0 0 18px 6px rgba(var(--accent-rgb), 0.55); }
}

/* ---------- Configurações: tabuleiro, destaque, divisória ---------- */

.setting {
  padding: 8px;
  margin: 0 -8px 10px;
  border-radius: 12px;
}

.setting.highlight {
  animation: setting-highlight 1.2s ease-in-out 3;
}

@keyframes setting-highlight {
  0%, 100% { background: transparent; box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
  50%      { background: rgba(var(--accent-rgb), 0.12); box-shadow: 0 0 0 2px var(--accent); }
}

.board-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 8px;
}

.setting-divider {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #bbada0;
  border-top: 1px solid #e6ddd3;
  padding-top: 14px;
  margin: 6px 0 12px;
}

.setting-label .link-button {
  font-size: 13px;
}

/* ---------- Ranking: filtro por região ---------- */

.ranking-scope {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.ranking-scope button {
  flex: 1;
  min-width: 0;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: rgba(238, 228, 218, 0.35);
  color: #f9f6f2;
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  transition: background 120ms, opacity 120ms;
}

.ranking-scope button svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.ranking-scope button.active {
  background: #f9f6f2;
  color: var(--accent);
}

.ranking-scope button.unavailable {
  opacity: 0.55;
}

.ranking-place {
  font-size: 12px;
  font-weight: bold;
  color: #eee4da;
  min-height: 0;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-place:empty {
  display: none;
}

/* ---------- Ajuda ---------- */

.help-body {
  line-height: 1.55;
  font-size: 15px;
}

.help-body p {
  margin: 0 0 12px;
}

.help-body h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 18px 0 8px;
}

.help-body ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.help-body li {
  margin-bottom: 6px;
}

.help-body kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #eee4da;
  font-family: inherit;
  font-weight: bold;
  font-size: 13px;
  text-align: center;
}

.help-powers {
  list-style: none;
  padding-left: 0 !important;
}

.help-powers li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-tile {
  --cell: 38px;
  flex: none;
  width: 38px;
  height: 38px;
  line-height: 38px;
  border-radius: 9px;
  text-align: center;
  font-weight: bold;
  font-size: 18px;
}

.help-tile[data-power="slow"] {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #fff;
  box-shadow: 0 0 0 2px #93c5fd inset;
}

.help-tile[data-power="joker"] {
  background: radial-gradient(circle at 50% 85%, #f0abfc 0%, #d946ef 45%, #a21caf 80%, #701a75 100%);
  color: #fff;
}

.help-tile[data-power="fire"] {
  background: radial-gradient(circle at 50% 85%, #fde047 0%, #fb923c 40%, #ef4444 75%, #b91c1c 100%);
  color: #fff;
}

.help-body .footnote {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e6ddd3;
  font-size: 13px;
}

/* Barra superior mais compacta no celular */
@media (max-width: 520px) {
  .actions { gap: 5px; }
  .toolbar .icon-button { width: 34px; height: 34px; }
  .toolbar .restart-button { height: 34px; line-height: 34px; padding: 0 10px; font-size: 14px; }
  .mode-badge { height: 34px; padding: 0 10px; font-size: 13px; }
  .layout { padding: 14px 16px; }
}

/* ---------- "drop" no título: esteira descendo sem fim ---------- */

h1.title {
  display: flex;
  align-items: center;
  gap: 0.08em;
}

.drop-word {
  display: inline-block;
  height: 1.15em;
  overflow: hidden;
  font-size: 0.42em;
  color: var(--accent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}

/* Duas cópias empilhadas descendo meio trilho: quando uma some embaixo,
   a outra já está entrando por cima, então o loop não tem emenda. */
.drop-track {
  display: flex;
  flex-direction: column;
  animation: conveyor 2.2s linear infinite;
}

.drop-track span {
  display: block;
  height: 1.15em;
  line-height: 1.15em;
}

@keyframes conveyor {
  from { transform: translateY(-50%); }
  to   { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .drop-track { animation: none; transform: translateY(-50%); }
}

/* ---------- Título centralizado ---------- */

.heading {
  justify-content: center;
}

h1.title {
  justify-content: center;
}

.toolbar {
  margin-top: 0;
}

/* ---------- Divisória leve entre o título e o jogo ---------- */

.heading {
  position: relative;
  padding-bottom: 12px;
}

.heading::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(119, 110, 101, 0.28) 20%, rgba(119, 110, 101, 0.28) 80%, transparent);
}

/* ---------- Rodapé com crédito ---------- */

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 12px;
  color: rgba(119, 110, 101, 0.8);
  background: #faf8ef;
}

.site-footer a {
  color: var(--accent);
  font-weight: bold;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.layout {
  padding-bottom: 36px;
}

/* ---------- Ranking online: nick + PIN ---------- */

.rank-form .pin-input {
  width: 104px;
  padding: 0 10px;
  text-align: center;
  letter-spacing: 6px;
}

.rank-form-hint {
  font-size: 12px;
  margin-top: 8px;
  opacity: 0.8;
}

.rank-error {
  min-height: 18px;
  margin-top: 6px;
  font-size: 14px;
  font-weight: bold;
  color: #c0392b;
}

.rank-note {
  display: none;
  max-width: 300px;
  margin-bottom: 20px;
  font-size: 15px;
  line-height: 1.4;
}

.game-message.show-note .rank-note {
  display: block;
}

.rank-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ---------- Prévia da posição e anúncio antes de salvar ---------- */

.rank-preview {
  display: none;
  font-weight: bold;
  font-size: 17px;
  margin-bottom: 14px;
  max-width: 340px;
  line-height: 1.4;
}

.game-message.ask-name .rank-preview:not(:empty) {
  display: block;
}

.ad-modal {
  z-index: 1100;
}

.ad-card {
  text-align: center;
}

.ad-label {
  display: inline-block;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #776e65;
  color: #f9f6f2;
  border-radius: 6px;
  padding: 3px 10px;
}

.ad-text {
  margin: 12px 0 14px;
  font-size: 15px;
}

.ad-slot {
  min-height: 250px;
  border-radius: 12px;
  border: 2px dashed #cdc1b4;
  background: #f3efe9;
  color: #bbada0;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.ad-card .restart-button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Temas de cor ---------- */

.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.theme-options button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: bold;
  color: #776e65;
}

.theme-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 4px;
  box-sizing: border-box;
  background: #bbada0;
  transition: box-shadow 120ms, transform 120ms;
}

.theme-swatch span {
  border-radius: 5px;
}

.theme-options button:hover .theme-swatch {
  transform: translateY(-2px);
}

.theme-options button.active .theme-swatch {
  box-shadow: 0 0 0 3px var(--accent);
}

.help-body .privacy li {
  font-size: 14px;
}

/* Linha de cima: zona de perigo, com um tom avermelhado bem leve. */
.grid-cell.danger {
  background: rgba(242, 200, 186, 0.42);
}

.setting[hidden] {
  display: none;
}

.install-setting .restart-button {
  flex: none;
  height: 38px;
  line-height: 38px;
  font-size: 15px;
  padding: 0 16px;
}

/* ---------- Anúncios ---------- */

.ad-rail,
.ad-footer {
  display: none;
}

/* Laterais: só em telas bem largas, longe do tabuleiro. */
@media (min-width: 1300px) and (min-height: 700px) and (min-aspect-ratio: 1/1) {
  body.has-ads .ad-rail {
    display: block;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    height: 600px;
  }
  body.has-ads .ad-left { left: 16px; }
  body.has-ads .ad-right { right: 16px; }
}

/* Celular: faixa no rodapé, acima do crédito, com folga do tabuleiro. */
@media (max-width: 899px), (max-aspect-ratio: 1/1) {
  body.has-ads .ad-footer {
    display: block;
    width: 320px;
    max-width: 100%;
    height: 50px;
    margin: 4px auto 6px;
  }
}

/* Aviso de cookies dos anúncios */
.consent {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  box-sizing: border-box;
  z-index: 1200;
  background: #faf8ef;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(60, 58, 50, 0.3);
  font-size: 14px;
  line-height: 1.45;
}

.consent[hidden] {
  display: none;
}

.consent p {
  margin: 0 0 12px;
}

.consent a {
  color: var(--accent);
  font-weight: bold;
}

.consent-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
}

.consent .restart-button {
  height: 38px;
  line-height: 38px;
  font-size: 15px;
  padding: 0 18px;
}

.footer-links {
  font-size: 10px;
  margin-top: 1px;
  opacity: 0.85;
}

.site-footer .footer-links a {
  color: inherit;
  font-weight: normal;
}

/* ---------- Celular: topo compacto, tabuleiro com prioridade ---------- */

/* As linhas do layout não esticam para preencher a tela (isso abria buracos
   entre título, placar e botões); o espaço que sobra fica para o tabuleiro. */
.layout {
  align-content: start;
}

@media (max-width: 520px) {
  .layout {
    padding: 10px 12px 0;
    row-gap: 10px;
  }

  h1.title {
    font-size: 44px;
  }

  .heading {
    padding-bottom: 8px;
  }

  .side .scores-container {
    gap: 8px;
  }

  .side .score-container,
  .side .best-container {
    padding: 5px 10px 4px;
    border-radius: 10px;
  }

  .scores-container .label {
    font-size: 11px;
    line-height: 12px;
  }

  .scores-container .value {
    font-size: 20px;
    line-height: 24px;
  }

  .toolbar {
    margin: 0 0 10px;
  }
}

/* Celulares baixos: título menor para sobrar altura para o tabuleiro. */
@media (max-width: 520px) and (max-height: 700px) {
  h1.title {
    font-size: 36px;
  }
  .layout {
    row-gap: 8px;
  }
}

/* ---------- Faixa do ranking no celular (1º, 2º e você) ---------- */

.mini-rank {
  display: none;
}

@media (max-width: 899px), (max-aspect-ratio: 1/1) {
  .mini-rank {
    display: flex;
    gap: 6px;
    width: 100%;
    border: 0;
    padding: 0;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    color: #776e65;
    justify-content: center;
    align-items: center;
    min-height: 28px;
  }

  .side {
    gap: 8px;
  }
}

.mr-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(187, 173, 160, 0.35);
  border-radius: 8px;
  padding: 5px 8px;
}

.mr-item.live {
  background: var(--accent);
  color: #f9f6f2;
}

.mr-item.me {
  box-shadow: 0 0 0 2px #edc22e inset;
}

.mr-pos {
  flex: none;
}

.mr-pos[data-pos="1"] { color: #edc22e; }
.mr-pos[data-pos="2"] { color: #a39b92; }
.mr-item.live .mr-pos { color: inherit; }

.mr-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.mr-pts {
  flex: none;
  font-weight: normal;
}

/* ---------- Aviso de instalação do app (topo, longe do tabuleiro) ---------- */

.install-banner {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 24px));
  box-sizing: border-box;
  z-index: 1150;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  background: #faf8ef;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 10px 34px rgba(60, 58, 50, 0.28);
  font-size: 14px;
  line-height: 1.35;
  animation: install-in 300ms ease;
}

.install-banner[hidden] {
  display: none;
}

@keyframes install-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.install-icon {
  width: 44px;
  height: 44px;
  flex: none;
}

.install-text {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
}

.install-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.install-actions .restart-button {
  height: 36px;
  line-height: 36px;
  font-size: 15px;
  padding: 0 16px;
}

/* ---------- Salvar no ranking: botão chamando atenção, campos em coluna no celular ---------- */

.rank-form #rankSubmit {
  animation: attention 1.4s ease-in-out infinite;
}

.rank-form #rankSubmit:disabled {
  animation: none;
}

@media (max-width: 520px) {
  .rank-form-row {
    flex-direction: column;
    align-items: stretch;
    width: min(260px, 78vw);
    margin: 0 auto;
  }

  .rank-form input,
  .rank-form .pin-input {
    width: 100%;
    max-width: none;
  }
}

/* Formulário do ranking sempre em coluna (computador e celular). */
.rank-form-row {
  flex-direction: column;
  align-items: stretch;
  width: min(260px, 78vw);
  margin: 0 auto;
}

.rank-form input,
.rank-form .pin-input {
  width: 100%;
  max-width: none;
}

/* ---------- Barra: tamanho (seletor rápido) + botão de poderes ---------- */

.mode-chips {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-wrap {
  position: relative;
}

.size-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf8ef;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 12px 34px rgba(60, 58, 50, 0.3);
  animation: fade-in 120ms ease;
}

.size-pop[hidden] {
  display: none;
}

.powers-chip {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  font-family: inherit;
  font-weight: bold;
  font-size: 15px;
  cursor: pointer;
  background: #bbada0;
  color: #f9f6f2;
  transition: background 200ms, box-shadow 200ms;
}

.powers-chip svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.powers-chip.on {
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(var(--accent-rgb), 0.45);
}

.powers-chip.burst {
  animation: chip-burst 450ms ease-out;
}

@keyframes chip-burst {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.7); }
  35%  { transform: scale(1.12); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(var(--accent-rgb), 0); }
}

/* Ícone do "Novo jogo" só aparece nas telas bem estreitas (no lugar do texto). */
.restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.restart-button svg {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 899px), (max-aspect-ratio: 1/1) {
  /* No celular a faixa do ranking abre o ranking; o troféu sai para caber tudo. */
  .toolbar .ranking-button {
    display: none;
  }
}

@media (max-width: 520px) {
  .powers-chip {
    height: 34px;
    font-size: 13px;
    padding: 0 10px;
  }
}

@media (max-width: 380px) {
  .toolbar .restart-button {
    width: 34px;
    padding: 0;
  }
  .toolbar .restart-button span {
    display: none;
  }
  .toolbar .restart-button svg {
    display: block;
  }
}
