:root {
    --aj-teal: #0ea5e9;
    --aj-green: #10b981;
    --aj-navy: #1e3a5f;
    --aj-ink: #0f2744;
    --aj-mist: #e8eef2;
    --aj-paper: #f7fafc;
    --aj-copper: #c2784a;
    --aj-shadow: rgba(15, 39, 68, 0.12);
    --aj-radius: 18px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Manrope", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--aj-ink);
    background:
        radial-gradient(ellipse 80% 50% at 10% 0%, rgba(14, 165, 233, 0.18), transparent 55%),
        radial-gradient(ellipse 70% 45% at 90% 10%, rgba(16, 185, 129, 0.16), transparent 50%),
        linear-gradient(165deg, #dce8f0 0%, var(--aj-paper) 45%, #eef6f3 100%);
}

.oculto {
    display: none !important;
}

.aj-shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.aj-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.aj-brand {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.35rem;
    color: var(--aj-navy);
}

.aj-lead {
    margin: 0;
    max-width: 42rem;
    line-height: 1.55;
    color: rgba(15, 39, 68, 0.78);
}

.aj-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.aj-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.aj-btn:hover {
    transform: translateY(-1px);
}

.aj-btn--primary {
    background: linear-gradient(135deg, var(--aj-teal), var(--aj-green));
    color: #fff;
}

.aj-btn--ghost {
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(30, 58, 95, 0.18);
    color: var(--aj-navy);
}

.aj-section-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    margin: 0 0 0.85rem;
    color: var(--aj-navy);
}

.aj-team {
    margin-bottom: 2.25rem;
}

.aj-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.aj-card {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(30, 58, 95, 0.1);
    border-radius: var(--aj-radius);
    box-shadow: 0 10px 28px var(--aj-shadow);
    padding: 0.85rem 0.85rem 1rem;
    text-align: center;
}

.aj-card__figure {
    position: relative;
    aspect-ratio: 1;
    border-radius: 14px;
    background:
        radial-gradient(circle at 50% 70%, rgba(14, 165, 233, 0.12), transparent 55%),
        var(--aj-mist);
    overflow: hidden;
    margin-bottom: 0.7rem;
}

.aj-card__figure img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform-origin: 50% 85%;
    animation: aj-idle 2.8s ease-in-out infinite;
}

.aj-card:nth-child(2n) .aj-card__figure img {
    animation-delay: -0.7s;
}

.aj-card:nth-child(3n) .aj-card__figure img {
    animation-delay: -1.4s;
}

.aj-card__name {
    margin: 0;
    font-weight: 800;
    font-size: 1rem;
    color: var(--aj-navy);
}

.aj-card__meta {
    margin: 0.25rem 0 0;
    font-size: 0.82rem;
    color: rgba(15, 39, 68, 0.62);
}

.aj-note {
    margin-top: 1.5rem;
    padding: 1rem 1.15rem;
    border-radius: var(--aj-radius);
    background: rgba(30, 58, 95, 0.06);
    border-left: 4px solid var(--aj-teal);
    line-height: 1.5;
}

.aj-hero-home {
    display: grid;
    gap: 1.5rem;
    align-items: center;
}

@media (min-width: 820px) {
    .aj-hero-home {
        grid-template-columns: 1.1fr 0.9fr;
    }
}

.aj-preview-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.aj-preview-row img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 16px;
    background: var(--aj-mist);
    animation: aj-idle 2.8s ease-in-out infinite;
}

.aj-preview-row img:nth-child(2) {
    animation-delay: -0.9s;
}

.aj-preview-row img:nth-child(3) {
    animation-delay: -1.6s;
}

@keyframes aj-idle {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    40% {
        transform: translateY(-5px) rotate(-1.2deg);
    }
    70% {
        transform: translateY(-2px) rotate(1deg);
    }
}

