/* ==== VARIABLES GLOBALES ==== */
:root {
    --bg-page: #0f172a; /* Fondo oscuro base para evitar parpadeos blancos */
    --bg-sidebar: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-color: #06b6d4; /* Turquesa tecnológico */
    --accent-hover: #0891b2;
    --danger-color: #ec4899; /* Rosa innovador */
    --danger-hover: #db2777;
    --border-color: #e2e8f0;
    --card-shadow: 0 10px 25px -5px rgba(6, 182, 212, 0.1), 0 8px 10px -6px rgba(6, 182, 212, 0.05); /* Sombra turquesa sutil */
    --card-shadow-hover: 0 20px 25px -5px rgba(6, 182, 212, 0.2), 0 10px 10px -5px rgba(6, 182, 212, 0.08); /* Glow turquesa */
    --star-color: #ec4899; /* Estrellas rosas */
    --font-main: 'Outfit', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==== PERSONALIZACIÓN DE SCROLLBAR (Premium Dark) ==== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(193, 155, 103, 0.3); /* Oro Viejo sutil */
    border-radius: 10px;
    border: 2px solid rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb:hover {
    background: #c19b67; /* Oro Viejo sólido */
}

/* Indicador de Sincronización (Badge Premium) */
.sync-status-badge {
    position: absolute;
    top: 20px;
    right: 30px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    font-size: 0.70rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    transition: var(--transition);
    z-index: 100;
    opacity: 0.6;
}

.sync-status-badge:hover {
    opacity: 1;
    color: rgba(255, 255, 255, 0.8);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.sync-status-badge.online {
    color: rgba(16, 185, 129, 0.7);
}
.sync-status-badge.online .sync-dot {
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.sync-status-badge.offline {
    color: rgba(239, 68, 68, 0.7);
}
.sync-status-badge.offline .sync-dot {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

.sync-status-badge.syncing {
    color: rgba(59, 130, 246, 0.7);
}
.sync-status-badge.syncing .sync-dot {
    background-color: #3b82f6;
    box-shadow: 0 0 8px #3b82f6;
    animation: dotPulse 0.8s infinite alternate;
}

@keyframes badgePulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

@keyframes dotPulse {
    from { transform: scale(0.8); opacity: 0.5; }
    to { transform: scale(1.2); opacity: 1; }
}

/* ==== RESET Y BASE ==== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

/* ==== LAYOUT PRINCIPAL ==== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==== SIDEBAR (El Sagrario / Altar de Creación) ==== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 400px;
    background: rgba(15, 23, 42, 0.95); /* Azul Pizarra Profundo Premium */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 2px solid rgba(193, 155, 103, 0.3); /* Borde Oro Viejo sutil */
    display: flex;
    flex-direction: column;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: #e2e8f0;
}

.sidebar.open {
    transform: translateX(0);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-sidebar {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #94a3b8;
    cursor: pointer;
    transition: var(--transition);
}

.close-sidebar:hover {
    background: rgba(236, 72, 153, 0.2);
    color: #f472b6;
    border-color: #f472b6;
    transform: rotate(90deg);
}

.app-header {
    padding: 30px 24px;
    border-bottom: 2px solid rgba(193, 155, 103, 0.2);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.02), transparent);
}

.app-header h1 {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fde68a, #d97706); /* Gradiente Oro */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.app-header h1 span {
    color: #ec4899;
    background: linear-gradient(135deg, #f472b6, #db2777); /* Gradiente Magenta */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Great Vibes', cursive;
    text-transform: none;
    font-size: 2.2rem;
    margin-left: 8px;
}

.app-header p {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 8px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Vacío Místico */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: rgba(15, 23, 42, 0.5);
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    border: 2px dashed rgba(193, 155, 103, 0.3);
    margin: 40px auto;
    max-width: 600px;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 25px;
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.4));
    animation: floatingIcon 4s ease-in-out infinite;
}

@keyframes floatingIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.empty-state h3 {
    font-family: 'Marcellus', serif;
    font-size: 1.8rem;
    color: #0f172a;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.empty-state p {
    font-size: 1.1rem;
    color: #475569;
    font-style: italic;
}

.character-form {
    padding: 24px;
    flex-grow: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-family: 'Marcellus', serif;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #c19b67; /* Oro Viejo */
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    background: rgba(30, 41, 59, 0.4); /* Slate profundo semi-transparente */
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-sm);
    color: #f8fafc;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #ec4899;
    background: rgba(30, 41, 59, 0.6);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.2);
}

.form-group small {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Local Image Configurator */
.local-image-selector {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px dashed rgba(193, 155, 103, 0.3);
    transition: var(--transition);
}

.local-image-selector:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ec4899;
}

.local-image-selector small {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-bottom: 10px;
    display: block;
}

.local-image-selector input[type="file"] {
    font-size: 0.82rem;
    color: #cbd5e1;
    width: 100%;
    cursor: pointer;
}

/* Rating Stars */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.star-rating input {
    display: none;
}

.star-rating label {
    font-size: 1.6rem;
    color: rgba(148, 163, 184, 0.3);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 0;
}

.star-rating label:not(.zero-star):hover,
.star-rating label:not(.zero-star):hover ~ label:not(.zero-star),
.star-rating input:checked ~ label:not(.zero-star) {
    color: #fbbf24; /* Oro Radiante para estrellas */
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
    transform: scale(1.2);
}

