/* D&D Combat Simulator - AD&D 2nd Edition Style */

@import 'stat-card.css';

:root {
    --paper: #F3E9D2;
    --paper-aged: #E6D7B5;
    --ink: #1A1A1A;
    --ink-2: #3A342B;
    --iron: #808080;
    --iron-dark: #5A5A5A;
    --iron-dark: #5A5A5A;
    --crimson: #990000;
    --crimson-dark: #660000;
    --brass: #C7A34A;
    --arcane-purple: #8e44ad;
    --rule: rgba(26, 26, 26, .25);
    --shadow: rgba(0, 0, 0, .18);
    --radius: 14px;
    --page-max: 95%;
}

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

/* Page shell */
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(1200px 800px at 50% 20%, rgba(0, 0, 0, .10), transparent 55%),
        linear-gradient(180deg, #151515, #0E0F10);
    font-family: "Bitter", Georgia, serif;
    min-height: 100vh;
    padding: 15px;
}

.container {
    max-width: var(--page-max);
    margin: 10px auto 24px;
}

/* Paper texture */
.panel,
.setup-panel,
.battle-viewer {
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px var(--shadow);
    position: relative;
    padding: 20px;
    margin-bottom: 20px;
}

/* .battle-viewer independent layout handles height now */

.panel {
    overflow: hidden;
}

.setup-panel {
    overflow: visible !important;
}

/* Subtle paper grain */
.panel::before,
.setup-panel::before,
.battle-viewer::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(0, 0, 0, .04), transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(0, 0, 0, .035), transparent 48%),
        linear-gradient(0deg, rgba(0, 0, 0, .03), rgba(0, 0, 0, 0));
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

/* All content above grain */
.panel>*,
.setup-panel>*,
.battle-viewer>* {
    position: relative;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 20px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 5px 20px 10px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: var(--paper);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: 0 4px 12px var(--shadow);
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    font-family: "Bitter", serif;
    font-size: 1.2em;
    font-variant-caps: small-caps;
    font-weight: bold;
    background: transparent;
    color: var(--ink-2);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
}

.tab-button:hover {
    background: var(--paper-aged);
    color: var(--iron);
}

.tab-button.active {
    background: var(--iron);
    color: var(--paper);
    border-color: var(--iron);
    box-shadow: 0 2px 8px rgba(139, 30, 30, 0.3);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Under Construction */
.under-construction {
    text-align: center;
    padding: 80px 20px;
}

.under-construction h3 {
    color: var(--brass);
    font-size: 2em;
    margin-bottom: 15px;
    font-family: "Bitter", serif;
    font-weight: 600;
}

.under-construction p {
    color: var(--ink-2);
    font-size: 1.3em;
    font-style: italic;
}

header h1 {
    font-family: "Cinzel", "Marcellus SC", "EB Garamond", serif;
    font-size: 2.5em;
    color: var(--brass);
    letter-spacing: .05em;
    margin-bottom: 5px;
    font-variant-caps: small-caps;
    font-weight: normal;
}

.subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9em;
    font-style: italic;
}

.subtitle a {
    color: var(--brass);
    text-decoration: none;
    border-bottom: 1px dotted var(--brass);
}

.subtitle a:hover {
    color: rgba(199, 163, 74, 0.8);
    border-bottom-color: rgba(199, 163, 74, 0.8);
}

/* Headings */
h2 {
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    border-bottom: 2px solid var(--iron);
    padding-bottom: 6px;
    margin-top: 1.2em;
    margin-bottom: 20px;
    color: var(--iron);
    font-size: 1.8em;
    letter-spacing: .02em;
    font-weight: 700;
}

h3 {
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    color: var(--crimson);
    margin-bottom: 15px;
    font-size: 1.3em;
    letter-spacing: .02em;
    font-weight: 600;
}

/* Team Setup */
.team-setup {
    display: flex;
    align-items: stretch;
    gap: 30px;
    margin-bottom: 30px;
}

.team-config {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--paper-aged);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--rule);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .08);
    overflow: visible;
}

.team-config:first-child {
    border-color: var(--iron);
}

.team-config:first-child h3 {
    color: var(--iron);
}

.team-config:last-child {
    border-color: var(--crimson);
}

/* Legacy VS divider removed in favor of integrated iron sign */

/* Iron Bolted Sign - Difficulty Indicator Redesign */
.difficulty-indicator {
    margin: 30px auto !important;
    padding: 30px !important;
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%) !important;
    border: 1px solid #000 !important;
    outline: 4px solid #2a2a2a !important;
    outline-offset: -5px !important;
    border-radius: 4px !important;
    text-align: center !important;
    position: relative !important;
    max-width: 90% !important;
    width: 420px !important;
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.8) !important;
    transition: all 0.4s ease !important;
    color: #eee !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100px !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Corner Bolts - Robust placement */
.iron-bolt {
    position: absolute;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 30% 30%, #bbb, #333);
    border-radius: 50%;
    border: 1px solid #000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.iron-bolt-tl {
    top: 12px;
    left: 12px;
}

.iron-bolt-tr {
    top: 12px;
    right: 12px;
}

.iron-bolt-bl {
    bottom: 12px;
    left: 12px;
}

.iron-bolt-br {
    bottom: 12px;
    right: 12px;
}



.difficulty-message {
    font-family: "Cinzel", serif;
    font-size: 1.6em;
    font-variant-caps: small-caps;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
    font-weight: bold;
    text-shadow:
        1px 1px 1px rgba(255, 255, 255, 0.2),
        -1px -1px 0px rgba(0, 0, 0, 0.8);
}

.xp-breakdown {
    font-family: "Bitter", serif;
    font-size: 0.9em;
    font-style: italic;
    color: #888;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 10px;
    width: 100%;
}

/* Match States - Engraved Glow Effects */
.difficulty-indicator.good-match .difficulty-message {
    color: var(--brass);
    text-shadow: 0 0 10px rgba(199, 163, 74, 0.4);
}

.difficulty-indicator.challenging .difficulty-message {
    color: #aaa;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.difficulty-indicator.very-challenging .difficulty-message,
.difficulty-indicator.bloodbath .difficulty-message {
    color: #ff4444;
    text-shadow: 0 0 12px rgba(255, 0, 0, 0.4);
}


.creature-builder {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    overflow: visible;
}

.creature-select,
.ai-select {
    flex: 1;
    padding: 10px;
    background: white;
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-family: "Bitter", Georgia, serif;
    font-size: 1.05em;
}

.creature-select:focus,
.ai-select:focus {
    outline: none;
    border-color: var(--brass);
}

/* Typeahead styles */
.typeahead-wrapper {
    flex: 1;
    position: relative;
    overflow: visible;
    z-index: 100;
}

.creature-typeahead {
    width: 100%;
    padding: 10px 35px 10px 10px;
    /* Extra padding-right for clear button */
    background: white;
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-family: "Bitter", Georgia, serif;
    font-size: 1.05em;
}

.creature-typeahead:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 2px rgba(199, 163, 74, 0.2);
}