@keyframes aj-joints {
    0%,
    100% {
        transform: translateY(0) rotate(0deg) scaleY(1);
    }
    25% {
        transform: translateY(-3px) rotate(-2deg) scaleY(1.02);
    }
    50% {
        transform: translateY(-6px) rotate(1.5deg) scaleY(0.98);
    }
    75% {
        transform: translateY(-2px) rotate(-1deg) scaleY(1.01);
    }
}

@media (prefers-reduced-motion: reduce) {
    .aj-card__figure img,
    .aj-preview-row img,
    .aj-piece--idle {
        animation: none;
    }

    .aj-flyer--go,
    .aj-weapon--thrust,
    .aj-piece--vanish,
    .aj-piece--hit,
    .aj-burst__p,
    .aj-burst__spark,
    .aj-burst__ring,
    .aj-burst__flash,
    .aj-shock,
    .aj-trail,
    .aj-land,
    .aj-sq--impact::before {
        animation-duration: 0.01ms !important;
    }
}

/* —— Juego / tablero —— */
.aj-shell--juego {
    width: min(1200px, calc(100% - 1.25rem));
}

.aj-juego {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 900px) {
    .aj-juego {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
        align-items: start;
    }
}

.aj-panel {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(30, 58, 95, 0.12);
    border-radius: var(--aj-radius);
    box-shadow: 0 10px 28px var(--aj-shadow);
    padding: 1.1rem 1.15rem 1.25rem;
}

.aj-turno {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--aj-navy);
}

.aj-estado {
    margin: 0 0 1rem;
    min-height: 2.6em;
    line-height: 1.45;
    color: rgba(15, 39, 68, 0.75);
}

.aj-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 1.15rem;
}

.aj-capturas {
    display: grid;
    gap: 0.9rem;
}

.aj-capturas-title {
    margin: 0 0 0.4rem;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: rgba(30, 58, 95, 0.65);
}

.aj-capturas-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-height: 2.4rem;
}

.aj-cap-thumb--fig {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1;
}

.aj-cap-thumb--blanco {
    background: #f4efe6;
    color: #1e3a5f;
    border: 1px solid rgba(30, 58, 95, 0.25);
}

.aj-cap-thumb--negro {
    background: #1e3a5f;
    color: #ecfdf5;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.aj-cap-thumb {
    width: 2.2rem;
    height: 2.2rem;
    object-fit: contain;
    border-radius: 8px;
    background: var(--aj-mist);
}

.aj-tablero-wrap {
    display: grid;
    gap: 0.35rem;
    justify-items: center;
}

.aj-coords {
    display: grid;
    color: rgba(30, 58, 95, 0.55);
    font-size: 0.78rem;
    font-weight: 700;
}

.aj-coords--files {
    grid-template-columns: repeat(8, 1fr);
    width: min(72vw, 640px);
    padding-left: 1.4rem;
    text-align: center;
}

.aj-tablero-frame {
    display: grid;
    grid-template-columns: 1.4rem minmax(0, 1fr);
    gap: 0.25rem;
    align-items: stretch;
}

.aj-coords--ranks {
    grid-template-rows: repeat(8, 1fr);
    height: min(72vw, 640px);
    align-items: center;
    justify-items: center;
}

.aj-board-stack {
    position: relative;
    width: min(72vw, 640px);
    aspect-ratio: 1;
}

.aj-board {
    --aj-light: #e7f0f4;
    --aj-dark: #3d6b7a;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 0 0 4px rgba(30, 58, 95, 0.2),
        0 18px 40px rgba(15, 39, 68, 0.22);
    background: var(--aj-navy);
}

.aj-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    border-radius: 16px;
    overflow: visible;
}

.aj-sq {
    position: relative;
    border: 0;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--aj-light);
}

.aj-sq--dark {
    background: var(--aj-dark);
}

.aj-sq--selected {
    box-shadow: inset 0 0 0 3px #fbbf24;
}

.aj-sq--last {
    box-shadow: inset 0 0 0 3px rgba(14, 165, 233, 0.55);
}

