/* TWIRLDROP: marfim quente, cerâmica esmaltada. Sem tema escuro, sem caixas quadradas, sem emoji.
   Tamanhos em em e em unidades do contêiner (#stage), nunca em vw/vh. HUD e telas ficam numa coluna de
   retrato (--colw, vinda do JS) e o 3D ocupa a área de jogo inteira. Fontes empacotadas, com versão fixa. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fraunces-latin-ext-full-normal-YHFkNujK.woff2')
    format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./fraunces-latin-full-normal-CFFu7zhK.woff2')
    format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./outfit-latin-ext-wght-normal-DdQaqQDo.woff2')
    format('woff2-variations');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('./outfit-latin-wght-normal-Bc-8i84L.woff2')
    format('woff2-variations');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ivory: #f7f0e3;
  --ivory-deep: #ecdfc9;
  --paper: #fffaf1;
  --clay: #e9dfcf;
  --ink: #2c2231;
  --ink-soft: #5d4f60;
  --coral: #f0745e;
  --coral-deep: #d95a45;
  --teal: #2fa7a0;
  --lavender: #a99be2;
  --apricot: #f0a45e;
  --amber: #b97a12;
  --brass: #c9a35a;
  /* cores do ambiente da torre atual; o jogo troca conforme a paleta */
  --sky-top: #faf4ea;
  --sky-bottom: #eddfc8;
  /* largura da coluna de jogo, em pixels; vem do JS */
  --colw: 320px;
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --ui: 'Outfit', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --shadow: 0 0.5em 1.2em -0.5em rgb(74 52 40 / 0.45), 0 0.1em 0.2em rgb(74 52 40 / 0.14);
  --lift: inset 0 0.09em 0 rgb(255 255 255 / 0.75), inset 0 -0.12em 0 rgb(74 52 40 / 0.12);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ivory-deep);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
svg {
  width: 1.5em;
  height: 1.5em;
  flex: none;
}

/* O ambiente é um degradê só, da página. O canvas é transparente, então não existe emenda nem moldura. */
#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
}
/* Área de jogo: a janela inteira (ou menos, só quando passaria do teto de pixels). Tamanho e fonte vêm do JS. */
#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  container-type: size;
  font-size: 16px;
}
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
#stage.inset #game {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
}
/* Véus do ambiente: reservam a faixa do placar e, no título, a área do logo e dos botões. Nada do 3D
   aparece por trás do texto. Vão de ponta a ponta, então não deixam faixa central. */
#stage::before,
#stage::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s;
}
/* em partida, o véu do topo é sólido até a base do placar (medida pelo JS) e some logo abaixo */
#stage::before {
  top: 0;
  height: calc(var(--hud-h, 7.5em) * 1.3);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-top) 77%, transparent 100%);
}
#stage::after {
  bottom: 0;
  height: 44%;
  background: linear-gradient(0deg, var(--sky-bottom) 0%, var(--sky-bottom) 58%, transparent 100%);
}
#stage[data-view='play']::before,
#stage[data-view='menu']::before,
#stage[data-view='menu']::after {
  opacity: 1;
}
/* No título, o bloco do logo e o dos botões são reservados (medidos pelo JS). Os véus repetem o degradê da
   página, pixel por pixel, e só esmaecem nos últimos 28 px: a torre aparece em cor cheia entre os dois. */
#stage[data-view='menu']::before,
#stage[data-view='menu']::after {
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom)) no-repeat;
  background-size: 100% 100cqh;
}
#stage[data-view='menu']::before {
  height: calc(var(--menu-h, 34cqh) + 28px);
  background-position: top;
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 calc(100% - 28px), transparent 100%);
}
#stage[data-view='menu']::after {
  top: calc(var(--menu-b, 60cqh) - 28px);
  height: auto;
  background-position: bottom;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 28px);
  mask-image: linear-gradient(180deg, transparent 0, #000 28px);
}
/* tela larga: a vitrine fica ao lado do menu, inteira, sem véu nenhum */
#stage.side[data-view='menu']::before,
#stage.side[data-view='menu']::after {
  opacity: 0;
}
/* Véu de corte entre tentativas: um plano animado pelo JS, que nunca recebe toque. (O jogo não tem clarão.) */
#flash {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}
/* Pontos que sobem ao lado da bola. */
/* Etiqueta do aro: de quem é a marca. A posição vem do mundo 3D, a cada quadro. */
#rival {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: max(0.8em, 11px);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 0.15em 0.5em rgb(44 34 49 / 0.28);
}
#rival.me {
  background: var(--brass);
  color: var(--ink);
}
#pops {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}
#pops i {
  position: absolute;
  opacity: 0;
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 0,
    'opsz' 144;
  font-style: normal;
  font-weight: 800;
  font-size: 1.5em;
  line-height: 1;
  color: var(--ink);
  -webkit-text-stroke: 0.22em var(--paper);
  paint-order: stroke fill;
  white-space: nowrap;
  will-change: transform, opacity;
}
#pops i.warm {
  color: #8a5a12;
}
/* "Ufa!": o único texto vermelho do jogo, porque fala do perigo */
#pops i.close {
  color: #c81e3a;
}
#pops i.gold {
  color: var(--amber);
}
#pops i.big {
  font-size: 2.3em;
}
/* Depois da falha a cena perde cor por um instante: o erro lê-se sem clarão nenhum. */
#game {
  transition: filter 0.25s ease-out;
}
#stage.dead #game {
  filter: saturate(0.55) brightness(0.97);
}
/* Coluna de retrato no centro: HUD e telas. O toque fora dos botões atravessa e chega ao canvas. */
#col {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - var(--colw) / 2);
  width: var(--colw);
  z-index: 2;
  pointer-events: none;
}
#col button,
#col input,
#result {
  pointer-events: auto;
}

