* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: #1b1f3a;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

#app {
  --cell: 56px;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(120% 80% at 50% 0%, #2c3270 0%, #1b1f3a 60%, #12142a 100%);
}

/* ---------- HUD ---------- */
#hud {
  width: 100%; max-width: 520px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px 6px;
}
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .65; }
.stat .value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .value.bump { animation: bump .25s ease-out; }
#best { color: #ffd54a; }
.stat.next { align-items: center; }
#nextBox { position: relative; width: 38px; height: 38px; margin-top: 2px; }
.btns { display: flex; gap: 6px; }
.btns button {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; font-size: 20px; line-height: 1;
}
.btns button:active { background: rgba(255,255,255,.25); }

/* ---------- Palco e grade ---------- */
#stage {
  position: relative; width: 100%; flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center;
  padding-top: calc(var(--cell) * 1.12);
  touch-action: none; cursor: pointer;
}
#board {
  position: relative;
  width: calc(var(--cell) * var(--cols, 5)); height: calc(var(--cell) * var(--rows, 7));
  border-radius: 14px;
  background:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px) 0 0 / 100% var(--cell),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px) 0 0 / var(--cell) 100%,
    rgba(8, 10, 30, .55);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 12px 30px rgba(0,0,0,.45);
}
#hint { margin: 10px 0 0; font-size: 13px; opacity: .55; text-align: center; transition: opacity .4s; }
#hint.hide { opacity: 0; }

/* ---------- Blocos ---------- */
.block {
  position: absolute; left: 0; top: 0;
  width: var(--cell); height: var(--cell);
  padding: 3px; z-index: 2;
  will-change: transform; pointer-events: none;
}
.block .face {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 22%;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35), 0 3px 0 rgba(0,0,0,.28);
}
.block .num {
  font-weight: 900; color: #fff; letter-spacing: -.02em;
  text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 6px rgba(0,0,0,.25);
}
.block .face.pop { animation: pop var(--pop, 280ms) cubic-bezier(.2,.9,.3,1.4); }
.block .face.spawn { animation: spawn .22s ease-out; }
.block .face.land { animation: land .16s ease-out; }
.block .face.dead { animation: dead var(--dead, 260ms) ease-in forwards; }
.block.blocked { opacity: .55; }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.38); } 100% { transform: scale(1); } }
@keyframes spawn { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes land { 0% { transform: scale(1.1, .8); } 100% { transform: scale(1); } }
@keyframes dead { to { transform: scale(0) rotate(40deg); opacity: 0; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ---------- Sombra de onde vai cair ---------- */
#shadowCol {
  position: absolute; top: 0; left: 0; height: 100%; width: var(--cell);
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.13));
  border-radius: 10px; pointer-events: none; z-index: 1;
  transition: transform 70ms ease-out; opacity: 0;
}
#shadowCol.bad { background: linear-gradient(180deg, rgba(255,60,60,0), rgba(255,60,60,.22)); }
#ghost {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell);
  padding: 3px; pointer-events: none; z-index: 1; opacity: 0;
  transition: transform 70ms ease-out;
}
#ghost i {
  display: block; width: 100%; height: 100%; border-radius: 22%;
  border: 3px dashed rgba(255,255,255,.75); background: rgba(255,255,255,.12);
}
#ghost.merge i { animation: ghostPulse .7s ease-in-out infinite; border-style: solid; }
@keyframes ghostPulse { 50% { background: rgba(255,255,255,.3); } }

/* ---------- Combo e pontos flutuantes ---------- */
#board .comboPop, .comboPop {
  position: absolute; left: 0; right: 0; top: 8%; text-align: center; z-index: 6;
  font-weight: 900; font-style: italic; pointer-events: none; opacity: 0;
  font-size: calc(var(--cell) * .75);
  color: #ffe45e; -webkit-text-stroke: 2px #7a2a00; paint-order: stroke fill;
  text-shadow: 0 4px 0 #7a2a00, 0 0 24px rgba(255,170,0,.8);
}
.comboPop.show { animation: comboIn .35s cubic-bezier(.2,.9,.3,1.5) forwards; }
.comboPop.out { animation: comboOut .4s ease-in forwards; }
@keyframes comboIn { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 100% { opacity: 1; transform: scale(1) rotate(-3deg); } }
@keyframes comboOut { from { opacity: 1; transform: scale(1) rotate(-3deg); } to { opacity: 0; transform: translateY(-20px) scale(1.1) rotate(-3deg); } }

.float {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  font-weight: 900; font-size: calc(var(--cell) * .36);
  transform: translate(-50%, -50%);
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5), 0 0 8px rgba(0,0,0,.4);
  animation: floatUp .9s ease-out forwards;
}
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: calc(var(--cell) * -1.1); } }
.spark { position: absolute; z-index: 4; border-radius: 3px; pointer-events: none; }