/* Clear button inside input */
.input-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--ink-2);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.input-clear-btn:hover {
    background: var(--iron);
    transform: translateY(-50%) scale(1.1);
}

.typeahead-suggestions {
    /* Position set dynamically by JavaScript */
    background: white;
    border: 1px solid var(--rule);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 999999;
    display: none;
    box-shadow: 0 4px 8px var(--shadow);
}

.typeahead-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(26, 26, 26, .1);
    transition: background 0.15s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--paper-aged);
}

.suggestion-name {
    font-weight: bold;
    color: var(--ink);
}

.suggestion-cr {
    font-size: 0.9em;
    color: var(--ink-2);
    margin-left: 8px;
}

.suggestion-legendary {
    color: var(--brass);
    margin-left: 5px;
}

.suggestion-count {
    font-size: 0.85em;
    color: var(--brass);
    margin-left: 8px;
    font-weight: bold;
}

.suggestion-item.in-team {
    background: rgba(199, 163, 74, 0.1);
    border-left: 3px solid var(--brass);
}

.suggestion-item.in-team:hover {
    background: rgba(199, 163, 74, 0.2);
}

.suggestion-group-header {
    padding: 8px 10px;
    background: var(--paper-aged);
    font-size: 0.85em;
    font-weight: bold;
    color: var(--iron);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 1;
    font-family: "Bitter", serif;
}

.count-input,
.sim-input {
    width: 80px;
    padding: 10px;
    background: white;
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-family: "Bitter", Georgia, serif;
    text-align: center;
    transition: all 0.2s ease;
}

.count-input:focus,
.sim-input:focus {
    outline: none;
    border-color: var(--brass);
}

.count-input:invalid,
.count-input.error {
    border-color: var(--iron);
    background: rgba(139, 30, 30, 0.05);
}

.count-input:valid:not(:placeholder-shown) {
    border-color: rgba(45, 110, 45, 0.4);
}

.sim-input {
    width: 120px;
}

.btn-add {
    padding: 10px 20px;
    background: var(--crimson);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: "Bitter", Georgia, serif;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 0 2px 4px var(--shadow);
}

.btn-add:hover {
    background: #2a5fa0;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.composition-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 40px;
    flex: 1;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--rule);
    position: relative;
    transition: all 0.3s ease;
}

.composition-display.empty {
    border-color: rgba(139, 30, 30, 0.3);
    background: rgba(139, 30, 30, 0.02);
}

.composition-display.valid {
    border-color: rgba(45, 110, 45, 0.4);
    background: rgba(45, 110, 45, 0.02);
}

.composition-display.empty::after {
    content: 'Add creatures to this team';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--ink-2);
    font-style: italic;
    font-size: 0.9em;
    opacity: 0.5;
    pointer-events: none;
}

.composition-display:not(.empty)::after {
    display: none;
}

.composition-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.composition-item:hover {
    border-color: var(--brass);
    transform: translateX(4px);
}

@keyframes highlight-flash {
    0% {
        background-color: rgba(199, 163, 74, 0.4);
        border-color: var(--brass);
        transform: translateX(4px);
    }

    100% {
        background-color: var(--paper);
        border-color: var(--rule);
        transform: translateX(0);
    }
}

.composition-item.highlight-flash {
    animation: highlight-flash 1s ease-out forwards;
}

.composition-token {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--rule);
    flex-shrink: 0;
    background: var(--paper-aged);
}

.composition-token img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.composition-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.composition-name {
    font-weight: bold;
    color: var(--ink);
    font-size: 0.95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.composition-cr {
    font-size: 0.8em;
    color: var(--ink-2);
    font-style: italic;
}

.composition-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Stacked layout for roster panel */
.composition-info-stacked {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.composition-info-stacked .composition-name {
    font-weight: bold;
    color: var(--ink);
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.composition-info-stacked .composition-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.composition-count {
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    font-family: monospace;
}

.btn-icon.small {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.btn-icon.remove:hover {
    color: var(--iron);
    background: rgba(139, 30, 30, 0.1);
}

.composition-tag {
    padding: 5px 12px;
    background: var(--paper-aged);
    border: 1px solid var(--rule);
    border-radius: 12px;
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.composition-tag:hover {
    background: var(--paper);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px var(--shadow);
}

.composition-tag.selected {
    background: var(--ink-2);
    color: var(--paper);
    border-color: var(--ink-2);
    box-shadow: 0 2px 8px var(--shadow);
}

.composition-tag .remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--iron);
    opacity: 0.7;
}

.composition-tag.selected .remove {
    color: var(--paper);
    opacity: 0.9;
}

.composition-tag .remove:hover {
    opacity: 1;
}

/* Simulation Config */
.simulation-config {
    background: var(--paper-aged);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--rule);
}

.config-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.config-row label {
    min-width: 200px;
    font-weight: bold;
    color: var(--ink);
}

.config-row:last-child {
    margin-bottom: 0;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-nav,
.btn-close {
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-family: "Bitter", Georgia, serif;
    font-size: 1.05em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px var(--shadow);
}

.btn-primary {
    background: var(--iron);
    color: white;
}

.btn-primary:hover {
    background: #a02424;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-large {
    width: 100%;
    padding: 15px;
    font-size: 1.3em;
    letter-spacing: .05em;
}

.btn-secondary {
    background: var(--crimson);
    color: white;
}

.btn-secondary:hover {
    background: #2a5fa0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-nav {
    background: var(--paper-aged);
    color: var(--ink);
    border: 1px solid var(--rule);
}

.btn-nav:hover {
    background: var(--paper);
}

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

.btn-close {
    background: var(--iron);
    color: white;
    padding: 8px 15px;
}

.btn-close:hover {
    background: #a02424;
}

/* Battle Buttons */
.battle-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
}

.btn-battle {
    flex: 1;
    min-width: 140px;
    padding: 12px 20px;
    font-size: 1.1em;
}

.btn-large {
    flex-basis: 100%;
    position: relative;
}

/* Fight button validation states */
#single-battle-btn {
    transition: all 0.3s ease;
}

#single-battle-btn.not-ready {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--ink-2);
}

#single-battle-btn.not-ready:hover {
    transform: none;
    box-shadow: 0 2px 6px var(--shadow);
}

#single-battle-btn.not-ready {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--ink-2);
}

#single-battle-btn.not-ready:hover {
    transform: none;
    box-shadow: 0 2px 6px var(--shadow);
}

.battle-validation-message {
    width: 100%;
    text-align: center;
    padding: 8px;
    margin-top: -5px;
    font-size: 0.9em;
    color: var(--iron);
    font-style: italic;
    display: none;
}

.battle-validation-message.show {
    display: block;
}

/* Status Message */
.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    border: 2px solid;
    position: relative;
    z-index: 100;
    display: none;
}

.status-message:not(:empty) {
    display: block;
}

.status-message.loading {
    background: rgba(199, 163, 74, 0.15);
    color: var(--brass);
    border-color: var(--brass);
}

