:root {
    --color-gold: #d4af37;
    --color-gold-dim: #8a7018;
    --color-wood-dark: #2b1d0e;
    --color-parchment: #f4e8d0;
    --color-ink: #0d0a08;
    --color-hp: #c0392b;
    --color-mana: #2980b9;
    --card-width: 180px;
    --card-height: 300px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Lato', sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.08), transparent 25%),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.04), transparent 28%),
        linear-gradient(135deg, #0d0a08 0%, #15100d 60%, #0b0806 100%);
    background-color: #0d0a08;
    color: #e0dacc;
    height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px 24px 14px;
    gap: 12px;
    position: relative;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.08), rgba(0, 0, 0, 0.3)),
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.04), transparent 60%);
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), inset 0 0 40px rgba(0, 0, 0, 0.35);
}

/* HEADER */
.game-header {
    text-align: center;
    padding: 10px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    position: relative;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.05), transparent 60%);
}

h1 {
    font-family: 'Cinzel', serif;
    color: var(--color-gold);
    font-size: 2.2rem;
    letter-spacing: 4px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
    margin-bottom: 5px;
}

.turn-indicator {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--color-parchment);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--color-gold);
    padding: 5px 20px;
    display: inline-block;
    border-radius: 8px;
    box-shadow: inset 0 0 12px rgba(212, 175, 55, 0.3);
}

/* PLAYER AREAS */
.player-area {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 320px;
    position: relative;
    z-index: 200;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
    border-radius: 12px;
    padding: 10px 12px;
}

.cpu-area {
    justify-content: flex-start;
}

.player-area-bottom {
    justify-content: flex-start;
}

/* STATS PANEL */
.stats-panel {
    min-width: 280px;
    background: linear-gradient(160deg, rgba(44, 30, 16, 0.95), rgba(24, 16, 9, 0.95));
    padding: 16px;
    border: 2px solid rgba(212, 175, 55, 0.35);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55), inset 0 0 18px rgba(0, 0, 0, 0.35);
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.avatar {
    width: 60px;
    height: 60px;
    border: 2px solid var(--color-gold);
    border-radius: 4px;
    background-size: cover;
    flex-shrink: 0;
}

.cpu-avatar {
    background-image: url('https://api.dicebear.com/7.x/bottts/svg?seed=DarkLord');
}

.player-avatar {
    background-image: url('https://api.dicebear.com/7.x/adventurer/svg?seed=Warrior');
}

.player-name {
    font-family: 'Cinzel', serif;
    color: var(--color-gold);
    font-size: 0.9rem;
}

.bar-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-bar {
    height: 18px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 9px;
    position: relative;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.5s ease;
    position: relative;
}

.hp-fill {
    background: linear-gradient(90deg, #8b0000, #c0392b);
}

.mana-fill {
    background: linear-gradient(90deg, #1a5490, #2980b9);
}

.bar-value {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    z-index: 2;
}

.bar-label {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    z-index: 2;
}

/* STATUS ICONS */
.status-container {
    display: inline-flex;
    gap: 5px;
    margin-left: 10px;
    vertical-align: middle;
}

.status-icon {
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-icon.poison {
    color: #2ecc71;
    border-color: #2ecc71;
}

.status-icon.regen {
    color: #e67e22;
    border-color: #e67e22;
}

.status-icon.stun {
    color: #f1c40f;
    border-color: #f1c40f;
}

/* HAND */
.hand {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1200;
    overflow-x: auto;
    overflow-y: visible;
    padding: 40px 20px 20px 20px;
    max-width: 100%;
}

.hand::-webkit-scrollbar {
    height: 8px;
}

.hand::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.hand::-webkit-scrollbar-thumb {
    background: var(--color-gold-dim);
    border-radius: 4px;
}

/* CARDS */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--color-parchment);
    border-radius: 8px;
    border: 2px solid #8a7018;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.card:hover,
.card:focus,
.card:focus-visible,
.card:active {
    transform: translateY(-30px) scale(1.08);
    z-index: 4000;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: var(--color-gold);
}

.card.disabled {
    filter: grayscale(0.8) brightness(0.6);
    cursor: not-allowed;
}

.card.disabled:hover {
    transform: none;
}

.card-inner {
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #8a7018;
}

.card-cost {
    background: var(--color-mana);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.card-name {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    color: #4a3218;
    font-size: 0.8rem;
    text-align: right;
    flex: 1;
    margin-left: 5px;
}

.card-image {
    flex: 1;
    background: #dcd0b8;
    border: 1px solid #8a7018;
    border-radius: 4px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    overflow: hidden;
}

.card-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.card-body {
    font-size: 0.75rem;
    color: #2b1d0e;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-lore {
    line-height: 1.3;
    min-height: 1.8em;
    color: #1f1409;
    font-weight: 600;
}

.card-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.card-effect {
    background: linear-gradient(180deg, #fbf2e0, #f1e2c3);
    border: 1px solid #c8a95b;
    border-radius: 999px;
    padding: 4px 8px;
    font-weight: 700;
    color: #4c3610;
    letter-spacing: 0.15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.draw {
    background: #f39c12;
}

.card-back {
    background: linear-gradient(135deg, #2b1d0e 0%, #1a1108 100%);
    border-color: var(--color-gold-dim);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back-logo {
    font-size: 3rem;
    color: rgba(212, 175, 55, 0.3);
    border: 3px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* BATTLE BOARD */
.battle-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 100;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.08), transparent 50%),
        linear-gradient(180deg, rgba(19, 14, 10, 0.85), rgba(12, 9, 7, 0.92));
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 14px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55);
}

.played-card-area {
    /* Dimensiones de la carta */
    width: var(--card-width);
    height: var(--card-height);

    /* Posicionamiento absoluto en el centro de la pantalla */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    /* Z-Index Supremo: Superior a player-area (200), modales y overlays */
    z-index: 9999;

    /* Eventos: Permitir clicks a través de la animación (opcional pero recomendado) */
    pointer-events: none;

    display: flex;
    justify-content: center;
    align-items: center;
}

.played-card-enter {
    animation: cardEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.played-card-exit {
    animation: cardExit 0.4s ease-in forwards;
}

@keyframes cardEnter {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2) rotate(-15deg);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.4) rotate(0deg);
    }
}

@keyframes cardExit {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.4);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1.6);
        filter: blur(4px);
    }
}

