/* Tela de subir de nível (ui/levelup.js), carta que fecha combo, troca de
   habilidade e a revelação de combo (ui/comboReveal.js). Carregado depois do style.css.
   Tudo fica dentro do #levelup. Os tempos da entrada (--dd/--dur) casam com DEAL em levelup.js. */
/* safe: se não couber (janela baixa), rola sem cortar o título lá em cima. */
#levelup { place-content: safe center; background: rgba(5, 4, 4, 0.74); overflow-y: auto; overflow-x: hidden; padding: 16px 0; }
#levelup h2 { margin: 0; font: 400 clamp(36px, 5.5vw, 66px)/1 var(--title); letter-spacing: 0.14em; text-shadow: 4px 4px 0 #000; }
#levelup h2.stamp { animation: lu-title 0.5s cubic-bezier(.2, .9, .3, 1.25) backwards; }
#levelup .sub { margin: 6px 0 4px; font: italic 18px var(--text); }
#levelup .sub b { font-style: normal; }
#levelup .sub-combo { display: inline-block; animation: lu-subglow 1.1s ease-in-out infinite alternate; }
#levelup .sub-combo b { color: #ffcf6a; letter-spacing: 0.06em; text-shadow: 0 0 10px rgba(255, 140, 40, 0.85), 2px 2px 0 #000; }
#levelup .controls { margin-top: 14px; }
#levelup kbd {
  display: inline-block; min-width: 22px; padding: 0 6px; vertical-align: 1px;
  font: 700 13px/21px var(--mono); text-align: center; color: var(--paper);
  background: var(--ink); border-radius: 3px; box-shadow: 2px 2px 0 var(--blood-dark);
}
@keyframes lu-title { from { opacity: 0; transform: scale(1.5); letter-spacing: 0.5em; } }
@keyframes lu-subglow { to { transform: scale(1.04); } }

/* ---------- Cartas: casca (levanta ao selecionar) + face de papel (vira e brilha) ---------- */
#levelup .cards { position: relative; display: flex; gap: 26px; justify-content: center; align-items: stretch; flex-wrap: wrap; margin: 6px 0 0; padding: 30px 12px 8px; }
#levelup .card {
  --rar: var(--paper);
  --dd: calc(var(--i, 0) * 120ms + 80ms); /* atraso da entrada desta carta */
  --dur: 620ms;
  position: relative; z-index: 0; display: flex; width: clamp(176px, 27vw, 236px);
  perspective: 900px; cursor: pointer; transition: transform 0.14s cubic-bezier(.3, .7, .4, 1.5);
}
#levelup.dealt .card { --dd: 0ms; --dur: 1ms; }
/* Só a selecionada levanta (é a que o Enter/A pega). O mouse que anda já seleciona
   (levelup.js); :hover aqui deixava a carta debaixo do cursor parado "escolhida" também. */
#levelup .card.sel { transform: translateY(-12px) rotate(-1deg); z-index: 1; }
#levelup .face {
  position: relative; flex: 1; min-height: clamp(230px, 42vh, 300px); padding: 22px 15px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--ink); background: linear-gradient(180deg, #efe5cf, #d9ccb0);
  border: 3px solid var(--ink); border-top: 10px solid var(--rar); box-shadow: 6px 6px 0 #000;
  transform-origin: 50% 60%; animation: lu-deal var(--dur) var(--dd) backwards; transition: box-shadow 0.14s;
}
#levelup .card.sel .face { box-shadow: 10px 14px 0 #000, 0 0 0 3px var(--rar); }
#levelup .face .key { position: absolute; left: 8px; top: 3px; font: 700 13px var(--mono); opacity: 0.55; }
#levelup.pad .face .key { display: none; }
#levelup .face .icon { font-size: 44px; line-height: 1.1; }
#levelup .face .name { font: 400 25px/1.02 var(--title); text-align: center; letter-spacing: 0.02em; }
#levelup .face .rar { font: italic 13px var(--text); color: #3b342c; border-bottom: 2px solid var(--rar); padding-bottom: 2px; }
#levelup .face .lvl { font: 700 12px var(--mono); letter-spacing: 0.08em; color: var(--blood); }
#levelup .face .desc { flex: 1; margin-top: 2px; font: 16px/1.3 var(--text); text-align: center; }
#levelup .face .now { width: 100%; padding-top: 4px; font: italic 13px var(--text); color: #4a4037; text-align: center; border-top: 1px dashed #9c8f78; }
#levelup .face .note { font: italic 12px var(--text); color: #7a1018; text-align: center; }