/* ---------------------------------------------------------------- peças comuns */
.num {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 0,
    'opsz' 144;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
  min-height: max(3.1em, 48px);
  padding: 0.55em 1.3em;
  border-radius: 999px;
  font-weight: 650;
  font-size: 1.05em;
  letter-spacing: 0.01em;
  background: var(--paper);
  box-shadow: var(--shadow), var(--lift);
}
/* Todo botão responde ao dedo: afunda na hora e volta com uma mola curta. */
.btn,
.chip,
.icon,
.tile,
.seg button {
  transition:
    transform 0.22s cubic-bezier(0.3, 1.7, 0.5, 1),
    box-shadow 0.18s ease-out,
    filter 0.18s ease-out;
}
.btn:active,
.chip:active,
.icon:active,
.tile:active:not(.locked),
.seg button:active {
  transform: translateY(0.12em) scale(0.955);
  box-shadow:
    0 0.15em 0.4em -0.2em rgb(74 52 40 / 0.5),
    var(--lift);
  transition-duration: 0.05s;
}
@media (hover: hover) {
  .btn:hover:not(:active),
  .chip:hover:not(:active),
  .icon:hover:not(:active),
  .tile:hover:not(:active):not(.locked) {
    transform: translateY(-0.08em);
    filter: brightness(1.03);
  }
}
/* A ação principal tem um brilho que passa de tempos em tempos: é para onde o olho deve ir. */
.btn.primary {
  position: relative;
  overflow: hidden;
}
/* O brilho é o fundo de uma camada do tamanho exato do botão: o que anda é a posição do fundo, então nada
   sai da caixa (uma faixa que se movesse para fora contaria como conteúdo transbordando). */
