/* DioFX — efeitos de tabuleiro compartilhados por /play e /play/bot (ver fx.js). */

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9000; overflow: hidden; }
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9002; }
.fx-layer > * { position: absolute; }

/* Deslize da peça (também usado pelo /play/bot) */
.live-piece.anim { z-index: 4; transition: transform 0.16s cubic-bezier(0.25, 0.8, 0.35, 1); }

/* Anel de choque */
.fx-ring {
  --c: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--c), 0 0 18px var(--c), inset 0 0 14px var(--c);
  animation: fx-ring 650ms cubic-bezier(.15,.7,.3,1) both;
  will-change: transform, opacity;
}
.fx-ring.fx-ring-thick { box-shadow: 0 0 0 5px var(--c), 0 0 30px var(--c), inset 0 0 22px var(--c); }
@keyframes fx-ring { from { transform: scale(.15); opacity: 1; } to { transform: scale(1); opacity: 0; } }

/* Clarão */
.fx-flash { --c: rgba(255,255,255,.8); background: radial-gradient(circle, var(--c), transparent 70%); animation: fx-flash 450ms ease-out both; mix-blend-mode: screen; }
@keyframes fx-flash { from { opacity: 1; } to { opacity: 0; } }

/* Peça capturada: encolhe girando */
.fx-ghost { background-size: contain; background-repeat: no-repeat; background-position: center; }
.fx-ghost-cap { animation: fx-ghost-cap 500ms cubic-bezier(.5,0,.75,0) both; }
@keyframes fx-ghost-cap {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  25% { transform: scale(1.12) rotate(-6deg); filter: brightness(2.2) drop-shadow(0 0 8px #fff); }
  100% { transform: scale(.1) rotate(40deg) translateY(30%); opacity: 0; filter: brightness(3); }
}

/* Impacto da peça que capturou */
.live-piece.fx-land { animation: fx-land 360ms cubic-bezier(.3,1.6,.5,1); }
@keyframes fx-land { 0% { transform: scale(1.22); } 100% { transform: scale(1); } }

/* Rei em xeque: tremida + pulso contínuo */
.live-piece.fx-shiver { animation: fx-shiver 520ms ease-in-out; }
@keyframes fx-shiver {
  15%, 55% { transform: translateX(-7%) rotate(-5deg); }
  35%, 75% { transform: translateX(7%) rotate(5deg); }
}
.live-board .live-square.in-check::after,
.live-board .live-square.check::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(255,40,40,.75), rgba(255,0,0,0) 70%);
  animation: fx-check-pulse 1.1s ease-in-out infinite;
}
@keyframes fx-check-pulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.08); } }

/* Rastro do último lance */
.fx-trail {
  transform-origin: 0 50%;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(255,240,170,0), rgba(255,240,170,.55) 70%, rgba(255,255,255,.85));
  filter: blur(3px);
  animation: fx-trail 650ms ease-out both;
}
@keyframes fx-trail { 0% { opacity: 0; clip-path: inset(0 100% 0 0); } 30% { opacity: 1; clip-path: inset(0 0 0 0); } 100% { opacity: 0; clip-path: inset(0 0 0 100%); } }

/* Promoção: coluna de luz */
.fx-pillar {
  background: linear-gradient(to top, rgba(253,224,71,.85), rgba(253,224,71,.25) 60%, transparent);
  filter: blur(2px); mix-blend-mode: screen; transform-origin: bottom;
  animation: fx-pillar 850ms ease-out both;
}
@keyframes fx-pillar { 0% { transform: scaleY(0) scaleX(.4); opacity: 0; } 30% { transform: scaleY(1) scaleX(1); opacity: 1; } 100% { transform: scaleY(1) scaleX(.1); opacity: 0; } }

