:root {
    --bg-dark: #1a1a1a;
    --panel-bg: rgba(40, 30, 20, 0.8);
    --gold: #d4af37;
    --hp-green: #2ecc71;
    --hp-red: #e74c3c;
    --fire: #ff4d4d;
    --water: #3498db;
    --earth: #795548;
    --air: #ecf0f1;
    --slot-border: rgba(212, 175, 55, 0.5);
    --active-glow: 0 0 15px var(--gold);
}

.hidden {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-dark);
    color: #f0e6d2;
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 1920px;
    height: 1280px;
    background: url('assets/tabellone.jpg') center center no-repeat;
    background-size: cover;
    padding: 20px;
    gap: 20px;

    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    transform-origin: center center;

    display: grid;
    grid-template-columns: 450px 1fr 400px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "altar p2  log"
        "altar cru log"
        "altar p1  log";
}

.player-zone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s ease;
}

.player-zone.active-turn {
    box-shadow: inset 0 0 20px var(--gold);
    background: rgba(40, 30, 20, 0.4);
}

#player-2 {
    grid-area: p2;
}

#player-1 {
    grid-area: p1;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 400px;
}

.player-name {
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px black;
    min-width: 100px;
}

.hp-bar-container {
    flex-grow: 1;
    height: 25px;
    background: #333;
    border: 2px solid var(--gold);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.hp-bar {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    transition: width 0.5s ease;
}

.hp-text {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

.shield-container {
    background: rgba(52, 152, 219, 0.8);
    border: 2px solid #fff;
    border-radius: 12px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
    animation: shield-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.shield-icon {
    font-size: 1.2rem;
}

#p1-shield-text, #p2-shield-text {
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
}

@keyframes shield-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.grimoire {
    display: flex;
    gap: 10px;
}

.slot {
    width: 149px;
    height: 140px;
    background: var(--panel-bg);
    border: 2px solid var(--slot-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.slot:hover {
    transform: scale(1.05);
    border-color: var(--gold);
}

/* Middle Zone */
#middle-zone {
    display: contents;
}

#altar-container {
    grid-area: altar;
    width: 100%;
    height: 100%;
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#game-log-container {
    grid-area: log;
    width: 100%;
    height: 100%;
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 15px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#game-log {
    flex: 1;
    height: 120px; /* Shortened */
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    font-size: 16px;
    color: #f0e6d2;
    display: flex;
    flex-direction: column;
}

#options-bar {
    height: 40px;
    background: linear-gradient(to right, rgba(0,0,0,0.8), rgba(40,30,10,0.8));
    border: 1px solid var(--gold);
    border-radius: 6px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#options-bar:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000000;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.modal-content {
    background: linear-gradient(145deg, #1a1510, #0a0805);
    border: 3px solid var(--gold);
    border-radius: 15px;
    padding: 40px;
    width: 400px;
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 0, 0, 1);
}

.modal-content h3 {
    color: var(--gold);
    margin-top: 0;
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 30px;
}

.setting-item {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-item label {
    color: #f0e6d2;
    font-size: 18px;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--gold);
}

.close-modal {
    margin-top: 20px;
    padding: 10px 30px;
    background: var(--gold);
    color: black;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-modal:hover {
    transform: scale(1.1);
}

.altar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.altar-slot {
    flex-grow: 1;
    height: auto;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--slot-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.altar-slot:hover {
    background: rgba(40, 30, 20, 0.6);
    transform: translateX(5px);
    border-color: var(--gold);
}

.magic-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.magic-element-icon {
    width: 80px;
    height: 62px;
    background-size: contain;
    background-repeat: no-repeat;
}

.magic-icon-square {
    width: 150px;
    height: 150px;
    background-size: cover;
    background-position: center;
    border-radius: 5px;
    /* border: 1px solid var(--gold); */
    flex-shrink: 0;
}

.magic-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.magic-name-text {
    font-weight: bold;
    font-size: 14px;
    color: var(--gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.magic-desc-text {
    font-size: 20px;
    color: #ccc;
    line-height: 1.2;
}

#crucible-container {
    grid-area: cru;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-5x5 {
    display: block;
    width: 770px;
    height: 770px;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 15px;
    border: 3px solid var(--gold);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    position: relative;
}

.element-tile {
    width: 130px;
    height: 130px;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.element-tile:active {
    cursor: grabbing;
}

.element-tile.selected {
    outline: 5px solid var(--gold);
    box-shadow: 0 0 25px var(--gold);
    z-index: 100;
    transform: scale(1.1);
}

.element-tile.fire {
    background-image: url('assets/fuoco.png');
}

.element-tile.water {
    background-image: url('assets/acqua.png');
}

.element-tile.earth {
    background-image: url('assets/terra.png');
}

.element-tile.air {
    background-image: url('assets/aria.png');
}

.element-tile.jolly {
    background-image: url('assets/jolly.png');
}

/* Magic Card Styles (Merged nearby) */
.magic-card-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 5px;
}

.card-level {
    background: var(--gold);
    color: black;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Animations */
@keyframes fall {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.2s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes earthquake {
    0% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-5px, -5px);
    }

    20% {
        transform: translate(5px, 5px);
    }

    30% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(5px, -5px);
    }

    50% {
        transform: translate(-5px, -5px);
    }

    60% {
        transform: translate(5px, 5px);
    }

    70% {
        transform: translate(-5px, 5px);
    }

    80% {
        transform: translate(5px, -5px);
    }

    90% {
        transform: translate(-5px, -5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.earthquake {
    animation: earthquake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

#game-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---- TIMELINE ENTRY ---- */
.log-entry {
    display: flex;
    align-items: stretch;
    gap: 10px;
    animation: log-slide-in 0.25s ease-out;
    padding: 0 4px;
}

@keyframes log-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Left column: dot + vertical line */
.log-timeline-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 18px;
    padding-top: 10px;
}

.log-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.log-dot-p1    { background: var(--fire);  color: var(--fire);  }
.log-dot-p2    { background: var(--water); color: var(--water); }
.log-dot-system { background: var(--gold); color: var(--gold);  width: 8px; height: 8px; margin: 2px; }

.log-line {
    flex-grow: 1;
    width: 2px;
    background: rgba(255, 255, 255, 0.07);
    margin-top: 4px;
}

/* Right column: content */
.log-content {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    min-width: 0;
}

.log-entry-p1 .log-content {
    background: rgba(255, 77, 77, 0.1);
    border-left: 3px solid var(--fire);
}

.log-entry-p2 .log-content {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--water);
}

.log-entry-system .log-content {
    background: rgba(212, 175, 55, 0.06);
    border-left: 3px solid rgba(212, 175, 55, 0.3);
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.log-label {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.log-label-p1 { color: #ff6b6b; }
.log-label-p2 { color: #5dade2; }

.log-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-family: monospace;
    letter-spacing: 1px;
}

.log-msg {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    word-break: break-word;
}

.log-entry-system .log-msg {
    color: rgba(212, 175, 55, 0.85);
    font-style: italic;
    font-size: 12px;
}

/* Sub-events (combos, spell outcomes) */
.log-subitems {
    list-style: none;
    margin: 6px 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.log-subitem {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.65);
    padding: 3px 6px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    line-height: 1.4;
    animation: log-slide-in 0.2s ease-out;
}

.log-subitem::before {
    content: '└';
    color: rgba(255,255,255,0.25);
    flex-shrink: 0;
    font-size: 11px;
    line-height: 1.6;
}

.log-subitems:empty { display: none; }


#turn-announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100000;
    font-size: 150px;
    font-weight: 900;
    text-transform: uppercase;
    color: #ffcc00;
    text-shadow:
        4px 4px 0 #cc0000,
        -4px -4px 0 #cc0000,
        4px -4px 0 #cc0000,
        -4px 4px 0 #cc0000,
        0 10px 20px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 10px;
}

.sf-animate-in {
    animation: sf-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.sf-animate-out {
    animation: sf-out 0.3s ease-in forwards;
}

.sf-animate-fight {
    animation: sf-fight 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.5) forwards;
}

.hidden {
    display: none !important;
}

@keyframes sf-in {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-20deg);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes sf-out {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

#turn-announcement.victory {
    font-size: 100px;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.8), 0 0 60px rgba(212, 175, 55, 0.4);
    background: radial-gradient(circle, rgba(0,0,0,0.95) 0%, transparent 90%);
    animation: sf-victory 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    line-height: 1.1;
    text-align: center;
    flex-direction: column;
    pointer-events: auto;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.replay-hint {
    display: block;
    margin-top: 40px;
    font-size: 24px;
    color: #fff;
    letter-spacing: 5px;
    text-transform: uppercase;
    opacity: 0.8;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: pulse-hint 1.5s infinite ease-in-out;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

@keyframes sf-victory {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: blur(10px); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); }
}

@keyframes sf-fight {
    0% { transform: translate(-50%, -50%) scale(5); opacity: 0; filter: brightness(5); }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; filter: brightness(2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: brightness(1); }
}

/* Removed duplicate card-level styles */
.rock-guardian-block {
    animation: block-shake 0.3s ease-in-out;
    position: relative;
    z-index: 1000;
}

.rock-guardian-block::after {
    content: '';
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(0, 207, 255, 0.9) 0%, transparent 70%);
    border: 4px solid #00cfff;
    border-radius: 50%;
    animation: vortex-flash 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes vortex-flash {
    0% { transform: scale(0) rotate(0deg); opacity: 0; filter: blur(5px); }
    50% { transform: scale(1.2) rotate(360deg); opacity: 1; filter: blur(0); }
    100% { transform: scale(1.5) rotate(720deg); opacity: 0; filter: blur(10px); }
}

@keyframes block-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    75% { transform: translateX(5px) rotate(2deg); }
}


/* ============================
   SPELL ZOOM OVERLAY
   ============================ */
#magic-tooltip {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#magic-tooltip.visible {
    opacity: 1;
}

#magic-tooltip .tooltip-inner {
    background: linear-gradient(145deg, rgba(30, 20, 10, 0.98), rgba(20, 10, 5, 0.99));
    border: 3px solid var(--gold);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(212, 175, 55, 0.5);
    padding: 30px;
    width: 500px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    text-align: center;
}

#tooltip-icon {
    width: 200px;
    height: 200px;
    background-size: cover;
    background-position: center;
    border-radius: 15px;
    border: 2px solid rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

#tooltip-name {
    margin: 0;
    font-size: 28px;
    color: var(--gold);
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.7);
}

#tooltip-element {
    width: 60px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin: 0 auto;
}

#tooltip-desc {
    font-size: 18px;
    color: #e0d0c0;
    line-height: 1.5;
    margin: 0;
}