.status-message.success {
    background: rgba(31, 79, 138, 0.15);
    color: var(--crimson);
    border-color: var(--crimson);
}

.status-message.error {
    background: rgba(139, 30, 30, 0.15);
    color: var(--iron);
    border-color: var(--iron);
}

/* Loading dots animation */
.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Battle Viewer */
.battle-viewer {
    position: relative;
    max-width: none;
    margin: 0 auto;
    padding: 15px;
    height: calc(100vh - 250px);
    display: flex;
    flex-direction: column;
    min-height: 400px;
    overflow: hidden;
    z-index: 1;
}

.setup-panel {
    position: relative;
}


/* Step buttons */
#step-back-btn,
#step-forward-btn {
    min-width: 50px;
    font-size: 1.2em;
    font-weight: bold;
}

#step-back-btn:disabled,
#step-forward-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#step-back-btn:hover:not(:disabled),
#step-forward-btn:hover:not(:disabled) {
    background: var(--brass);
    border-color: var(--brass);
    color: white;
}

.round-indicator {
    font-size: 1.2em;
    font-weight: bold;
    min-width: 200px;
    text-align: center;
    color: var(--iron);
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
}

.counter-separator {
    margin: 0 10px;
    color: var(--brass);
    opacity: 0.6;
}

.battle-content {
    display: grid;
    grid-template-columns: 320px 1fr 400px;
    grid-template-rows: 1fr;
    grid-template-areas: "info battlefield log";
    gap: 15px;
    margin-bottom: 0;
    align-items: stretch;
    height: 100%;
    min-height: 0;
}

.battlefield-container {
    grid-area: battlefield;
    position: relative;
    background: #ffffff;
    border: 3px solid var(--brass);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .08);
    min-height: 0;
}

#battlefield {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #F3E9D2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}




/* Ensure grid items can shrink */
.battle-info,
.battlefield-container,
.action-log {
    min-height: 0;
}

.battle-info.roster-panel {
    grid-area: info;
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    overflow: hidden;
    background: var(--paper);
    padding: 0;
}

.battle-info .roster-header {
    flex: 0 0 auto;
    padding: 10px 15px;
    border-bottom: 2px solid var(--iron);
}

.battle-info .team-roster-group {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.battle-info .team-status.team-config {
    flex: 0 0 auto;
    margin: 0;
    padding: 10px 15px;
    border: none;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    background: transparent;
}

.battle-info .team-status.team-config:hover {
    background: rgba(0, 0, 0, 0.02);
}

.battle-info .creature-list {
    max-height: 300px;
    margin-top: 5px;
}

.battle-info .creature-item.composition-item {
    margin-bottom: 4px;
    padding: 6px 10px;
}

.battle-info .creature-item .creature-name {
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.battle-info .creature-item .hp-text {
    font-size: 0.8em;
}

.battle-info .team-status[onclick] {
    cursor: default;
    /* Disable accordion click look if we want it always open or managed differently */
}

@media (min-width: 769px) {
    .battle-info .team-status.collapsed {
        /* On desktop we might want them expanded by default now */
    }
}

.team-status:first-child {
    border-color: var(--iron);
}

.team-status:first-child h3 {
    color: var(--iron);
}

.team-status:last-child {
    border-color: var(--crimson);
}

.team-status h3 {
    position: sticky;
    top: 0;
    background: var(--paper-aged);
    padding-bottom: 10px;
    margin-bottom: 10px;
    z-index: 1;
}

.creature-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.creature-item {
    padding: 10px;
    background: white;
    border-radius: 4px;
    border-left: 4px solid;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.creature-item.team0 {
    border-left-color: var(--iron);
}

.creature-item.team1 {
    border-left-color: var(--crimson);
}

.creature-item.dead {
    opacity: 0.4;
}

.creature-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--ink);
}

.hp-bar {
    width: 100%;
    height: 10px;
    background: var(--paper-aged);
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.hp-fill {
    height: 100%;
    background: var(--crimson);
    transition: width 0.3s;
}

.hp-fill.low {
    background: var(--brass);
}

.hp-fill.critical {
    background: var(--iron);
}

.hp-text {
    font-size: 0.9em;
    color: var(--ink-2);
}

/* Action Log */
.action-log {
    grid-area: log;
    background: var(--paper-aged);
    padding: 0;
    border-radius: 8px;
    border: 2px solid var(--rule);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.action-log h3 {
    color: var(--iron);
    margin-bottom: 0;
    font-size: 1.2em;
    margin-top: 0;
}

/* Action Log Header */
.action-log-header {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 15px;
    border-bottom: 2px solid var(--rule);
}

.log-counter-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.log-counter-text {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--iron);
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    min-width: 140px;
    text-align: center;
}

.log-autoplay-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
}

.btn-autoplay {
    padding: 10px 30px;
    background: #8B1E1E;
    color: white;
    border: 2px solid #8B1E1E;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    min-width: 140px;
}

.btn-autoplay:hover {
    background: #a02424;
    border-color: #a02424;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(139, 30, 30, 0.3);
}

.btn-autoplay:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(139, 30, 30, 0.3);
}

.btn-speed {
    padding: 8px 14px;
    background: #8B1E1E;
    color: white;
    border: 2px solid #8B1E1E;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.2s;
    min-width: 50px;
}

.btn-speed:hover {
    background: #a02424;
    border-color: #a02424;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(139, 30, 30, 0.3);
}

.btn-speed:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(139, 30, 30, 0.3);
}

/* Small navigation buttons for counters */
.btn-nav-small {
    padding: 6px 12px;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.15s;
    min-width: 36px;
}

.btn-nav-small:hover {
    background: var(--brass);
    color: white;
    border-color: var(--brass);
}

.btn-nav-small:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Icon-only playback buttons (for any remaining icon buttons) */
.btn-icon {
    padding: 8px 14px;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.3em;
    transition: all 0.15s;
    min-width: 42px;
}

.btn-icon:hover {
    background: var(--crimson);
    color: white;
    border-color: var(--crimson);
    transform: translateY(-1px);
}

.btn-icon-primary {
    background: var(--iron);
    color: white;
    border-color: var(--iron);
}

