:root { 
    --bg: #121212; 
    --panel: #1e1e1e; 
    --hero-top: #ffd700; 
    --hero-bottom: #2ecc71; 
    --enemy: #ff4d4d; 
    --gold: #ffd700; 
    --hp-green: #2ecc71; 
    --info: #00ccff; 
    --shield-bg: #70a1ff;
}

body { 
    background: var(--bg); 
    color: white; 
    font-family: 'Segoe UI', sans-serif; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    margin: 0; 
    padding: 20px; 
    min-height: 100vh; 
    overflow-x: hidden; 
}

/* Main Menu Overlay */
#main-menu {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, #1e1e1e 0%, #000 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 1000; transition: opacity 0.4s ease;
}

#main-menu h1 { font-size: 4rem; margin-bottom: 10px; color: var(--gold); text-shadow: 0 0 20px rgba(255, 215, 0, 0.3); }
.menu-subtitle { font-size: 1.2rem; color: #888; margin-bottom: 40px; letter-spacing: 2px; }

.menu-btns { display: flex; flex-direction: column; gap: 15px; width: 280px; }

.start-btn { 
    padding: 20px; font-size: 1.5rem; background: var(--hero-bottom); 
    color: #000; border: none; border-radius: 50px; cursor: pointer; 
    font-weight: bold; transition: 0.3s; box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}

.how-to-btn {
    padding: 12px; font-size: 1rem; background: rgba(255,255,255,0.1);
    color: white; border: 1px solid rgba(255,255,255,0.2); border-radius: 50px;
    cursor: pointer; transition: 0.2s;
}

.start-btn:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(46, 204, 113, 0.6); }
.how-to-btn:hover { background: rgba(255,255,255,0.2); }

/* How to Play Modal */
#how-to-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: none; align-items: center; 
    justify-content: center; z-index: 1100;
}

.modal-content {
    background: var(--panel); border: 2px solid var(--info);
    padding: 30px; border-radius: 20px; max-width: 450px; text-align: left;
    position: relative; line-height: 1.6; box-shadow: 0 0 40px rgba(0, 204, 255, 0.2);
}

.modal-content h2 { color: var(--info); margin-top: 0; }
.close-modal { margin-top: 20px; width: 100%; padding: 10px; background: var(--info); border: none; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* Exit Button */
.exit-btn {
    position: fixed; top: 20px; right: 20px;
    background: rgba(255, 255, 255, 0.1); color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2); padding: 8px 16px;
    border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: bold;
    z-index: 500; transition: 0.2s;
}
.exit-btn:hover { background: #ff4d4d; color: white; border-color: #ff4d4d; }

/* Game Layout */
.stage { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 1100px; margin-top: 60px; margin-bottom: 20px; padding: 0 50px; }
.party { display: flex; flex-direction: column; gap: 40px; }

/* Updated Unit Class with Transition */
.unit { 
    padding: 25px; 
    background: var(--panel); 
    border-radius: 16px; 
    text-align: center; 
    width: 170px; 
    border: 2px solid transparent; 
    position: relative; 
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border 0.3s, box-shadow 0.3s; 
}

.can-target { cursor: pointer; border: 2px dashed white !important; transform: scale(1.1); background: #333; z-index: 5; }
.targeted-by-enemy { border: 4px solid var(--enemy) !important; box-shadow: 0 0 20px rgba(255, 77, 77, 0.4); }
.target-marker { position: absolute; left: -50px; top: 50%; transform: translateY(-50%); font-size: 2rem; }
.hero-top { border-color: var(--hero-top); }
.hero-bottom { border-color: var(--hero-bottom); }
.unit.enemy { border-color: var(--enemy); transform: scale(1.4); } 

.hp-container { width: 100%; height: 12px; background: #333; border-radius: 6px; margin: 12px 0; overflow: hidden; }
.hp-fill { height: 100%; background: var(--hp-green); transition: width 0.3s ease; }
.hp-text { font-size: 1.8rem; font-weight: bold; }

/* Dice */
.dice-area { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 20px; }
.dice-tray { display: flex; gap: 20px; padding: 25px; background: rgba(0,0,0,0.4); border-radius: 20px; }
.die { width: 75px; height: 75px; background: #333; border: 3px solid #666; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: bold; transition: 0.2s; font-size: 1.2rem; }
.die.hero0-die { border-color: var(--hero-top); color: var(--hero-top); }
.die.hero1-die { border-color: var(--hero-bottom); color: var(--hero-bottom); }
.die.locked { border-color: white; transform: translateY(-10px); box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.die.selected { border-color: var(--info); box-shadow: 0 0 20px var(--info); transform: translateY(-20px); }
.die.assigned { opacity: 0.4; transform: scale(0.9); }

.controls { margin-top: 25px; display: flex; gap: 15px; }
button { padding: 14px 28px; border-radius: 8px; border: none; cursor: pointer; font-weight: bold; background: #444; color: white; font-size: 1rem; }
#roll-btn { background: #4da6ff; }
#exec-btn { background: #28a745; }

.floating-text { position: absolute; font-weight: bold; font-size: 1.5rem; animation: floatUp 1s forwards; pointer-events: none; width: 100%; text-align: center; left: 0; }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-50px); } }

/* --- NEW ANIMATION CLASS --- */
.hero-action-slide {
    transform: translateX(45px) scale(1.08) !important;
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.25);
    z-index: 100;
}