* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: #0a0e1a;
    font-family: 'Cinzel', serif;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(30, 58, 138, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(120, 53, 15, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(88, 28, 135, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#root { position: relative; z-index: 1; }

.font-mono { font-family: 'JetBrains Mono', monospace; }
.font-cinzel { font-family: 'Cinzel', serif; }

/* Character cards */
.char-card {
    background: linear-gradient(145deg, #1a1f35, #0f1322);
    border: 2px solid #2a3050;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.char-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.05) 0%, transparent 50%);
    pointer-events: none;
}
.char-card:hover {
    border-color: #d4af37;
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.15);
}
.char-card.picked {
    border-color: #d4af37;
    box-shadow: 0 0 24px rgba(212, 175, 55, 0.3);
}
.char-card.dimmed {
    opacity: 0.35;
    pointer-events: none;
}

/* Player panels */
.player-panel {
    background: linear-gradient(145deg, #111827, #0d1117);
    border: 2px solid #1e293b;
    border-radius: 12px;
    position: relative;
}
.player-panel.p1 { border-color: #1e40af55; }
.player-panel.p2 { border-color: #9f123155; }
.player-panel.active-turn {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    border-color: #d4af37 !important;
}

/* Dice */
.die-btn {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
    position: relative;
    user-select: none;
}
.die-btn .die-value { font-size: 1.5rem; line-height: 1; }
.die-btn .die-type { font-size: 0.65rem; opacity: 0.7; margin-top: 2px; }

.die-btn.p1-die {
    background: linear-gradient(145deg, #1e40af, #1e3a8a);
    color: #bfdbfe;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}
.die-btn.p2-die {
    background: linear-gradient(145deg, #9f1239, #881337);
    color: #fecdd3;
    box-shadow: 0 4px 12px rgba(159, 18, 57, 0.4);
}
.die-btn:hover { transform: scale(1.08); }
.die-btn.selected-attacker {
    border-color: #22c55e !important;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.6);
    transform: scale(1.1);
}
.die-btn.selected-target {
    border-color: #ef4444 !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    transform: scale(1.1);
}
.die-btn.valid-target {
    border-color: #fbbf2488;
    animation: pulse-border 1.5s ease-in-out infinite;
}
.die-btn.no-interact {
    cursor: default;
    opacity: 0.6;
}
.die-btn.no-interact:hover { transform: none; }

@keyframes pulse-border {
    0%, 100% { border-color: #fbbf2444; }
    50% { border-color: #fbbf24aa; }
}

/* Captured dice (small) */
.captured-die {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    opacity: 0.8;
}

/* Rolling animation */
@keyframes diceRoll {
    0% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
    20% { transform: rotateX(72deg) rotateY(36deg) scale(0.9); }
    40% { transform: rotateX(144deg) rotateY(72deg) scale(1.1); }
    60% { transform: rotateX(216deg) rotateY(108deg) scale(0.95); }
    80% { transform: rotateX(288deg) rotateY(144deg) scale(1.05); }
    100% { transform: rotateX(360deg) rotateY(180deg) scale(1); }
}
.rolling { animation: diceRoll 0.6s ease-out; }

/* Shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-6px); }
    30% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    70% { transform: translateX(4px); }
    90% { transform: translateX(-2px); }
}
.screen-shake { animation: shake 0.4s ease-out; }

/* Sparkle */
@keyframes sparkle {
    0% { opacity: 0; transform: scale(0) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
    100% { opacity: 0; transform: scale(0) rotate(360deg); }
}

/* Combat log */
.combat-log {
    background: rgba(6, 8, 16, 0.9);
    border: 1px solid #1e293b;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}
.combat-log-entry {
    padding: 6px 10px;
    border-bottom: 1px solid #1e293b22;
    color: #94a3b8;
}

/* Action bar */
.action-bar {
    background: linear-gradient(145deg, #1a1f35, #111827);
    border: 2px solid #d4af3733;
    border-radius: 12px;
}

/* Attack buttons */
.atk-btn {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}
.atk-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}
.atk-btn.power {
    background: linear-gradient(145deg, #c2410c, #9a3412);
    color: #fed7aa;
    border-color: #ea580c;
}
.atk-btn.power:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(234, 88, 12, 0.4);
}
.atk-btn.skill {
    background: linear-gradient(145deg, #7c3aed, #6d28d9);
    color: #ddd6fe;
    border-color: #8b5cf6;
}
.atk-btn.skill:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.4);
}
.atk-btn.pass {
    background: linear-gradient(145deg, #374151, #1f2937);
    color: #9ca3af;
    border-color: #4b5563;
}
.atk-btn.pass:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(75, 85, 99, 0.4);
}

/* Turn banner */
.turn-banner {
    background: linear-gradient(90deg, transparent, #d4af3722, transparent);
    border-top: 1px solid #d4af3744;
    border-bottom: 1px solid #d4af3744;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.overlay-card {
    background: linear-gradient(145deg, #1a1f35, #0f1322);
    border: 2px solid #d4af37;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* Confetti */
@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: 200;
    animation: confetti-fall 3s linear forwards;
}

/* Validation message */
.validation-msg {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}
.validation-msg.valid { background: #052e16; color: #4ade80; border: 1px solid #16a34a44; }
.validation-msg.invalid { background: #1c0a0a; color: #f87171; border: 1px solid #dc262644; }

/* Rules modal */
.rules-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #d4af37;
    color: #0a0e1a;
    font-weight: 900;
    font-size: 1.2rem;
    border: none;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
    transition: transform 0.2s;
    font-family: 'Cinzel', serif;
}
.rules-btn:hover { transform: scale(1.1); }

/* Start battle button */
.start-battle-btn {
    background: linear-gradient(145deg, #d4af37, #b8941e);
    color: #0a0e1a;
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 1.3rem;
    padding: 16px 40px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.3);
    letter-spacing: 0.05em;
}
.start-battle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(212, 175, 55, 0.5);
}

/* Scrollbar styling */
.combat-log-scroll::-webkit-scrollbar { width: 6px; }
.combat-log-scroll::-webkit-scrollbar-track { background: transparent; }
.combat-log-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

/* Mobile responsive */
@media (max-width: 768px) {
    .die-btn { width: 56px; height: 56px; }
    .die-btn .die-value { font-size: 1.2rem; }
    .die-btn .die-type { font-size: 0.55rem; }
    .atk-btn { padding: 8px 14px; font-size: 0.75rem; }
}