/* ---------- Tela por cima (fim de jogo / confirmação) ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,30,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
#overlay[hidden] { display: none; }
.card {
  width: min(86vw, 340px); padding: 24px 20px; text-align: center;
  background: linear-gradient(180deg, #343b86, #232859);
  border-radius: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.6), 0 0 0 2px rgba(255,255,255,.15);
  animation: spawn .25s ease-out;
}
.card h2 { margin: 0 0 12px; font-size: 26px; }
#ovBody { font-size: 16px; line-height: 1.6; opacity: .95; margin-bottom: 16px; }
#ovBody b { color: #ffd54a; }
#ovButtons { display: flex; flex-direction: column; gap: 10px; }
#ovButtons button {
  border: 0; border-radius: 14px; padding: 14px; font-size: 17px; font-weight: 800; cursor: pointer;
  background: #ffd54a; color: #3b2a00; box-shadow: 0 4px 0 #b8901a;
}
#ovButtons button.secondary { background: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
#ovButtons button:active { transform: translateY(2px); }

/* ---------- Menu ---------- */
#overlay.solid { background: radial-gradient(120% 80% at 50% 0%, #2c3270 0%, #1b1f3a 70%); backdrop-filter: none; -webkit-backdrop-filter: none; }
#overlay.solid .card { background: none; box-shadow: none; }
#overlay.solid .card h2 { font-size: 32px; }

#fatal { position: fixed; inset: 0; z-index: 15; pointer-events: none; background: rgba(0,0,0,0); transition: background .6s; }
#fatal.show { background: rgba(0,0,0,.8); }
#fatalText {
  position: fixed; left: 0; right: 0; top: 36%; z-index: 17; text-align: center; pointer-events: none;
  font-size: min(13vw, 20vh, 96px); font-weight: 900; font-style: italic; opacity: 0;
  color: #ffe45e; -webkit-text-stroke: 3px #7a0a00; paint-order: stroke fill;
  text-shadow: 0 6px 0 #7a0a00, 0 0 40px rgba(255,60,0,.9);
}
#fatalText.show { animation: fatalIn .55s cubic-bezier(.2,.9,.3,1.3) forwards; }
@keyframes fatalIn { 0% { opacity: 0; transform: scale(3.2) rotate(-6deg); } 100% { opacity: 1; transform: scale(1) rotate(-4deg); } }

/* ==========================================================================
   BATALHA — celular deitado
   ========================================================================== */
#app.battle #hud { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); width: auto; padding: 0; z-index: 30; }
#app.battle #hud .stat { display: none; }
#app.battle .btns button { width: 30px; height: 30px; font-size: 14px; }
#app.battle #stage { position: static; padding-top: 0; flex: none; width: auto; }
#app.battle #hint { display: none; }

#arena {
  position: relative; flex: 1 1 auto; width: 100%; min-height: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 14px 6px;
}
#arena[hidden] { display: none; }
#colL, #colR { flex: none; display: flex; flex-direction: column; }
.names { height: 30px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 2px 4px; }
.names span { font-size: 13px; font-weight: 700; white-space: nowrap; }
.names b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
#scoreMe { color: #ffcf5a; }
#scoreOpp { color: #c9cdf0; }

#oppBoard {
  position: relative;
  width: calc(var(--cell) * var(--cols, 5)); height: calc(var(--cell) * var(--rows, 7));
  border-radius: 14px; background: rgba(10,12,30,.55);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 12px 30px rgba(0,0,0,.4);
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 100% var(--cell), var(--cell) 100%;
}
#oppBoard .block { z-index: 2; }

/* Sufoco: borda piscando em vermelho + brilho no topo */
#board.danger, #oppBoard.danger { animation: dangerPulse 1s ease-in-out infinite; }
#board.danger::after, #oppBoard.danger::after {
  content: ""; position: absolute; left: 0; top: 0; width: 100%; height: calc(var(--cell) * 1.3);
  border-radius: 14px 14px 0 0; pointer-events: none; z-index: 6;
  background: linear-gradient(180deg, rgba(255,60,60,.4), rgba(255,60,60,0));
}
@keyframes dangerPulse {
  0%,100% { box-shadow: 0 0 0 2px #ff5a5a, 0 0 18px rgba(255,70,70,.35); }
  50% { box-shadow: 0 0 0 4px #ff5a5a, 0 0 36px rgba(255,70,70,.85); }
}

/* Blocos de ataque: caem com rastro vermelho */
.block.atk { z-index: 4; }
.block.atk .face { outline: 2px solid #ff6b6b; outline-offset: -2px; }
.block .trail {
  position: absolute; left: 3px; right: 3px; bottom: 100%; height: 100%; border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,90,90,0), rgba(255,90,90,.55)); pointer-events: none;
}
.block.oppfall { animation: oppFall var(--fall-ms, 380ms) cubic-bezier(.5,0,.9,.55) backwards; animation-delay: var(--delay, 0ms); }
@keyframes oppFall { from { margin-top: calc(var(--cell) * var(--rows-from, -3)); opacity: .3; } to { margin-top: 0; opacity: 1; } }

/* Combo grande (batalha) */
#app.battle .comboPop {
  top: 10%; left: 50%; right: auto; transform: translateX(-50%); width: max-content; text-align: center;
  padding: 4px 14px; border-radius: 14px; background: #ffcf5a; color: #2b2140; -webkit-text-stroke: 0;
  text-shadow: none; font-style: normal; letter-spacing: .5px;
  font-size: calc(var(--cell) * .8); box-shadow: 0 6px 18px rgba(255,207,90,.5);
}
#app.battle .comboPop.show { animation: comboBattle .5s cubic-bezier(.2,.9,.3,1.4) forwards; }
#app.battle .comboPop.out { animation: comboBattleOut .4s ease-in forwards; }
@keyframes comboBattle { 0% { opacity: 0; transform: translateX(-50%) scale(.3); } 60% { transform: translateX(-50%) scale(1.15) rotate(-4deg); } 100% { opacity: 1; transform: translateX(-50%) scale(1) rotate(-4deg); } }
@keyframes comboBattleOut { from { opacity: 1; transform: translateX(-50%) rotate(-4deg); } to { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(1.1) rotate(-4deg); } }

