/**
 * Bastards Blood - Complete RPG Theme
 * Fantasy dark theme with full feature styling
 */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --bg-hover: #252533;
    --text-primary: #e8e6e3;
    --text-secondary: #9d9b98;
    --text-muted: #6b6965;
    --accent-gold: #c9a227;
    --accent-red: #9b2335;
    --accent-green: #2d5a27;
    --accent-blue: #1e4a8a;
    --accent-purple: #5a2d82;
    --border-color: #2a2a35;
    --hp-healthy: #4ade80;
    --hp-wounded: #fbbf24;
    --hp-critical: #ef4444;
    --rarity-common: #9ca3af;
    --rarity-uncommon: #22c55e;
    --rarity-rare: #3b82f6;
    --rarity-very-rare: #8b5cf6;
    --rarity-legendary: #f59e0b;
    --rarity-mythic: #ef4444;
}

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

body {
    font-family: 'Crimson Text', Georgia, serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Particles */
.particles {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(201, 162, 39, 0.3);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

/* Navigation */
.navbar {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(18,18,26,0.95) 100%);
    border-bottom: 2px solid var(--accent-gold);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon { font-size: 1.5rem; }

.brand-text {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(201, 162, 39, 0.3);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: var(--accent-gold); background: rgba(201, 162, 39, 0.1); }

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-icon:hover { background: var(--bg-hover); }

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h1 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: var(--accent-gold);
}

.subtitle { color: var(--text-secondary); margin-top: 0.25rem; }

.header-actions { display: flex; gap: 0.5rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.card-header {
    background: rgba(201, 162, 39, 0.1);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--accent-gold);
}

.card-content { padding: 1rem; }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child { border-bottom: none; }

.stat-value {
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    color: var(--accent-gold);
}

/* Quick Dice */
.quick-dice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dice-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.dice-btn:hover {
    border-color: var(--accent-gold);
    transform: scale(1.1);
}

.dice-btn.d20 { border-color: var(--accent-gold); }
.dice-btn.d100 { border-color: var(--accent-purple); }

.roll-result {
    margin-top: 1rem;
    text-align: center;
}

.roll-display {
    display: inline-block;
    padding: 1rem 2rem;
    background: rgba(201, 162, 39, 0.2);
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
}

.roll-display.animate { animation: rollBounce 0.3s; }

@keyframes rollBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.roll-value {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-gold);
}