.star-rating .zero-star {
    font-size: 1.3rem;
    margin-right: 12px;
    display: flex;
    align-items: center;
    color: rgba(239, 68, 68, 0.3);
}

.star-rating input:checked + .zero-star {
    color: #ef4444;
}

.star-rating .zero-star:hover {
    color: #ef4444;
    transform: scale(1.1);
}

/* Checkboxes (Tags) */
.tags-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox input {
    display: none;
}

.tag-checkbox span {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(30, 41, 59, 0.3); backdrop-filter: blur(5px);
    border: 1px solid rgba(193, 155, 103, 0.2);
    border-radius: 20px;
    font-size: 0.85rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition);
}

.tag-checkbox input:checked + span {
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: white;
    border-color: #ec4899;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
    transform: translateY(-2px);
}

/* Botones */
.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #db2777, #9d174d); /* Magenta Profundo */
    color: white;
    border: 1px solid rgba(251, 191, 36, 0.3); /* Borde Oro */
    border-radius: var(--radius-sm);
    font-family: 'Syne', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ec4899, #db2777);
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(236, 72, 153, 0.3);
    border-color: #fbbf24;
}

.btn-secondary {
    padding: 14px;
    background-color: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
}

.btn-danger {
    width: 100%;
    padding: 12px;
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

/* ==== ÁREA PRINCIPAL (TABLERO) ==== */
/* ==== ÁREA PRINCIPAL (TABLERO DE FANTASÍA MÍSTICA) ==== */
.main-content {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Se desactivará durante el zoom via CSS */
    position: relative;
    /* Fondo Santuario Celestial (Más claro para resaltar personajes) */
    background-color: #f1f3f9;
    background-image: 
        linear-gradient(rgba(240, 244, 250, 0.8), rgba(255, 255, 255, 0.7)), 
        url('https://images.unsplash.com/photo-1519750783826-e2420f4d687f?q=80&w=2000&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    perspective: 1200px;
}

/* Efecto de Polvo Rúnico y Pétalos Mágicos en tonos claros */
.main-content::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background-image: 
        radial-gradient(circle, rgba(251, 191, 36, 0.3) 1px, transparent 1px),
        radial-gradient(circle, rgba(236, 72, 153, 0.2) 2px, transparent 2px);
    background-size: 150px 150px, 200px 200px;
    animation: magicalFloat 45s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes magicalFloat {
    0% { transform: translateY(0) scale(1) rotate(0deg); }
    50% { transform: translateY(-50px) scale(1.05) rotate(5deg); }
    100% { transform: translateY(-100px) scale(1) rotate(10deg); }
}

/* Degradado suave para profundidad celestial */
.main-content::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, transparent 30%, rgba(240, 244, 250, 0.45) 100%);
    pointer-events: none;
    z-index: 1;
}

.board-title-area, .board, .fab-add {
    position: relative;
    z-index: 2;
}

.board-title-area {
    width: 100%;
    padding: 10px 40px;
    text-align: center;
    position: relative;
    margin: 0 0 30px 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 2px solid #fbbf24;
    border-bottom: 2px solid #fbbf24;
    border-left: none;
    border-right: none;
    border-radius: 0;
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.5),
        inset 0 0 20px rgba(251, 191, 36, 0.05);
    z-index: 10;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 80px;
    min-height: 220px; /* Suficiente espacio para que no se recorten las siluetas */
}

.title-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.muse-icon {
    height: 200px; /* Tamaño real para que luzcan imponentes */
    width: auto;
    mix-blend-mode: screen;
    filter: brightness(1.1) contrast(1.1) drop-shadow(0 0 15px rgba(255, 255, 255, 0.2));
    opacity: 0.95;
    pointer-events: none;
    flex-shrink: 0;
    /* Aseguramos que el fondo sea tratado como negro puro para el blend mode */
    background-color: transparent;
}

.muse-icon.right {
    transform: scaleX(-1);
}

/* Brillo del banner */
.board-title-area::after {
    content: '';
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
}

.main-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: 8px;
    text-transform: uppercase;
    font-family: 'Cinzel Decorative', cursive;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    /* Gradiente Oro TCG Pulido */
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 50%, #b45309 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    position: relative;
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-8px) scale(1.02); }
}

/* Adornos modernos */
.main-title::before, .main-title::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #fbbf24, transparent);
    top: 30%;
    transform: translateY(-50%);
}

.main-title::before { left: -80px; }
.main-title::after { right: -80px; }