.btn.primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 42%, rgb(255 255 255 / 0.42) 50%, transparent 58%)
    no-repeat;
  background-size: 260% 100%;
  background-position: 160% 0;
  animation: sheen 3.6s ease-in-out 1.2s infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%,
  62% {
    background-position: 160% 0;
  }
  88%,
  100% {
    background-position: -60% 0;
  }
}
.btn.primary {
  background: linear-gradient(180deg, #f58b76, var(--coral));
  color: var(--ink);
}
.btn.accent {
  flex-direction: column;
  gap: 0.05em;
  background: linear-gradient(180deg, #58c2bb, var(--teal));
  color: var(--ink);
}
.btn.accent small {
  font-weight: 500;
  font-size: 0.72em;
  opacity: 0.9;
}
/* botão com duas linhas: o nome da ação e, embaixo, do que se trata */
.btn.stack {
  flex-direction: column;
  gap: 0.05em;
}
.btn.stack small {
  font-weight: 600;
  font-size: 0.6em;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.btn.big {
  min-height: max(3.5em, 52px);
  font-size: 1.18em;
  font-weight: 750;
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: max(3em, 48px);
  min-width: max(3em, 48px);
  padding: 0.4em 1em;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow), var(--lift);
  font-weight: 600;
  font-size: 0.9em;
}
.chip svg {
  width: 1.3em;
  height: 1.3em;
}
.icon {
  display: grid;
  place-items: center;
  width: 3em;
  height: 3em;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow), var(--lift);
}
.link {
  background: none;
  min-height: 48px;
  min-width: 48px;
  padding: 0.4em 0.9em;
  font-weight: 600;
  font-size: 0.86em;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 0.08em;
}
.row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55em;
}
/* botão largo com um botão redondo ao lado (campanha e lista de torres) */
.duo {
  display: flex;
  align-items: center;
  gap: 0.55em;
  width: 100%;
}
.duo .btn {
  flex: 1;
  min-width: 0;
}
.duo .icon {
  flex: none;
}
.seg {
  display: inline-flex;
  padding: 0.22em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.1);
  gap: 0.15em;
}
.seg button {
  min-height: max(2.75em, 44px);
  min-width: max(2.9em, 44px);
  padding: 0.3em 0.9em;
  border-radius: 999px;
  background: none;
  font-weight: 600;
  font-size: 0.86em;
  color: var(--ink-soft);
}
.seg.small button {
  padding: 0.2em 0.75em;
}
.seg button[aria-pressed='true'],
.seg button[aria-selected='true'] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
/* Chamada de ação: respira de leve, sem nunca ficar apagada (o contraste se mantém). */
.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.74;
    transform: scale(0.975);
  }
}
.eyebrow {
  margin: 0;
  font-weight: 650;
  font-size: max(0.82em, 11px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}
.note {
  margin: 0;
  font-size: max(0.84em, 11px);
  color: var(--ink-soft);
  text-align: center;
}

/* ---------------------------------------------------------------- logo */
.logo {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1,
    'opsz' 144;
  font-weight: 850;
  font-size: min(calc(var(--colw) * 0.155), 9.5cqh);
  letter-spacing: -0.035em;
  line-height: 0.95;
  color: var(--ink);
}
.logo .ring {
  width: 0.62em;
  height: 0.78em;
  margin: 0 0.02em 0 0.015em;
  align-self: flex-end;
  overflow: visible;
}
.tagline {
  margin: 0.5em 0 0;
  font-weight: 600;
  font-size: 0.86em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------------------------------------------------------------- telas cheias */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(1.1em, env(safe-area-inset-top)) max(1.2em, env(safe-area-inset-right))
    max(1.3em, env(safe-area-inset-bottom)) max(1.2em, env(safe-area-inset-left));
  text-align: center;
}
#splash {
  justify-content: center;
  z-index: 30;
}
/* "Toque para começar": o logo sobre a torre de verdade; o toque libera o som e os botões entram. */
#splash .tap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
}
#splash .tap .logo {
  margin-top: calc(48px + 1.5cqh + 0.6em);
}
#splash .tap .tagline {
  margin-bottom: auto;
}
#tap-start {
  margin: 0 0 2.6em;
  font-weight: 700;
  font-size: 1.2em;
  letter-spacing: 0.03em;
  color: var(--ink);
}
#title {
  justify-content: space-between;
  z-index: 10;
}
.title-top {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}
#title .logo {
  margin-top: calc(1.5cqh + 0.6em);
}
#title .tagline {
  margin-bottom: auto;
}
#title .logo,
#splash .tap .logo {
  animation: logo-in 0.6s cubic-bezier(0.25, 1.4, 0.4, 1) backwards;
}
#title .tagline,
#splash .tap .tagline {
  animation: fade 0.4s ease-out 0.22s backwards;
}
/* a pérola do logo quica uma vez quando o nome chega */
.logo .ring circle {
  animation: pearl 0.7s cubic-bezier(0.3, 0, 0.5, 1) 0.45s backwards;
}
@keyframes logo-in {
  from {
    opacity: 0;
    transform: translateY(-0.5em) scale(0.92);
  }
}
@keyframes pearl {
  0% {
    transform: translateY(-34px);
    opacity: 0;
  }
  45% {
    transform: translateY(0);
    opacity: 1;
  }
  65% {
    transform: translateY(-9px);
  }
  100% {
    transform: translateY(0);
  }
}
.title-actions > * {
  animation: rise-in 0.42s cubic-bezier(0.25, 1.3, 0.4, 1) backwards;
}
.title-actions > :nth-child(1) {
  animation-delay: 0.12s;
}
.title-actions > :nth-child(2) {
  animation-delay: 0.2s;
}
.title-actions > :nth-child(3) {
  animation-delay: 0.28s;
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(1.3em);
  }
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  width: min(100%, 21em);
}

/* ---------------------------------------------------------------- partida */
#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(0.8em, env(safe-area-inset-top)) max(0.8em, env(safe-area-inset-right)) 0
    max(0.8em, env(safe-area-inset-left));
  z-index: 5;
}
.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  min-width: 0;
}
#hud-score {
  font-size: 2.9em;
  color: var(--ink);
}
#hud-score.bump {
  animation: bump 0.22s ease-out;
}
@keyframes bump {
  30% {
    transform: scale(1.2) translateY(-0.03em);
  }
}
/* O placar entra de cima quando a partida começa. */
#hud {
  animation: hud-in 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes hud-in {
  from {
    transform: translateY(-1.6em);
    opacity: 0;
  }
}
/* Carga: três pinos, um por passagem seguida. No terceiro o medidor vira a palavra de ordem. */
#hud-charge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.34em;
  height: 1.5em;
  min-width: 6.4em;
  padding: 0 0.7em;
  border-radius: 999px;
  transition:
    background-color 0.18s ease-out,
    box-shadow 0.18s ease-out;
}
#hud-charge i {
  width: 1.5em;
  height: 0.62em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.16);
  box-shadow: inset 0 0.08em 0.12em rgb(74 52 40 / 0.2);
  transition: background-color 0.12s ease-out;
}
#hud-charge i.on {
  background: linear-gradient(180deg, #f8d77c, #ecb93a);
  box-shadow:
    inset 0 0.08em 0 rgb(255 255 255 / 0.55),
    0 0.1em 0.3em -0.05em rgb(185 122 18 / 0.75);
  animation: pin 0.3s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes pin {
  from {
    transform: scale(1.9, 2.3);
  }
}
#hud-charge b {
  display: none;
  font-family: var(--ui);
  font-weight: 800;
  font-size: max(0.82em, 11px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
}
#hud-charge.armed {
  background: linear-gradient(180deg, #f8d77c, #ecb93a);
  box-shadow:
    0 0.2em 0.7em -0.15em rgb(185 122 18 / 0.75),
    inset 0 0.08em 0 rgb(255 255 255 / 0.6);
  animation:
    armed 0.36s cubic-bezier(0.3, 1.9, 0.5, 1),
    ready 0.9s ease-in-out 0.36s infinite;
}
#hud-charge.armed i {
  display: none;
}
#hud-charge.armed b {
  display: block;
}
@keyframes armed {
  from {
    transform: scale(1.5);
  }
}
/* sequência perdida: o medidor balança ao esvaziar */
#hud-charge.lost {
  animation: lost 0.3s ease-out;
}
@keyframes lost {
  25% {
    transform: translateX(-0.28em);
  }
  60% {
    transform: translateX(0.2em);
  }
}
@keyframes ready {
  50% {
    transform: scale(1.06);
  }
}
#hud-sub {
  font-weight: 600;
  font-size: max(0.8em, 11px);
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  white-space: nowrap;
}
#hud-progress {
  width: 7.5em;
  height: 0.42em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.16);
  overflow: hidden;
}
/* preenchimento em tinta escura: não depende da cor do andar que estiver atrás */
#hud-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--ink);
  transition: width 0.25s ease-out;
}
#hint {
  position: absolute;
  inset: auto 0 9cqh 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  padding: 0 1.4em;
  z-index: 4;
  text-align: center;
}
#hint p {
  margin: 0;
  max-width: 17em;
  padding: 0.55em 1.1em;
  border-radius: 1.4em;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 600;
  line-height: 1.3;
}
#hint .link {
  margin-top: 0.3em;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}