.btn-icon-primary:hover {
    background: #a02424;
    border-color: #a02424;
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.action-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.action-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: white;
    border-radius: 4px;
    border-left: 4px solid var(--brass);
    font-size: 1em;
    line-height: 1.6;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.action-item:hover {
    background: var(--paper);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

/* Team-specific action colors */
.action-item.team0 {
    border-left-color: var(--iron);
}

.action-item.team1 {
    border-left-color: var(--crimson);
}

/* Action type styling */
.action-item.attack {
    border-left-width: 5px;
}

.action-item.legendary_action,
.action-item.legendary {
    border-left-color: var(--brass);
    border-left-width: 6px;
    font-weight: bold;
    background: rgba(199, 163, 74, 0.08);
}

/* Enhanced action text styling */
.action-label {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: .5px;
    color: var(--brass);
    font-family: "Bitter", serif;
}

.actor-name {
    font-weight: bold;
}

.actor-name.team0 {
    color: var(--iron);
}

.actor-name.team1 {
    color: var(--crimson);
}

.hit {
    color: #2d6e2d;
    font-weight: bold;
}

.miss {
    color: #666666;
    font-weight: bold;
}

.damage {
    color: var(--iron);
    font-weight: bold;
}

.healing {
    color: #22C55E;
    font-weight: bold;
}

.blocked {
    color: #9CA3AF;
    font-weight: bold;
}

.killed {
    color: var(--iron);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
}

.save-success {
    color: #2d6e2d;
    font-weight: bold;
}

.save-fail {
    color: var(--arcane-purple);
    font-weight: bold;
}

.death-burst {
    color: #d97706;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(217, 119, 6, 0.3);
}

/* Condition Badges */
.conditions {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.condition-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: bold;
    background: white;
    color: var(--iron);
    border: 1px solid var(--iron);
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: help;
    transition: all 0.15s;
}

.condition-badge:hover {
    background: var(--iron);
    color: white;
}

/* Different colors for different condition types */
.condition-badge[title^="Poisoned"] {
    color: #2d6e2d;
    border-color: #2d6e2d;
}

.condition-badge[title^="Poisoned"]:hover {
    background: #2d6e2d;
}

.condition-badge[title^="Paralyzed"],
.condition-badge[title^="Stunned"],
.condition-badge[title^="Unconscious"] {
    color: var(--crimson);
    border-color: var(--crimson);
}

.condition-badge[title^="Paralyzed"]:hover,
.condition-badge[title^="Stunned"]:hover,
.condition-badge[title^="Unconscious"]:hover {
    background: var(--crimson);
}

/* Victory Overlay */
.victory-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 60px;
    text-align: center;
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    font-size: 3em;
    font-weight: bold;
    letter-spacing: 0.1em;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    transition: opacity 0.5s ease;
    background: linear-gradient(135deg, rgba(242, 234, 211, 0.95), rgba(242, 234, 211, 0.98));
    border: 3px solid var(--brass);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.victory-overlay.show {
    opacity: 1;
}

.victory-overlay.team0 {
    color: var(--iron);
    border-color: var(--iron);
}

.victory-overlay.team1 {
    color: var(--crimson);
    border-color: var(--crimson);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--paper-aged);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--brass);
    border-radius: 6px;
    border: 2px solid var(--paper-aged);
}

::-webkit-scrollbar-thumb:hover {
    background: #b89440;
}