/* ---------- Faixa central ---------- */
#strip { flex: 1 1 auto; min-width: 0; align-self: stretch; display: flex; flex-direction: column; align-items: center; padding: 0 8px; gap: 4px; }
#curNext { display: flex; gap: 12px; align-items: flex-end; margin-top: 26px; }
.cn { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cn small { font-size: 10px; color: #c9cdf0; letter-spacing: 1px; }
.cn.nx { opacity: .8; }
#stripCur, #stripNext, #stripNext2 { position: relative; }
#stripCur .block, #stripNext .block, #stripNext2 .block { position: relative; left: auto; top: auto; transform: none; }
#banners { display: flex; gap: 8px; min-height: 28px; align-items: center; justify-content: center; }
.banner {
  position: relative; overflow: hidden; padding: 4px 12px; border-radius: 999px; white-space: nowrap;
  background: #ff5a5a; color: #fff; font-weight: 900; font-size: 14px; box-shadow: 0 4px 14px rgba(255,90,90,.5);
  animation: chipPulse .6s ease-in-out infinite alternate;
}
.banner[hidden] { display: none; }
.banner i { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.9); }
#chars { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.char { position: relative; flex: 0 1 46%; height: 100%; min-width: 0; --fwd: 1; }
.char.flip { --fwd: -1; }
.char .flipbox { width: 100%; height: 100%; }
.char.flip .flipbox { transform: scaleX(-1); }
.char svg { width: 100%; height: 100%; display: block; overflow: visible; }
#vs {
  position: absolute; left: 50%; top: 14%; transform: translateX(-50%);
  font-size: 22px; font-weight: 900; color: #ffcf5a; text-shadow: 0 2px 0 #2b2140; z-index: 3;
}
.help {
  position: absolute; top: 2%; left: 50%; transform: translateX(-50%); padding: 3px 9px; border-radius: 10px;
  background: #fff; color: #2b2140; font-size: 12px; font-weight: 800; white-space: nowrap; display: none; z-index: 4;
}
.help::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 9px; height: 9px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.char.danger .help { display: block; }
#powers { display: flex; gap: 10px; padding-top: 2px; }
#powers button {
  width: 40px; height: 40px; border-radius: 13px; border: 0; background: rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center; opacity: .45;
}

/* Reações dos personagens (só CSS) */
.bob { animation: bob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px) scaleY(1.01); } }
.char.danger { animation: charDanger .35s linear infinite; }
@keyframes charDanger { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.char.attack { animation: charAttack .55s ease-out; }
@keyframes charAttack {
  0% { transform: translate(0,0); } 35% { transform: translate(calc(var(--fwd) * var(--hop, 26px)), calc(var(--hop, 26px) * -.7)) scale(1.08); }
  70% { transform: translate(calc(var(--fwd) * var(--hop, 26px) * .55), 0); } 100% { transform: translate(0,0); }
}
.char.hurt { animation: charHurt .6s linear; }
@keyframes charHurt {
  0%,100% { transform: translateX(0); filter: none; } 10% { transform: translateX(-6px); filter: brightness(2.2) saturate(.5); }
  20% { transform: translateX(6px); filter: none; } 30% { transform: translateX(-6px); filter: brightness(2.2); }
  40% { transform: translateX(6px); filter: none; } 50% { transform: translateX(-4px); filter: brightness(2); }
  60% { transform: translateX(4px); filter: none; } 80% { transform: translateX(-2px); }
}
.char.win { animation: charWin .6s ease-in-out infinite; }
@keyframes charWin { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-22%) rotate(calc(var(--fwd) * 4deg)); } }
.char.lose { animation: charLose .9s ease-in forwards; transform-origin: 50% 100%; }
@keyframes charLose { to { transform: translateY(8%) rotate(calc(var(--fwd) * -82deg)); filter: grayscale(.6); } }

/* ---------- Gire o celular ---------- */
#rotate {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(120% 80% at 50% 0%, #2c3270 0%, #12142a 80%); text-align: center;
}
#rotate[hidden] { display: none; }
.rotIcon { font-size: 72px; animation: rotPhone 1.8s ease-in-out infinite; }
@keyframes rotPhone { 0%,20% { transform: rotate(0); } 60%,100% { transform: rotate(-90deg); } }
.rotText { font-size: 28px; font-weight: 900; }
#rotate small { opacity: .7; font-size: 14px; }

/* ---------- Menu com a Guerreira ---------- */
#ovHead { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
#ovHead h2 { margin: 0; }
#ovArt { width: 78px; flex: none; }
#ovArt:empty { display: none; }
#ovArt svg { width: 100%; height: auto; display: block; }
@keyframes chipPulse { to { transform: scale(1.07); } }
.spot { position: relative; z-index: 16; }