#hint .finger {
  display: none;
  width: 9em;
  height: 2.6em;
  position: relative;
}
#hint.drag .finger {
  display: block;
}
/* dedo-fantasma: um disco de pérola com sombra suave, sem contorno escuro */
#hint .finger i {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2.3em;
  height: 2.3em;
  margin-left: -1.15em;
  border-radius: 50%;
  background: rgb(255 250 241 / 0.55);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px rgb(74 52 40 / 0.18);
  animation: sway 2.6s ease-in-out infinite;
}
/* rastro do arrasto, dos dois lados */
#hint .finger::before {
  content: '';
  position: absolute;
  left: 0.6em;
  right: 0.6em;
  top: 1.05em;
  height: 0.22em;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    rgb(255 250 241 / 0.9) 30%,
    rgb(255 250 241 / 0.9) 70%,
    transparent
  );
}
@keyframes sway {
  0%,
  100% {
    transform: translateX(-3.2em);
  }
  50% {
    transform: translateX(3.2em);
  }
}
#retry,
#toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.6em 1.3em;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 650;
  width: max-content;
  max-width: 88%;
  text-align: center;
  z-index: 6;
}
#retry {
  bottom: 16cqh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  border-radius: 1.5em;
  animation:
    retry-in 0.26s cubic-bezier(0.3, 1.6, 0.5, 1),
    nudge 1.6s ease-in-out 0.26s infinite;
}
/* ---------------------------------------------------------------- convite de anúncio premiado
   Pedido do dono: o "ver anúncio" é o botão que chama, no centro, com brilho; o "não" fica embaixo.
   Limites que continuam valendo: o "não" é legível e tem alvo de toque inteiro, o botão diz que é anúncio,
   e não existe contagem regressiva. Ouro é a cor de prêmio do jogo (a mesma da carga). */
.btn.cta {
  position: relative;
  overflow: hidden;
  gap: 0.7em;
  width: min(100%, 17em);
  min-height: max(4.2em, 62px);
  padding: 0.5em 1.4em 0.5em 0.9em;
  font-size: 1.16em;
  color: var(--ink);
  background: linear-gradient(180deg, #fde592 0%, #f3c044 55%, #e5a623 100%);
  box-shadow:
    0 0.6em 1.5em -0.35em rgb(185 122 18 / 0.85),
    inset 0 0.13em 0 rgb(255 255 255 / 0.75),
    inset 0 -0.18em 0 rgb(140 84 8 / 0.35);
  animation: cta 1.4s ease-in-out infinite;
}
/* brilho que atravessa o botão */
.btn.cta::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgb(255 255 255 / 0.72) 50%, transparent 60%)
    no-repeat;
  background-size: 260% 100%;
  background-position: 160% 0;
  animation: sheen 2.2s ease-in-out 0.5s infinite;
  pointer-events: none;
}
.btn.cta svg {
  box-sizing: content-box;
  width: 1.35em;
  height: 1.35em;
  padding: 0.42em;
  border-radius: 50%;
  background: var(--ink);
  color: #fde592;
}
.btn.cta span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.12;
  text-align: left;
}
.btn.cta b {
  font-weight: 800;
}
.btn.cta small {
  font-weight: 600;
  font-size: 0.62em;
  letter-spacing: 0.02em;
  opacity: 0.82;
}
.btn.cta:active {
  animation: none;
  transform: scale(0.955);
}
@keyframes cta {
  50% {
    transform: scale(1.045);
    box-shadow:
      0 0.8em 2.1em -0.3em rgb(214 142 20 / 0.95),
      inset 0 0.13em 0 rgb(255 255 255 / 0.75),
      inset 0 -0.18em 0 rgb(140 84 8 / 0.35);
  }
}
/* o "não": embaixo, sem caixa, mas com letra legível e alvo de toque inteiro */
.link.quiet {
  margin-top: -0.2em;
  font-size: 0.92em;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}