/* Stat Block - 5E Style */
.stat-block-container {
    margin: 30px 0;
    padding: 0;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Two-column stat blocks wrapper */
.stat-blocks-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stat-block {
    background: var(--paper);
    border: 2px solid var(--iron);
    border-radius: 6px;
    padding: 25px;
    box-shadow: 0 4px 12px var(--shadow);
    font-family: "Bitter", Georgia, serif;
    max-height: 500px;
    overflow-y: auto;
}

/* Team-specific stat block borders */
.team0-stat-block {
    border-color: var(--iron);
}

.team1-stat-block {
    border-color: var(--crimson);
}

.stat-block-header {
    margin-bottom: 15px;
    border-bottom: 3px solid var(--iron);
    padding-bottom: 10px;
}

.team0-stat-block .stat-block-header {
    border-bottom-color: var(--iron);
}

.team1-stat-block .stat-block-header {
    border-bottom-color: var(--crimson);
}

.stat-block-header h2 {
    font-family: "Bitter", serif;
    font-size: 2.2em;
    color: var(--iron);
    margin: 0 0 5px 0;
    border: none;
    padding: 0;
    letter-spacing: 0.05em;
    font-variant-caps: small-caps;
    font-weight: 700;
}

.stat-block-subtitle {
    font-style: italic;
    color: var(--ink-2);
    font-size: 1.1em;
    margin: 0;
}

.stat-block-section {
    break-inside: avoid;
    margin-bottom: 15px;
}

.stat-block-bar {
    height: 2px;
    background: var(--brass);
    margin: 12px 0;
}

.stat-block-row {
    margin: 8px 0;
    line-height: 1.6;
    font-size: 1.05em;
}

.stat-block-row strong {
    color: var(--iron);
    font-weight: bold;
}

.stat-block-abilities {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    text-align: center;
    margin: 15px 0;
}

.ability-score {
    font-size: 0.95em;
}

.ability-score strong {
    color: var(--crimson);
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

.ability-score span {
    color: var(--ink);
    font-weight: bold;
}

.stat-block-trait,
.stat-block-action {
    margin: 12px 0;
    break-inside: avoid;
}

.stat-block-trait-name,
.stat-block-action-name {
    font-weight: bold;
    font-style: italic;
    color: var(--iron);
    font-size: 1.1em;
}

.stat-block-trait-desc,
.stat-block-action-desc {
    margin-top: 4px;
    color: var(--ink);
    line-height: 1.5;
}

.stat-block-section-title {
    font-family: "Bitter", serif;
    font-variant-caps: small-caps;
    font-size: 1.5em;
    color: var(--iron);
    margin: 15px 0 10px 0;
    border-bottom: 2px solid var(--brass);
    padding-bottom: 4px;
    font-weight: 600;
}

/* Coded/Uncoded Indicator Badges */
.ability-coded-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: "Bitter", serif;
}

.ability-coded-badge.coded {
    background: rgba(31, 79, 138, 0.15);
    color: var(--crimson);
    border: 1px solid var(--crimson);
}

.ability-coded-badge.not-coded {
    background: rgba(139, 30, 30, 0.1);
    color: var(--iron);
    border: 1px solid var(--iron);
    opacity: 0.6;
}

.legendary-section {
    background: linear-gradient(135deg, rgba(199, 163, 74, 0.08), rgba(199, 163, 74, 0.15));
    border: 2px solid var(--brass);
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
}

.legendary-section .stat-block-section-title {
    color: var(--brass);
    border-bottom-color: var(--brass);
}

/* Responsive adjustments */


@media (max-width: 1024px) {
    body {
        padding: 10px;
    }

    .container {
        margin: 20px auto;
    }

    header h1 {
        font-size: 2.2em;
    }

    .battle-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "info"
            "battlefield"
            "log";
    }

    .battle-info {
        order: 1;
        max-height: none;
        height: auto;
    }

    .battlefield-container {
        order: 2;
        padding: 5px;
    }

    .action-log {
        order: 3;
        max-height: 300px;
    }

    #battlefield {
        width: 100%;
        max-width: 1000px;
        height: auto;
        aspect-ratio: 1;
    }

    .creature-list {
        max-height: 200px;
    }

    .action-list {
        max-height: 250px;
    }

    .stat-block {
        column-count: 1;
        column-rule: none;
    }

    .team-setup {
        flex-direction: column;
        gap: 15px;
    }

    .vs-divider {
        transform: rotate(90deg);
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .panel,
    .setup-panel,
    .battle-viewer {
        padding: 15px;
        border-radius: 8px;
    }

    header {
        margin-bottom: 15px;
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    /* Legacy VS divider removed */

    /* Mobile-friendly tabs */
    .tab-navigation {
        padding: 6px;
        margin-bottom: 15px;
    }

    .tab-button {
        padding: 12px 10px;
        font-size: 1em;
        min-height: 48px;
        /* Touch-friendly */
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1.1em;
    }

    /* Make buttons touch-friendly */
    .btn-primary,
    .btn-secondary,
    .btn-nav,
    .btn-close {
        padding: 14px 24px;
        font-size: 1.1em;
        min-height: 44px;
    }

    .btn-add {
        padding: 12px 18px;
        min-height: 44px;
    }

    /* Stack controls vertically */
    .round-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .autoplay-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .speed-select {
        width: 100%;
        max-width: 200px;
        min-height: 44px;
    }

    /* Make creature builder stack on mobile */
    .creature-builder {
        flex-direction: column;
    }

    .count-input,
    .sim-input {
        width: 100%;
        min-height: 44px;
    }

    .creature-typeahead,
    .ai-select {
        min-height: 44px;
    }

    /* Mobile battle viewer - stack vertically: teams, battlefield, actions */
    .battle-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 12px;
    }

    .battle-info {
        display: flex;
        flex-direction: row;
        gap: 10px;
        max-height: none;
    }

    .team-status {
        flex: 1;
    }

    .team-status h3 {
        cursor: pointer;
        user-select: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .team-status h3::after {
        content: '▼';
        font-size: 0.7em;
        transition: transform 0.2s;
    }

    .team-status.collapsed h3::after {
        transform: rotate(-90deg);
    }

    .team-status.collapsed .creature-list {
        display: none;
    }

    .team-summary {
        display: none;
        padding: 8px 0;
        font-size: 0.85em;
        border-top: 1px solid var(--rule);
        margin-top: 5px;
    }

    .team-summary-stat {
        display: flex;
        justify-content: space-between;
        margin-bottom: 3px;
        color: var(--ink-2);
    }

    .team-summary-stat strong {
        color: var(--ink);
    }

    .team-status.collapsed .team-summary {
        display: block;
    }

    .battlefield-container {
        order: 2;
        padding: 5px;
    }

    .action-log {
        order: 3;
        padding: 10px;
        max-height: 300px;
    }

    #battlefield {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .viewer-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .team-status {
        padding: 10px;
    }

    .team-status h3 {
        font-size: 0.95em;
        margin-bottom: 8px;
    }

    .creature-list {
        max-height: none;
    }

    .creature-item {
        padding: 8px;
    }

    .creature-name {
        font-size: 0.85em;
    }

    .hp-text {
        font-size: 0.8em;
    }

    .action-log h3 {
        font-size: 1em;
        margin-bottom: 8px;
    }

    .action-list {
        max-height: 250px;
    }

    .action-item {
        padding: 8px;
        font-size: 0.85em;
        margin-bottom: 6px;
    }

    /* Make stat blocks more compact */
    .stat-block {
        padding: 15px;
        font-size: 0.95em;
    }

    /* Stack stat blocks on mobile */
    .stat-blocks-wrapper {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-block-header h2 {
        font-size: 1.8em;
    }

    .stat-block-abilities {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    /* Victory banner */
    .victory-banner {
        padding: 15px;
    }

    .victory-content h2 {
        font-size: 1.6em;
    }

    .victory-content p {
        font-size: 1em;
    }

    /* Config rows */
    .config-row {
        flex-direction: column;
        align-items: stretch;
    }

    .config-row label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    h2 {
        font-size: 1.3em;
    }

    h3 {
        font-size: 1.1em;
    }

    .panel,
    .setup-panel,
    .battle-viewer {
        padding: 10px;
    }

    header {
        padding: 10px;
    }

    .round-indicator {
        font-size: 1em;
        min-width: auto;
    }

    .action-indicator {
        font-size: 0.9em;
    }

    .creature-name {
        font-size: 0.9em;
    }

    .hp-text {
        font-size: 0.85em;
    }

    .composition-tag {
        font-size: 0.85em;
        padding: 4px 10px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-nav,
    .btn-close {
        padding: 12px 20px;
        font-size: 1em;
    }

    .stat-block-abilities {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Welcome Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--paper);
    padding: 40px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s;
    position: relative;
}

.modal-content h2 {
    color: var(--iron);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 2em;
}

.modal-content>p {
    font-size: 1.2em;
    color: var(--ink-2);
    margin-bottom: 25px;
}

.welcome-section {
    margin-bottom: 25px;
}

.welcome-section h3 {
    color: var(--brass);
    margin-bottom: 10px;
    font-size: 1.4em;
}

.welcome-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.welcome-section li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: var(--ink);
}

.welcome-section li::before {
    content: "⚔";
    position: absolute;
    left: 0;
    color: var(--brass);
}

.modal-content .btn-large {
    width: 100%;
    margin-top: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Creature Size Classes - for grid tokens */
.creature-size-tiny {
    transform: scale(0.5);
}

.creature-size-small {
    transform: scale(0.75);
}

.creature-size-medium {
    transform: scale(1);
}

.creature-size-large {
    transform: scale(2);
}

.creature-size-huge {
    transform: scale(3);
}

.creature-size-gargantuan {
    transform: scale(4);
}

/* Team Introduction Modal */
.team-intro-modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.team-intro-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.team-intro-content {
    background: var(--paper);
    padding: 40px;
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s;
    position: relative;
}

.team-intro-content h2 {
    color: var(--iron);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 2.2em;
    text-align: center;
}

.team-intro-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 30px;
}

.team-intro-section {
    background: var(--paper-aged);
    padding: 20px;
    border-radius: 8px;
    border: 3px solid;
}

.team-intro-section.team0 {
    border-color: var(--iron);
}

.team-intro-section.team1 {
    border-color: var(--crimson);
}

.team-intro-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.6em;
    text-align: center;
}

.team-intro-section.team0 h3 {
    color: var(--iron);
}

.team-intro-section.team1 h3 {
    color: var(--crimson);
}

.team-intro-creatures {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.team-intro-creature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 2px solid var(--rule);
}

.team-intro-token {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid;
    object-fit: cover;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    background: var(--paper-aged);
}

.team-intro-token[data-src] {
    opacity: 0.3;
}

.team-intro-token.loaded {
    opacity: 1;
}

.team-intro-token-stack {
    position: relative;
    height: 50px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.team-intro-token-stack .team-intro-token {
    position: absolute;
    top: 0;
    background: white;
    /* Ensure tokens mask each other */
}

/* Hover effect for the stack */
.team-intro-creature:hover .team-intro-token-stack .team-intro-token {
    transform: translateY(-2px);
}

.team-intro-section.team0 .team-intro-token {
    border-color: var(--iron);
}

.team-intro-section.team1 .team-intro-token {
    border-color: var(--crimson);
}

.team-intro-creature-info {
    flex: 1;
}

.team-intro-creature-name {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--ink);
    margin-bottom: 3px;
}

.team-intro-creature-stats {
    font-size: 0.9em;
    color: var(--ink-2);
}

.creature-count {
    font-size: 0.9em;
    color: var(--brass);
    font-weight: bold;
    margin-left: 5px;
    background: rgba(199, 163, 74, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(199, 163, 74, 0.3);
}

/* Team-specific token colors in composition display */
#team0-composition .team-intro-token {
    border-color: var(--iron);
}

#team1-composition .team-intro-token {
    border-color: var(--crimson);
}