.main-title span {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 12px;
    /* Gradiente Magenta Terciopelo */
    background: linear-gradient(to right, #db2777 0%, #701a75 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.8rem;
    margin-top: 0;
    filter: drop-shadow(0 3px 10px rgba(219, 39, 119, 0.2));
    position: relative;
    padding: 0;
    line-height: 1.1;
}

/* Brillo mágico que recorre el texto */
.main-title span::after {
    content: '';
    position: absolute;
    top: 10%; left: -150%; width: 40%; height: 80%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transform: rotate(35deg);
    animation: luxuryShimmer 5s infinite;
    filter: blur(5px);
}

@keyframes luxuryShimmer {
    0% { left: -150%; opacity: 0; }
    20% { opacity: 1; }
    40% { left: 150%; opacity: 0; }
    100% { left: 150%; opacity: 0; }
}

.subtitle {
    font-family: 'Syne', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 5px;
    margin-top: 8px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 30px;
    
    /* Fondo Cósmico Épico */
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 30%, #4c1d95 70%, #831843 100%);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    /* Borde Metálico Dual (Aqua/Celestial) */
    border: 1px solid rgba(165, 243, 252, 0.6);
    outline: 1px solid rgba(34, 211, 238, 0.2);
    outline-offset: 3px;
    border-radius: 4px;
    
    /* Texto en Aqua/Cian Eléctrico */
    background-image: linear-gradient(180deg, #ccfbf1, #2dd4bf, #0d9488);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    
    /* Sombra y Aura de Poder */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    animation: subtitleAura 4s infinite alternate ease-in-out;
}

@keyframes subtitleAura {
    0% { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 5px rgba(34, 211, 238, 0.2); }
    100% { box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 25px rgba(124, 58, 237, 0.5); }
}

/* Ornamentos Laterales */
.subtitle::before, .subtitle::after {
    content: '✦';
    position: absolute;
    color: #22d3ee;
    font-size: 1.4rem;
    opacity: 0.8;
}

.subtitle::before { left: 15px; }
.subtitle::after { right: 15px; }

.board {
    flex-grow: 1;
    padding: 70px 100px 250px 100px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    justify-content: center;
    align-items: flex-start;
    align-content: flex-start;
    transform: rotateX(5deg);
    transform-origin: top;
    transition: none;
    position: relative;
    min-height: 80vh;
    
    /* Playmat Integrado (OPACO para evitar desaparición por blending) */
    background: 
        radial-gradient(circle at center, rgba(255, 255, 255, 0.5) 0%, rgba(230, 210, 255, 0.4) 40%, rgba(180, 150, 220, 0.3) 100%),
        url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M60 0 C 70 30, 90 30, 120 60 C 90 90, 70 90, 60 120 C 50 90, 30 90, 0 60 C 30 30, 50 30, 60 0' fill='none' stroke='%238b5cf6' stroke-width='0.5' opacity='0.3'/%3E%3C/svg%3E"),
        url('https://www.transparenttextures.com/patterns/paper-fibers.png');
    background-color: #faf5ff; /* Opaco total para que no se pierda al quitar transform */
    background-blend-mode: multiply;
    border-radius: 40px;
    margin: 20px;
    box-shadow: 
        inset 0 0 100px rgba(139, 92, 246, 0.2),
        0 10px 40px rgba(0,0,0,0.1);
    border: 3px double rgba(139, 92, 246, 0.3);
}

/* El Playmat ahora es parte del fondo de .board para mayor estabilidad */


/* Estilo Vacío: Altar de Invocación */
.empty-state {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #f472b6;
    text-align: center;
    transform: rotateX(-5deg);
}

.empty-icon {
    font-size: 5.5rem;
    margin-bottom: 24px;
    color: #fbbf24;
    text-shadow: 0 0 40px rgba(251, 191, 36, 0.6);
    animation: mysticalPulse 3s infinite ease-in-out;
}

@keyframes mysticalPulse {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.8; }
    50% { transform: scale(1.1) rotate(5deg); opacity: 1; filter: drop-shadow(0 0 20px #fbbf24); }
}

.empty-state h3 {
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 12px;
    color: #fce7f3;
    text-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.empty-state p {
    font-size: 1.1rem;
    color: #f9a8d4;
    max-width: 400px;
    line-height: 1.4;
}

/* ==== BOTON FLOTANTE ==== */
.fab-add {
    position: fixed !important;
    bottom: 40px !important;
    right: 40px !important;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 20000 !important;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.fab-add:hover {
    background-color: var(--danger-color); /* Pasa a rosa vibrante al hover! Tecnológico y llamativo */
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--card-shadow-hover);
}

/* ==== TARJETAS DE PERSONAJE (FLIP CARDS) ==== */
/* ==== ZOOM GALERÍA (MODAL TCG) ==== */
.zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8); /* Oscurecimiento premium */
    backdrop-filter: blur(8px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.zoom-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal de Imagen Sola */
.full-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: simpleFadeIn 0.3s ease;
}

.full-image-modal.active {
    display: flex;
}

.full-image-modal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 60px rgba(0,0,0,1);
    border: 1px solid rgba(255,255,255,0.2);
}

@keyframes simpleFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

body.zoom-active .main-content {
    perspective: none !important;
    overflow: visible !important;
    z-index: auto !important;
}

body.zoom-active .board {
    transform: none !important;
    transition: none !important;
    overflow: visible !important;
    z-index: auto !important;
}

body.zoom-active .board-title-area {
    z-index: 0 !important; /* Forzar por debajo del overlay y la carta */
    pointer-events: none; /* No estorbar clics al overlay */
}

/* Forzar que el overlay sea visible y capture clics sobre el tablero */
.zoom-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 10000;
}

.character-card.is-zoomed {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    width: 416px !important;
    height: 608px !important;
    transform: translate(-50%, -50%) !important;
    z-index: 20000 !important; /* Súper prioridad sobre todo */
    margin: 0 !important;
    box-shadow: 0 0 100px rgba(0,0,0,1), 0 0 40px rgba(231, 166, 26, 0.4);
    cursor: zoom-out;
    pointer-events: auto !important;
}

/* El hueco que deja la carta en el tablero */
.card-placeholder {
    width: 260px;
    height: 380px;
    background: rgba(0,0,0,0.2);
    border: 2px dashed rgba(251, 191, 36, 0.1);
    border-radius: 12px;
    flex-shrink: 0;
}

/* Evitar inclinación (tilt) durante el zoom, pero PERMITIR el volteo (flip) */
.character-card.is-zoomed .card-inner {
    transform: rotateY(0deg); /* Base sin tilt */
}

.character-card.is-zoomed.is-flipped .card-inner {
    transform: rotateY(180deg) !important; /* Forzar el volteo en zoom */
}

/* Transiciones suaves para el "vuelo" y dimensiones base */
.character-card {
    width: 260px;
    height: 380px;
    perspective: 1500px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    will-change: transform, top, left, width, height;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.4s ease, 
                top 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
                left 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
                width 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* El rastro fantasma que dejas atrás en el mazo */
.character-card.dragging {
    opacity: 0.15;
    transform: scale(0.95);
}

/* La tarjeta debajo se hace pequeña y esquiva como una baraja real */
.character-card.drag-over-visual .card-inner {
    transform: scale(0.92) rotate(4deg) translateY(15px);
    box-shadow: none;
    opacity: 0.6;
}
.character-card.is-flipped.drag-over-visual .card-inner {
    transform: rotateY(180deg) scale(0.92) rotate(4deg) translateY(15px);
    opacity: 0.6;
}

/* Contenedor interior que hace el flip y las poses (CSS driven) */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    /* Efecto "muelle" elastico para el movimiento balatro/solitario */
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    transform-style: preserve-3d;
    border-radius: var(--radius-xl);
    box-shadow: var(--card-shadow);
}

.character-card:hover .card-inner {
    box-shadow: var(--card-shadow-hover);
}

/* Al presionar con el ratón se levanta (Pick UP) rotando sutilmente */
.character-card.is-picked-up .card-inner {
    transform: scale(1.08) rotate(-4deg) translateY(-15px);
    box-shadow: 0 40px 50px -10px rgba(0,0,0,0.4);
}
.character-card.is-flipped.is-picked-up .card-inner {
    transform: rotateY(180deg) scale(1.08) rotate(-4deg) translateY(-15px);
    box-shadow: 0 40px 50px -10px rgba(0,0,0,0.4);
}

.character-card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

/* Frontal y Dorso */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.card-front *, .card-back * {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* FRONT: Imagen completa y estilos TCG Gamificados */
.card-front {
    background-color: #1a202c; /* Fondo base oscuro tipo roca */
    transform: rotateY(0deg) translateZ(1px); /* Prevent bleeding on Safari/Chrome */
}

.char-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
}

/* Oscurecimiento sutil para destacar estelaridad y nombre encima de imágenes muy brillantes */
.tcg-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, transparent 25%, transparent 75%, rgba(0,0,0,0.4) 100%);
    z-index: 2;
}