.pulse-glow {
    animation: gold-pulse 0.5s ease-out;
}


/* ============================
   TITLE SCREEN
   ============================ */
#title-screen {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: url('assets/title.jpg') center center no-repeat;
    background-size: cover;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease, transform 1s ease;
}

#title-screen.fade-out {
    opacity: 0;
    transform: scale(1.1);
    pointer-events: none;
}

.title-content {
    position: relative;
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.start-button {
    padding: 22px 70px;
    font-size: 26px;
    font-weight: bold;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 5px;
    backdrop-filter: blur(5px);
    min-width: 380px;
}

.start-button:hover {
    transform: scale(1.1);
    background: var(--gold);
    color: #000;
    box-shadow: 0 0 50px var(--gold);
}

.start-button:active {
    transform: scale(0.95);
}

/* CPU label in player-2 zone */
#cpu-badge {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid #7f5af0;
    color: #a78bfa;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(127, 90, 240, 0.4);
}

.title-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.15) 0%, transparent 80%);
    animation: pulse-glow 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes title-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}


@keyframes pulse-glow {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.2); }
}

/* Magical Particles */
.particles-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: #fdf5e6;
    border-radius: 50%;
    opacity: 0.2;
    filter: blur(1px);
    animation: particle-float linear infinite;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}