/* Verso da carta: aparece só na primeira metade da virada. */
#levelup .back {
  position: absolute; inset: -10px -3px -3px; z-index: 6; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #b3121c 0 13%, #5c070c 14% 17%, transparent 18%), repeating-linear-gradient(45deg, #1b0e0b 0 7px, #0b0605 7px 14px);
  box-shadow: inset 0 0 0 5px #0d0a09, inset 0 0 0 7px #8a6a2a;
  animation: lu-back var(--dur) linear var(--dd) backwards;
}
#levelup .back::after { content: '✠'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: #f1d9b0; }
/* Entrada: sobe de costas, vira (90° em ~64%) e assenta com um pulinho. */
@keyframes lu-deal {
  0% { opacity: 0; transform: translateY(110px) rotateZ(-10deg) rotateY(180deg) scale(.78); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  42% { opacity: 1; transform: translateY(0) rotateZ(0deg) rotateY(180deg) scale(1); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  86% { transform: translateY(-8px) rotateZ(0deg) rotateY(0deg) scale(1.05); animation-timing-function: ease-out; }
  100% { opacity: 1; transform: translateY(0) rotateZ(0deg) rotateY(0deg) scale(1); }
}
@keyframes lu-back { 0%, 63% { opacity: 1; } 64%, 100% { opacity: 0; } }

/* ---------- Carta que AVANÇA um combo: tratamento leve (bolinhas de progresso) ---------- */
#levelup .card.avanca .face { box-shadow: 6px 6px 0 #000, inset 0 0 0 2px rgba(224, 163, 58, 0.4); }
#levelup .adv {
  width: 100%; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px 6px;
  margin-top: 2px; padding: 4px 6px; font: italic 13px var(--text); color: #7a1018;
  border: 1px dashed rgba(122, 16, 24, 0.6); background: rgba(224, 163, 58, 0.14);
}
#levelup .adv .a-name { width: 100%; }
#levelup .adv .num { color: #7a1018; font-style: normal; }
#levelup .pips { display: inline-flex; gap: 3px; }
#levelup .pips i { width: 9px; height: 9px; border: 1.5px solid #7a1018; border-radius: 50%; }
#levelup .pips i.on { background: #7a1018; }
#levelup .pips i.new { background: #e0a33a; border-color: #9c6a12; animation: lu-pip 0.7s ease-in-out infinite alternate; }
@keyframes lu-pip { to { scale: 1.3; box-shadow: 0 0 0 3px rgba(224, 163, 58, 0.45); } }

/* ---------- Carta que FECHA um combo: brilha, pula e solta faíscas ("me escolhe!") ---------- */
#levelup .sparks, #levelup .shine { display: none; }
#levelup .card.forma { --rar: #e0a33a; }
#levelup .card.forma .face {
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 214, 120, 0.6), transparent 62%), linear-gradient(180deg, #f8eed4, #e4cf9c);
  border-color: #3a0a0e; border-top-color: #e0a33a;
  animation: lu-deal var(--dur) var(--dd) backwards, forma-glow 1.1s ease-in-out calc(var(--dd) + var(--dur)) infinite alternate,
    forma-hop 2.6s ease-in-out calc(var(--dd) + var(--dur) + 200ms) infinite;
}
@keyframes forma-glow {
  from { box-shadow: 6px 6px 0 #000, 0 0 16px 2px rgba(200, 16, 46, 0.6), 0 0 0 2px rgba(224, 163, 58, 0.6); }
  to { box-shadow: 6px 6px 0 #000, 0 0 40px 12px rgba(255, 170, 50, 0.7), 0 0 0 3px rgba(255, 214, 120, 1); }
}
/* Pulos com uma tremidinha e depois flutua. */
@keyframes forma-hop {
  0%, 30%, 100% { translate: 0 0; rotate: 0deg; }
  6% { translate: 0 -20px; rotate: -3deg; }
  12% { translate: 0 0; rotate: 2deg; }
  17% { translate: 0 -9px; rotate: -1.5deg; }
  22% { translate: 0 0; rotate: 0.6deg; }
  65% { translate: 0 -6px; rotate: 0deg; }
}
/* Raios girando: ficam no .cards, atrás de TODAS as cartas (o JS centraliza na carta). */
#levelup .cards > .halo {
  --after: 0ms;
  position: absolute; z-index: -1; width: 640px; height: 640px; translate: -50% -50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 176, 70, 0.4), rgba(200, 16, 46, 0.22) 34%, transparent 62%),
    repeating-conic-gradient(rgba(255, 196, 90, 0.6) 0deg 4deg, transparent 4deg 13deg, rgba(200, 16, 46, 0.55) 13deg 16deg, transparent 16deg 24deg);
  -webkit-mask: radial-gradient(closest-side, #000 28%, transparent 100%);
  mask: radial-gradient(closest-side, #000 28%, transparent 100%);
  animation: halo-in 0.5s ease-out var(--after) backwards, halo-spin 16s linear infinite;
}
#levelup .cards > .halo.burst { animation: halo-burst 0.58s ease-in forwards; }
#levelup .cards > .halo.gone { animation: cr-fade-out 0.2s ease-in forwards; }
@keyframes halo-in { from { opacity: 0; scale: 0.3; } }
@keyframes halo-spin { to { rotate: 360deg; } }
@keyframes halo-burst { to { scale: 2.6; opacity: 0; } }
/* Faíscas subindo. */
#levelup .card.forma .sparks { display: block; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#levelup .sparks b {
  position: absolute; left: var(--x); bottom: 8%; width: 5px; height: 5px; border-radius: 50%; opacity: 0;
  background: #ffe1a0; box-shadow: 0 0 6px 2px rgba(255, 150, 40, 0.9), 0 0 14px 4px rgba(200, 16, 46, 0.45);
  animation: lu-spark 1.9s ease-out calc(var(--dd) + var(--dur) + var(--d)) infinite;
}
#levelup .sparks b:nth-child(3n) { width: 4px; height: 4px; background: #ff5a3c; }
@keyframes lu-spark { 0% { opacity: 0; transform: translate(0, 0) scale(1); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), -250px) scale(0.2); } }
/* Reflexo de luz passando. */
#levelup .card.forma .shine { display: block; position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
#levelup .shine::before {
  content: ''; position: absolute; top: -30%; bottom: -30%; left: -45%; width: 34%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 250, 225, 0.7), transparent);
  animation: lu-shine 2.8s ease-in-out calc(var(--dd) + var(--dur) + 300ms) infinite;
}
@keyframes lu-shine { 0% { transform: translateX(0) skewX(-20deg); } 38%, 100% { transform: translateX(560%) skewX(-20deg); } }
/* Fita "completa o combo" e o selo com o que o combo faz. */
#levelup .ribbon {
  position: absolute; top: -25px; left: 50%; z-index: 4; translate: -50% 0; padding: 4px 12px 5px; white-space: nowrap;
  font: 700 11px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: #ffe9b5;
  background: linear-gradient(180deg, #d01624, #7a0610); border: 2px solid #e0a33a; box-shadow: 3px 3px 0 #000;
  animation: lu-ribbon 1.1s ease-in-out infinite alternate;
}
@keyframes lu-ribbon { to { scale: 1.08; } }
#levelup .seal {
  width: 100%; display: flex; gap: 8px; align-items: center; margin-top: 3px; padding: 7px 8px; text-align: left;
  color: #f6dcc0; background: linear-gradient(180deg, #3a0a0e, #170305); border: 2px solid #e0a33a; box-shadow: inset 0 0 14px rgba(255, 110, 40, 0.35);
}
#levelup .s-ico {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  font: 400 23px/1 Georgia, serif; color: #ffe2c0;
  background: radial-gradient(circle at 38% 32%, #ff4a3a, #b3121c 50%, #5c070c 85%); box-shadow: 0 0 12px rgba(255, 80, 40, 0.8);
}
#levelup .s-txt > b { display: block; font: 400 20px/1 var(--title); color: #ffd27a; }
#levelup .s-txt span { display: block; margin-top: 2px; font: 12.5px/1.25 var(--text); }
#levelup .s-txt .num { color: #ffd27a; }