.aj-sq--move::after,
.aj-sq--capture::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.aj-sq--move::after {
    width: 22%;
    height: 22%;
    background: rgba(16, 185, 129, 0.55);
}

.aj-sq--capture::after {
    inset: 10%;
    border: 3px solid rgba(239, 68, 68, 0.75);
    background: rgba(239, 68, 68, 0.12);
}

.aj-piece {
    width: 92%;
    height: 92%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    transform-origin: 50% 90%;
    background: transparent;
}

.aj-piece--idle {
    animation: aj-joints 2.6s ease-in-out infinite;
}

.aj-piece--windup {
    transform: rotate(var(--aj-lean, -6deg)) scale(1.04);
    transition: transform 0.18s ease-out;
}

.aj-sq:nth-child(3n) .aj-piece--idle {
    animation-delay: -0.6s;
}

.aj-sq:nth-child(5n) .aj-piece--idle {
    animation-delay: -1.3s;
}

.aj-piece--selected {
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.9))
        drop-shadow(0 0 18px rgba(14, 165, 233, 0.45));
}

.aj-piece--hit {
    animation: aj-hit 0.55s ease-in-out;
    z-index: 3;
}

.aj-piece--vanish {
    animation: aj-vanish 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    z-index: 3;
}

.aj-sq--impact::before {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: 18%;
    background: radial-gradient(
        circle,
        rgba(251, 191, 36, 0.55) 0%,
        rgba(239, 68, 68, 0.28) 42%,
        transparent 70%
    );
    animation: aj-sq-impact 0.7s ease-out forwards;
    pointer-events: none;
    z-index: 0;
}

.aj-sq--land {
    box-shadow: inset 0 0 0 3px rgba(14, 165, 233, 0.55),
        0 0 22px rgba(16, 185, 129, 0.35);
}

.aj-flyer {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: var(--fx-w);
    height: var(--fx-h);
    object-fit: contain;
    z-index: 6;
    background: transparent;
    filter: drop-shadow(0 10px 14px rgba(15, 39, 68, 0.4))
        drop-shadow(0 0 12px rgba(14, 165, 233, 0.35));
    transition: transform 0.52s cubic-bezier(0.22, 0.9, 0.3, 1);
    transform: translate(0, 0) scale(1);
    will-change: transform, filter;
}

.aj-flyer--go {
    transform: translate(var(--fx-dx), var(--fx-dy)) scale(1.05);
}

.aj-flyer--travel.aj-flyer--go {
    animation: aj-hop 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}

.aj-trail {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: var(--fx-w);
    height: var(--fx-h);
    object-fit: contain;
    z-index: 5;
    pointer-events: none;
    opacity: 0.55;
    filter: blur(1px) saturate(1.3) drop-shadow(0 0 8px rgba(14, 165, 233, 0.55));
    animation: aj-trail-fade 0.45s ease-out forwards;
    transform: translate(var(--fx-dx), var(--fx-dy)) scale(0.92);
}

.aj-weapon {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: var(--fx-w);
    height: var(--fx-h);
    object-fit: contain;
    z-index: 8;
    background: transparent;
    pointer-events: none;
    filter: drop-shadow(0 8px 12px rgba(15, 39, 68, 0.45))
        drop-shadow(0 0 14px rgba(251, 191, 36, 0.65));
    transform-origin: 20% 80%;
    transform: rotate(var(--fx-rot, -20deg)) scale(0.85);
    opacity: 0.98;
    will-change: transform, opacity, filter;
}

.aj-weapon--thrust {
    animation: aj-weapon-thrust 0.78s cubic-bezier(0.15, 0.85, 0.25, 1) forwards;
}

.aj-weapon--escudo.aj-weapon--thrust,
.aj-weapon--torre.aj-weapon--thrust {
    animation-name: aj-weapon-bash;
}