.composition-remove-btn {
    padding: 6px 12px;
    background: var(--iron);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: "Bitter", Georgia, serif;
    font-size: 0.85em;
    font-weight: bold;
    transition: all 0.2s ease;
}

.composition-remove-btn:hover {
    background: #a02424;
    transform: translateY(-1px);
}

.team-intro-vs {
    font-size: 3em;
    font-weight: bold;
    color: var(--brass);
    font-family: "Bitter", serif;
    letter-spacing: .1em;
    align-self: center;
}

.battle-summary-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    align-self: center;
}




.health-dots {
    display: flex;
    gap: 3px;
    margin-top: 5px;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--ink-2);
}

.health-dot.filled {
    background-color: var(--iron);
}

.health-dot.empty {
    background-color: transparent;
}

.health-dot.healing {
    background-color: #22C55E;
}

.health-dot.temp-hp {
    background-color: #3B82F6;
}

.team-intro-content .btn-large {
    width: 100%;
    margin-top: 10px;
}

/* Mobile responsiveness for team intro */
@media (max-width: 768px) {
    .battle-content {
        grid-template-columns: 1fr;
        grid-template-areas:
            "info"
            "battlefield"
            "log";
        gap: 15px;
    }

    .team-intro-teams {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .team-intro-vs {
        display: none;
    }

    .team-intro-content {
        padding: 25px;
    }

    .team-intro-content h2 {
        font-size: 1.8em;
    }

    .team-intro-section h3 {
        font-size: 1.3em;
    }
}

/* Footer */
.page-footer {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    font-family: "Bitter", serif;
}

.page-footer a {
    color: var(--brass);
    text-decoration: none;
    border-bottom: 1px dotted var(--brass);
    transition: all 0.2s;
    margin: 0 5px;
}

.page-footer a:hover {
    color: rgba(199, 163, 74, 0.8);
    border-bottom-color: rgba(199, 163, 74, 0.8);
}

/* Saved Battles UI */
.saved-battles-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.battle-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: 0.9rem;
}

.battle-filter-select {
    padding: 8px 12px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: 0.9rem;
    background-color: white;
    cursor: pointer;
}

.saved-battles-container {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--rule);
    border-radius: 4px;
}

.battles-table {
    width: 100%;
    border-collapse: collapse;
}

.battles-table th {
    background-color: #f5f5f5;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--rule);
    position: sticky;
    top: 0;
    background-color: #f8f8f8;
}

.battles-table td {
    padding: 12px;
    border-bottom: 1px solid var(--rule);
}

.battles-table tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.battle-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.battle-row:hover {
    background-color: rgba(211, 13, 13, 0.05);
}

.battle-winner {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
}

.battle-winner.team0 {
    background-color: rgba(128, 128, 128, 0.1);
    color: #808080;
    /* Iron Gray */
}

.battle-winner.team1 {
    background-color: rgba(153, 0, 0, 0.1);
    color: #990000;
    /* Crimson Red */
}

.battle-winner.draw {
    background-color: rgba(128, 128, 128, 0.1);
    color: #666;
}

.loading-text {
    text-align: center;
    padding: 40px;
    color: #888;
    font-style: italic;
}

.no-battles-text {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Monster Gallery - Consistent Theme */
.monster-gallery-container {
    margin-top: 20px;
    overflow: hidden;
    /* Constrain height */
    display: flex;
    flex-direction: column;
    height: 600px;
    /* Fixed height for the container */
    background: var(--paper-aged);
    /* Matches other panels */
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--shadow);
}

.gallery-header {
    margin-bottom: 20px;
    flex-shrink: 0;
    border-bottom: 2px solid var(--iron);
    padding-bottom: 15px;
}

.gallery-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.gallery-title-row h3 {
    margin: 0;
    font-family: "Cinzel", serif;
    font-size: 1.5em;
    color: var(--iron);
}

/* Team Target Toggle */
.team-target-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    font-size: 0.95em;
    font-weight: bold;
    color: var(--ink);
    font-family: "Bitter", serif;
}

.toggle-buttons {
    display: flex;
    background: var(--paper);
    /* Consistent theme */
    border-radius: 6px;
    border: 1px solid var(--rule);
    overflow: hidden;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: "Bitter", serif;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--ink-2);
}

.toggle-btn.active {
    color: white;
    /* Keep white text for active state */
}

.toggle-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
}

/* Specific colors for team toggle active states */
#target-team-0.active {
    background: var(--iron);
}

#target-team-1.active {
    background: var(--crimson);
}

.gallery-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.03);
    /* Subtle dark overlay instead of hard white/gray */
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--rule);
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-item input[type="text"],
.filter-item input[type="number"],
.filter-item select {
    padding: 8px 12px;
    border: 1px solid var(--brass);
    /* Brass border for inputs */
    border-radius: 4px;
    font-family: "Bitter", serif;
    background: var(--paper);
    /* Paper background */
    font-size: 0.9em;
    color: var(--ink);
}

.filter-item input[type="text"] {
    width: 220px;
}

.filter-item input[type="number"] {
    width: 70px;
}

.gallery-stats {
    margin-left: auto;
    font-size: 0.9em;
    color: var(--ink-2);
    font-weight: bold;
    font-family: "Bitter", serif;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    /* Slightly adjusted size */
    gap: 15px;
    overflow-y: auto;
    flex: 1;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    /* Very subtle texture */
    border: 1px solid var(--rule);
    border-radius: 4px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.05);
}

.gallery-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--ink-2);
    font-style: italic;
    font-family: "Bitter", serif;
}

/* Skeleton Loading Animations */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            var(--paper-aged) 0%,
            var(--paper) 50%,
            var(--paper-aged) 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
}

.skeleton-card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 4px var(--shadow);
}