/* cartão do convite: uma luz quente atrás do botão, e o prêmio à vista */
.card.ad {
  gap: 0.6em;
  background: radial-gradient(120% 60% at 50% 70%, #fff1c9 0%, var(--paper) 62%);
}
.card.ad .lead {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-weight: 750;
  font-size: 1.45em;
  text-align: center;
}
.card.ad .note {
  margin-bottom: 0.3em;
}
.prize b {
  display: inline-block;
  padding: 0.3em 1.1em;
  border-radius: 999px;
  background: linear-gradient(180deg, #f8d77c, #ecb93a);
  box-shadow:
    0 0.2em 0.7em -0.15em rgb(185 122 18 / 0.75),
    inset 0 0.08em 0 rgb(255 255 255 / 0.6);
  font-weight: 800;
  font-size: 0.86em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: ready 0.9s ease-in-out infinite;
}
/* a bola com o acabamento oferecido */
.card.ad .ball {
  width: 4.2em;
  height: 4.2em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgb(255 255 255 / 0.85) 0 7%, transparent 22%),
    linear-gradient(168deg, transparent 43%, var(--s, #f0745e) 43% 57%, transparent 57%),
    radial-gradient(
      circle at 40% 34%,
      var(--c, #fcfaf5),
      color-mix(in srgb, var(--c, #fcfaf5) 72%, #5a3a1a) 96%
    );
  box-shadow: 0 0.7em 1.2em -0.5em rgb(74 52 40 / 0.6);
  animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: translateY(-0.35em);
  }
}
/* "Continuar daqui" (campanha): o mesmo botão dourado, logo acima do aviso da falha */
#btn-continue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(16cqh + 5.6em);
  margin: 0 auto;
  z-index: 6;
  width: max-content;
  max-width: 88%;
  font-size: 1.02em;
  min-height: max(3.7em, 56px);
  animation:
    cta-in 0.3s cubic-bezier(0.3, 1.6, 0.5, 1),
    cta 1.4s ease-in-out 0.3s infinite;
}
@keyframes cta-in {
  from {
    opacity: 0;
    transform: translateY(0.9em) scale(0.84);
  }
}
#retry b {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-weight: 750;
  font-size: 1.25em;
}
#retry b:empty {
  display: none;
}
#retry span {
  font-size: 0.92em;
  color: var(--ink-soft);
}
@keyframes retry-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0.8em) scale(0.86);
  }
}
/* Dica e aviso do topo também entram com mola, em vez de aparecer de uma vez. */
#hint {
  animation: hint-in 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes hint-in {
  from {
    opacity: 0;
    transform: translateY(0.8em) scale(0.94);
  }
}
#toast {
  animation: toast-in 0.34s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-1.2em) scale(0.9);
  }
}
@keyframes nudge {
  50% {
    transform: translateX(-50%) scale(1.045);
  }
}
#toast {
  top: max(1em, env(safe-area-inset-top));
  z-index: 45;
}

/* ---------------------------------------------------------------- resultado (bandeja de baixo, opaca) */
.tray {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  padding: 1.2em max(1.2em, env(safe-area-inset-right)) max(1.2em, env(safe-area-inset-bottom))
    max(1.2em, env(safe-area-inset-left));
  border-radius: 2em 2em 0 0;
  background: var(--paper);
  box-shadow: 0 -0.8em 2em -1em rgb(74 52 40 / 0.4);
  z-index: 12;
  animation: rise 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes rise {
  from {
    transform: translateY(40%);
    opacity: 0;
  }
}
/* fim da campanha: o título vira a comemoração */
.tray.finale .eyebrow {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1,
    'opsz' 144;
  font-weight: 850;
  font-size: 1.9em;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  animation: stamp 0.4s cubic-bezier(0.3, 1.9, 0.5, 1) backwards;
}
.tray.finale .note {
  max-width: 22em;
  font-size: max(0.95em, 12px);
  line-height: 1.4;
  color: var(--ink);
}
.num.huge {
  font-size: min(calc(var(--colw) * 0.2), 12cqh);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin: 0;
  padding: 0.3em 0.9em;
  border-radius: 999px;
  background: var(--apricot);
  font-weight: 700;
  font-size: max(0.82em, 11px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tag.plain {
  background: rgb(74 52 40 / 0.07);
}
.tag {
  animation: stamp 0.34s cubic-bezier(0.3, 1.9, 0.5, 1) backwards;
}
.tag.plain {
  animation-delay: 0.12s;
}
@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(1.7) rotate(-6deg);
  }
}
.stats div {
  animation: fade 0.3s ease-out backwards;
}
.stats div:nth-child(2) {
  animation-delay: 0.07s;
}
.stats div:nth-child(3) {
  animation-delay: 0.14s;
}
.tag svg {
  width: 1.15em;
  height: 1.15em;
  color: var(--amber);
}
.stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5em;
  width: 100%;
  animation: fade 0.3s ease-out;
}
.stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  font-size: max(0.74em, 11px);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}
.stats b {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-size: 2em;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: 0;
}
.chip.fresh {
  background: linear-gradient(180deg, #58c2bb, var(--teal));
}
.chip.fresh::after {
  content: '';
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--apricot);
  box-shadow: 0 0 0 0.12em var(--paper);
}
.rankline {
  margin: 0;
  font-weight: 650;
  font-size: 0.95em;
  text-align: center;
}
.actions {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  width: min(100%, 21em);
  margin-top: 0.3em;
  animation: fade 0.3s ease-out;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(0.4em);
  }
}