.aj-slash {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: var(--fx-w);
    height: var(--fx-h);
    z-index: 7;
    pointer-events: none;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.95) 35%,
        rgba(251, 191, 36, 0.9) 55%,
        rgba(239, 68, 68, 0.75) 75%,
        transparent 100%
    );
    transform: translate(-50%, -50%) rotate(var(--fx-rot, 35deg)) scaleX(0.2);
    filter: blur(1px);
    opacity: 0;
    animation: aj-slash 0.45s ease-out forwards;
    animation-delay: var(--fx-delay, 0ms);
}

.aj-burst {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: 0;
    height: 0;
    z-index: 7;
}

.aj-burst__flash {
    position: absolute;
    width: 120px;
    height: 120px;
    margin: -60px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(251, 191, 36, 0.7) 28%,
        rgba(239, 68, 68, 0.35) 55%,
        transparent 72%
    );
    animation: aj-flash 0.55s ease-out forwards;
}

.aj-burst__ring {
    position: absolute;
    width: 24px;
    height: 24px;
    margin: -12px;
    border-radius: 50%;
    border: 3px solid rgba(251, 191, 36, 0.9);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.55), inset 0 0 12px rgba(255, 255, 255, 0.35);
    animation: aj-ring 0.65s cubic-bezier(0.15, 0.85, 0.3, 1) forwards;
}

.aj-burst__ring--late {
    animation-delay: 0.08s;
    border-color: rgba(14, 165, 233, 0.85);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.5);
}

.aj-burst__p {
    position: absolute;
    width: var(--s, 10px);
    height: var(--s, 10px);
    margin: calc(var(--s, 10px) / -2);
    border-radius: 50%;
    background: var(--c, linear-gradient(135deg, #fbbf24, #ef4444));
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.75);
    animation: aj-particle 0.75s ease-out forwards;
    animation-delay: var(--d, 0ms);
    transform: rotate(var(--a)) translateY(0);
}

.aj-burst__spark {
    position: absolute;
    width: 4px;
    height: var(--len, 18px);
    margin: calc(var(--len, 18px) / -2) -2px;
    border-radius: 999px;
    background: linear-gradient(180deg, #fff 0%, #fbbf24 40%, transparent 100%);
    box-shadow: 0 0 8px #f59e0b;
    animation: aj-spark 0.55s ease-out forwards;
    animation-delay: var(--d, 0ms);
    transform: rotate(var(--a)) translateY(0);
}

.aj-shock {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: 16px;
    height: 16px;
    margin: -8px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.55);
    z-index: 7;
    animation: aj-shock 0.7s ease-out forwards;
}

.aj-land {
    position: absolute;
    left: var(--fx-x);
    top: var(--fx-y);
    width: 28px;
    height: 28px;
    margin: -14px;
    border-radius: 50%;
    border: 3px solid rgba(14, 165, 233, 0.8);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.45);
    z-index: 6;
    animation: aj-land-ring 0.55s ease-out forwards;
}