.skeleton-token {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
    background: linear-gradient(90deg,
            #d4c5a9 0%,
            #e6d7b5 50%,
            #d4c5a9 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.title {
    width: 80%;
    height: 16px;
    margin-bottom: 10px;
}

.skeleton-text.subtitle {
    width: 50%;
    height: 12px;
}

/* Battle Loading Overlay */
.battle-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(243, 233, 210, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    border-radius: var(--radius);
}

.battle-loading-overlay.hidden {
    display: none;
}

.battle-loading-spinner {
    width: 80px;
    height: 80px;
    border: 6px solid var(--paper-aged);
    border-top-color: var(--iron);
    border-right-color: var(--brass);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.battle-loading-text {
    margin-top: 20px;
    font-family: "Bitter", serif;
    font-size: 1.3em;
    color: var(--iron);
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

.battle-loading-subtext {
    margin-top: 8px;
    font-family: "Bitter", serif;
    font-size: 0.95em;
    color: var(--ink-2);
    font-style: italic;
}

/* Monster Card - Consistent Theme */
.monster-card {
    background: var(--paper);
    /* Matches app theme */
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* STRICT CENTER ALIGNMENT */
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    box-shadow: 0 2px 4px var(--shadow);
    text-align: center;
    /* Ensure text is centered */
}

.monster-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
    border-color: var(--brass);
    z-index: 10;
}

.gallery-token-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
    /* Force center horizontally */
    overflow: hidden;
    position: relative;
    border: 3px solid var(--brass);
    /* BRASS BORDER */
    background: #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.monster-card:hover .gallery-token-container {
    border-color: var(--iron);
    /* Highlight on hover */
    transform: scale(1.05);
    transition: all 0.2s;
}

.gallery-token-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.gallery-token-img[data-src] {
    opacity: 0;
}

.gallery-token-img.loaded {
    opacity: 1;
}

/* Image loading placeholder - only show when loading */
.gallery-token-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid var(--paper-aged);
    border-top-color: var(--brass);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0.5;
}

.gallery-monster-name {
    font-size: 1em;
    font-weight: bold;
    text-align: center;
    line-height: 1.3;
    margin-bottom: 6px;
    color: var(--ink);
    font-family: "Bitter", serif;
}

.gallery-monster-cr {
    font-size: 0.85em;
    color: var(--ink-2);
    font-family: "Spectral", serif;
    font-style: italic;
    background: rgba(0, 0, 0, 0.05);
    padding: 3px 8px;
    border-radius: 12px;
}

/* Gallery Hover Popup */
.gallery-stat-block-popup {
    position: absolute;
    z-index: 1000;
    width: 450px;
    background: var(--paper);
    /* Matches theme */
    border: 2px solid var(--brass);
    /* Matches theme */
    border-radius: 6px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    font-family: "Spectral", serif;
    font-size: 0.95em;
    color: var(--ink);
    display: none;
    animation: fadeIn 0.15s ease-out;
    text-align: left;
    /* Reset text align for stat block */
}

.sb-header {
    font-family: "Cinzel", serif;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--iron);
    margin-bottom: 4px;
    border-bottom: 2px solid var(--iron);
    padding-bottom: 2px;
}

.sb-type {
    font-style: italic;
    color: var(--ink-2);
    margin-bottom: 10px;
    font-size: 0.9em;
}

.sb-divider {
    height: 1px;
    background: var(--brass);
    margin: 6px 0;
    opacity: 0.8;
}

.sb-attr-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
    color: var(--ink);
}

.sb-attr-label {
    font-weight: bold;
    color: var(--iron);
}

/* Stat Block Action Sections */
.sb-section-header {
    font-variant: small-caps;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 5px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--brass);
    color: var(--iron);
    font-size: 1.1em;
}

.sb-action {
    margin-bottom: 8px;
    line-height: 1.4;
    color: var(--ink);
    font-size: 0.9em;
}

.sb-action-name {
    font-weight: bold;
    font-style: italic;
    color: var(--ink);
}

/* ==================================================================
   UNIFIED STAT BLOCK STYLES
   Used by: Setup tab panels, Monster Gallery popup, Overlay modal
   ================================================================== */

.stat-block {
    font-family: 'Libre Baskerville', serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--parchment);
    padding: 20px;
    border-radius: 4px;
}

.stat-block-header {
    font-family: "Bitter", serif;
    font-size: 1.8em;
    font-weight: bold;
    color: var(--iron);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-block-subtitle {
    font-size: 0.95em;
    font-style: italic;
    color: var(--ink-2);
    margin-bottom: 10px;
}

.stat-block-divider {
    height: 2px;
    background: linear-gradient(to right, var(--brass), transparent);
    margin: 10px 0;
}

.stat-block-stat-line {
    margin: 5px 0;
}

.stat-block-stat-line .stat-label {
    font-weight: bold;
    color: var(--iron);
}

.stat-block-abilities {
    display: flex;
    justify-content: space-around;
    margin: 12px 0;
    gap: 8px;
}

.stat-block-ability {
    text-align: center;
    flex: 1;
}

.stat-block-ability .ability-name {
    font-weight: bold;
    font-size: 0.85em;
    color: var(--iron);
    text-transform: uppercase;
}

.stat-block-ability .ability-score {
    font-size: 0.95em;
    color: var(--ink);
}

.stat-block-section-title {
    font-family: "Bitter", serif;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--iron);
    margin-top: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-block-section {
    margin: 10px 0;
}

.stat-block-section-name {
    font-weight: bold;
    font-style: italic;
    color: var(--ink);
    margin-bottom: 3px;
}

.stat-block-section-text {
    color: var(--ink);
    margin-left: 10px;
}

/* ==================================================================
   STAT BLOCK OVERLAY MODAL
   ================================================================== */

.stat-block-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.stat-block-overlay-content {
    position: relative;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--parchment);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 30px;
}

.stat-block-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--iron);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.stat-block-close:hover {
    background: #c41e3a;
    transform: scale(1.1);
}

/* ==================================================================
   STATS PAGE
   ================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.stats-card {
    background: var(--parchment);
    border: 2px solid var(--iron);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stats-card.full-width {
    grid-column: 1 / -1;
}

.stats-card h3 {
    margin: 0 0 15px 0;
    color: var(--blood-red);
    border-bottom: 2px solid var(--iron);
    padding-bottom: 8px;
}

.stats-placeholder {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: var(--iron);
}

.error-message {
    text-align: center;
    padding: 20px;
    background: #fee;
    border: 2px solid #c00;
    border-radius: 4px;
    color: #c00;
}

/* Status Indicators (A, B, R, M, C) */
.status-indicators {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75em;
    font-weight: bold;
    color: var(--ink-2);
    border: 1px solid var(--rule);
    background: rgba(0, 0, 0, 0.05);
    cursor: help;
    user-select: none;
    transition: all 0.2s ease;
}

/* Specific Indicators */
.status-icon.action::before {
    content: 'A';
}

.status-icon.bonus::before {
    content: 'B';
}

.status-icon.reaction::before {
    content: 'R';
}

.status-icon.movement::before {
    content: 'M';
}

.status-icon.concentration::before {
    content: 'C';
}

/* States */
.status-icon.available {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--iron);
    opacity: 1;
    font-weight: 800;
}

.status-icon.used {
    background: transparent;
    color: var(--iron);
    border-color: transparent;
    opacity: 0.4;
    text-decoration: line-through;
}

/* Movement specific: Visualizing usage */
.status-icon.movement {
    position: relative;
    overflow: hidden;
    color: var(--ink);
    border-color: var(--iron);
    z-index: 0;
}