/* Abertura: peças caem em cascata */
.live-board.fx-intro .live-piece:not(.empty) {
  animation: fx-drop 560ms cubic-bezier(.2,1.5,.45,1) both;
  animation-delay: var(--fx-d, 0ms);
}
@keyframes fx-drop {
  0% { transform: translateY(var(--fx-dy, -70%)) scale(.4); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* Faixas (início, vitória, derrota, empate) */
.fx-banner {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  text-align: center; color: #fff; z-index: 2;
  animation: fx-banner-out 2.4s ease-in both;
}
.fx-banner .t {
  font-size: clamp(1.6rem, 6vmin, 3.4rem); font-weight: 900; letter-spacing: .02em; line-height: 1;
  padding: .35em .9em; border-radius: 14px;
  text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 24px rgba(255,255,255,.35);
  background: linear-gradient(180deg, rgba(20,20,28,.82), rgba(20,20,28,.7));
  box-shadow: 0 20px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.15);
  animation: fx-slam 600ms cubic-bezier(.2,1.6,.4,1) both;
  position: relative; overflow: hidden;
}
.fx-banner .t::after {
  content: ""; position: absolute; inset: -20% -60%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%);
  animation: fx-sheen 1.1s .35s ease-in-out both;
}
.fx-banner .s {
  font-size: .9rem; font-weight: 700; color: #e2e8f0; background: rgba(0,0,0,.55);
  padding: .3em .8em; border-radius: 99px; animation: fx-rise 500ms .25s ease-out both;
}
.fx-banner-start .t { background: linear-gradient(180deg, #81b64c, #5d8d34); font-size: clamp(1.2rem, 4.6vmin, 2.4rem); }
.fx-banner-start { animation-duration: 2s; }
.fx-banner-win .t { background: linear-gradient(180deg, #fde047, #f59e0b 55%, #b45309); color: #3b1d00; text-shadow: 0 2px 0 rgba(255,255,255,.4); box-shadow: 0 0 60px rgba(250,204,21,.65), 0 20px 50px rgba(0,0,0,.5); }
.fx-banner-loss .t { background: linear-gradient(180deg, #3f3f46, #18181b); color: #fca5a5; }
.fx-banner-draw .t { background: linear-gradient(180deg, #64748b, #334155); }
.fx-banner-win, .fx-banner-loss, .fx-banner-draw { animation-duration: 3.4s; }
@keyframes fx-slam { 0% { transform: scale(2.6) rotate(-4deg); opacity: 0; filter: blur(6px); } 100% { transform: none; opacity: 1; filter: none; } }
@keyframes fx-sheen { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
@keyframes fx-rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fx-banner-out { 0%, 82% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

/* Derrota: tabuleiro dessaturado e rachado */
.live-board.fx-defeated { filter: grayscale(.85) brightness(.75) contrast(1.05); transition: filter .8s ease; }
.live-board { transition: filter .8s ease; }
.fx-crack-box svg { width: 100%; height: 100%; overflow: visible; }
.fx-crack path {
  fill: none; stroke: rgba(15,15,20,.85); stroke-width: .6; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 .6px rgba(255,255,255,.6));
  stroke-dasharray: 400; stroke-dashoffset: 400;
  animation: fx-crack 450ms ease-out forwards, fx-flash 900ms 4.2s ease-in forwards;
}
@keyframes fx-crack { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .live-board.fx-intro .live-piece, .live-piece.fx-land, .live-piece.fx-shiver,
  .live-board .live-square.in-check::after, .live-board .live-square.check::after {
    animation: none !important;
  }
}

/* Fila: radar procurando adversário */
.fx-radar {
  position: relative; width: clamp(110px, 30%, 170px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(129,182,76,.18), rgba(129,182,76,.04) 60%, transparent 70%);
  box-shadow: inset 0 0 0 1.5px rgba(129,182,76,.45), 0 0 30px rgba(129,182,76,.15);
}
.fx-radar .sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(129,182,76,.55), rgba(129,182,76,0) 25%, transparent);
  animation: fx-spin 1.6s linear infinite;
}
.fx-radar .ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(129,182,76,.6); animation: fx-ping 2.4s cubic-bezier(.2,.6,.3,1) infinite; }
.fx-radar .r2 { animation-delay: .8s; }
.fx-radar .r3 { animation-delay: 1.6s; }
.fx-radar .core, .fx-radar .blip { position: absolute; display: grid; place-items: center; color: #e8f5d8; text-shadow: 0 0 10px rgba(129,182,76,.9); }
.fx-radar .core { inset: 0; font-size: 2.2rem; animation: fx-breathe 1.6s ease-in-out infinite; }
.fx-radar .blip { font-size: 1.05rem; opacity: 0; animation: fx-blip 3.2s ease-in-out infinite; }
.fx-radar .b1 { left: 14%; top: 18%; }
.fx-radar .b2 { right: 12%; top: 34%; animation-delay: 1.1s; }
.fx-radar .b3 { left: 40%; bottom: 8%; animation-delay: 2.1s; }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-ping { from { transform: scale(.2); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
@keyframes fx-breathe { 50% { transform: scale(1.12); } }
@keyframes fx-blip { 0%, 100% { opacity: 0; transform: scale(.5); } 15% { opacity: 1; transform: scale(1.15); } 45% { opacity: .6; transform: scale(1); } 70% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fx-radar * { animation: none !important; } .fx-radar .blip { opacity: .6; } }

/* Novo título no ranking de poder */
.fx-banner-title .t { font-size: 1.1rem; padding: .3em .8em; background: linear-gradient(180deg, #a855f7, #6d28d9); box-shadow: 0 0 30px rgba(168,85,247,.6); }
.fx-banner-title .s { color: #fde68a; }
.power-me.fx-titleup { animation: fx-titleup 2.4s ease-out; }
@keyframes fx-titleup { 0%, 100% { box-shadow: none; } 15%, 60% { box-shadow: 0 0 0 2px #fde68a, 0 0 30px rgba(253,230,138,.6); } }

/* Tabuleiro 3D inclinado (preferência "Tabuleiro 3D inclinado") */
html.bp-tilt .board-wrap { perspective: 1200px; perspective-origin: 50% 20%; overflow: visible; }
html.bp-tilt .live-board {
  transform: rotateX(24deg); transform-origin: 50% 100%; transform-style: preserve-3d; overflow: visible;
  box-shadow: 0 2px 0 #1b1a17, 0 10px 0 #2b2924, 0 34px 40px rgba(0,0,0,.55);
  border-radius: 4px;
}
html.bp-tilt .live-board .live-square { transform-style: preserve-3d; }
html.bp-tilt .live-board .live-piece:not(.empty) {
  rotate: x -24deg; transform-origin: 50% 88%; pointer-events: auto;
  filter: drop-shadow(0 6px 3px rgba(0,0,0,.35));
}
@media (prefers-reduced-motion: no-preference) {
  html .live-board { transition: transform .5s cubic-bezier(.2,.8,.2,1), filter .8s ease; }
}