@keyframes aj-hit {
    0%,
    100% {
        transform: translateX(0) scale(1);
        filter: brightness(1) saturate(1);
    }
    20% {
        transform: translateX(-8px) rotate(-8deg) scale(1.08);
        filter: brightness(1.8) saturate(1.4) drop-shadow(0 0 12px #ef4444);
    }
    45% {
        transform: translateX(10px) rotate(7deg) scale(1.12);
        filter: brightness(2.2) saturate(1.6) drop-shadow(0 0 16px #fbbf24);
    }
    70% {
        transform: translateX(-4px) rotate(-3deg) scale(1.05);
        filter: brightness(1.5);
    }
}

@keyframes aj-vanish {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: brightness(1) drop-shadow(0 0 0 transparent);
    }
    25% {
        opacity: 1;
        transform: scale(1.25) rotate(-8deg);
        filter: brightness(2.4) drop-shadow(0 0 18px #fbbf24);
    }
    55% {
        opacity: 0.75;
        transform: scale(0.85) rotate(18deg);
        filter: brightness(2.8) hue-rotate(20deg) drop-shadow(0 0 22px #ef4444);
    }
    100% {
        opacity: 0;
        transform: scale(0.05) rotate(55deg) translateY(-18px);
        filter: brightness(3.5) drop-shadow(0 0 28px #fff);
    }
}

@keyframes aj-hop {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        filter: drop-shadow(0 8px 10px rgba(15, 39, 68, 0.35))
            drop-shadow(0 0 8px rgba(14, 165, 233, 0.25));
    }
    35% {
        transform: translate(calc(var(--fx-dx) * 0.35), calc(var(--fx-dy) * 0.35 - 28px))
            scale(1.14) rotate(-4deg);
        filter: drop-shadow(0 16px 18px rgba(15, 39, 68, 0.4))
            drop-shadow(0 0 16px rgba(14, 165, 233, 0.55));
    }
    70% {
        transform: translate(calc(var(--fx-dx) * 0.78), calc(var(--fx-dy) * 0.78 - 10px))
            scale(1.06) rotate(3deg);
    }
    100% {
        transform: translate(var(--fx-dx), var(--fx-dy)) scale(1) rotate(0deg);
        filter: drop-shadow(0 8px 10px rgba(15, 39, 68, 0.35))
            drop-shadow(0 0 10px rgba(16, 185, 129, 0.45));
    }
}

@keyframes aj-trail-fade {
    0% {
        opacity: 0.55;
        transform: translate(var(--fx-dx), var(--fx-dy)) scale(0.95);
        filter: blur(0.5px) saturate(1.4) drop-shadow(0 0 10px rgba(14, 165, 233, 0.65));
    }
    100% {
        opacity: 0;
        transform: translate(var(--fx-dx), var(--fx-dy)) scale(0.7);
        filter: blur(3px) saturate(0.8);
    }
}

@keyframes aj-weapon-thrust {
    0% {
        opacity: 0;
        transform: rotate(var(--fx-rot, -20deg)) scale(0.55) translate(0, 0);
        filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.3));
    }
    15% {
        opacity: 1;
        transform: rotate(var(--fx-rot, -20deg)) scale(1.05) translate(0, 0);
        filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.8));
    }
    48% {
        opacity: 1;
        transform: rotate(calc(var(--fx-rot, -20deg) + 12deg)) scale(1.35)
            translate(var(--fx-dx), var(--fx-dy));
        filter: drop-shadow(0 0 22px rgba(239, 68, 68, 0.9))
            drop-shadow(0 0 10px #fff);
    }
    75% {
        opacity: 0.85;
        transform: rotate(calc(var(--fx-rot, -20deg) - 6deg)) scale(1.15)
            translate(var(--fx-dx), var(--fx-dy));
    }
    100% {
        opacity: 0;
        transform: rotate(var(--fx-rot, -20deg)) scale(0.9)
            translate(var(--fx-dx), var(--fx-dy));
    }
}

@keyframes aj-weapon-bash {
    0% {
        opacity: 0;
        transform: rotate(-12deg) scale(0.7) translate(0, 0);
    }
    22% {
        opacity: 1;
        transform: rotate(-28deg) scale(1.1) translate(0, 0);
        filter: drop-shadow(0 0 18px rgba(14, 165, 233, 0.75));
    }
    52% {
        opacity: 1;
        transform: rotate(18deg) scale(1.4) translate(var(--fx-dx), var(--fx-dy));
        filter: drop-shadow(0 0 24px rgba(251, 191, 36, 0.95));
    }
    100% {
        opacity: 0;
        transform: rotate(0deg) scale(1) translate(var(--fx-dx), var(--fx-dy));
    }
}

@keyframes aj-slash {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--fx-rot, 35deg)) scaleX(0.15) scaleY(0.6);
    }
    35% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--fx-rot, 35deg)) scaleX(1.35) scaleY(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--fx-rot, 35deg)) scaleX(1.6) scaleY(0.35);
    }
}