/* ---------- Instalar como app ---------- */
#btnInstall { margin-top: 14px; width: 100%; border: 2px solid rgba(255,255,255,.35); background: transparent;
  color: #fff; font-size: 15px; font-weight: 700; padding: 11px 14px; border-radius: 14px; cursor: pointer; }
#btnInstall[hidden] { display: none; }
#installHelp { position: fixed; inset: 0; z-index: 9999; background: rgba(10,12,30,.8); display: flex;
  align-items: center; justify-content: center; padding: 20px; }
#installHelp[hidden] { display: none; }
#installHelp .ihCard { background: #262b55; color: #fff; border-radius: 20px; padding: 20px 22px; max-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); }
#installHelp h3 { margin: 0 0 10px; font-size: 19px; }
#installHelp ol { margin: 0 0 10px; padding-left: 20px; line-height: 1.5; }
#installHelp p { margin: 0 0 14px; color: #c9cdf0; font-size: 14px; }
#installHelp .ihIcon { display: inline-block; padding: 0 5px; border: 1px solid #c9cdf0; border-radius: 5px; font-size: 12px; }
#installHelp button { width: 100%; border: 0; border-radius: 12px; padding: 11px; font-size: 15px; font-weight: 800;
  background: #ffcf5a; color: #2b2140; cursor: pointer; }

/* ---------- Fila de blocos: "Depois" menor e mais apagado ---------- */
.stat.next2 { align-items: center; opacity: .6; }
#next2Box { position: relative; width: 28px; height: 28px; margin-top: 8px; }
.cn.nx2 { opacity: .55; }

/* ---------- Personagens menores (~60%) e faixa central mais estreita ---------- */
.char { flex: 0 1 30%; height: 62%; }
#chars { gap: 2px; }
#vs { top: 34%; font-size: 18px; }
#banners { flex-wrap: wrap; row-gap: 3px; }
.banner { font-size: 13px; padding: 3px 10px; }
#arena { padding: 4px 10px 4px; }
.names { height: 26px; padding-bottom: 2px; }

/* ---------- Destro: a minha grade fica à direita ---------- */
#arena.rh { flex-direction: row-reverse; }
#arena.rh .names { flex-direction: row-reverse; }
#arena.rh #chars { flex-direction: row-reverse; }
#arena.rh #banners { flex-direction: row-reverse; }
#ovButtons button.small { padding: 8px; font-size: 14px; font-weight: 700; }
#ovButtons button.big { padding: 22px 14px; font-size: 20px; }

/* ==========================================================================
   BATALHA — layout "Espelhado" (celular em pé): adversário em cima, faixa fina, eu embaixo
   ========================================================================== */
#oppQueue { display: none; }
#app.battle.mirror #hud { left: auto; right: 6px; top: calc(env(safe-area-inset-top, 0px) + 6px); transform: none; }
#arena.mirror { flex-direction: column; align-items: stretch; justify-content: space-between; padding: 0; }
#arena.mirror #colR { order: 1; position: relative; align-items: center; }
#arena.mirror #strip { order: 2; flex: none; align-self: stretch; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: 60px; height: 60px; align-items: center; gap: 0 6px; padding: 0 6px; }
#arena.mirror #colL { order: 3; position: relative; align-items: center; }
#arena.mirror #banners { grid-column: 2; grid-row: 1; align-self: center; justify-self: center; }
#arena.mirror #oppQueue { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
#arena.mirror #curNext { grid-column: 3; grid-row: 1; margin-top: 0; flex-direction: column-reverse; align-items: center; gap: 3px; }
#oppQueue .block { position: relative; left: auto; top: auto; transform: none; }
#arena.mirror #powers { display: none; }
#arena.mirror #chars { display: none; }

/* Personagens pequenos (44 px) + nome/pontos nos cantos, sobrepostos à lateral (não empurram as grades).
   Adversário: canto de cima à esquerda. Eu: canto de baixo à direita. */
#arena.mirror .char { position: absolute; flex: none; width: 35px; height: 44px; z-index: 5; --hop: 12px; }
#arena.mirror #charOpp { top: 2px; left: 6px; }
#arena.mirror #charMe { bottom: 2px; right: 6px; }
#arena.mirror .names { position: absolute; width: calc((100% - var(--cell) * var(--cols)) / 2 - 8px); min-width: 50px; height: auto; flex-direction: column; gap: 1px; padding: 0; z-index: 5; pointer-events: none; }
#arena.mirror .names span { white-space: normal; font-size: 11px; line-height: 1.15; }
#arena.mirror .names b { font-size: 14px; }
#arena.mirror #colR .names { top: 48px; left: 6px; align-items: flex-start; flex-direction: column-reverse; }
#arena.mirror #colL .names { bottom: 48px; right: 6px; left: auto; align-items: flex-end; text-align: right; }
#arena.mirror .help { font-size: 10px; padding: 2px 6px; top: 2px; }
#arena.mirror #charOpp .help { left: 100%; transform: none; margin-left: 4px; }
#arena.mirror #charMe .help { left: auto; right: 100%; transform: none; margin-right: 4px; }
#arena.mirror .help::after { display: none; }

