#combat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.combat-container {
    width: 1000px;
    max-width: 95%;
    background-color: #1a1a1a;
    border: 2px solid #5d4037;
    border-radius: 8px;
    padding: 20px;
    color: #e0e0e0;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: left;
}

.monster-frame {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

#monster-name {
    color: #ff4444;
    font-family: 'Cinzel', serif;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hp-bar-container {
    width: 100%;
    height: 25px;
    background-color: #333;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

#monster-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b0000, #ff0000);
     /* width: 100%;  causes overrun with spans*/
    transition: width 0.5s ease-in-out;
}

#monster-hp-text {
    position: absolute;
    /* width: 100%;  causes overrun with spans*/
    text-align: center;
    top: 0;
    line-height: 25px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

#battle-log {
    height: 200px;
    overflow-y: auto;
    background-color: #0f0f0f;
    border: 1px solid #333;
    padding: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

#battle-log.sidebar-log {
    height: 400px;
}

#battle-log p {
    margin: 5px 0;
    border-bottom: 1px dashed #333;
    padding-bottom: 2px;
}

.system-msg {
    color: #ffd700;
    font-style: italic;
}

.party-tray {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.hero-card {
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 15px;
    width: 200px;
    text-align: center;
}

.hero-card.dead {
    filter: grayscale(100%);
    opacity: 0.6;
    background-color: #1a1a1a;
    border-color: #333;
}

.hero-card.dead p,
.hero-card.dead .hero-hp {
    color: #777;
}

.hero-card p {
    font-weight: bold;
    color: #87ceeb;
    margin-bottom: 5px;
}

.hero-hp {
    font-size: 0.85rem;
    color: #98fb98;
    margin-bottom: 10px;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hero-actions button {
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.hero-actions button:first-child {
    background-color: #d32f2f;
    color: white;
}

.hero-actions button:first-child:hover {
    background-color: #b71c1c;
}

.hero-actions button:disabled {
    background-color: #444 !important;
    color: #777 !important;
    cursor: not-allowed;
}

.hero-actions .ad-btn {
    background-color: #fbc02d;
    color: #333;
}

.hero-actions .ad-btn:hover {
    background-color: #f9a825;
}

.hero-actions button:last-child {
    background-color: #555;
    color: #ccc;
}

.hero-actions button:last-child:hover {
    background-color: #444;
}

.action-group {
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.action-group-title {
    font-size: 0.75rem;
    color: #aaa;
    text-align: center;
    margin-bottom: 2px;
    text-transform: uppercase;
}

/* Combat Layout & Initiative Pane */
.combat-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.combat-main {
    flex: 1;
}

.combat-sidebar {
    width: 240px;
    flex-shrink: 0;
}

.combat-tabs {
    display: flex;
    margin-bottom: 5px;
}

.tab-btn {
    flex: 1;
    background-color: #333;
    border: 1px solid #444;
    color: #ccc;
    padding: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.tab-btn.active {
    background-color: #2c2c2c;
    color: #ffd700;
    border-bottom: none;
}

.initiative-pane {
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px;
    height: 100%;
}

.initiative-pane h3 {
    font-size: 1.1rem;
    color: #e0e0e0;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-family: 'Cinzel', serif;
}

#round-counter {
    color: #ffd700;
}

.initiative-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.initiative-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
}

.initiative-item.hero {
    color: #87ceeb;
}

.initiative-item.monster {
    color: #ff4444;
}

.initiative-item.active {
    border-left: 4px solid #ffd700;
    background-color: #3a3a3a;
}

.initiative-item.dead {
    color: #777;
    text-decoration: line-through;
}

.initiative-score {
    font-weight: bold;
    color: #ffd700;
}

/* Shake animation for damage */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.5s;
    animation-iteration-count: 1;
}

@keyframes skullPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.pulse-skull {
    animation: skullPulse 0.5s ease-out;
    display: inline-block;
}

@keyframes critScale {
    0% { transform: translate(-50%, -50%) scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.5) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2) rotate(10deg); opacity: 0; }
}

.crit-anim {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cinzel', serif;
    font-size: 5rem;
    font-weight: bold;
    color: #ffeb3b;
    text-shadow: 0 0 10px #ff0000, 0 0 20px #8b0000, 2px 2px 0px #000;
    pointer-events: none;
    z-index: 10001;
    animation: critScale 1.5s ease-out forwards;
    white-space: nowrap;
    background-color: rgba(0,0,0,0.5);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #ffeb3b;
}