@keyframes particle-float {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    25% { opacity: 0.8; transform: translate(calc(var(--dx) * 0.25), calc(var(--dy) * 0.25)) scale(1.5); }
    50% { opacity: 0.4; transform: translate(calc(var(--dx) * 0.5), calc(var(--dy) * 0.5)) scale(0.8); }
    75% { opacity: 0.8; transform: translate(calc(var(--dx) * 0.75), calc(var(--dy) * 0.75)) scale(1.5); }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.5); opacity: 0; }
}

/* Background Dimming for Altar Calling Phase */
#crucible-container {
    transition: filter 0.3s ease;
}

#crucible-container.dimmed,
#player-1.dimmed,
#player-2.dimmed {
    filter: brightness(0.35);
    pointer-events: none;
}

/* Element Backgrounds for Altar */
.element-bg-fire { background: rgba(255, 77, 77, 0.15) !important; }
.element-bg-water { background: rgba(52, 152, 219, 0.15) !important; }
.element-bg-earth { background: rgba(121, 85, 72, 0.3) !important; }
.element-bg-air { background: rgba(236, 240, 241, 0.15) !important; }
.element-bg-jolly { background: rgba(212, 175, 55, 0.15) !important; }

.altar-slot.element-bg-fire:hover { background: rgba(255, 77, 77, 0.3) !important; border-color: var(--fire) !important; }
.altar-slot.element-bg-water:hover { background: rgba(52, 152, 219, 0.3) !important; border-color: var(--water) !important; }
.altar-slot.element-bg-earth:hover { background: rgba(121, 85, 72, 0.45) !important; border-color: var(--earth) !important; }
.altar-slot.element-bg-air:hover { background: rgba(236, 240, 241, 0.3) !important; border-color: var(--air) !important; }
.altar-slot.element-bg-jolly:hover { background: rgba(212, 175, 55, 0.3) !important; border-color: var(--gold) !important; }