/* Sufoco: a borda que encosta na faixa central pisca e brilha */
#arena.mirror #board.danger, #arena.mirror #oppBoard.danger { animation: none; }
#arena.mirror #board.danger::before, #arena.mirror #oppBoard.danger::before {
  content: ""; position: absolute; left: 0; right: 0; height: 5px; z-index: 7; pointer-events: none;
  background: #ff4a4a; box-shadow: 0 0 14px 3px rgba(255,70,70,.9); animation: edgePulse .8s ease-in-out infinite;
}
#arena.mirror #board.danger::before { top: -3px; border-radius: 3px; }
#arena.mirror #oppBoard.danger::before { bottom: -3px; border-radius: 3px; }
#arena.mirror #oppBoard.danger::after { top: auto; bottom: 0; border-radius: 0 0 14px 14px; background: linear-gradient(0deg, rgba(255,60,60,.4), rgba(255,60,60,0)); }
@keyframes edgePulse { 50% { opacity: .35; } }
/* Rastro dos ataques na grade de cima: o bloco sobe, o rastro fica para o lado da faixa */
#arena.mirror #oppBoard .trail { bottom: auto; top: 100%; background: linear-gradient(180deg, rgba(255,90,90,.55), rgba(255,90,90,0)); }
/* Espelhado: botões de som/menu em coluna no canto de cima à direita (não cobrem a grade) */
#app.battle.mirror .btns { flex-direction: column; }

/* ==========================================================================
   BATALHA — layout "Compacto" (celular em pé)
   Em cima (~1/3): miniatura do adversário, fila dele, personagens, aviso, minha fila.
   Embaixo (~2/3): minha grade na largura toda.
   ========================================================================== */
#app.battle.compact #hud { left: auto; right: calc(env(safe-area-inset-right, 0px) + 8px); top: calc(env(safe-area-inset-top, 0px) + 1px); transform: none; }
#app.battle.compact .btns { gap: 4px; }
#app.battle.compact .btns button { width: 24px; height: 24px; font-size: 12px; }

#arena.compact { display: grid; align-items: start; justify-content: stretch; padding: 0 8px; column-gap: 6px; row-gap: 0; }
#arena.compact #strip { display: contents; }
#arena.compact #powers, #arena.compact #chars, #arena.compact #vs { display: none; }

/* Opp: miniatura no canto de cima à esquerda (ocupa as linhas 1 a 3) */
#arena.compact #colR { grid-column: 1; grid-row: 1 / 3; align-self: start; }
#arena.compact #colR .names { height: 26px; padding: 0 2px; align-items: center; justify-content: flex-start; flex-direction: row-reverse; gap: 6px; }
#arena.compact #colR .names span { font-size: 11px; }
#arena.compact #colR .names b { font-size: 13px; }
#oppBoard.mini { border-radius: 8px; box-shadow: 0 0 0 2px rgba(255,255,255,.14); }
#oppBoard.mini .block { padding: 2px; }
#oppBoard.mini .block .face { border-radius: 24%; box-shadow: inset 0 2px 0 rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.28); }

/* Fila do adversário, em pé, logo à direita da miniatura */
#arena.compact #oppQueue { grid-column: 2; grid-row: 2; align-self: start; display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* Personagens lado a lado, de frente um para o outro */
#arena.compact .char { position: relative; flex: none; width: var(--charw, 100%); height: var(--charh, 120px); align-self: end; justify-self: center; z-index: 2; }
/* sombrinha embaixo dos pés (os dois pés ficam na mesma linha) */
#arena.compact .char::after { content: ""; position: absolute; left: 14%; right: 14%; bottom: 0; height: 7px; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,.45), rgba(0,0,0,0) 70%); pointer-events: none; }
#arena.compact #charOpp { grid-column: 3; grid-row: 2; }
#arena.compact #charMe { grid-column: 4; grid-row: 2; }
#arena.compact #namesMe { grid-column: 4 / 6; grid-row: 2; align-self: start; justify-self: end; white-space: nowrap; height: auto; padding: 0; gap: 6px; justify-content: center; z-index: 3; }
#arena.compact #namesMe span { font-size: 11px; }
#arena.compact #namesMe b { font-size: 13px; }
#arena.compact .help { font-size: 11px; }

/* Aviso de ataque entre os personagens */
#arena.compact #banners { grid-column: 3 / 5; grid-row: 2; align-self: end; margin-bottom: calc(var(--charh, 100px) * .5); justify-self: center; z-index: 6; flex-wrap: wrap; justify-content: center; row-gap: 3px; }
#arena.compact .banner { font-size: 15px; padding: 5px 12px; }

/* Minha fila deitada embaixo da Guerreira: ATUAL maior à esquerda */
#arena.compact #curNext { grid-column: 5; grid-row: 2; justify-self: end; align-self: end; margin-top: 0; flex-direction: row; align-items: flex-end; gap: 8px; }
#arena.compact .cn.nx2 { opacity: .6; }

/* Minha grade: largura toda */
#arena.compact #colL { grid-column: 1 / -1; grid-row: 4; justify-self: center; align-self: start; align-items: center; }

/* ==========================================================================
   Fila na batalha: só o PRÓXIMO (rótulo + bloco grande). O ATUAL flutua sobre a grade; sem DEPOIS.
   ========================================================================== */