@keyframes aj-particle {
    0% {
        opacity: 1;
        transform: rotate(var(--a)) translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: rotate(var(--a)) translateY(calc(-1 * var(--dist, 64px))) scale(0.2);
    }
}

@keyframes aj-spark {
    0% {
        opacity: 1;
        transform: rotate(var(--a)) translateY(0) scaleY(1);
    }
    100% {
        opacity: 0;
        transform: rotate(var(--a)) translateY(calc(-1 * var(--dist, 72px))) scaleY(0.2);
    }
}

@keyframes aj-flash {
    0% {
        opacity: 1;
        transform: scale(0.35);
    }
    40% {
        opacity: 1;
        transform: scale(1.15);
    }
    100% {
        opacity: 0;
        transform: scale(1.8);
    }
}

@keyframes aj-ring {
    0% {
        opacity: 1;
        transform: scale(0.4);
    }
    100% {
        opacity: 0;
        transform: scale(4.2);
    }
}

@keyframes aj-shock {
    0% {
        opacity: 1;
        transform: scale(0.5);
    }
    100% {
        opacity: 0;
        transform: scale(5.5);
    }
}

@keyframes aj-land-ring {
    0% {
        opacity: 1;
        transform: scale(0.35);
    }
    100% {
        opacity: 0;
        transform: scale(2.4);
    }
}

@keyframes aj-sq-impact {
    0% {
        opacity: 1;
        transform: scale(0.6);
    }
    100% {
        opacity: 0;
        transform: scale(1.25);
    }
}

@media (max-width: 640px) {
    .aj-coords--files,
    .aj-board-stack {
        width: min(92vw, 520px);
    }

    .aj-coords--ranks {
        height: min(92vw, 520px);
    }
}

/* —— Lobby / modos —— */
.aj-lobby {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: min(70vh, 560px);
    padding: 1rem 0 2rem;
}

.aj-lobby.oculto {
    display: none !important;
}

.aj-lobby__card {
    width: min(520px, 100%);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(30, 58, 95, 0.12);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(15, 39, 68, 0.14);
    padding: 1.6rem 1.4rem 1.5rem;
    text-align: center;
}

.aj-lobby__title {
    margin: 0 0 0.45rem;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    color: var(--aj-navy);
}

.aj-lobby__text {
    margin: 0 0 1.25rem;
    color: rgba(15, 39, 68, 0.72);
    line-height: 1.45;
}

.aj-lobby__actions {
    display: grid;
    gap: 0.75rem;
}

.aj-lobby__btn {
    width: 100%;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 1.1rem;
    border-radius: 16px;
    text-align: center;
    line-height: 1.25;
}

.aj-lobby__hint {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.78;
}

.aj-lobby__subtitle {
    margin: 0 0 0.85rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--aj-navy);
}

.aj-lobby-online {
    text-align: left;
}

.aj-field {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    color: var(--aj-navy);
}

.aj-field input {
    width: 100%;
    border: 1px solid rgba(30, 58, 95, 0.22);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-weight: 600;
    background: #fff;
    color: var(--aj-ink);
}

.aj-lobby-online__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.aj-lobby-online__divider {
    text-align: center;
    margin: 0.35rem 0 0.85rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(30, 58, 95, 0.55);
}

.aj-lobby-online__msg {
    min-height: 1.3em;
    margin: 0.25rem 0 0;
    color: #b45309;
    font-weight: 700;
    font-size: 0.9rem;
}

.aj-lobby-online__wait {
    margin-top: 0.25rem;
    padding: 1.1rem 0.9rem 1.2rem;
    border-radius: 14px;
    background: rgba(14, 165, 233, 0.1);
    text-align: center;
}

.aj-lobby-online__wait .aj-btn {
    margin-top: 0.75rem;
}

.aj-lobby-online__link-hint {
    margin: 0.55rem 0 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(30, 58, 95, 0.65);
}