/* ==== TCG: Nombre en Franja TCG (Ancho completo) ==== */
.tcg-title-banner {
    position: absolute;
    bottom: 35px;
    left: 10px;
    right: 10px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-align: center;
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    z-index: 5;
    /* Permitir que los ornamentos sobresalgan */
    overflow: visible;
    container-type: inline-size;
}

/* El ornamento flotante central superior */
.tcg-title-banner::after {
    content: var(--ornament-top, '✧');
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--badge-border);
    font-size: 1.2rem;
    text-shadow: 0 0 10px var(--badge-glow);
    z-index: 6;
}

/* Alas / Filigranas Grandes Laterales del Banner */
.tcg-title-banner::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140%; /* Más ancho que el banner para las alas */
    height: 120px;
    background-image: var(--ornament-svg-l);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: translate(-50%, -50%);
    filter: var(--ornament-filter);
    opacity: 0.7;
    pointer-events: none;
    z-index: -1;
}

.card-name {
    font-size: clamp(0.8rem, 14cqw, 1.6rem);
    font-weight: 800;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.1;
    margin-bottom: 2px;
    white-space: nowrap;
    position: relative;
    display: flex;
    align-items: center;
    gap: clamp(4px, 2cqw, 10px);
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 5px;
    
    /* Gradiente Magenta Terciopelo (Identidad del Códice) */
    background: linear-gradient(to right, #db2777 0%, #701a75 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* Micro-filigranas pegadas al nombre */
.card-name::before,
.card-name::after {
    content: var(--filigree-icon, '⚜');
    flex-shrink: 0; /* Evitar que el icono se aplaste */
    color: var(--badge-border, #fff);
    font-size: clamp(0.6rem, 3vw, 1rem); 
    opacity: 0.9;
    text-shadow: 0 0 10px var(--badge-glow);
    -webkit-text-fill-color: initial;
    animation: ornamentPulse 4s infinite ease-in-out;
}

@keyframes ornamentPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.card-name::before { transform: scaleX(-1); }

.banner-title {
    font-size: 0.7rem;
    color: #cbd5e1;
    font-weight: 700;
    font-family: var(--font-main);
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.9;
}

/* ==== TCG: Insignia Inferior Derecha (Estrellas integradas en esquina) ==== */
.tcg-badge-rating {
    position: absolute;
    bottom: -1px;
    right: -1px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
    color: var(--badge-border, var(--star-color));
    padding: 6px 12px 4px 14px;
    border-radius: 16px 0 0 0;
    font-size: 1rem;
    font-weight: 900;
    z-index: 5;
    border: 3px solid var(--badge-border, var(--star-color));
    border-right: none;
    border-bottom: none;
    box-shadow: -4px -4px 12px rgba(0,0,0,0.5);
    letter-spacing: 1px;
}

/* =======================================
   SISTEMA DE RAREZA TCG (BORDES METÁLICOS)
   ======================================= */
/* Aseguramos que el borde se dibuje hacia adentro sin romper el layout */
.character-card, .card-inner, .card-front, .card-back {
    box-sizing: border-box;
}

/* Rareza Oro (5 Estrellas) */
.character-card.rarity-gold {
    --badge-bg-start: #f59e0b; --badge-bg-mid: #b45309; --badge-bg-end: #451a03;
    --badge-border: #fbbf24; --badge-glow: rgba(251, 191, 36, 0.8);
    --badge-icon: '✦';
    --filigree-icon: '⚜';
    --ornament-top: '👑';
    --ornament-filter: drop-shadow(0 0 10px #fbbf24);
    --ornament-svg-l: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M200 70 C 120 70, 80 0, 0 30 C 30 60, 100 100, 200 70' fill='rgba(251,191,36,0.1)' stroke='%23fbbf24' stroke-width='2'/%3E%3Cpath d='M200 70 C 280 70, 320 0, 400 30 C 370 60, 300 100, 200 70' fill='rgba(251,191,36,0.1)' stroke='%23fbbf24' stroke-width='2'/%3E%3C/svg%3E");
    --lore-icon: '🔱'; /* Sello Real del Relato */
}
.character-card.rarity-gold .card-front,
.character-card.rarity-gold .card-back {
    border: 3px double #fbbf24; /* Borde doble como el titulo */
    outline: 2px solid rgba(251, 191, 36, 0.4);
    outline-offset: -8px;
    box-shadow: 
        0 0 30px rgba(251, 191, 36, 0.4), 
        inset 0 0 20px rgba(251, 191, 36, 0.2);
}
.character-card.rarity-gold .tcg-overlay { box-shadow: inset 0 0 50px rgba(251, 191, 36, 0.4); pointer-events: none; }
.character-card.rarity-gold .tcg-badge-rating { border-color: #fbbf24; color: #fbbf24; }
.character-card.rarity-gold .card-name { 
    background: linear-gradient(to bottom, #fef3c7 0%, #fbbf24 50%, #b45309 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.9));
}
.character-card.rarity-gold .tcg-title-banner { border-color: #fbbf24; }

/* Rareza Plata (4 Estrellas) */
/* Rareza Plata (4 Estrellas) - Plata Cromada Metálica */
.character-card.rarity-silver {
    --badge-bg-start: #cbd5e1; --badge-bg-mid: #64748b; --badge-bg-end: #1e293b;
    --badge-border: #f8fafc; --badge-glow: rgba(248, 250, 252, 0.6);
    --badge-icon: '✧';
    --filigree-icon: '✥';
    --ornament-top: '🌙';
    --ornament-filter: drop-shadow(0 0 10px #60a5fa);
    --ornament-svg-l: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M200 50 L 100 10 L 0 50 L 100 90 L 200 50' fill='none' stroke='%23f8fafc' stroke-width='1' opacity='0.7'/%3E%3Cpath d='M200 50 L 300 10 L 400 50 L 300 90 L 200 50' fill='none' stroke='%23f8fafc' stroke-width='1' opacity='0.7'/%3E%3Ccircle cx='200' cy='50' r='3' fill='%23f8fafc'/%3E%3C/svg%3E");
    --lore-icon: '📜'; /* Pergamino de Historia */
}
.character-card.rarity-silver .card-front,
.character-card.rarity-silver .card-back {
    border: 3px double #f8fafc;
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: -8px;
    box-shadow: 
        0 0 25px rgba(248, 250, 252, 0.6), 
        inset 0 0 20px rgba(255, 255, 255, 0.4);
}
.character-card.rarity-silver .tcg-overlay { 
    box-shadow: inset 0 0 50px rgba(148, 163, 184, 0.4); 
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 40%, transparent 60%, rgba(255,255,255,0.1) 100%);
    pointer-events: none; 
}
.character-card.rarity-silver .tcg-badge-rating { border-color: #cbd5e1; color: #f8fafc; background: #334155; }
.character-card.rarity-silver .card-name { 
    background: linear-gradient(to bottom, #f0fdfa 0%, #2dd4bf 50%, #0d9488 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 950;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}
.character-card.rarity-silver .tcg-title-banner { border-color: #94a3b8; background: rgba(30, 41, 59, 0.9); }

/* Rareza Bronce (3 Estrellas) */
.character-card.rarity-bronze {
    --badge-bg-start: #ea580c; --badge-bg-mid: #9a3412; --badge-bg-end: #431407;
    --badge-border: #fdba74; --badge-glow: rgba(234, 88, 12, 0.6);
    --badge-icon: '❖';
    --filigree-icon: '❧';
    --ornament-top: '🌿';
    --ornament-filter: drop-shadow(0 0 10px #fdba74);
    --ornament-svg-l: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M200 50 C 150 100, 50 100, 0 50 C 50 0, 150 0, 200 50' fill='none' stroke='%23fdba74' stroke-width='1.5'/%3E%3Cpath d='M200 50 C 250 100, 350 100, 400 50 C 350 0, 250 0, 200 50' fill='none' stroke='%23fdba74' stroke-width='1.5'/%3E%3C/svg%3E");
    --lore-icon: '✒️'; /* Pluma de Crónica */
}
.character-card.rarity-bronze .card-front,
.character-card.rarity-bronze .card-back {
    border: 3px double #ed8936;
    outline: 1px solid rgba(237, 137, 54, 0.2);
    outline-offset: -8px;
    box-shadow: 0 0 15px rgba(237, 137, 54, 0.5);
}
.character-card.rarity-bronze .tcg-overlay { box-shadow: inset 0 0 40px rgba(237, 137, 54, 0.4); pointer-events: none; }
.character-card.rarity-bronze .tcg-badge-rating { border-color: #ed8936; color: #ed8936; }
.character-card.rarity-bronze .card-name { 
    background: linear-gradient(to bottom, #fff7ed 0%, #f97316 50%, #9a3412 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.9));
}
.character-card.rarity-bronze .tcg-title-banner { border-color: #ed8936; }

/* Categoria Sin Usar (0 Estrellas) - Muted Slate */
.character-card.rarity-unused {
    filter: saturate(0.7);
    --badge-bg-start: #475569; --badge-bg-mid: #1e293b; --badge-bg-end: #020617;
    --badge-border: #94a3b8; --badge-glow: rgba(148, 163, 184, 0.2);
    --badge-icon: '⊘';
    --filigree-icon: '❂';
    --ornament-top: '⛓';
    --ornament-svg-l: none;
    --lore-icon: '🔒'; /* Historia bajo Candado */
}
.character-card.rarity-unused .card-front,
.character-card.rarity-unused .card-back {
    border: 3px double #475569; 
    background-color: #0f172a;
    outline: 1px solid rgba(148, 163, 184, 0.1);
    outline-offset: -8px;
}
.character-card.rarity-unused .card-name { 
    background: linear-gradient(to bottom, #faf5ff 0%, #a855f7 50%, #581c87 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9));
}
.character-card.rarity-unused .tcg-badge-rating { border-color: #475569; color: #64748b; }
.character-card.rarity-unused .tcg-title-banner { border-color: #475569; }

/* Badge "SIN USAR" en la esquina superior derecha */
.status-badge-unused {
    position: absolute;
    top: 20px;
    right: -32px;
    background: linear-gradient(135deg, #64748b 0%, #334155 100%);
    color: white;
    font-size: 0.6rem;
    font-weight: 900;
    padding: 3px 0;
    width: 120px;
    text-align: center;
    transform: rotate(45deg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    z-index: 10;
    letter-spacing: 1.5px;
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
}

/* Rareza Arcilla / Tierra (2 Estrellas) - Mate */
.character-card.rarity-clay {
    --badge-bg-start: #78350f; --badge-bg-mid: #451a03; --badge-bg-end: #220e01;
    --badge-border: #d97706; --badge-glow: rgba(217, 119, 6, 0.4);
    --badge-icon: '⟐';
    --filigree-icon: '❦';
    --ornament-top: '🍁';
    --ornament-svg-l: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M100 80 Q 200 20, 300 80' fill='none' stroke='%2378350f' stroke-width='3'/%3E%3C/svg%3E");
    --lore-icon: '🏺'; /* Reliquia de Antigüedad */
}
.character-card.rarity-clay .card-front,
.character-card.rarity-clay .card-back {
    border: 3px double #78350f; /* Marrón tierra / Caoba */
    background-color: #1a0f0a;
    outline: 1px solid rgba(180, 83, 9, 0.2);
    outline-offset: -8px;
}
.character-card.rarity-clay .card-name { 
    background: linear-gradient(to bottom, #f0fdf4 0%, #22c55e 50%, #166534 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.9));
}
.character-card.rarity-clay .tcg-badge-rating { 
    border-color: #78350f !important; 
    color: #d97706 !important; 
}
.character-card.rarity-clay .tcg-title-banner { border-color: #78350f; }

/* Rareza Hierro Oscuro / Acero frío (1 Estrella) - Tonos Azules Metálicos */
.character-card.rarity-iron {
    --badge-bg-start: #2563eb; --badge-bg-mid: #1e3a8a; --badge-bg-end: #0f172a;
    --badge-border: #93c5fd; --badge-glow: rgba(37, 99, 235, 0.6);
    --badge-icon: '◈';
    --filigree-icon: '⚔';
    --ornament-top: '🛡';
    --ornament-svg-l: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 50 L 400 50' fill='none' stroke='%232563eb' stroke-width='5' opacity='0.3'/%3E%3C/svg%3E");
    --lore-icon: '🗝️'; /* Llave de Archivo */
}
.character-card.rarity-iron .card-front,
.character-card.rarity-iron .card-back {
    border: 3px double #2563eb; /* Azul acero intenso */
    background-color: #081229; /* Azul muy oscuro para el fondo base */
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.3);
    outline: 1px solid rgba(37, 99, 235, 0.2);
    outline-offset: -8px;
}
.character-card.rarity-iron .tcg-overlay { box-shadow: inset 0 0 30px rgba(37, 99, 235, 0.2); pointer-events: none; }
.character-card.rarity-iron .tcg-badge-rating { border-color: #2563eb; color: #60a5fa; }
.character-card.rarity-iron .card-name { 
    background: linear-gradient(to bottom, #eff6ff 0%, #3b82f6 50%, #1e40af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.9));
}
.character-card.rarity-iron .tcg-title-banner { border-color: #2563eb; background: rgba(15, 23, 42, 0.95); }

/* Categoría Genérica (Fallback) */
.character-card.rarity-basic {
    --badge-bg-start: #64748b; --badge-bg-mid: #334155; --badge-bg-end: #0f172a;
    --badge-border: #94a3b8; --badge-glow: rgba(148, 163, 184, 0.4);
    --badge-icon: '✦';
    --filigree-icon: '⚜';
    --ornament-top: '✧';
    --ornament-svg-l: none;
    --lore-icon: '📑'; /* Notas de Campo */
}
.character-card.rarity-basic .card-front,
.character-card.rarity-basic .card-back {
    border: 3px double #4b5563; 
    background-color: #111827;
    outline: 1px solid rgba(156, 163, 175, 0.1);
    outline-offset: -8px;
}
.character-card.rarity-basic .card-name { 
    background: linear-gradient(to bottom, #f5f5f5 0%, #737373 50%, #262626 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 2px rgba(255,255,255,0.1), 0 2px 4px rgba(0,0,0,0.8));
}
.character-card.rarity-basic .tcg-title-banner { border-color: #4b5563; }

/* BACK: Trasfondo y Tags */
.card-back {
    background-color: #110c11; /* Oscuro onírico */
    background-image: 
        radial-gradient(circle at top right, rgba(236, 72, 153, 0.15), transparent 50%),
        radial-gradient(circle at center, rgba(15, 23, 42, 0.7), rgba(0, 0, 0, 0.95)),
        url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1" fill="rgba(255,255,255,0.03)"/></svg>');
    background-size: 100% 100%, 100% 100%, 15px 15px;
    background-position: center;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    padding: 24px 24px 70px 24px; /* Aumentamos el padding inferior para proteger la zona de botones */
    border: 1px solid #3f3f46;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
    outline: 1px solid rgba(251, 191, 36, 0.35); /* Borde dorado interior rolero */
    outline-offset: -6px;
}

.card-back-header {
    margin: -24px -24px 20px -24px; /* Pegado al borde superior */
    position: relative;
    display: block;
    z-index: 5;
}

.card-actions {
    position: absolute;
    bottom: 15px; /* De vuelta al pie */
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.action-btn {
    width: 32px; /* Ligeramente más grandes para mejor click habit */
    height: 32px;
    border-radius: 8px; /* Look más moderno tipo app */
    border: 1px solid rgba(251, 191, 36, 0.4);
    background: rgba(15, 23, 42, 0.9);
    color: #fbbf24; /* Color oro para los iconos */
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.action-btn:hover {
    background: #fbbf24;
    color: #0f172a;
    transform: scale(1.15) translateY(-2px);
    border-color: #ffffff;
    box-shadow: 0 6px 15px rgba(251, 191, 36, 0.4);
}

.action-btn.delete-btn:hover {
    background: #ef4444;
    border-color: #f87171;
    color: white;
}


.card-back-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.6), transparent);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back h4 {
    font-size: clamp(0.7rem, 4.5vw, 1.1rem);
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    color: #ffffff;
    margin: 0;
    line-height: 1.2; /* Aumentado para evitar cortes */
    white-space: normal;
    text-wrap: balance;
    text-align: center;
    width: 100%;
    word-break: break-word;

    /* === ESTILO PLACA TCG METÁLICA (DINÁMICO POR RAREZA) === */
    background: linear-gradient(180deg, var(--badge-bg-start, #64748b) 0%, var(--badge-bg-mid, #334155) 35%, var(--badge-bg-end, #0f172a) 100%);
    padding: 22px 10px 15px 10px; /* Restaurado el padding normal, ya no desplaza el nombre */
    border-bottom: 2px solid var(--badge-border, #fbbf24);
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 14px 14px 0 0; /* Sincronizado con la carta (15px) */    
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.5), 
        inset 0 -3px 6px rgba(0,0,0,0.8), 
        0 4px 10px rgba(0,0,0,0.5);
    
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 1px 1px 2px #000;
    position: relative;
}

/* Iconos de ornamento laterales */
.card-back h4::before,
.card-back h4::after {
    content: var(--badge-icon, '✦');
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--badge-border, #fbbf24);
    font-size: 0.8rem;
    text-shadow: 0 0 5px var(--badge-glow, rgba(251, 191, 36, 0.4));
    opacity: 0.9;
}

.card-back h4::before { left: 8px; }
.card-back h4::after { right: 8px; }

.card-back h5 {
    font-size: 0.9rem;
    color: #e2e8f0; /* Blanco roto */
    font-weight: 400;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    margin-top: 2px;
}

.card-lore {
    display: none; /* Oculto por defecto en vista normal */
    font-size: 0.90rem;
    color: #1a1a1a;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    line-height: 1.5;
    flex-grow: 1;
    overflow-y: auto;
    text-align: left;
    background: 
        linear-gradient(rgba(255, 255, 255, 0.75), rgba(245, 245, 245, 0.85)),
        url('https://www.transparenttextures.com/patterns/paper-fibers.png');
    padding: 18px;
    border-radius: 2px;
    border: 1px solid #000;
    margin: 10px 0 15px 0;
    position: relative;
    backdrop-filter: blur(2px);
    /* El ribete dorado interior */
    outline: 1px solid rgba(184, 134, 11, 0.4);
    outline-offset: -5px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.1);
}

.card-lore-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem; /* Más pequeño para no quitar protagonismo */
    margin: 10px 0;
    opacity: 0.6;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.3));
    animation: floatingScroll 3s infinite ease-in-out;
}

.card-lore-placeholder::before {
    content: var(--lore-icon, '📜');
}

@keyframes floatingScroll {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Cuando la tarjeta está MAXIMIZADA (Zoom) */
.character-card.is-zoomed .card-lore {
    display: block;
}

.character-card.is-zoomed .card-lore-placeholder {
    display: none;
}

.character-card.is-zoomed .card-tags {
    flex-grow: 0;
}

/* Adornos de las esquinas (Ribetes) */
.card-lore::before, .card-lore::after {
    content: '✦';
    position: absolute;
    font-size: 0.6rem;
    color: rgba(184, 134, 11, 0.8);
    pointer-events: none;
    z-index: 2;
}

.card-lore::before {
    top: 4px;
    left: 4px;
    text-shadow: 247px 0 rgba(184, 134, 11, 0.8); /* Esto es un truco para duplicar el adorno a la derecha si el ancho fuera fijo, pero mejor usamos after */
}

/* Usamos after para las otras esquinas */
.card-lore::after {
    bottom: 4px;
    right: 4px;
}

/* Añadimos un contenedor extra para las otras dos esquinas si queremos perfección, 
   pero con before/after podemos simularlo con sombras de texto */
.card-lore::before {
    top: 3px;
    left: 4px;
    /* Sombras para posicionar el icono en las 4 esquinas */
    text-shadow: 
        218px 0 rgba(184, 134, 11, 0.8), 
        0 248px rgba(184, 134, 11, 0.8), 
        218px 248px rgba(184, 134, 11, 0.8);
}
/* Al ser flexible el lore, el text-shadow de ancho fijo no funcionará perfecto. 
   Mejor usamos un degradado para el ribete */
   
.card-lore {
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.75), rgba(245, 245, 245, 0.85)),
        radial-gradient(circle at 0 0, rgba(184, 134, 11, 0.4) 2px, transparent 3px),
        radial-gradient(circle at 100% 0, rgba(184, 134, 11, 0.4) 2px, transparent 3px),
        radial-gradient(circle at 0 100%, rgba(184, 134, 11, 0.4) 2px, transparent 3px),
        radial-gradient(circle at 100% 100%, rgba(184, 134, 11, 0.4) 2px, transparent 3px);
}

.card-lore::-webkit-scrollbar {
    width: 4px;
}
.card-lore::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.3);
    border-radius: 4px;
}

.card-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center; /* Centradas horizontalmente */
    align-content: center; /* Centradas verticalmente */
    flex-grow: 1; /* Ocupa todo el centro */
    padding: 10px 0;
    overflow-y: auto;
}

/* Tags tipo TCG Épico */
.tag-bubble {
    position: relative;
    background: linear-gradient(135deg, #374151 0%, #111827 100%);
    color: #e5e7eb;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        inset 0 1px 1px rgba(255,255,255,0.1),
        0 2px 4px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag-bubble::before {
    content: '◈';
    font-size: 0.6rem;
    color: inherit;
    opacity: 0.7;
}

/* Eliminamos la colita de comic */
.tag-bubble::after {
    display: none;
}

/* Botones y Cabecera de Dorso */
.header-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.action-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
    background-color: transparent;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
}

.edit-btn:hover {
    color: rgba(251, 191, 36, 0.9); /* Dorado en hover */
    transform: scale(1.15);
}

.delete-btn:hover {
    color: rgba(239, 68, 68, 0.9); /* Rojo rubí en hover */
    transform: scale(1.15);
}

/* ==== ANIMACIONES DE CARGA Y ENTRADA (SKELETONS & STAGGER) ==== */

@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* La animación de entrada solo se aplica mediante clase temporal en JS */
.character-card.card-entrance {
    animation: cardEntrance 0.8s cubic-bezier(0.23, 1, 0.32, 1) both;
}

/* El estado zoom vuelve a su comportamiento original sin interferencias */
.character-card.is-zoomed {
    animation: none !important;
}

/* Skeleton Loading State */
.skeleton-card {
    width: 260px;
    height: 380px;
    background: rgba(30, 41, 59, 0.3); backdrop-filter: blur(5px);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.skeleton-card::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        transparent 0,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.1) 60%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.skeleton-img {
    height: 70%;
    background: rgba(15, 23, 42, 0.6);
    margin: 10px;
    border-radius: 8px;
}

.skeleton-text {
    height: 15px;
    background: rgba(15, 23, 42, 0.6);
    margin: 10px 20px;
    border-radius: 4px;
    width: 60%;
}

.skeleton-text.short { width: 40%; }

/* Placeholder para imágenes mientras cargan */
.char-img {
    background: radial-gradient(circle at center, rgba(236, 72, 153, 0.1), rgba(15, 23, 42, 0.5));
}