/* ---------- Saída: a escolhida sobe, as outras caem; a de combo explode em luz ---------- */
#levelup .card.chosen .face { animation: lu-chosen 0.26s ease-in forwards; }
#levelup .card.discard .face { animation: lu-discard 0.24s ease-in forwards; }
#levelup .card.discard .sparks { display: none; }
#levelup .card.chosen-forma .face { animation: lu-forma-out 0.58s ease-in forwards; }
@keyframes lu-chosen { 30% { transform: scale(1.08); } 100% { transform: translateY(-46px) scale(1.12); opacity: 0; } }
@keyframes lu-discard { to { transform: translateY(70px) rotate(calc((var(--i) - 1) * 9deg)); opacity: 0; } }
@keyframes lu-forma-out {
  0% { transform: scale(1); filter: brightness(1); }
  14% { transform: scale(1.12) rotate(-3deg); }
  24% { transform: scale(1.12) rotate(3deg); }
  34% { transform: scale(1.14) rotate(-3deg); }
  44% { transform: scale(1.14) rotate(2deg); filter: brightness(1.4); }
  70% { transform: scale(1.22) rotate(0deg); filter: brightness(2.2); opacity: 1; }
  100% { transform: scale(1.7); filter: brightness(4); opacity: 0; }
}
#levelup.forming::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 226, 170, 0.95), rgba(200, 16, 46, 0.65) 42%, transparent 78%);
  animation: lu-flash 0.58s ease-in forwards;
}
@keyframes lu-flash { 0%, 55% { opacity: 0; } 88% { opacity: 1; } 100% { opacity: 0.85; } }