/* ---------------------------------------------------------------- janelas por cima */
.sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(0.9em, env(safe-area-inset-top)) max(0.9em, env(safe-area-inset-right))
    max(0.9em, env(safe-area-inset-bottom)) max(0.9em, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--sky-top) 72%, transparent);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  z-index: 20;
}
#audio,
#ad-wait {
  z-index: 35;
}
/* "Vire o celular": cobre a janela inteira com o mesmo ambiente, sem faixa nem emenda. */
#rotate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 60;
  font-size: 18px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
}
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7em;
  width: min(100%, 19.5em);
  max-height: 100%;
  padding: 1.4em 1.2em 1.2em;
  border-radius: 2em;
  background: var(--paper);
  box-shadow:
    0 1.4em 3em -1.2em rgb(74 52 40 / 0.5),
    var(--lift);
  animation: pop 0.28s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes pop {
  from {
    transform: translateY(1em) scale(0.9);
    opacity: 0;
  }
}
.sheet {
  animation: veil 0.18s ease-out;
}
@keyframes veil {
  from {
    opacity: 0;
  }
}
.card.wide {
  width: min(100%, 23em);
}
.card.bare {
  background: none;
  box-shadow: none;
  text-align: center;
}
.card h2 {
  margin: 0;
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-weight: 750;
  font-size: 1.5em;
  text-align: center;
}
.card p {
  margin: 0;
}
.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.6em;
}
.card header .icon {
  box-shadow: none;
  background: rgb(74 52 40 / 0.08);
}
.big-icon {
  width: 4.2em;
  height: 4.2em;
  color: var(--coral-deep);
  overflow: visible;
}
.lead {
  font-weight: 650;
  font-size: 1.06em;
  text-align: center;
  line-height: 1.35;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
  width: 100%;
}
.pair .btn {
  font-size: 0.92em;
  padding-inline: 0.6em;
}
.inline {
  display: flex;
  gap: 0.5em;
  width: 100%;
}
.inline input {
  flex: 1;
  min-width: 0;
  min-height: max(3.1em, 48px);
  padding: 0 1.1em;
  border: 0.14em solid rgb(74 52 40 / 0.18);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
.inline .btn {
  width: auto;
}
/* a janela do nome: o campo em cima e o botão grande embaixo (o texto "Entrar no ranking" não cabe ao lado) */
.inline.col {
  flex-direction: column;
}
.inline.col .btn {
  width: 100%;
}
#nick-sum {
  margin: 0;
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 0,
    'opsz' 144;
  font-weight: 800;
  font-size: 1.25em;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}
.note.fine {
  font-size: max(0.78em, 11px);
  opacity: 0.85;
}
/* Convite dourado do resultado: entrar no ranking, escolher outro nome, ver os outros jogadores. O brilho
   pulsa só na sombra, sem mexer no tamanho (o toque não perde o alvo). */
.chip.hot {
  background: linear-gradient(180deg, #ffe08a, #f2b84b);
  animation: glow 1.8s ease-in-out infinite;
}
@keyframes glow {
  50% {
    box-shadow:
      var(--shadow),
      var(--lift),
      0 0 0 0.3em rgb(242 184 75 / 0.38);
  }
}
#app.calm .chip.hot {
  animation: none;
}