#arena .cn:not(.nx) { display: none; }
#arena .cn.nx { opacity: 1; }
#arena .cn small { display: block; font-size: 9px; letter-spacing: .6px; }

/* Layout Deitado: fila minha SEMPRE do lado da MINHA grade (colada nela); fila do adversário do lado dele.
   Canhoto: minha grade à esquerda => minha fila à esquerda. Destro (.rh): à direita. */
#arena:not(.mirror):not(.compact) #strip { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto 1fr auto; align-items: start; justify-items: center; padding: 0 4px; gap: 0; }
#arena:not(.mirror):not(.compact) #curNext { grid-column: 1; grid-row: 1; justify-self: start; margin-top: 4px; }
#arena:not(.mirror):not(.compact) #oppQueue { grid-column: 2; grid-row: 1; justify-self: end; display: flex; flex-direction: column; align-items: center; margin-top: 16px; }
#arena.rh:not(.mirror):not(.compact) #curNext { grid-column: 2; justify-self: end; }
#arena.rh:not(.mirror):not(.compact) #oppQueue { grid-column: 1; justify-self: start; }
#arena:not(.mirror):not(.compact) #banners { grid-column: 1 / -1; grid-row: 2; }
#arena:not(.mirror):not(.compact) #chars { grid-column: 1 / -1; grid-row: 3; align-self: stretch; }
#arena:not(.mirror):not(.compact) #powers { grid-column: 1 / -1; grid-row: 4; }

/* ==========================================================================
   LUTA DOS PERSONAGENS — partes do SVG animáveis + camadas de efeito (só transform/opacity)
   ========================================================================== */
.char .mv { position: absolute; inset: 0; will-change: transform; }
.char .mv .flipbox { width: 100%; height: 100%; }
/* pontos de giro (em unidades do desenho, relativos ao SVG inteiro) */
.chsvg .c-weapon { transform-origin: 142px 197px; transform-box: view-box; }
.chsvg .c-shield { transform-origin: 52px 192px; transform-box: view-box; }
.chsvg .c-head, .chsvg .c-face, .chsvg .c-hairback, .chsvg .c-hairfront, .chsvg .c-helmet { transform-origin: 100px 150px; transform-box: view-box; }
.chsvg .c-body, .chsvg .c-arms, .chsvg .c-legs { transform-origin: 100px 200px; transform-box: view-box; }

/* estrelinhas girando sobre a cabeça */
.char .stars { position: absolute; left: 50%; top: -2%; width: 46%; height: 16%; margin-left: -23%; opacity: 0; pointer-events: none; z-index: 4; }
.char .stars i { position: absolute; left: 50%; top: 50%; width: 0; height: 0; font-style: normal; font-size: 13px; line-height: 0; color: #ffe45e; text-shadow: 0 1px 0 #7a5a00; }
.char .stars i::before { content: "★"; position: absolute; left: -7px; top: 0; }
.char .stars i:nth-child(1) { transform: translate(-16px, 0); }
.char .stars i:nth-child(2) { transform: translate(16px, 0); }
.char .stars i:nth-child(3) { transform: translate(0, -7px); }
/* piscar em vermelho */
.char .redflash { position: absolute; inset: -6% -14%; border-radius: 50%; opacity: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, rgba(255,40,40,.8), rgba(255,40,40,0) 68%); }
/* gotas de suor no perigo */
.char .sweat { position: absolute; left: 0; right: 0; top: 6%; height: 30%; display: none; pointer-events: none; z-index: 4; }
.char.danger .sweat { display: block; }
.char .sweat i { position: absolute; width: 5px; height: 8px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; background: #8fd3ff; opacity: 0; animation: sweatFall 1s linear infinite; }
.char .sweat i:nth-child(1) { left: 14%; animation-delay: 0s; }
.char .sweat i:nth-child(2) { left: 82%; animation-delay: .35s; }
.char .sweat i:nth-child(3) { left: 24%; animation-delay: .7s; }
.char .sweat i:nth-child(4) { left: 72%; animation-delay: .15s; }
@keyframes sweatFall { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(22px); } }

/* camada dos projéteis e faíscas (tela inteira, por cima de tudo menos do golpe final) */
#fx { position: fixed; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
#fx .px, #fx .spark2 { position: fixed; left: 0; top: 0; will-change: transform; }
#fx .pebble { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 35%; background: #b3a898; border: 2px solid #5d564c; box-shadow: 0 0 8px 2px rgba(255,80,80,.7); }
#fx .spark2 { font-size: 18px; line-height: 1; color: #fff3a8; text-shadow: 0 0 6px #ffb300, 0 0 12px #ff6a00; margin: -9px 0 0 -9px; }


/* ==========================================================================
   Drop Knights — menu, mapa da campanha, configurações, tutorial, bloco travado
   ========================================================================== */