/* ---------- Habilidade nova com os 2 espaços cheios: onde ela entra + Q ↔ E ---------- */
#levelup.mode-swap .cards {
  display: grid; gap: 12px 22px; padding-top: 18px; justify-content: center;
  grid-template-columns: minmax(150px, 220px) minmax(150px, 178px) minmax(150px, 220px);
  grid-template-areas: 'nova nova nova' 'q swap e' 'prev prev prev' 'keep keep keep';
}
#levelup.mode-swap .card { width: auto; }
#levelup.mode-swap h2 { font-size: clamp(30px, 4.4vw, 52px); }
#levelup .card.slot .face { min-height: 196px; }
#levelup .badge { position: absolute; right: 7px; top: 5px; }
#levelup .badge kbd { min-width: 30px; font-size: 16px; line-height: 27px; }
#levelup .act { font: 700 15px/1.3 var(--text); color: var(--blood); text-align: center; }
#levelup .small { font: italic 12px var(--text); color: #4a4037; }
#levelup .card.slot .lvl { margin-bottom: auto; }
#levelup .card.slot .act { width: 100%; margin-top: 6px; padding-top: 6px; border-top: 1px dashed #9c8f78; }
#levelup .entra { visibility: hidden; font: 700 12px var(--mono); color: #7a1018; letter-spacing: 0.05em; }
#levelup .card.slot.sel .entra { visibility: visible; animation: lu-blink 0.55s ease-in-out infinite alternate; }
@keyframes lu-blink { to { opacity: 0.45; } }
#levelup .card.swapbtn { align-self: center; }
#levelup .card.swapbtn .face { min-height: 136px; justify-content: center; border-top-width: 6px; }
#levelup .card.swapbtn .icon { font-size: 40px; }
#levelup .card.swapbtn .act { white-space: nowrap; }
#levelup .card.keep { justify-self: center; width: min(330px, 100%); }
#levelup .card.keep .face { min-height: 0; flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 10px; padding: 10px 14px; border-top-width: 3px; }
#levelup .card.keep .icon { font-size: 26px; }
#levelup .card.keep .small { width: 100%; text-align: center; }
/* Trocar Q ↔ E: as duas cartas cruzam de lugar. */
#levelup .card.moved .face { animation: lu-move 0.38s cubic-bezier(.3, .8, .3, 1.15) backwards; }
@keyframes lu-move { from { transform: translateX(var(--dx)) rotate(6deg) scale(0.92); } }
#levelup .nova {
  grid-area: nova; justify-self: center; position: relative; display: flex; gap: 12px; align-items: center;
  width: min(540px, 100%); padding: 13px 16px 12px 14px; text-align: left; color: var(--ink);
  background: linear-gradient(180deg, #efe5cf, #d9ccb0); border: 3px solid var(--ink); border-left: 10px solid var(--gold);
  box-shadow: 6px 6px 0 #000, 0 0 24px rgba(216, 165, 49, 0.45); animation: lu-in 0.4s ease-out backwards;
}
#levelup.dealt .nova { animation: none; }
#levelup .nova .n-tag { position: absolute; top: -12px; left: 12px; padding: 1px 8px; font: 700 11px var(--mono); letter-spacing: 0.16em; color: var(--ink); background: var(--gold); box-shadow: 2px 2px 0 #000; }
#levelup .nova .n-ico { font-size: 40px; }
#levelup .nova div > b { display: block; font: 400 25px/1.05 var(--title); }
#levelup .nova span { font: 15px/1.3 var(--text); }
#levelup .nova::after { content: '▼'; position: absolute; bottom: -24px; left: 50%; translate: -50% 0; color: var(--gold); font-size: 15px; text-shadow: 2px 2px 0 #000; animation: lu-arrow 0.7s ease-in-out infinite alternate; }
@keyframes lu-arrow { to { translate: -50% 5px; } }
@keyframes lu-in { from { opacity: 0; transform: translateY(-14px); } }
#levelup .preview { grid-area: prev; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; font: 16px var(--text); color: var(--paper); }
#levelup .preview > i { opacity: 0.75; }
#levelup .preview span { padding: 3px 10px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(232, 220, 194, 0.35); box-shadow: 3px 3px 0 #000; }
#levelup .preview em { width: 100%; font-size: 14px; opacity: 0.8; }