/* Torres: doze fichas de cerâmica nas cores dos andares. Travada é barro cru, sem esmalte.
   A altura das linhas sai da altura da área de jogo, então as doze sempre cabem, sem rolar. */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: clamp(48px, calc((100cqh - 17em) / var(--rows, 4)), 5.6em);
  gap: 0.6em;
  width: 100%;
  justify-items: center;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  aspect-ratio: 1;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 24%,
    color-mix(in srgb, var(--c) 52%, #fff) 0%,
    var(--c) 44%,
    color-mix(in srgb, var(--c) 80%, #2c2231) 100%
  );
  box-shadow:
    inset 0 0.14em 0 rgb(255 255 255 / 0.5),
    inset 0 -0.2em 0 rgb(44 34 49 / 0.18),
    0 0.35em 0.7em -0.3em rgb(74 52 40 / 0.6);
}
.tile b {
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-size: 1.75em;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}
.tile.locked {
  background: var(--clay);
  box-shadow: inset 0 0 0 0.1em rgb(74 52 40 / 0.1);
  cursor: default;
}
.tile.locked b {
  color: #c4b8a2;
  font-weight: 650;
  text-shadow: 0 0.04em 0 rgb(255 255 255 / 0.7);
}
/* concluída ganha o friso de latão da base final; "de primeira" ganha a estrela */
.tile.done {
  box-shadow:
    0 0 0 0.16em var(--brass),
    inset 0 0.14em 0 rgb(255 255 255 / 0.5),
    inset 0 -0.2em 0 rgb(44 34 49 / 0.18),
    0 0.35em 0.7em -0.3em rgb(74 52 40 / 0.6);
}
.tile svg {
  position: absolute;
  top: -0.1em;
  right: -0.1em;
  width: 1.25em;
  height: 1.25em;
  padding: 0.12em;
  border-radius: 50%;
  background: var(--paper);
  color: var(--amber);
}
/* a próxima a jogar tem a pérola pousada em cima */
.tile.current::after {
  content: '';
  position: absolute;
  top: -0.3em;
  left: 50%;
  width: 0.9em;
  height: 0.9em;
  margin-left: -0.45em;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff 0%, var(--paper) 55%, #dccfbb 100%);
  box-shadow: 0 0.14em 0.3em rgb(74 52 40 / 0.5);
}
#tw-caption {
  min-height: 1.3em;
  font-weight: 650;
  text-align: center;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1em;
  font-weight: 600;
  font-size: 0.86em;
  color: var(--ink-soft);
}
.pager .icon {
  box-shadow: none;
  background: rgb(74 52 40 / 0.08);
}
.pager .icon:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ranking e recordes */
.board {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.18em;
}
.board li {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  align-items: center;
  gap: 0.5em;
  padding: 0.34em 0.8em;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9em;
}
.board li.me {
  background: var(--apricot);
}
.board li i {
  font-style: normal;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.board li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.board li b {
  font-variant-numeric: tabular-nums;
}
.recs {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}
.recs .line {
  display: grid;
  grid-template-columns: 1fr 1.3em auto;
  align-items: center;
  gap: 0.6em;
  padding: 0.36em 0.4em;
  font-weight: 600;
  font-size: 0.9em;
}
.recs .line span {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recs .line b {
  font-variant-numeric: tabular-nums;
}
.recs .line svg {
  width: 1.2em;
  height: 1.2em;
  color: var(--amber);
}
.recs .trio {
  padding: 0.6em 0;
}
/* recordes das torres: doze fichas pequenas, três por linha */
.marks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35em;
}
.marks div {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  min-height: 2.5em;
  padding: 0.5em 0.8em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.07);
  font-weight: 600;
  font-size: 0.9em;
}
.recs .note {
  padding-top: 0.5em;
}
.marks i {
  font-style: normal;
  font-family: var(--display);
  font-variation-settings:
    'SOFT' 100,
    'opsz' 60;
  font-weight: 800;
  color: var(--ink-soft);
}
.marks b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.marks svg {
  align-self: center;
  width: 1.05em;
  height: 1.05em;
  color: var(--amber);
}

/* Ajustes: rótulo e controle direto na folha, sem caixa dentro de caixa */
.pane {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  width: 100%;
}
.slider,
.toggle,
.field,
.keycap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  width: 100%;
  min-height: 48px;
  padding: 0.15em 0.2em;
  background: none;
  font-weight: 600;
  font-size: 0.95em;
  text-align: left;
}
.field {
  flex-wrap: wrap;
}
.slider input {
  flex: 1;
  max-width: 54%;
  height: 44px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.slider input::-webkit-slider-runnable-track {
  height: 0.5em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.18);
}
.slider input::-moz-range-track {
  height: 0.5em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.18);
}
.slider input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: calc(0.25em - 14px);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #f9a493, var(--coral) 60%, var(--coral-deep));
  box-shadow: 0 0.15em 0.4em rgb(74 52 40 / 0.45);
}
.slider input::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #f9a493, var(--coral) 60%, var(--coral-deep));
  box-shadow: 0 0.15em 0.4em rgb(74 52 40 / 0.45);
}
.toggle i {
  position: relative;
  flex: none;
  width: 3.1em;
  height: 1.8em;
  border-radius: 999px;
  background: rgb(74 52 40 / 0.24);
  transition: background 0.15s;
}
.toggle i::after {
  content: '';
  position: absolute;
  top: 0.2em;
  left: 0.2em;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.1em 0.3em rgb(74 52 40 / 0.4);
  transition: transform 0.15s;
}
.toggle[aria-checked='true'] i {
  background: var(--teal);
}
.toggle[aria-checked='true'] i::after {
  transform: translateX(1.3em);
}
.keys {
  display: grid;
  gap: 0.2em;
}
kbd {
  min-width: 2.6em;
  padding: 0.42em 0.7em;
  border-radius: 0.6em;
  background: #fff;
  box-shadow:
    0 0.16em 0 rgb(74 52 40 / 0.28),
    0 0 0 0.08em rgb(74 52 40 / 0.14);
  font: 650 0.84em var(--ui);
  text-align: center;
}
.keycap.waiting kbd {
  background: var(--apricot);
}
.swatches {
  display: flex;
  gap: 0.15em;
}
.swatches button {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  background: none;
}
.swatches button::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #fff 0%,
    var(--c) 46%,
    color-mix(in srgb, var(--c) 70%, #2c2231) 100%
  );
  box-shadow: 0 0.12em 0.3em rgb(74 52 40 / 0.4);
}
.swatches button[aria-pressed='true'] {
  box-shadow: inset 0 0 0 3px var(--ink);
}
.swatches button.locked::before {
  background: var(--clay);
  box-shadow: inset 0 0 0 0.1em rgb(74 52 40 / 0.14);
}
.swatches button svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.1em;
  height: 1.1em;
  color: var(--ink-soft);
}