.played-by-player .card {
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.9);
    border-color: var(--color-gold);
}

.played-by-cpu .card {
    box-shadow: 0 0 50px rgba(192, 57, 43, 0.9);
    border-color: var(--color-hp);
}

/* CONTROLS */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    position: relative;
    z-index: 200;
    pointer-events: auto;
}

.btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 10px 30px;
    background: rgba(43, 29, 14, 0.95);
    color: var(--color-parchment);
    border: 2px solid var(--color-gold-dim);
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    border-color: var(--color-gold);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.6);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* FLOATING TEXT */
.floating-text {
    position: absolute;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 9999;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    white-space: nowrap;
}

.float-dmg {
    color: #ff3333;
    font-size: 3rem;
}

.float-heal {
    color: #44ff44;
    font-size: 2rem;
}

.float-mana {
    color: #44aaff;
    font-size: 2rem;
}

.float-info {
    color: #ffd700;
    font-size: 1.5rem;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    15% {
        transform: translateY(-40px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translateY(-120px) scale(1);
        opacity: 0;
    }
}

.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(2px);
    }

    30%,
    50%,
    70% {
        transform: translateX(3px);
    }

    40%,
    60% {
        transform: translateX(3px);
    }
}

/* DECK BUILDER */
.builder-area {
    display: flex;
    flex: 1;
    gap: 20px;
    overflow: hidden;
    padding: 10px;
}

.deck-column h3 span {
    float: right;
    font-size: 0.95rem;
}

.opponent-panel {
    margin-top: 10px;
    background: linear-gradient(180deg, rgba(27, 19, 11, 0.94), rgba(19, 14, 9, 0.97));
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
}

.opponent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.opponent-hint {
    color: rgba(224, 218, 204, 0.8);
    font-size: 0.9rem;
    margin-top: 4px;
}

.opponent-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opponent-selection-label {
    font-size: 0.9rem;
    color: var(--color-parchment);
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--color-gold-dim);
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-block;
}

.opponent-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.opponent-card {
    background: radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.1), transparent 45%), rgba(43, 29, 14, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.opponent-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-gold);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
}

.opponent-card.active {
    border-color: var(--color-gold);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.35);
}

.opponent-name {
    font-family: 'Cinzel', serif;
    color: var(--color-gold);
    margin-bottom: 4px;
}

.opponent-tagline {
    font-size: 0.9rem;
    color: rgba(224, 218, 204, 0.8);
}