/* Element Borders for Grimoire Slots */
.element-border-fire { border-color: var(--fire) !important; box-shadow: inset 0 0 15px rgba(255, 77, 77, 0.2), 0 0 10px rgba(255, 77, 77, 0.3); }
.element-border-water { border-color: var(--water) !important; box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.2), 0 0 10px rgba(52, 152, 219, 0.3); }
.element-border-earth { border-color: var(--earth) !important; box-shadow: inset 0 0 15px rgba(121, 85, 72, 0.2), 0 0 10px rgba(121, 85, 72, 0.3); }
.element-border-air { border-color: var(--air) !important; box-shadow: inset 0 0 15px rgba(236, 240, 241, 0.2), 0 0 10px rgba(236, 240, 241, 0.3); }
.element-border-jolly { border-color: var(--gold) !important; box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.2), 0 0 10px rgba(212, 175, 55, 0.3); }

.slot.element-border-fire:hover { box-shadow: inset 0 0 15px rgba(255, 77, 77, 0.3), 0 0 20px rgba(255, 77, 77, 0.6); }
.slot.element-border-water:hover { box-shadow: inset 0 0 15px rgba(52, 152, 219, 0.3), 0 0 20px rgba(52, 152, 219, 0.6); }
.slot.element-border-earth:hover { box-shadow: inset 0 0 15px rgba(121, 85, 72, 0.3), 0 0 20px rgba(121, 85, 72, 0.6); }
.slot.element-border-air:hover { box-shadow: inset 0 0 15px rgba(236, 240, 241, 0.3), 0 0 20px rgba(236, 240, 241, 0.6); }
.slot.element-border-jolly:hover { box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.3), 0 0 20px rgba(212, 175, 55, 0.6); }

/* Activation Badges */
.magic-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    margin-left: auto;
}
.magic-type-badge.immediato {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.9), rgba(192, 57, 43, 0.9));
    color: white;
    border: 1px solid rgba(255, 121, 121, 0.5);
}
.magic-type-badge.attivazione {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.9), rgba(41, 128, 185, 0.9));
    color: white;
    border: 1px solid rgba(116, 185, 255, 0.5);
}

.tooltip-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
}

/* Screen Flash Effect */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100000;
    background: white;
    opacity: 0;
}

.animate-flash {
    animation: flash-anim 0.8s ease-out forwards;
}

@keyframes flash-anim {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}