.ad-test {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: grid;
  place-content: center;
  gap: 1em;
  background: #2c2231;
  color: #fff;
  text-align: center;
  font-weight: 600;
}
.ad-test button {
  min-height: 48px;
  padding: 0 1.2em;
  border-radius: 999px;
  background: #fff;
  color: #2c2231;
}
#fatal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 2em;
  background: var(--ivory);
  text-align: center;
  font-weight: 600;
  z-index: 50;
  pointer-events: auto;
}

/* Telas baixas (iframe de portal, celular pequeno): mesma composição, mais justa. Nada rola. */
#stage.compact .card {
  padding: 1em 1em 0.9em;
  gap: 0.5em;
}
#stage.compact .title-actions {
  gap: 0.5em;
}
#stage.tiny #res-title {
  display: none;
}
/* altura curta: o nome da torre sai do HUD e sobram o placar e a barra */
#stage.compact #hud-sub.long,
#stage.tiny .tagline {
  display: none;
}
#stage.compact #hud-score {
  font-size: 2.4em;
}

/* Janela baixa e larga (PC ou iframe com menos de 500 px de altura): as janelas usam a largura que sobra,
   com os controles em duas colunas, para nada passar do fim da tela. */
@container (max-height: 500px) and (min-width: 600px) {
  .card.wide {
    width: min(100%, 38em);
  }
  .pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.4em;
  }
  .keys {
    display: contents;
  }
  .card header h2 {
    font-size: 1.25em;
  }
}

/* Janela baixa E estreita (por exemplo 320x360): o título da janela sai e o X fica na linha das abas. */
@container (max-height: 420px) and (max-width: 599px) {
  .card.wide {
    padding: 0.6em 0.8em 0.7em;
    gap: 0.3em;
  }
  .card.wide header {
    justify-content: flex-end;
    height: 0;
    align-items: flex-start;
    overflow: visible;
    position: relative;
    z-index: 1;
  }
  .card.wide header h2 {
    display: none;
  }
  .card.wide .seg[role='tablist'] {
    align-self: flex-start;
  }
  .card:not(.wide) {
    padding: 0.7em 0.9em;
    gap: 0.4em;
  }
  .card h2 {
    font-size: 1.15em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse,
  #retry,
  #hint,
  #hint .finger i,
  #toast,
  #hud,
  .tray,
  .card,
  .sheet,
  .tag,
  .stats,
  .stats div,
  .actions,
  .logo,
  .tagline,
  .logo .ring circle,
  .title-actions > *,
  #hud-charge,
  #hud-charge i,
  .btn.primary::after,
  .btn.cta,
  .btn.cta::after,
  .prize b,
  .card.ad .ball,
  #btn-continue {
    animation: none;
  }
}
#app.calm .tray.finale .eyebrow,
#app.calm #btn-continue,
#app.calm .btn.cta,
#app.calm .btn.cta::after,
#app.calm .prize b,
#app.calm .card.ad .ball,
#app.calm .pulse,
#app.calm #retry,
#app.calm #hint,
#app.calm #hint .finger i,
#app.calm #toast,
#app.calm #hud,
#app.calm .tray,
#app.calm .card,
#app.calm .sheet,
#app.calm .tag,
#app.calm .stats div,
#app.calm .logo,
#app.calm .tagline,
#app.calm .logo .ring circle,
#app.calm .title-actions > *,
#app.calm #hud-charge,
#app.calm #hud-charge i,
#app.calm .btn.primary::after,
#app.calm #hud-score.bump {
  animation: none;
}
#app.calm #game {
  transition: none;
}

/* Nota do ranking externo: discreta no menu, legível quando aberta. */
#portal-privacy {
  position: fixed;
  bottom: calc(4px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: min(90%, 420px);
  font-size: 11px;
  text-align: center;
  color: #5d4f60;
}
#portal-privacy[open] {
  background: #fffaf1;
  padding: 12px;
  border-radius: 14px;
  box-shadow: 0 6px 30px #30203433;
}
#portal-privacy summary {
  cursor: pointer;
  min-height: 24px;
  display: grid;
  place-items: center;
}
#portal-privacy p {
  margin: 8px 0;
  line-height: 1.45;
}
#portal-privacy a {
  color: #356b6a;
}
