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

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

/* Deep stone cavern background */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 150% 50% at 50% 120%, rgba(255, 80, 20, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 20%, rgba(255, 100, 40, 0.05) 0%, transparent 30%),
        radial-gradient(ellipse at 90% 20%, rgba(255, 100, 40, 0.05) 0%, transparent 30%),
        linear-gradient(180deg, #12100e 0%, #1a1815 20%, #1f1c18 40%, #181510 70%, #0d0b08 100%);
    z-index: -2;
}

/* Stone texture overlay */
.stone-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 80px, rgba(0,0,0,0.15) 80px, rgba(0,0,0,0.05) 82px),
        repeating-linear-gradient(90deg, transparent, transparent 120px, rgba(0,0,0,0.1) 120px, rgba(0,0,0,0.03) 123px),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.12;
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #8b7355;
    text-decoration: none;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    padding: 8px 16px;
    border: 1px solid rgba(139, 115, 85, 0.3);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.back-link:hover {
    color: #d4a574;
    border-color: rgba(212, 165, 116, 0.5);
    background: rgba(0, 0, 0, 0.5);
    text-shadow: 0 0 10px rgba(255, 150, 80, 0.3);
}

.back-link .arrow {
    font-size: 0.8em;
}

/* Stone header banner */
.header-banner {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.stone-plate {
    display: inline-block;
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 20%, #2a2520 60%, #1a1510 100%);
    padding: 20px 60px;
    border-radius: 8px;
    border: 3px solid #5a4a3a;
    box-shadow:
        0 8px 30px rgba(0,0,0,0.8),
        inset 0 2px 4px rgba(255,255,255,0.1),
        inset 0 -4px 8px rgba(0,0,0,0.4);
    position: relative;
}

.stone-plate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.08;
    border-radius: 8px;
    pointer-events: none;
}

h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.2em;
    color: transparent;
    background: linear-gradient(180deg,
        #fff8e8 0%,
        #ffe4a0 15%,
        #ffcc44 30%,
        #ff9922 50%,
        #ff6600 70%,
        #dd3300 90%,
        #aa1100 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow:
        0 0 10px rgba(255, 200, 100, 1),
        0 0 20px rgba(255, 150, 50, 0.9),
        0 0 40px rgba(255, 100, 30, 0.8),
        0 0 60px rgba(255, 80, 20, 0.6),
        0 0 80px rgba(255, 50, 10, 0.5),
        0 0 120px rgba(255, 30, 0, 0.4),
        2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 3px;
    animation: headerGlow 2s ease-in-out infinite alternate;
}

@keyframes headerGlow {
    0% {
        text-shadow:
            0 0 10px rgba(255, 200, 100, 1),
            0 0 20px rgba(255, 150, 50, 0.9),
            0 0 40px rgba(255, 100, 30, 0.8),
            0 0 60px rgba(255, 80, 20, 0.6),
            0 0 80px rgba(255, 50, 10, 0.5),
            0 0 120px rgba(255, 30, 0, 0.4),
            2px 2px 4px rgba(0,0,0,0.8);
        filter: brightness(1);
    }
    100% {
        text-shadow:
            0 0 15px rgba(255, 220, 120, 1),
            0 0 30px rgba(255, 180, 80, 1),
            0 0 50px rgba(255, 130, 50, 0.9),
            0 0 80px rgba(255, 100, 40, 0.7),
            0 0 100px rgba(255, 70, 20, 0.6),
            0 0 150px rgba(255, 40, 10, 0.5),
            2px 2px 4px rgba(0,0,0,0.8);
        filter: brightness(1.1);
    }
}

.subtitle {
    font-family: 'Metamorphous', serif;
    font-size: 1em;
    color: transparent;
    background: linear-gradient(180deg,
        #ffeecc 0%,
        #ffcc66 30%,
        #ff9933 60%,
        #ff6600 100%);
    -webkit-background-clip: text;
    background-clip: text;
    margin-top: 8px;
    letter-spacing: 4px;
    text-shadow:
        0 0 8px rgba(255, 180, 80, 0.9),
        0 0 15px rgba(255, 130, 50, 0.7),
        0 0 30px rgba(255, 100, 30, 0.5),
        0 0 50px rgba(255, 60, 10, 0.4);
    animation: subtitleGlow 2.5s ease-in-out infinite alternate;
}

@keyframes subtitleGlow {
    0% {
        text-shadow:
            0 0 8px rgba(255, 180, 80, 0.9),
            0 0 15px rgba(255, 130, 50, 0.7),
            0 0 30px rgba(255, 100, 30, 0.5),
            0 0 50px rgba(255, 60, 10, 0.4);
    }
    100% {
        text-shadow:
            0 0 12px rgba(255, 200, 100, 1),
            0 0 25px rgba(255, 160, 70, 0.9),
            0 0 40px rgba(255, 120, 50, 0.7),
            0 0 60px rgba(255, 80, 20, 0.5);
    }
}

/* Round Counter Section */
.round-section {
    background: linear-gradient(180deg, #3a3530 0%, #2a2520 50%, #1a1510 100%);
    border: 3px solid #5a4a3a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
    position: relative;
}

.round-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.06;
    border-radius: 12px;
    pointer-events: none;
}

.round-display {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.round-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.2em;
    color: #d4a574;
}

.round-number {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.5em;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 200, 50, 0.5);
    min-width: 60px;
    text-align: center;
}