/* —— Chat en línea —— */
.aj-chat {
    margin-top: 1rem;
    border-top: 1px solid rgba(30, 58, 95, 0.12);
    padding-top: 0.85rem;
}

.aj-chat__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.aj-chat__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--aj-navy);
}

.aj-chat__toggle {
    padding: 0.25rem 0.55rem;
    min-width: 2rem;
}

.aj-chat--collapsed .aj-chat__list,
.aj-chat--collapsed .aj-chat__compose,
.aj-chat--collapsed .aj-chat-emoji-panel,
.aj-chat--collapsed .aj-chat__status {
    display: none !important;
}

.aj-chat__list {
    max-height: 180px;
    overflow: auto;
    display: grid;
    gap: 0.45rem;
    padding: 0.35rem 0.15rem 0.55rem;
    margin-bottom: 0.4rem;
}

.aj-chat-msg {
    border-radius: 12px;
    padding: 0.45rem 0.6rem;
    background: rgba(30, 58, 95, 0.06);
}

.aj-chat-msg--mine {
    background: rgba(14, 165, 233, 0.14);
}

.aj-chat-msg__head {
    font-size: 0.72rem;
    font-weight: 800;
    color: rgba(30, 58, 95, 0.62);
    margin-bottom: 0.15rem;
}

.aj-chat-msg__body {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--aj-ink);
    word-break: break-word;
    white-space: pre-wrap;
}

.aj-chat-audio-btn {
    border: 0;
    background: rgba(30, 58, 95, 0.1);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: var(--aj-navy);
}

.aj-chat__compose {
    display: grid;
    gap: 0.4rem;
}

.aj-chat__input {
    width: 100%;
    border: 1px solid rgba(30, 58, 95, 0.2);
    border-radius: 12px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-weight: 600;
}

.aj-chat__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.aj-chat-btn {
    border: 1px solid rgba(30, 58, 95, 0.16);
    background: #fff;
    border-radius: 10px;
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.05rem;
    cursor: pointer;
    line-height: 1;
}

.aj-chat-btn--live {
    background: #fee2e2;
    border-color: #ef4444;
    animation: aj-pulse 1s ease-in-out infinite;
}

.aj-chat__send {
    margin-left: auto;
    padding: 0.45rem 0.85rem;
}

.aj-chat__status {
    min-height: 1.2em;
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(30, 58, 95, 0.65);
}

.aj-chat-emoji-panel {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.4rem;
    padding: 0.4rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(30, 58, 95, 0.12);
}

.aj-chat-emoji-item {
    border: 0;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    padding: 0.2rem;
}

.aj-chat-emoji-item:hover {
    background: rgba(14, 165, 233, 0.12);
}

@keyframes aj-pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
}

.aj-lobby-online__code {
    margin: 0.45rem 0;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.18em;
    color: var(--aj-navy);
}

.aj-rivales {
    margin: 0 0 0.45rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: rgba(15, 39, 68, 0.78);
    line-height: 1.35;
}

.aj-install-back {
    margin-top: 1rem;
}

.aj-modo {
    margin: 0 0 0.2rem;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: rgba(30, 58, 95, 0.62);
}

/* —— Pantalla completa (solo tablero) —— */
.aj-stage {
    position: relative;
    width: 100%;
}

.aj-fs-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: min(920px, 100%);
    margin: 0 auto 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: rgba(15, 39, 68, 0.72);
    color: #f8fafc;
}

.aj-fs-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.aj-fs-status {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

/* —— Llamada en vivo (WebRTC) —— */
.aj-call-panel {
    margin: 0 0 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.1));
    border: 1px solid rgba(14, 165, 233, 0.22);
}

.aj-call-panel__title {
    margin: 0 0 0.2rem;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--aj-navy);
}

.aj-call-panel__status {
    margin: 0 0 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(30, 58, 95, 0.7);
    min-height: 1.2em;
}

.aj-call-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.aj-call-btn--live {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.45);
}

.aj-call-btn--busy {
    opacity: 0.85;
}