/* ---------- Revelação de combo: pergaminho que desenrola ---------- */
#levelup.revealing > h2, #levelup.revealing > .sub, #levelup.revealing > .cards, #levelup.revealing > .controls { visibility: hidden; }
.combo-reveal {
  position: fixed; inset: 0; z-index: 30; overflow: hidden; cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(46, 5, 8, 0.8), rgba(0, 0, 0, 0.95) 72%);
  animation: cr-fade 0.3s ease-out backwards;
}
.combo-reveal.closing { animation: cr-fade-out 0.38s ease-in forwards; }
@keyframes cr-fade { from { opacity: 0; } }
@keyframes cr-fade-out { to { opacity: 0; } }
.cr-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(255, 232, 196, 0.95), rgba(200, 16, 46, 0.7) 45%, transparent 82%); animation: cr-flash 0.6s ease-out; }
@keyframes cr-flash { from { opacity: 1; } }
.cr-rays {
  position: absolute; left: 50%; top: 50%; width: 170vmax; height: 170vmax; margin: -85vmax 0 0 -85vmax; pointer-events: none;
  background: repeating-conic-gradient(rgba(200, 16, 46, 0.32) 0deg 5deg, transparent 5deg 13deg, rgba(255, 190, 90, 0.16) 13deg 15deg, transparent 15deg 22deg);
  -webkit-mask: radial-gradient(closest-side, #000 6%, transparent 60%);
  mask: radial-gradient(closest-side, #000 6%, transparent 60%);
  animation: cr-rays 0.9s ease-out backwards, halo-spin 50s linear infinite;
}
@keyframes cr-rays { from { opacity: 0; scale: 0.3; } }
.cr-embers i {
  position: absolute; bottom: -10px; left: var(--x); width: 4px; height: 4px; border-radius: 50%; scale: var(--s); opacity: 0;
  background: #ffcf7a; box-shadow: 0 0 8px 2px rgba(255, 120, 40, 0.8); animation: cr-ember 3.4s ease-out var(--d) infinite;
}
@keyframes cr-ember { 0% { opacity: 0; transform: translate(0, 0); } 10% { opacity: 1; } 100% { opacity: 0; transform: translate(40px, -88vh); } }
/* O rolo de cima fica parado (topo calculado pela altura final --h) e o de baixo desce. */
.cr-scroll { position: absolute; left: 50%; top: max(12px, calc(50% - (var(--h, 400px) + 58px) / 2)); translate: -50% 0; width: min(600px, calc(100vw - 72px)); animation: cr-drop 0.4s cubic-bezier(.3, 1.35, .5, 1) backwards; }
@keyframes cr-drop { from { transform: translateY(-70vh) rotate(-4deg) scale(0.9); } }
.cr-rod {
  position: relative; z-index: 2; height: 26px; margin: 0 -24px; border-radius: 13px;
  background: linear-gradient(180deg, #7a4e2c 0%, #4a2b14 45%, #1d0e05 100%); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.7), inset 0 2px 0 rgba(255, 220, 170, 0.3);
}
.cr-rod::before, .cr-rod::after {
  content: ''; position: absolute; top: -6px; width: 20px; height: 38px; border-radius: 6px;
  background: linear-gradient(90deg, #6b4d16, #e6b84f 45%, #7a5a1e); box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.6);
}
.cr-rod::before { left: -14px; }
.cr-rod::after { right: -14px; }
/* Embaixo fica o rolo de papel que vai descendo enquanto desenrola. */
.cr-rod.bottom { height: 32px; margin: 0 -14px; background: linear-gradient(180deg, #f3e6c4 0%, #dcc697 38%, #a98d5b 74%, #5e4728 100%); }
.cr-rod.bottom::before, .cr-rod.bottom::after { top: -3px; }
.cr-paper {
  position: relative; z-index: 1; height: 0; margin: -6px 0; overflow: hidden; color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, rgba(120, 70, 20, 0.2), transparent 55%), radial-gradient(ellipse at 50% 100%, rgba(120, 70, 20, 0.24), transparent 50%),
    linear-gradient(90deg, #c4ab7c 0%, #eadbb5 7%, #f4e9cd 50%, #eadbb5 93%, #c4ab7c 100%);
  box-shadow: inset 0 0 40px rgba(90, 50, 10, 0.32);
  animation: cr-unroll 0.85s cubic-bezier(.35, .1, .25, 1) 0.38s forwards;
}
.cr-paper.open { height: auto; animation: none; }
.combo-reveal.closing .cr-paper { animation: cr-rollup 0.34s ease-in forwards; }
@keyframes cr-unroll { from { height: 0; } to { height: var(--h); } }
@keyframes cr-rollup { from { height: var(--from); } to { height: 0; } }
.cr-in { padding: 24px 40px 14px; text-align: center; }
.cr-kicker { margin: 0; font: 700 13px var(--mono); letter-spacing: 0.3em; text-transform: uppercase; color: #5c070c; animation: cr-up 0.4s ease-out 0.55s backwards; }
.cr-seal {
  width: 94px; height: 94px; margin: 12px auto 6px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ff5a46, #b3121c 48%, #5c070c 84%);
  box-shadow: 0 0 0 5px rgba(92, 7, 12, 0.45), 0 6px 0 #2a0305, 0 0 34px rgba(220, 30, 40, 0.65);
  animation: cr-stamp 0.38s cubic-bezier(.2, .9, .3, 1.3) 0.86s backwards;
}
.cr-seal span { font: 400 52px/1 Georgia, serif; color: #ffe6c8; text-shadow: 0 3px 0 #5c070c; }
@keyframes cr-stamp { from { opacity: 0; transform: scale(2.6) rotate(-20deg); } 60% { opacity: 1; } }
.cr-name { margin: 2px 0 0; font: 400 clamp(40px, 6vw, 62px)/1 var(--title); letter-spacing: 0.04em; color: #7a0a12; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); animation: cr-name 0.6s ease-out 1s backwards; }
@keyframes cr-name { from { opacity: 0; letter-spacing: 0.45em; filter: blur(4px); } }
.cr-motto { margin: 4px 0 0; font: italic 17px var(--text); color: #3b2a1c; animation: cr-up 0.5s ease-out 1.15s backwards; }
.cr-sep { display: flex; align-items: center; gap: 8px; width: 72%; margin: 12px auto 6px; font-size: 14px; color: #7a0a12; }
.cr-sep::before, .cr-sep::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #7a0a12); }
.cr-sep::after { background: linear-gradient(90deg, #7a0a12, transparent); }
.cr-label { margin: 0; font: 700 12px var(--mono); letter-spacing: 0.28em; text-transform: uppercase; color: var(--blood); animation: cr-up 0.4s ease-out 1.25s backwards; }
.cr-effect { max-width: 30em; margin: 3px auto 0; font: 21px/1.35 var(--text); animation: cr-up 0.5s ease-out 1.3s backwards; }
.cr-recipe { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 14px 0 2px; animation: cr-up 0.5s ease-out 1.45s backwards; }
.cr-rlabel { width: 100%; font: italic 13px var(--text); color: #5a4a38; }
.cr-ing { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; font: 14px var(--text); background: linear-gradient(180deg, #efe5cf, #d9ccb0); border: 2px solid var(--ink); border-top: 4px solid var(--rar); box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55); }
.cr-ing b { font: 400 18px Georgia, serif; }
.cr-ing i { font: 700 11px var(--mono); font-style: normal; color: var(--blood); }
.cr-plus { font: 400 22px var(--title); color: #7a0a12; }
.cr-hint { margin: 14px 0 6px; font: 700 13px var(--mono); letter-spacing: 0.14em; color: #4a3a2a; animation: cr-up 0.4s ease-out 1.6s backwards, blink 1.2s 2s infinite; }
.cr-timer { height: 3px; background: rgba(122, 10, 18, 0.18); }
.cr-timer i { display: block; height: 100%; background: #7a0a12; transform-origin: left; animation: cr-timer 4.8s linear 1.2s both; }
@keyframes cr-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes cr-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Telas estreitas (janela pela metade, notebook pequeno) ---------- */
@media (max-width: 760px), (max-height: 560px) {
  #levelup .cards { gap: 12px; padding-top: 26px; }
  #levelup .face { padding: 16px 10px 10px; min-height: 200px; }
  #levelup .face .icon { font-size: 32px; }
  #levelup .face .name { font-size: 21px; }
  #levelup .face .desc { font-size: 14px; }
  #levelup h2 { font-size: 32px; }
  #levelup.mode-swap .cards { grid-template-columns: minmax(120px, 1fr) minmax(96px, 130px) minmax(120px, 1fr); gap: 12px; }
  #levelup .card.swapbtn .act { white-space: normal; }
  .cr-in { padding: 14px 20px 10px; }
  .cr-seal { width: 70px; height: 70px; }
  .cr-seal span { font-size: 38px; }
  .cr-effect { font-size: 18px; }
}

/* Menos movimento: tudo continua, só que menor e mais calmo. */
@media (prefers-reduced-motion: reduce) {
  @keyframes lu-deal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes lu-back { from, to { opacity: 0; } }
  @keyframes forma-hop { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
  @keyframes lu-spark { 0% { opacity: 0; transform: translate(0, 0); } 20% { opacity: 0.8; } 100% { opacity: 0; transform: translate(0, -110px); } }
  @keyframes lu-forma-out { 0% { filter: brightness(1); } 100% { filter: brightness(2.4); opacity: 0; } }
  @keyframes lu-move { from { opacity: 0.4; } }
  @keyframes cr-drop { from { opacity: 0; transform: translateY(-24px); } }
  @keyframes cr-stamp { from { opacity: 0; transform: scale(1.25); } }
  @keyframes cr-ember { 0% { opacity: 0; transform: translate(0, 0); } 15% { opacity: 0.7; } 100% { opacity: 0; transform: translate(0, -30vh); } }
  #levelup .sparks b:nth-child(2n), .cr-embers i:nth-child(2n) { display: none; }
  #levelup .cards > .halo { animation: halo-in 0.5s ease-out var(--after) backwards, halo-spin 90s linear infinite; }
  .cr-rays { animation: cr-rays 0.9s ease-out backwards, halo-spin 240s linear infinite; }
  #levelup .ribbon, #levelup .sub-combo { animation-duration: 2.4s; }
}

/* ---------- Correções do QA ---------- */
/* Tela de nível aberta: HUD, números e faixas somem por trás (como na pausa). */
body.lu-open #hud, body.lu-open #fx { opacity: 0; transition: opacity 0.18s; }
body.lu-open #banner { visibility: hidden; }
/* Raios fixos na tela: girando, não criam barra de rolagem (o JS posiciona). */
#levelup .cards > .halo { position: fixed; }
/* Revelação: 1º toque mostra tudo de uma vez (sem as animações de entrada). */
.combo-reveal.cr-skip .cr-scroll, .combo-reveal.cr-skip .cr-kicker, .combo-reveal.cr-skip .cr-seal,
.combo-reveal.cr-skip .cr-name, .combo-reveal.cr-skip .cr-motto, .combo-reveal.cr-skip .cr-label,
.combo-reveal.cr-skip .cr-effect, .combo-reveal.cr-skip .cr-recipe { animation: none; }
.combo-reveal.cr-skip .cr-hint { animation: blink 1.2s infinite; }
/* Janela baixa (PC da escola: 1366×657, notebook 1024×600): a troca de habilidade cabe sem rolar. */
@media (max-height: 760px) {
  #levelup { padding: 8px 0; }
  #levelup.mode-swap h2 { font-size: 34px; }
  #levelup.mode-swap .sub { margin: 2px 0; font-size: 15px; }
  #levelup.mode-swap .cards { gap: 8px 18px; padding-top: 12px; }
  #levelup .nova { padding: 8px 12px; }
  #levelup .nova .n-ico { font-size: 30px; }
  #levelup .nova div > b { font-size: 21px; }
  #levelup .nova span { font-size: 13px; }
  #levelup .nova::after { display: none; }
  #levelup .card.slot .face { min-height: 150px; padding: 14px 10px 10px; }
  #levelup .card.slot .icon, #levelup .card.swapbtn .icon { font-size: 32px; }
  #levelup .card.swapbtn .face { min-height: 104px; }
  #levelup .preview { font-size: 14px; gap: 4px 10px; }
  #levelup .preview em { font-size: 12px; }
  #levelup .card.keep .face { padding: 6px 12px; }
  #levelup .controls { margin-top: 6px; }
}
/* "Manter as minhas" começa selecionada (levanta 12 px): folga para não cobrir a prévia. */
#levelup.mode-swap .card.keep { margin-top: 10px; }