.lair-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    position: relative;
}

.lair-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.lair-toggle input {
    width: 20px;
    height: 20px;
    accent-color: #d4a574;
}

.lair-label {
    color: #c9a86c;
    font-size: 0.95em;
}

.lair-initiative {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lair-initiative label {
    color: #8b7355;
    font-size: 0.85em;
}

.lair-initiative input {
    width: 60px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 6px;
    color: #e8dcc0;
    font-family: 'Cinzel', serif;
    font-size: 0.95em;
    text-align: center;
}

.lair-initiative input:focus {
    outline: none;
    border-color: #8b7355;
}

/* Combat Controls */
.combat-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 50%, #2a2520 100%);
    border: 2px solid #5a4a3a;
    border-radius: 8px;
    padding: 10px 18px;
    font-family: 'Cinzel', serif;
    font-size: 0.85em;
    color: #c9a86c;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.1;
    pointer-events: none;
}

.control-btn:hover:not(:disabled) {
    border-color: #8b7355;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.control-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.control-btn.primary {
    background: linear-gradient(180deg, #4a5540 0%, #3a4530 50%, #2a3520 100%);
    border-color: #5a6a4a;
    color: #8bba8b;
}

.control-btn.danger {
    background: linear-gradient(180deg, #5a4540 0%, #4a3530 50%, #3a2520 100%);
    border-color: #6a4a4a;
    color: #ba8b8b;
}

.control-btn.add-btn {
    background: linear-gradient(180deg, #4a4550 0%, #3a3540 50%, #2a2530 100%);
    border-color: #5a4a6a;
    color: #a08bc9;
}

.control-btn.share-btn {
    background: linear-gradient(180deg, #404550 0%, #303540 50%, #202530 100%);
    border-color: #4a5a6a;
    color: #8baabb;
}

.control-btn.player-btn {
    background: linear-gradient(180deg, #404555 0%, #303545 50%, #202535 100%);
    border-color: #4a5a7a;
    color: #80a0d0;
}

.control-btn.enemy-btn {
    background: linear-gradient(180deg, #554045 0%, #453035 50%, #352025 100%);
    border-color: #7a4a4a;
    color: #d08080;
}

.btn-icon {
    font-size: 1.1em;
}

/* Initiative List */
.initiative-list {
    background: linear-gradient(180deg, #2a2520 0%, #1a1510 100%);
    border: 3px solid #5a4a3a;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 25px;
    min-height: 200px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
    position: relative;
}

.initiative-list::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.04;
    border-radius: 12px;
    pointer-events: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #5a4a3a;
    text-align: center;
}

.empty-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-text {
    font-size: 1.1em;
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.85em;
    color: #4a3a2a;
}

/* Combatant Card */
.combatant-card {
    background: linear-gradient(180deg, #3a3530 0%, #2a2520 100%);
    border: 2px solid #4a3a2a;
    border-radius: 10px;
    padding: 12px 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.combatant-card:last-child {
    margin-bottom: 0;
}

.combatant-card:hover {
    border-color: #6a5a4a;
}

.combatant-card.active {
    border-color: #ffd700;
    background: linear-gradient(180deg, #4a4030 0%, #3a3020 100%);
    box-shadow: 0 0 20px rgba(255, 200, 50, 0.2), inset 0 0 30px rgba(255, 200, 50, 0.05);
}

.combatant-card.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #ffd700 0%, #ff9900 100%);
    border-radius: 10px 0 0 10px;
}

.combatant-card.player {
    border-left: 4px solid #5080c0;
}

.combatant-card.enemy {
    border-left: 4px solid #c05050;
}

.combatant-card.ally {
    border-left: 4px solid #50c080;
}

.combatant-card.lair-action {
    border-left: 4px solid #a050c0;
    background: linear-gradient(180deg, #3a3040 0%, #2a2030 100%);
}

.combatant-card.defeated {
    opacity: 0.5;
    filter: grayscale(50%);
}

/* Shared Initiative Highlighting */
.combatant-card.shared-init .initiative-badge {
    box-shadow: 0 0 8px rgba(255, 200, 50, 0.4);
}

.combatant-card.shared-init-group {
    margin-bottom: 2px;
    border-left-width: 6px;
    position: relative;
}

.combatant-card.shared-init-group::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, rgba(255, 200, 50, 0.6) 0%, rgba(255, 150, 30, 0.4) 100%);
    border-radius: 2px;
}

.combatant-card.shared-init-first {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.combatant-card.shared-init-first::before {
    top: 10px;
    border-radius: 2px 2px 0 0;
}

.combatant-card.shared-init-last {
    margin-bottom: 10px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.combatant-card.shared-init-last::before {
    bottom: 10px;
    border-radius: 0 0 2px 2px;
}

.initiative-badge {
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 100%);
    border: 2px solid #5a4a3a;
    border-radius: 8px;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    font-weight: 700;
    color: #ffd700;
    flex-shrink: 0;
}

.combatant-info {
    flex: 1;
    min-width: 0;
}

.combatant-name {
    font-size: 1.1em;
    color: #e8dcc0;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.combatant-details {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.combatant-hp {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    color: #8b7355;
}

.hp-current {
    color: #80c080;
    font-weight: 600;
}

.hp-current.low {
    color: #c0a050;
}

.hp-current.critical {
    color: #c05050;
}

.hp-max {
    color: #666;
}

.condition-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.condition-badge {
    background: rgba(0,0,0,0.4);
    border: 1px solid #4a3a2a;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.7em;
    color: #c9a86c;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.condition-badge:hover {
    border-color: #8b7355;
    background: rgba(0,0,0,0.6);
}

.condition-badge .duration {
    background: rgba(255, 200, 50, 0.3);
    border-radius: 8px;
    padding: 0 4px;
    color: #ffd700;
    font-weight: 600;
}

.combatant-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    background: rgba(0,0,0,0.3);
    border: 1px solid #4a3a2a;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #8b7355;
    font-size: 0.9em;
}

.action-btn:hover {
    border-color: #8b7355;
    color: #d4a574;
    background: rgba(0,0,0,0.5);
}

.action-btn.damage:hover {
    border-color: #c05050;
    color: #ff6666;
}

.action-btn.heal:hover {
    border-color: #50c080;
    color: #66ff99;
}

/* HP Controls */
.hp-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hp-input {
    width: 50px;
    height: 32px;
    padding: 4px 6px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #4a3a2a;
    border-radius: 6px;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 0.85em;
    text-align: center;
    -moz-appearance: textfield;
}

.hp-input::-webkit-outer-spin-button,
.hp-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hp-input:focus {
    outline: none;
    border-color: #8b7355;
}

.hp-input::placeholder {
    color: #5a4a3a;
}

/* Modals */
.modal, .share-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active, .share-modal.active {
    display: flex;
}

.modal-content, .share-modal-content {
    background: linear-gradient(180deg, #3a3530 0%, #2a2520 50%, #1a1510 100%);
    border: 3px solid #5a4a3a;
    border-radius: 16px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.modal-content.wide {
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content h2, .share-modal-content h2 {
    font-family: 'Cinzel Decorative', serif;
    color: #d4a574;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    color: #8b7355;
    font-size: 0.85em;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 8px;
    color: #e8dcc0;
    font-family: 'Cinzel', serif;
    font-size: 0.95em;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #8b7355;
}

.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 8px;
    color: #e8dcc0;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    resize: vertical;
    min-height: 120px;
}

.bulk-hint {
    font-size: 0.8em;
    color: #6a5a4a;
    margin-top: -10px;
    margin-bottom: 15px;
}

/* Saved List Modal */
.saved-list-container {
    flex: 1;
    min-height: 100px;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 15px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #3a3025;
    border-radius: 8px;
    padding: 10px;
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-list-empty {
    text-align: center;
    color: #5a4a3a;
    padding: 30px;
    font-style: italic;
}

.saved-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #4a3a2a;
    border-radius: 8px;
    padding: 10px 12px;
    transition: all 0.2s ease;
}

.saved-entry:hover {
    border-color: #6a5a4a;
}

.saved-entry.selected {
    border-color: #d4a574;
    background: rgba(212, 165, 116, 0.15);
}

.saved-entry-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #d4a574;
    cursor: pointer;
}

.saved-entry-info {
    flex: 1;
    min-width: 0;
}

.saved-entry-name {
    color: #e8dcc0;
    font-weight: 600;
    font-size: 0.95em;
}

.saved-entry-hp {
    color: #8b7355;
    font-size: 0.8em;
}

.saved-entry-initiative {
    width: 60px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 6px;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    text-align: center;
}

.saved-entry-initiative:focus {
    outline: none;
    border-color: #8b7355;
}

.saved-entry-initiative::placeholder {
    color: #5a4a3a;
}

.saved-entry-delete {
    background: none;
    border: none;
    color: #6a4a4a;
    cursor: pointer;
    font-size: 1.1em;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.saved-entry-delete:hover {
    color: #ff6666;
}

.saved-list-actions {
    margin-bottom: 15px;
}

.new-saved-entry {
    display: flex;
    gap: 8px;
    align-items: center;
}

.new-saved-entry input {
    flex: 1;
    padding: 8px 10px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 6px;
    color: #e8dcc0;
    font-family: 'Cinzel', serif;
    font-size: 0.85em;
}

.new-saved-entry input:focus {
    outline: none;
    border-color: #8b7355;
}

.new-saved-entry input[type="number"] {
    width: 80px;
    flex: none;
}

.modal-btn.small {
    padding: 8px 15px;
    font-size: 0.8em;
}

.init-mod-input {
    width: 70px !important;
    flex: none !important;
}

.saved-entry-qty {
    width: 45px;
    padding: 6px 4px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 6px;
    color: #80c080;
    font-family: 'Cinzel', serif;
    font-size: 0.85em;
    text-align: center;
}

.saved-entry-qty:focus {
    outline: none;
    border-color: #50a050;
}

.saved-entry-roll {
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 100%);
    border: 2px solid #5a4a3a;
    border-radius: 6px;
    padding: 4px 8px;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.saved-entry-roll:hover {
    border-color: #8b7355;
    background: linear-gradient(180deg, #5a5550 0%, #4a4540 100%);
}

.saved-entry-init-mod {
    color: #8b7355;
    font-size: 0.8em;
    min-width: 35px;
    text-align: center;
}

.saved-list-header {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.roll-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
}

.roll-options-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.roll-option {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8b7355;
    font-size: 0.85em;
    cursor: pointer;
}

.roll-option input {
    accent-color: #d4a574;
}

.roll-option:has(input:checked) {
    color: #d4a574;
}

/* Roll Breakdown Popover */
.roll-breakdown-popover {
    position: fixed;
    background: linear-gradient(180deg, #3a3530 0%, #2a2520 100%);
    border: 2px solid #5a4a3a;
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 3000;
    transform: translate(-50%, -100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    min-width: 100px;
    text-align: center;
}

.roll-breakdown-popover::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #5a4a3a;
}

.breakdown-mode {
    color: #d4a574;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.breakdown-rolls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.breakdown-roll {
    color: #8b7355;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.roll-value {
    font-size: 1.1em;
    font-weight: 600;
}

.roll-value.used {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 200, 50, 0.5);
}

.roll-value.unused {
    color: #5a4a3a;
    text-decoration: line-through;
}

.roll-separator {
    color: #5a4a3a;
}

.breakdown-modifier {
    color: #8b7355;
    font-size: 0.8em;
    margin-bottom: 5px;
}

.breakdown-total {
    color: #ffd700;
    font-weight: 600;
    font-size: 0.9em;
    padding-top: 5px;
    border-top: 1px solid #4a3a2a;
}

.saved-entry-initiative.has-breakdown {
    cursor: pointer;
    border-color: #6a5a4a;
}

/* Initiative badge clickable when has breakdown */
.initiative-badge.has-breakdown {
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.initiative-badge.has-breakdown::after {
    content: '🎲';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    opacity: 0.7;
}

.initiative-badge.has-breakdown:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(255, 200, 50, 0.6);
}

.saved-entry-initiative.has-breakdown:hover {
    border-color: #8b7355;
}

.bulk-add-link {
    text-align: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #3a3025;
}

.bulk-add-link a {
    color: #8b7355;
    text-decoration: none;
    font-size: 0.85em;
    cursor: pointer;
    transition: color 0.2s ease;
}

.bulk-add-link a:hover {
    color: #d4a574;
}

.hp-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hp-edit-row input {
    flex: 1;
}

.hp-separator {
    color: #666;
    font-size: 1.2em;
}

.type-buttons {
    display: flex;
    gap: 8px;
}

.type-btn {
    flex: 1;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #4a3a2a;
    border-radius: 6px;
    color: #8b7355;
    font-family: 'Cinzel', serif;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-btn:hover {
    border-color: #6a5a4a;
}

.type-btn.active {
    background: rgba(212, 165, 116, 0.2);
    border-color: #d4a574;
    color: #d4a574;
}

.type-btn[data-type="player"].active {
    background: rgba(80, 128, 192, 0.2);
    border-color: #5080c0;
    color: #80a0d0;
}

.type-btn[data-type="enemy"].active {
    background: rgba(192, 80, 80, 0.2);
    border-color: #c05050;
    color: #d08080;
}

.type-btn[data-type="ally"].active {
    background: rgba(80, 192, 128, 0.2);
    border-color: #50c080;
    color: #80d0a0;
}

.modal-buttons, .share-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal-btn, .share-modal-btn {
    padding: 10px 20px;
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 50%, #2a2520 100%);
    border: 2px solid #5a4a3a;
    border-radius: 8px;
    color: #c9a86c;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:hover, .share-modal-btn:hover {
    border-color: #8b7355;
    transform: translateY(-2px);
}

.modal-btn.primary, .share-modal-btn.primary {
    background: linear-gradient(180deg, #4a5540 0%, #3a4530 50%, #2a3520 100%);
    border-color: #5a6a4a;
    color: #8bba8b;
}

.modal-btn.danger {
    background: linear-gradient(180deg, #5a4540 0%, #4a3530 50%, #3a2520 100%);
    border-color: #6a4a4a;
    color: #ba8b8b;
}

/* Condition Grid */
.condition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.condition-option {
    background: rgba(0,0,0,0.3);
    border: 2px solid #4a3a2a;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.condition-option:hover {
    border-color: #6a5a4a;
    background: rgba(0,0,0,0.5);
}

.condition-option.selected {
    border-color: #d4a574;
    background: rgba(212, 165, 116, 0.2);
}

.condition-icon {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.condition-name {
    font-size: 0.75em;
    color: #c9a86c;
}

/* Share Modal */
.share-url-box {
    background: rgba(0,0,0,0.4);
    border: 2px solid #4a3a2a;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.75em;
    color: #8bba8b;
    max-height: 120px;
    overflow-y: auto;
}

.copy-success {
    color: #80ff80;
    font-size: 0.9em;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-success.show {
    opacity: 1;
}

/* Reference Section */
.reference-section {
    background: linear-gradient(180deg, #2a2520 0%, #1a1510 100%);
    border: 3px solid #5a4a3a;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 6px 25px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
    position: relative;
}

.reference-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.04;
    border-radius: 12px;
    pointer-events: none;
}

.reference-section h2 {
    font-family: 'Cinzel Decorative', serif;
    color: #d4a574;
    font-size: 1.1em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a3a2a;
    position: relative;
}

.condition-reference {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    position: relative;
}

.condition-ref-item {
    background: rgba(0,0,0,0.3);
    border: 1px solid #3a3025;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.8em;
}

.condition-ref-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.condition-ref-icon {
    font-size: 1.2em;
}

.condition-ref-name {
    color: #d4a574;
    font-weight: 600;
}

.condition-ref-desc {
    color: #8a7a6a;
    font-size: 0.9em;
    line-height: 1.4;
}

/* View-only mode */
body.view-only .back-link,
body.view-only .header-banner,
body.view-only .combat-controls,
body.view-only .reference-section,
body.view-only .combatant-actions,
body.view-only .lair-section {
    display: none !important;
}

body.view-only .round-section {
    justify-content: center;
}

.view-only-header {
    display: none;
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
}

body.view-only .view-only-header {
    display: block;
}

.view-only-header h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.8em;
    color: #d4a574;
    margin-bottom: 10px;
}

.view-only-header .subtitle {
    color: #8b7355;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.create-own-btn {
    background: linear-gradient(180deg, #4a4540 0%, #3a3530 50%, #2a2520 100%);
    border: 2px solid #5a4a3a;
    border-radius: 8px;
    padding: 10px 20px;
    font-family: 'Cinzel', serif;
    font-size: 0.9em;
    color: #c9a86c;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
}

.create-own-btn:hover {
    border-color: #8b7355;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px 10px;
    }

    .stone-plate {
        padding: 15px 30px;
    }

    h1 {
        font-size: 1.6em;
    }

    .round-section {
        flex-direction: column;
        text-align: center;
    }

    .combat-controls {
        flex-direction: column;
    }

    .control-btn {
        justify-content: center;
    }

    .combatant-card {
        flex-wrap: wrap;
    }

    .combatant-info {
        width: 100%;
        order: 1;
    }

    .initiative-badge {
        order: 0;
    }

    .combatant-actions {
        order: 2;
        width: 100%;
        justify-content: flex-end;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #3a3025;
    }
}