.opponent-deck-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.opponent-deck-card {
    background: linear-gradient(160deg, rgba(10, 8, 6, 0.85), rgba(33, 22, 14, 0.9));
    border: 1px solid #5d4037;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.opponent-deck-card:hover {
    border-color: var(--color-gold);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.opponent-deck-card.active {
    border-color: var(--color-gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.35);
}

.opponent-deck-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.deck-label {
    font-weight: bold;
    color: var(--color-parchment);
}

.deck-style {
    font-size: 0.8rem;
    color: rgba(224, 218, 204, 0.8);
}

.deck-meta {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.deck-difficulty {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(224, 218, 204, 0.15);
    border: 1px solid rgba(224, 218, 204, 0.3);
    color: #e0dacc;
}

.deck-difficulty.easy {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.5);
    color: #2ecc71;
}

.deck-difficulty.medium {
    background: rgba(52, 152, 219, 0.15);
    border-color: rgba(52, 152, 219, 0.5);
    color: #3498db;
}

.deck-difficulty.hard {
    background: rgba(243, 156, 18, 0.15);
    border-color: rgba(243, 156, 18, 0.5);
    color: #f39c12;
}

.deck-difficulty.expert {
    background: rgba(155, 89, 182, 0.15);
    border-color: rgba(155, 89, 182, 0.5);
    color: #9b59b6;
}

.deck-preview {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: rgba(224, 218, 204, 0.9);
}

.deck-preview span {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 4px 6px;
    border-radius: 6px;
}

.deck-choose {
    align-self: flex-start;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.opponent-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.btn-ghost {
    background: transparent;
    border-color: rgba(224, 218, 204, 0.4);
    color: var(--color-parchment);
}

.deck-builder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 40% 0%, rgba(212, 175, 55, 0.05), transparent 40%), rgba(0, 0, 0, 0.92);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 12px;
    backdrop-filter: blur(2px);
}

.builder-header {
    text-align: center;
    margin-bottom: 8px;
}

.builder-header h2 {
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.builder-header p {
    color: rgba(244, 232, 208, 0.8);
    font-size: 0.95rem;
}

.library-column {
    flex: 2.5;
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, rgba(33, 23, 13, 0.95), rgba(21, 15, 9, 0.95));
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(212, 175, 55, 0.35);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35);
}

.deck-column {
    flex: 0.9;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, rgba(60, 39, 16, 0.95), rgba(34, 24, 12, 0.95));
    border-radius: 12px;
    padding: 14px;
    border: 2px solid rgba(212, 175, 55, 0.6);
    min-width: 240px;
    max-width: 360px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 18px;
    overflow-y: auto;
    padding: 12px;
    flex: 1;
}

.card-grid .card {
    width: 100%;
    height: 260px;
    font-size: 0.95em;
}

.card-grid .card:hover {
    transform: scale(1.04);
    z-index: 10;
}

.deck-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.deck-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #5d4037;
    cursor: pointer;
    transition: background 0.2s;
}

.deck-item:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--color-gold);
}

.deck-item-name {
    font-size: 0.9rem;
    color: var(--color-parchment);
}

.deck-item-cost {
    background: var(--color-mana);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 8px;
}

.deck-stats {
    font-family: 'Cinzel', serif;
    color: var(--color-parchment);
    font-size: 1.2rem;
    margin-top: 5px;
}

h2 {
    font-family: 'Cinzel', serif;
    color: var(--color-gold);
    border-bottom: 1px solid #5d4037;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

/* SCROLLBARS */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: var(--color-gold-dim);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gold);
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.opponent-overlay {
    justify-content: center;
    padding: 30px;
    background: radial-gradient(circle at 30% 30%, rgba(212, 175, 55, 0.08), transparent 38%), rgba(0, 0, 0, 0.88);
    z-index: 4000;
}

.modal-content {
    background: rgba(43, 29, 14, 0.95);
    border: 2px solid var(--color-gold);
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    height: 80%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-gold-dim);
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    color: var(--color-gold);
    font-family: 'Cinzel', serif;
}

.close-btn {
    background: none;
    border: none;
    color: var(--color-parchment);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #e74c3c;
}

#cpu-deck-grid {
    overflow-y: auto;
    padding-right: 10px;
}

/* DICE OVERLAY */
.dice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 10, 8, 0.85);
    backdrop-filter: blur(4px);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dice-overlay.active {
    opacity: 1;
}

.dice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice-overlay.active .dice-container {
    transform: scale(1);
}

.dice-shape {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #2b1d0e, #5d4037);
    border: 3px solid var(--color-gold);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transform: rotate(45deg);
}

.dice-shape span {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    transform: rotate(-45deg);
    width: 100%;
    text-align: center;
}

.dice-shape.crit-success {
    border-color: #2ecc71;
    box-shadow: 0 0 50px #2ecc71;
    background: linear-gradient(135deg, #0f3d0f, #2ecc71);
}

.dice-formula {
    font-family: 'Lato', sans-serif;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.dice-label {
    font-family: 'Cinzel', serif;
    color: var(--color-gold);
    font-size: 1.5rem;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes diceShake {
    0% {
        transform: rotate(45deg) translate(0, 0);
    }
    25% {
        transform: rotate(45deg) translate(5px, 5px);
    }
    50% {
        transform: rotate(45deg) translate(-5px, -5px);
    }
    75% {
        transform: rotate(45deg) translate(5px, -5px);
    }
    100% {
        transform: rotate(45deg) translate(0, 0);
    }
}

.shaking {
    animation: diceShake 0.1s infinite;
}