.aj-call-audio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.aj-call-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: min(920px, 100%);
    margin: 0 auto 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 14px;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: #ecfdf5;
    backdrop-filter: blur(6px);
}

.aj-call-hud__dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 10px #34d399;
    animation: aj-call-pulse 1.2s ease-in-out infinite;
}

.aj-call-hud__label {
    flex: 1;
    font-weight: 800;
    font-size: 0.92rem;
}

.aj-call-incoming {
    width: min(920px, 100%);
    margin: 0 auto 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.55);
    color: #fffbeb;
    text-align: center;
}

.aj-call-incoming__text {
    margin: 0 0 0.65rem;
    font-weight: 800;
}

.aj-call-incoming__actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.aj-stage:fullscreen .aj-call-hud,
.aj-stage:-webkit-full-screen .aj-call-hud,
.aj-stage:fullscreen .aj-call-incoming,
.aj-stage:-webkit-full-screen .aj-call-incoming {
    display: flex;
}

.aj-stage:fullscreen .aj-call-incoming.oculto,
.aj-stage:-webkit-full-screen .aj-call-incoming.oculto,
.aj-stage:fullscreen .aj-call-hud.oculto,
.aj-stage:-webkit-full-screen .aj-call-hud.oculto {
    display: none !important;
}

@keyframes aj-call-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.25);
        opacity: 0.65;
    }
}

.aj-stage:fullscreen,
.aj-stage:-webkit-full-screen {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 1rem;
    background:
        radial-gradient(ellipse 70% 50% at 50% 20%, rgba(14, 165, 233, 0.18), transparent 55%),
        #0f2744;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.aj-stage:fullscreen .aj-fs-bar,
.aj-stage:-webkit-full-screen .aj-fs-bar {
    display: flex;
}

.aj-stage:fullscreen .aj-tablero-wrap,
.aj-stage:-webkit-full-screen .aj-tablero-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.aj-stage:fullscreen .aj-coords--files,
.aj-stage:fullscreen .aj-board-stack,
.aj-stage:-webkit-full-screen .aj-coords--files,
.aj-stage:-webkit-full-screen .aj-board-stack {
    width: min(86vh, 86vw, 820px);
}

.aj-stage:fullscreen .aj-coords--ranks,
.aj-stage:-webkit-full-screen .aj-coords--ranks {
    height: min(86vh, 86vw, 820px);
}

.aj-stage--3d:fullscreen .aj-canvas-wrap,
.aj-stage--3d:-webkit-full-screen .aj-canvas-wrap {
    width: min(96vw, 1400px);
    height: min(88vh, 900px);
    min-height: min(88vh, 900px);
    flex: 1;
}

.aj-stage--3d:fullscreen,
.aj-stage--3d:-webkit-full-screen {
    gap: 0.5rem;
}

body.aj-cinematic .aj-canvas-wrap {
    box-shadow:
        0 0 0 4px rgba(251, 191, 36, 0.35),
        0 18px 40px rgba(15, 39, 68, 0.35);
}

/* —— Modo 3D —— */
.aj-home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 1rem;
}

.aj-juego--3d {
    align-items: stretch;
}

.aj-hint-3d {
    margin: 0 0 1rem;
    font-size: 0.84rem;
    line-height: 1.4;
    color: rgba(15, 39, 68, 0.62);
}

.aj-canvas-wrap {
    position: relative;
    width: 100%;
    min-height: min(72vh, 640px);
    height: min(72vh, 640px);
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 0 0 4px rgba(30, 58, 95, 0.18),
        0 18px 40px rgba(15, 39, 68, 0.2);
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.55), transparent 45%),
        linear-gradient(160deg, #c5dbe8, #e8f4ef 55%, #d7e8f0);
}

.aj-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

@media (max-width: 899px) {
    .aj-canvas-wrap {
        min-height: min(70vw, 520px);
        height: min(78vw, 560px);
    }
}