.roll-notation {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Party Status */
.party-member {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.party-member:last-child { border-bottom: none; }

.member-icon { font-size: 1.2rem; }
.member-name { flex: 1; }
.member-hp {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.member-hp.healthy { color: var(--hp-healthy); }
.member-hp.wounded { color: var(--hp-wounded); }
.member-hp.critical { color: var(--hp-critical); }

/* Event List */
.event-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    font-size: 0.9rem;
}

.event-icon { font-size: 1rem; }
.event-content { flex: 1; }
.event-actor { color: var(--accent-gold); font-weight: 600; }
.event-time { color: var(--text-muted); font-size: 0.8rem; }

/* Character Grid */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.character-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.character-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.character-card.dead { opacity: 0.5; }

.char-portrait {
    font-size: 3rem;
    text-align: center;
    padding: 1rem;
}

.char-name {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
}

.char-class {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.char-hp { margin: 0.75rem 0; }

.hp-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.hp-fill {
    height: 100%;
    transition: width 0.3s;
}

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

.hp-text {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.char-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.char-stats span {
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.char-tag {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.tag-party { background: var(--accent-green); }
.tag-npc { background: var(--accent-blue); }
.tag-enemy { background: var(--accent-red); }

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input, .filter-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.search-input { flex: 1; }
.filter-select { min-width: 150px; }

/* Combat */
.combat-status {
    text-align: center;
    padding: 3rem;
}

.no-combat .icon { font-size: 4rem; margin-bottom: 1rem; }
.no-combat p { color: var(--text-secondary); }
.no-combat .hint { font-size: 0.9rem; color: var(--text-muted); }

.combat-tracker {
    background: var(--bg-card);
    border: 2px solid var(--accent-red);
    border-radius: 8px;
    overflow: hidden;
}

.combat-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
    background: rgba(155, 35, 53, 0.2);
    border-bottom: 1px solid var(--border-color);
}

.round-display, .turn-display {
    text-align: center;
}

.round-display .label, .turn-display .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.round-display .value, .turn-display .value {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--accent-gold);
}

.initiative-list { padding: 1rem; }

.initiative-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    transition: all 0.2s;
}

.initiative-row.active {
    background: rgba(201, 162, 39, 0.2);
    border: 1px solid var(--accent-gold);
}

.initiative-row.dead { opacity: 0.4; text-decoration: line-through; }

.init-order {
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    color: var(--accent-gold);
    width: 40px;
}

.init-name { flex: 1; font-weight: 600; }

.init-hp { display: flex; align-items: center; gap: 0.5rem; }

.hp-bar-sm {
    width: 80px;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.init-ac { color: var(--text-secondary); }

.init-actions { display: flex; gap: 0.25rem; }

.btn-sm {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-damage { background: rgba(239, 68, 68, 0.2); }
.btn-heal { background: rgba(74, 222, 128, 0.2); }

.combat-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    justify-content: center;
}

/* Actions Section */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.action-card .card-content { min-height: 200px; }

.dice-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dice-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 1.25rem;
    text-align: center;
}

.preset-dice {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.preset-dice .label { color: var(--text-secondary); font-size: 0.9rem; }

.preset-dice button {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
}

.preset-dice button:hover { border-color: var(--accent-gold); }

.dice-result { text-align: center; margin: 1rem 0; }

.roll-result-display {
    padding: 1rem;
    background: rgba(201, 162, 39, 0.1);
    border-radius: 8px;
}

.roll-result-display .total {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    display: block;
}

.roll-result-display .breakdown {
    color: var(--text-secondary);
    font-family: 'Fira Code', monospace;
}

.roll-history {
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.hist-result { color: var(--text-primary); font-weight: 600; }

.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-select, .form-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--text-primary);
}

.action-result {
    margin-top: 1rem;
}

.action-result-display {
    padding: 1rem;
    border-radius: 8px;
    background: var(--bg-secondary);
}

.action-result-display.success { border-left: 4px solid var(--hp-healthy); }
.action-result-display.failure { border-left: 4px solid var(--hp-critical); }
.action-result-display.hit { border-left: 4px solid var(--hp-critical); }
.action-result-display.miss { border-left: 4px solid var(--text-muted); }
.action-result-display.danger { border-left: 4px solid var(--hp-wounded); }

.result-header {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.result-detail { font-size: 0.95rem; color: var(--text-secondary); }
.result-detail strong { color: var(--text-primary); }

.death { color: var(--hp-critical); font-weight: bold; }

/* World Section */
.world-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: var(--accent-gold);
    background: rgba(201, 162, 39, 0.1);
    border-bottom: 2px solid var(--accent-gold);
    margin-bottom: -2px;
}

.world-tab { display: none; }
.world-tab.active { display: block; }

.world-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.world-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

.world-card:hover { border-color: var(--accent-gold); }

.world-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.world-card h4 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
}

.world-card .terrain, .world-card .role, .world-card .rarity, .world-card .status, .world-card .alignment {
    font-size: 0.85rem;
    text-transform: capitalize;
    margin-bottom: 0.5rem;
}

.world-card .description {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Item Rarity Colors */
.rarity-common { border-left: 3px solid var(--rarity-common); }
.rarity-uncommon { border-left: 3px solid var(--rarity-uncommon); }
.rarity-rare { border-left: 3px solid var(--rarity-rare); }
.rarity-very_rare { border-left: 3px solid var(--rarity-very-rare); }
.rarity-legendary { border-left: 3px solid var(--rarity-legendary); }
.rarity-mythic { border-left: 3px solid var(--rarity-mythic); }

/* Quest Status */
.status-available .status { color: var(--hp-healthy); }
.status-active .status { color: var(--hp-wounded); }
.status-completed .status { color: var(--text-muted); }
.status-failed .status { color: var(--hp-critical); }

/* NPC Attitude */
.attitude { padding: 0.2rem 0.5rem; border-radius: 4px; display: inline-block; }
.friendly { background: rgba(74, 222, 128, 0.2); color: var(--hp-healthy); }
.neutral { background: rgba(156, 163, 175, 0.2); color: var(--text-secondary); }
.hostile { background: rgba(239, 68, 68, 0.2); color: var(--hp-critical); }

/* Sessions */
.sessions-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1.5rem;
}

.sessions-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.sessions-sidebar h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.sessions-list { max-height: 60vh; overflow-y: auto; }

.session-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: rgba(201, 162, 39, 0.1); border: 1px solid var(--accent-gold); }

.session-number {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    color: var(--accent-gold);
}

.session-date { font-size: 0.85rem; color: var(--text-secondary); }
.session-events { font-size: 0.8rem; color: var(--text-muted); }

.session-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.session-detail { padding: 1.5rem; min-height: 400px; }

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.session-header h3 { font-family: 'Cinzel', serif; color: var(--accent-gold); }

.session-summary {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-style: italic;
    color: var(--text-secondary);
}

.events-timeline {
    max-height: 400px;
    overflow-y: auto;
}

.log-event-form {
    border-top: 1px solid var(--border-color);
    padding: 1rem;
}

.log-event-form h4 { margin-bottom: 0.75rem; color: var(--accent-gold); }

.form-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-textarea {
    width: 100%;
    min-height: 80px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--text-primary);
    resize: vertical;
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-gold);
    color: #000;
}