/* CSS Variable --pct-used is set in JS */
.status-icon.movement::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--pct-used, 0%);
    background: rgba(0, 0, 0, 0.15);
    z-index: -1;
    transition: height 0.3s ease;
}

/* Full movement used */
.status-icon.movement.used {
    background: rgba(0, 0, 0, 0.1);
    /* Slightly dark background to show it is empty/used */
    color: var(--iron);
    text-decoration: none;
    /* Don't strike through M, just dim it or fill it */
}

/* Concentration specific */
.status-icon.concentration {
    border-radius: 3px;
    /* Distinct shape */
    display: none;
    /* Hidden by default if not concentrating? Or just dimmed? Plan said active/inactive. */
}

.status-icon.concentration.active {
    display: inline-flex;
    background: var(--arcane-purple);
    color: white;
    border-color: #6c3483;
    box-shadow: 0 0 5px rgba(142, 68, 173, 0.5);
    animation: pulse-purple 2s infinite;
}

@keyframes pulse-purple {
    0% {
        box-shadow: 0 0 0 0 rgba(142, 68, 173, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(142, 68, 173, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(142, 68, 173, 0);
    }
}

/* ==========================================================================
   DECK BUILDER LAYOUT
   ========================================================================== */

.deck-builder-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    height: calc(100vh - 180px);
    min-height: 500px;
}

.roster-panel {
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--rule);
}

.roster-header {
    background: var(--paper-aged);
    padding: 15px;
    border-bottom: 2px solid var(--iron);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.roster-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: var(--ink);
}

/* Battle Controls Island */
.battle-controls-island {
    background: var(--paper-aged);
    padding: 12px;
    margin: 10px;
    border-radius: 12px;
    border: 1px solid var(--rule);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.controls-row {
    display: flex;
    gap: 8px;
}

.controls-row .btn-battle-action {
    flex: 1;
    white-space: nowrap;
    padding: 8px 4px;
    font-size: 0.8em;
}

.btn-battle-action {
    padding: 6px 12px;
    font-size: 0.85em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: "Bitter", serif;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.btn-battle-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-battle-action:active {
    transform: translateY(0);
}

/* Iron-themed Fight button */
.btn-battle-action.btn-iron {
    background: linear-gradient(135deg, #808080, #a0a0a0);
    color: white;
    border: 1px solid #606060;
}

.btn-battle-action.btn-iron:hover {
    background: linear-gradient(135deg, #909090, #b0b0b0);
}

.btn-battle-action.btn-iron.not-ready {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-battle-action.btn-iron.not-ready:hover {
    transform: none;
}

/* Blue-themed Fair Fight button */
.btn-battle-action.btn-fair-fight {
    background: linear-gradient(135deg, #2e86de, #54a0ff);
    color: white;
    border: 1px solid #1d69b3;
}

.btn-battle-action.btn-fair-fight:hover {
    background: linear-gradient(135deg, #54a0ff, #74b9ff);
}

/* Neutral 1v1 button */
.btn-battle-action.btn-neutral {
    background: linear-gradient(135deg, #C7A34A, #d4b55e);
    color: white;
    border: 1px solid #a88a3a;
}

.btn-battle-action.btn-neutral:hover {
    background: linear-gradient(135deg, #d4b55e, #e1c672);
}

/* Crimson-themed Chaos button */
.btn-battle-action.btn-crimson {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    border: 1px solid #962d22;
}

.btn-battle-action.btn-crimson:hover {
    background: linear-gradient(135deg, #e74c3c, #ff7675);
}

.difficulty-indicator-compact {
    font-size: 0.8em;
    font-weight: bold;
    color: var(--brass);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.team-roster-group {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.team-config.compact {
    cursor: pointer;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 10px;
    margin-bottom: 5px;
    transition: background 0.2s;
    border-radius: 6px;
    border: 1px solid transparent;
}

.team-config.compact:hover {
    background: rgba(0, 0, 0, 0.02);
}

.team-config.compact.active-target {
    background: rgba(199, 163, 74, 0.1);
    border: 1px solid var(--brass);
}

/* Team-specific active highlights - BOLD and COLORED */
.team-config.compact[data-team="0"].active-target {
    background: rgba(128, 128, 128, 0.12);
    border: 3px solid var(--iron);
    box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.25), inset 0 0 20px rgba(128, 128, 128, 0.1);
}

.team-config.compact[data-team="1"].active-target {
    background: rgba(153, 0, 0, 0.12);
    border: 3px solid var(--crimson);
    box-shadow: 0 0 0 3px rgba(153, 0, 0, 0.25), inset 0 0 20px rgba(153, 0, 0, 0.1);
}

.team-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.team-header-row h3 {
    margin: 0;
    font-size: 1em;
}

.team-stats-summary {
    font-size: 0.8em;
    color: var(--ink-2);
    font-family: monospace;
}

.scrollable-list {
    max-height: 200px;
    overflow-y: auto;
    min-height: 40px;
}

.roster-divider {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
}

.roster-divider .iron-bolt {
    position: static;
    transform: scale(0.8);
}

.battle-controls-footer {
    background: var(--paper-aged);
    padding: 15px;
    border-top: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.secondary-controls {
    display: flex;
    gap: 5px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 0.85em;
    flex: 1;
}

.codex-panel {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--rule);
}

.sticky-header {
    background: var(--paper);
    padding: 15px 20px;
    border-bottom: 1px solid var(--rule);
    z-index: 10;
    box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.gallery-controls-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.search-container {
    flex: 2;
}

.gallery-search-input {
    width: 100%;
    padding: 10px 15px;
    font-size: 1.1em;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-family: "Bitter", serif;
    background: rgba(255, 255, 255, 0.8);
}

.target-selector {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper-aged);
    padding: 5px 15px;
    border-radius: 20px;
    border: 1px solid var(--rule);
}

.toggle-buttons.mini .toggle-btn {
    padding: 4px 12px;
    font-size: 0.85em;
}

.gallery-filters-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-select {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--rule);
    font-family: "Bitter", serif;
}

.cr-filter input {
    width: 60px;
    padding: 6px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    text-align: center;
}

.deck-builder-grid {
    flex: 1;
    overflow-y: scroll;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    align-content: start;
}

.deck-builder-grid .monster-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 15px;
    border: 1px solid var(--rule);
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    cursor: pointer;
}

.deck-builder-grid .monster-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(199, 163, 74, 0.3);
    border-color: var(--brass);
}

.deck-builder-grid .gallery-token-container {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--paper-aged);
}

.deck-builder-grid .gallery-token-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 900px) {
    .deck-builder-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .roster-panel {
        max-height: 500px;
    }

    .codex-panel {
        height: 600px;
    }
}

@keyframes pulse-gold {
    0% {
        box-shadow: 0 0 0 0 rgba(199, 163, 74, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(199, 163, 74, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(199, 163, 74, 0);
    }
}

.pulse {
    animation: pulse-gold 0.5s ease-out;
}