#overlay { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#ovTitle[hidden] { display: none; }
#ovBody .note, .card .note { font-size: 12px; opacity: .65; margin: 6px 0 4px; line-height: 1.4; }
#ovButtons button.reward { background: linear-gradient(180deg, #7be37b, #3fb85a); color: #0b3a14; box-shadow: 0 4px 0 #23813b; }
#ovButtons button.danger { background: #e2574c; color: #fff; box-shadow: 0 4px 0 #8f2a22; }
.toast { position: fixed; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9000;
  background: rgba(10,12,30,.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: spawn .25s ease-out; max-width: 86vw; text-align: center; }
.stars3 { display: inline-flex; gap: 2px; font-size: 22px; }
.stars3 i { font-style: normal; color: rgba(255,255,255,.22); }
.stars3 i.on { color: #ffd54a; text-shadow: 0 2px 0 #7a5a00; }
.unl { color: #7be37b; font-weight: 800; }

/* menu temático: céu ao entardecer, castelo e colinas */
#overlay.menu, #overlay.solid {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 140' preserveAspectRatio='xMidYMax slice'><g fill='%2314183a'><path d='M0 140V104Q60 84 120 100T240 96T400 90V140Z' fill='%2316204a'/><rect x='150' y='62' width='100' height='78'/><rect x='140' y='46' width='26' height='94'/><rect x='234' y='40' width='26' height='100'/><rect x='186' y='28' width='28' height='112'/><path d='M140 46h6v-6h6v6h6v-6h6v6h2v6h-26zM234 40h6v-6h6v6h6v-6h6v6h2v6h-26zM186 28h6v-6h6v6h6v-6h6v6h2v6h-28z'/><path d='M193 28l7-20 7 20z'/><path d='M0 140V116Q70 100 130 114T260 112T400 106V140Z' fill='%230f1330'/></g><g fill='%23ffd54a'><rect x='197' y='50' width='6' height='10' rx='3'/><rect x='146' y='66' width='5' height='9' rx='2.5'/><rect x='240' y='62' width='5' height='9' rx='2.5'/><rect x='186' y='86' width='5' height='9' rx='2.5'/><rect x='209' y='86' width='5' height='9' rx='2.5'/></g></svg>") center bottom / 100% auto no-repeat,
    linear-gradient(180deg, #1c2260 0%, #3d3a86 38%, #8a4f8f 66%, #e58a5c 100%);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
#overlay.solid .card { background: none; box-shadow: none; max-height: 100%; overflow-y: auto; }
#overlay.main .card { padding-top: 10px; }
#overlay.main #ovHead { flex-direction: column; gap: 0; margin-bottom: 4px; }
#overlay.main #ovArt { width: 112px; margin-bottom: -4px; }
#overlay.main h2 { font-family: Georgia, "Times New Roman", serif; font-size: 40px !important; letter-spacing: .02em; line-height: 1;
  color: #ffe27a; -webkit-text-stroke: 2px #4a2a00; paint-order: stroke fill; text-shadow: 0 4px 0 #4a2a00, 0 0 24px rgba(255,190,60,.55); }
.tagline { font-size: 16px; font-weight: 700; opacity: .9; margin-bottom: 4px; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
#overlay.menu .card { width: min(88vw, 340px); }
@media (max-height: 420px) {
  #overlay.main #ovArt { display: none; }
  #overlay.main h2 { font-size: 30px !important; }
  #ovButtons { gap: 6px; } #ovButtons button { padding: 9px; font-size: 15px; } #ovButtons button.big { padding: 12px; }
  #overlay .card { padding: 10px 14px; }
}

/* mapa */
#overlay.mapScreen .card { width: min(94vw, 420px); height: 100%; max-height: 100%; display: flex; flex-direction: column; padding: 14px 8px 10px; overflow: hidden; }
#overlay.mapScreen #ovBody { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; margin-bottom: 8px; border-radius: 18px;
  background: radial-gradient(60% 18% at 20% 20%, #5aa24a 0 60%, transparent 62%), radial-gradient(50% 16% at 80% 55%, #4f9a45 0 60%, transparent 62%), linear-gradient(180deg, #76bd5a, #4c9144 60%, #3b7a3c);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.25), inset 0 0 40px rgba(0,0,0,.25); -webkit-overflow-scrolling: touch; }
.map { position: relative; height: 100%; min-height: 560px; margin: 0 auto; width: 100%; }
.mapNote { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.5); opacity: .85 !important; }
.map .road { position: absolute; inset: 0; width: 100%; height: 100%; }
.stop { position: absolute; transform: translate(-50%, -50%); width: 96px; background: none; border: 0; padding: 0; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; font: inherit; }
.stop .pt { width: 66px; height: 66px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #5a4d98, #2f2862); border: 4px solid #ffd54a;
  box-shadow: 0 4px 0 #7a5a00, 0 8px 14px rgba(0,0,0,.4); overflow: hidden; display: block; }
.stop .pt svg { width: 100%; height: 100%; display: block; }
.stop.boss { width: 112px; } .stop.boss .pt { width: 88px; height: 88px; border-color: #ff7a5a; box-shadow: 0 4px 0 #7a2a1a, 0 0 22px rgba(255,120,80,.7); }
.stop.locked .pt { filter: grayscale(1) brightness(.55); border-color: #9aa0b8; box-shadow: 0 4px 0 #444; }
.stop .lockIco { position: absolute; top: 18px; width: 30px; height: 30px; }
.stop.boss .lockIco { top: 28px; } .stop .lockIco svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
.stop .check { position: absolute; top: -4px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: #3fb85a; border: 2px solid #fff; font-weight: 900; font-size: 15px; line-height: 20px; box-shadow: 0 2px 0 #1d6a30; }
.stop.boss .check { right: 14px; }
.stop .nm { margin-top: 5px; font-weight: 800; font-size: 14px; text-shadow: 0 2px 0 rgba(0,0,0,.55), 0 0 6px rgba(0,0,0,.4); }
.stop .bossTag { font-size: 10px; font-weight: 900; letter-spacing: .1em; background: #e2574c; padding: 1px 7px; border-radius: 8px; margin-top: 2px; }
.stop .stars3 { font-size: 16px; margin-top: 1px; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.stop:active .pt { transform: scale(.95); }
.bigPortrait { width: 150px; height: 150px; margin: 0 auto 12px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #5a4d98, #2f2862); border: 5px solid #ffd54a; overflow: hidden; box-shadow: 0 6px 0 #7a5a00, 0 12px 24px rgba(0,0,0,.4); }
.bigPortrait svg { width: 100%; height: 100%; display: block; } .bigPortrait.locked { filter: grayscale(1) brightness(.55); }
#ovBody p { margin: 8px 0; }

/* configurações */
.settings { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-bottom: 6px; }
.srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 14px; background: rgba(255,255,255,.12);
  color: #fff; text-decoration: none; font-size: 16px; font-weight: 700; cursor: pointer; }
.srow b { color: #ffd54a; font-size: 15px; text-align: right; } .srow.static { cursor: default; } .srow:active:not(.static) { background: rgba(255,255,255,.22); }

/* tutorial */
.tutArt { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 130px; margin-bottom: 4px; font-size: 26px; font-weight: 900; }
.tutArt .block { position: relative; flex: none; } .tutArt b { color: #ffd54a; }
.tutArt .tcol { display: flex; flex-direction: column; align-items: center; width: 44px; height: 110px; justify-content: flex-start; border-radius: 10px; background: rgba(255,255,255,.08); }
.tutArt .tcol i { font-style: normal; color: #ffd54a; }
.tutArt.chars div { width: 96px; } .tutArt.chars div svg { width: 100%; height: auto; } .tutArt.chars .flip { transform: scaleX(-1); }
.dots { display: flex; gap: 8px; justify-content: center; margin: 8px 0 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.3); } .dots i.on { background: #ffd54a; }

/* bloco travado pelo Dragão: pedra com correntes e contador de jogadas */
.block.locked .face { filter: grayscale(.92) brightness(.74) contrast(1.15); }
.block.locked::before { content: ""; position: absolute; inset: 3px; border-radius: 22%; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(45deg, rgba(30,30,44,.62) 0 3px, transparent 3px 10px), repeating-linear-gradient(-45deg, rgba(190,190,205,.55) 0 3px, transparent 3px 10px);
  box-shadow: inset 0 0 0 2.5px #5a5f70, inset 0 0 12px rgba(0,0,0,.5); }
.block.locked::after { content: attr(data-left); position: absolute; right: 3px; bottom: 3px; z-index: 4; min-width: 36%; padding: 0 3px; text-align: center;
  font-weight: 900; font-size: calc(var(--cell) * .24); line-height: 1.25; color: #fff; background: #2b2140; border: 2px solid #ffd54a; border-radius: 8px; }
.block.chainIn::before { animation: chainDrop .55s cubic-bezier(.2,.9,.3,1.2); }
@keyframes chainDrop { 0% { transform: scale(1.7); opacity: 0; } 60% { transform: scale(.94); opacity: 1; } 100% { transform: scale(1); } }

/* anúncio falso (só na versão web) */
#fakeAd { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
#fakeAd .faCard { width: min(80vw, 320px); text-align: center; background: #262b55; border-radius: 20px; padding: 24px 20px; }
#fakeAd h3 { margin: 0 0 8px; } #fakeAd p { opacity: .8; margin: 0 0 14px; }
#fakeAd .faTime { font-size: 44px; font-weight: 900; color: #ffd54a; } #fakeAd button { margin-top: 12px; width: 100%; border: 0; border-radius: 12px; padding: 12px; font-size: 16px; font-weight: 800; background: #ffd54a; color: #3b2a00; }
#fakeAd button[hidden] { display: none; }

/* app nativo: sem zoom, seleção, bounce */
html, body { -webkit-text-size-adjust: 100%; touch-action: manipulation; }

#overlay.solid #ovButtons button.secondary { background: rgba(20,24,58,.55); }

/* menu com o celular deitado: sem castelo, botões em duas colunas */
@media (max-height: 420px) {
  #overlay.menu, #overlay.solid { background: linear-gradient(180deg, #1c2260 0%, #3d3a86 40%, #8a4f8f 72%, #e58a5c 100%); }
  #overlay.main .card, #overlay.menu .card { width: min(92vw, 600px); }
  #overlay.main #ovButtons { display: grid; grid-template-columns: 1fr 1fr; }
  #overlay.main #ovButtons button.big { grid-column: 1 / -1; }
  #overlay.main #ovHead { margin-bottom: 0; } #overlay.main .tagline { display: none; }
  #overlay.mapScreen .card { width: min(80vw, 420px); }
}