.btn-primary:hover { background: #dab432; }

.btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover { border-color: var(--text-secondary); }

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover { background: #b12a3f; }

.btn-success {
    background: var(--accent-green);
    color: white;
}

.btn-success:hover { background: #366a30; }

.btn-action {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-action:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

.btn-block { width: 100%; justify-content: center; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
}

.modal.active { display: block; animation: modalIn 0.2s; }
.modal.modal-lg { max-width: 700px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1rem; }

/* Create Character Form */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.stat-input {
    text-align: center;
}

.stat-input label {
    display: block;
    font-weight: bold;
    color: var(--accent-gold);
    margin-bottom: 0.25rem;
}

.stat-input input {
    width: 100%;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: var(--text-primary);
}

/* Character Detail */
.char-detail { }

.detail-header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.portrait-large { font-size: 5rem; }

.detail-info { flex: 1; }

.hp-display { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.hp-display .label { color: var(--text-secondary); }
.hp-bar-large { flex: 1; height: 12px; background: var(--bg-secondary); border-radius: 6px; overflow: hidden; }

.stats-display {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    text-align: center;
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
}

.stat-label { display: block; font-size: 0.8rem; color: var(--text-muted); }
.stat-val { display: block; font-size: 1.25rem; font-weight: bold; }
.stat-mod { display: block; font-size: 0.9rem; color: var(--accent-gold); }

.detail-section { margin-bottom: 1.5rem; }
.detail-section h4 { color: var(--accent-gold); margin-bottom: 0.5rem; }

.inventory-list { list-style: none; }
.inventory-list li { padding: 0.25rem 0; }

.conditions-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.condition-tag {
    background: rgba(139, 92, 246, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.detail-actions { display: flex; gap: 0.5rem; }

/* Combatant Select */
.combatant-select {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.combatant-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
}

.combatant-option:hover { background: var(--bg-hover); }

.combatant-option input { width: 18px; height: 18px; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { border-left: 4px solid var(--hp-healthy); }
.toast-error { border-left: 4px solid var(--hp-critical); }
.toast-info { border-left: 4px solid var(--accent-blue); }

/* Empty States */
.empty-state, .loading, .empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .navbar { flex-wrap: wrap; }
    .nav-links { order: 3; width: 100%; justify-content: center; margin-top: 0.5rem; }
    .sessions-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .character-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-display { grid-template-columns: repeat(3, 1fr); }
    .detail-header { flex-direction: column; }
    .combat-header { flex-wrap: wrap; }
}

/* ==================== AI DM SECTION ==================== */
.ai-link {
    background: linear-gradient(135deg, #7b2cbf, #c77dff) !important;
    color: white !important;
}

.ai-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.ai-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.ai-context-panel h4,
.ai-quick-actions h4,
.ai-conversations h4 {
    color: var(--purple);
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.context-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.context-item span {
    color: var(--gold);
    font-weight: 600;
}

.ai-quick-actions button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(123, 44, 191, 0.2);
    border: 1px solid var(--purple);
    border-radius: 8px;
    color: var(--text-light);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.ai-quick-actions button:hover {
    background: rgba(123, 44, 191, 0.4);
    transform: translateX(4px);
}

.ai-conversations {
    flex: 1;
    min-height: 0;
}

#conversationList {
    max-height: 200px;
    overflow-y: auto;
}

.ai-chat-main {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-welcome {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.chat-welcome .welcome-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.chat-welcome h3 {
    color: var(--gold);
    margin-bottom: 16px;
}

.chat-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    line-height: 1.5;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    background: linear-gradient(135deg, #1a5f7a, #0f3854);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.ai {
    background: linear-gradient(135deg, #2d1b4e, #1a0f2e);
    border: 1px solid var(--purple);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-message.ai .msg-label {
    display: block;
    font-size: 0.75rem;
    color: var(--purple);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-message.ai .msg-content {
    white-space: pre-wrap;
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--purple);
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--purple);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.chat-input-row {
    display: flex;
    gap: 12px;
}

.chat-input-row textarea {
    flex: 1;
    padding: 14px 18px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
}

.chat-input-row textarea:focus {
    border-color: var(--purple);
    outline: none;
    box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.2);
}

.btn-send {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.4rem;
    background: linear-gradient(135deg, #7b2cbf, #c77dff);
}

.btn-send:hover {
    transform: scale(1.05);
}

.btn-ai {
    background: linear-gradient(135deg, #7b2cbf, #9d4edd);
    border: none;
    color: white;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #9d4edd, #c77dff);
}

.btn-ai.btn-block {
    margin-bottom: 8px;
}

/* Mobile responsive */
@media (max-width: 900px) {
    .ai-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .ai-sidebar {
        display: none; /* Hide on mobile, show toggle */
    }
}

/* ==== NPC CONVERSATION PANEL ==== */
.ai-npc-panel {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.3), rgba(205, 133, 63, 0.1));
    border: 1px solid rgba(139, 69, 19, 0.5);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-npc-panel h4 {
    color: var(--color-gold);
    margin-bottom: 0.75rem;
    font-family: var(--font-display);
}

.npc-list {
    max-height: 200px;
    overflow-y: auto;
}

.npc-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
}

.npc-item:hover {
    background: rgba(139, 69, 19, 0.4);
    transform: translateX(4px);
}

.npc-item.selected {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.6), rgba(205, 133, 63, 0.4));
    border: 1px solid var(--color-gold);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.npc-icon {
    font-size: 1.2rem;
}

.npc-name {
    flex: 1;
    font-weight: 600;
    color: var(--color-text);
}

.npc-type {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.npc-relationship {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(139, 69, 19, 0.3);
}

.relationship-display {
    text-align: center;
}

.relationship-display strong {
    display: block;
    color: var(--color-gold);
    margin-bottom: 0.5rem;
}

.rel-bar {
    height: 8px;
    background: linear-gradient(to right, 
        #dc3545 0%, 
        #dc3545 25%, 
        #ffc107 25%, 
        #ffc107 50%, 
        #28a745 50%, 
        #28a745 75%, 
        #17a2b8 75%, 
        #17a2b8 100%
    );
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.rel-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: calc(var(--rel-value, 50%) - 2px);
    width: 4px;
    height: 100%;
    background: white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.rel-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ==== ENHANCED CHAT MESSAGES ==== */
.chat-message.npc {
    border-left: 3px solid var(--color-gold);
}

.chat-message.npc .msg-label {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.8), rgba(205, 133, 63, 0.6));
}

.chat-message.combat {
    border-left: 3px solid #dc3545;
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), transparent);
}

.chat-message.combat .msg-label {
    background: linear-gradient(135deg, #dc3545, #c82333);
}

.chat-message.suggest {
    border-left: 3px solid #17a2b8;
}

.chat-message.suggest .msg-label {
    background: linear-gradient(135deg, #17a2b8, #138496);
}

.chat-message.lore {
    border-left: 3px solid #6f42c1;
    background: linear-gradient(135deg, rgba(111, 66, 193, 0.1), transparent);
}

.chat-message.lore .msg-label {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
}

.msg-content q {
    font-style: italic;
    color: var(--color-gold);
}

.msg-content strong {
    color: var(--color-gold);
}

.msg-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
}

/* Quick button grid */
.quick-btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.quick-btn-grid button {
    font-size: 12px;
    padding: 6px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-quick-actions h5 {
    color: var(--text-secondary);
    font-size: 11px;
    margin: 8px 0 4px 0;
    text-transform: uppercase;
}

/* Token cost display */
#tokenCost {
    color: var(--gold);
}

/* Message type labels */
.chat-message .mode-label {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 8px;
    text-transform: uppercase;
    font-weight: bold;
}

.chat-message.dm .mode-label { background: var(--primary); }
.chat-message.npc .mode-label { background: var(--accent); }
.chat-message.combat .mode-label { background: #c0392b; }
.chat-message.lore .mode-label { background: #8e44ad; }
.chat-message.suggest .mode-label { background: #27ae60; }
.chat-message.narrator .mode-label { background: #2980b9; }

/* =================================================================
   PORTRAIT SYSTEM STYLES
   ================================================================= */

/* Character card portrait */
.char-portrait-container {
    position: relative;
    width: 100%;
    height: 120px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    margin: -1rem -1rem 0.5rem -1rem;
    width: calc(100% + 2rem);
}

.char-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.char-portrait:hover {
    transform: scale(1.05);
}

.char-portrait-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.3), rgba(210, 180, 140, 0.1));
    transition: all 0.3s ease;
}

.char-portrait-placeholder:hover {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.5), rgba(210, 180, 140, 0.2));
}

.char-portrait-placeholder span {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.char-portrait-placeholder small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Portrait modal overlay */
.portrait-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}

.portrait-modal {
    position: relative;
    max-width: 600px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.portrait-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: all 0.2s ease;
}

.portrait-close:hover {
    background: var(--danger);
    transform: scale(1.1);
}

.portrait-full {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    display: block;
}

.portrait-info {
    padding: 1rem;
    text-align: center;
}

.portrait-info h3 {
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.portrait-prompt {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    max-height: 60px;
    overflow-y: auto;
}

.portrait-actions {
    display: flex;
    gap: 1rem;
    padding: 0 1rem 1rem;
    justify-content: center;
}

/* Portrait generator modal */
.portrait-generator-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.portrait-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

#portraitResult {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 1rem;
}

.portrait-preview img,
.scene-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.portrait-preview img:hover,
.scene-preview img:hover {
    transform: scale(1.02);
}

.portrait-prompt-small {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-portrait {
    font-size: 1.5rem;
    color: var(--gold);
    animation: pulse 1.5s infinite;
}

/* NPC portrait in chat */
.chat-npc-portrait {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold);
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.chat-message-with-portrait {
    display: flex;
    align-items: flex-start;
}

.chat-message-with-portrait .message-content {
    flex: 1;
}

/* Scene display in game */
.scene-display {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.scene-display img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scene-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
}

/* Portrait gallery */
.portrait-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.25rem;
    background: rgba(0,0,0,0.7);
    font-size: 0.65rem;
    text-align: center;
    color: white;
}

/* Portrait style selector */
.style-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.style-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.style-btn:hover,
.style-btn.active {
    background: var(--gold);
    color: var(--bg-dark);
    border-color: var(--gold);
}

/* Quick portrait button in header */
.portrait-quick-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #8B4513, #D2691E);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.portrait-quick-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.4);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Additional portrait styles */
.portrait-options .form-group {
    flex: 1;
    min-width: 100px;
}

.portrait-options .btn {
    margin-top: 0;
    white-space: nowrap;
}

.card.wide-card {
    grid-column: span 1;
}

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

.error {
    color: var(--danger);
    padding: 1rem;
    text-align: center;
}

#charPortraitResult,
#npcPortraitResult,
#sceneResult {
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#charPortraitResult img,
#npcPortraitResult img {
    max-width: 256px;
    border-radius: 8px;
    margin-top: 1rem;
}

#sceneResult img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 1rem;
}

/* Responsive adjustments for portrait page */
@media (max-width: 768px) {
    .portrait-options {
        grid-template-columns: 1fr;
    }
    
    .card.wide-card {
        grid-column: 1 / -1;
    }
}
