﻿/* ═══════════════════════════════════════════════════════════════════════════════
   CLAWDISTAN - Professional Space UI (Stellaris-Inspired)
   Performance-First Design | Hardware-Accelerated Animations
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
   RESET & VARIABLES
   ═══════════════════════════════════════════════════════════════════════════════ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Core palette - Stellaris inspired with Glassmorphism */
    --bg-void: #030308;
    --bg-space: #060610;
    --bg-panel: rgba(8, 12, 24, 0.85);
    --bg-panel-glass: rgba(10, 15, 30, 0.75);
    --bg-panel-header: rgba(12, 18, 35, 0.9);
    --bg-card: rgba(15, 20, 40, 0.8);
    --bg-hover: rgba(30, 45, 80, 0.6);
    --bg-active: rgba(40, 60, 100, 0.5);
    --bg-input: rgba(5, 8, 18, 0.85);
    
    /* Glassmorphism */
    --glass-blur: 16px;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    
    /* Accent colors */
    --accent: #00d4ff;
    --accent-bright: #40e8ff;
    --accent-dim: rgba(0, 212, 255, 0.15);
    --accent-glow: rgba(0, 212, 255, 0.5);
    --accent-line: rgba(0, 212, 255, 0.3);
    
    --purple: #9855f7;
    --purple-glow: rgba(152, 85, 247, 0.4);
    --gold: #f5c842;
    --gold-glow: rgba(245, 200, 66, 0.3);
    
    /* Status colors */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f43f5e;
    --info: #60a5fa;
    
    /* Text */
    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-dim: #5a6070;
    --text-accent: var(--accent);
    
    /* Borders */
    --border-subtle: rgba(60, 80, 120, 0.3);
    --border-panel: rgba(80, 100, 140, 0.4);
    --border-glow: rgba(0, 212, 255, 0.6);
    
    /* Shadows */
    --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);
    
    /* Sizing */
    --header-height: 48px;
    --panel-width: 320px;
    --panel-width-collapsed: 48px;
    --border-radius: 4px;
    --border-radius-lg: 8px;
    
    /* Transitions - GPU accelerated */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Fonts */
    --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    --font-mono: 'Consolas', 'SF Mono', 'Monaco', monospace;
}

body {
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════════════════════════ */
.loading-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #0a0a1a 0%, #030308 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    font-size: 80px;
    animation: pulse 2s ease-in-out infinite;
    margin-bottom: 16px;
}

.loading-content h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 8px;
    margin-bottom: 24px;
    background: linear-gradient(90deg, #00d4ff, #9855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar {
    width: 280px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto 16px;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d4ff, #9855f7);
    border-radius: 2px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.loading-progress.indeterminate {
    width: 30%;
    animation: loadingProgress 2s ease-in-out infinite;
}

@keyframes loadingProgress {
    0% { width: 0%; margin-left: 0; }
    50% { width: 60%; margin-left: 20%; }
    100% { width: 0%; margin-left: 100%; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.loading-content p {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

/* Loading info row */
.loading-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

#loadingPercent {
    font-size: 18px;
    font-weight: 600;
    color: #00d4ff;
    min-width: 45px;
    text-align: right;
}

#loadingStatus {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Loading stages indicator */
.loading-stages {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.loading-stage {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.3s ease;
}

.loading-stage.active {
    color: rgba(255, 255, 255, 0.7);
}

.loading-stage.complete {
    color: #4ade80;
}

.loading-stage .stage-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.loading-stage.active .stage-icon {
    animation: stagePulse 1s ease-in-out infinite;
}

.loading-stage.complete .stage-icon {
    color: #4ade80;
}

@keyframes stagePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN CONTAINER & STARFIELD
   ═══════════════════════════════════════════════════════════════════════════════ */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    background: 
        radial-gradient(ellipse at 15% 85%, rgba(100, 40, 180, 0.08) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 15%, rgba(0, 140, 220, 0.06) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, var(--bg-space) 0%, var(--bg-void) 100%);
}

/* Animated starfield - GPU optimized */
.game-container::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(1.5px 1.5px at 20px 30px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1.5px 1.5px at 90px 40px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 230px 80px, rgba(200,220,255,0.8), transparent),
        radial-gradient(1px 1px at 300px 150px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1.5px 1.5px at 370px 60px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 450px 180px, rgba(255,220,200,0.6), transparent),
        radial-gradient(1.5px 1.5px at 520px 100px, rgba(255,255,255,0.5), transparent),
        radial-gradient(2px 2px at 600px 40px, rgba(200,200,255,0.8), transparent);
    background-size: 650px 220px;
    animation: starfield 80s linear infinite;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    will-change: transform;
}

@keyframes starfield {
    from { transform: translateX(0) translateY(0); }
    to { transform: translateX(-650px) translateY(-220px); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HEADER BAR - Stellaris Top Bar Style
   ═══════════════════════════════════════════════════════════════════════════════ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: linear-gradient(180deg, 
        rgba(12, 18, 32, 0.9) 0%, 
        rgba(8, 12, 24, 0.85) 100%);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.5),
        inset 0 -1px 0 var(--accent-line),
        inset 0 1px 0 var(--glass-highlight);
    position: relative;
    z-index: 100;
    animation: headerFadeIn 0.5s ease-out;
}

@keyframes headerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-shadow: 0 0 20px var(--accent-glow);
}

.tagline {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.stat-badge.status-running {
    color: var(--success);
    border-color: rgba(52, 211, 153, 0.3);
}

/* Council status badge */
.stat-badge.council-badge {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.1));
    border-color: rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    font-weight: 600;
    cursor: pointer;
    animation: council-pulse 3s infinite;
}

.stat-badge.council-badge:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.2));
    border-color: rgba(251, 191, 36, 0.8);
}

.stat-badge.council-badge.voting {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.2));
    border-color: rgba(139, 92, 246, 0.6);
    color: #a78bfa;
    animation: voting-pulse 1s infinite;
}

.stat-badge.council-badge.no-leader {
    background: var(--bg-card);
    border-color: var(--border-subtle);
    color: var(--text-muted);
    animation: none;
}

@keyframes council-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(251, 191, 36, 0.3); }
    50% { box-shadow: 0 0 15px rgba(251, 191, 36, 0.5); }
}

@keyframes voting-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.7); }
}

/* Crisis status badge */
.stat-badge.crisis-badge {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.3), rgba(127, 29, 29, 0.2));
    border-color: rgba(220, 38, 38, 0.7);
    color: #f87171;
    font-weight: 700;
    cursor: pointer;
    animation: crisis-pulse 0.5s infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-badge.crisis-badge:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.4), rgba(127, 29, 29, 0.3));
    border-color: rgba(248, 113, 113, 0.9);
}

.stat-badge.crisis-badge.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(180, 83, 9, 0.2));
    border-color: rgba(245, 158, 11, 0.6);
    color: #fbbf24;
    animation: warning-pulse 1s infinite;
}

.stat-badge.crisis-badge.swarm {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.4), rgba(75, 0, 0, 0.3));
    border-color: rgba(139, 0, 0, 0.8);
    color: #ff6b6b;
}

.stat-badge.crisis-badge.precursors {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(184, 134, 11, 0.2));
    border-color: rgba(255, 215, 0, 0.6);
    color: #ffd700;
}

.stat-badge.crisis-badge.rebellion {
    background: linear-gradient(135deg, rgba(0, 206, 209, 0.3), rgba(0, 139, 139, 0.2));
    border-color: rgba(0, 206, 209, 0.6);
    color: #00ced1;
}

/* ═══════════════════════════════════════════════════════════════════
   GAME TIMER - 24h countdown to victory
   ═══════════════════════════════════════════════════════════════════ */
.stat-badge.timer-badge {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(79, 70, 229, 0.2));
    border-color: rgba(99, 102, 241, 0.6);
    color: #a5b4fc;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    min-width: 120px;
    text-align: center;
}

.stat-badge.timer-badge.ending-soon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.4), rgba(217, 119, 6, 0.3));
    border-color: rgba(245, 158, 11, 0.8);
    color: #fbbf24;
    animation: timer-pulse 1s ease-in-out infinite;
}

.stat-badge.timer-badge.final-minutes {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(185, 28, 28, 0.3));
    border-color: rgba(239, 68, 68, 0.8);
    color: #fca5a5;
    animation: timer-pulse 0.5s ease-in-out infinite;
}

.stat-badge.timer-badge.game-over {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.4), rgba(22, 163, 74, 0.3));
    border-color: rgba(34, 197, 94, 0.8);
    color: #86efac;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ═══════════════════════════════════════════════════════════════════
   GALACTIC CYCLES - Periodic galaxy-wide events
   ═══════════════════════════════════════════════════════════════════ */
.stat-badge.cycle-badge {
    background: linear-gradient(135deg, rgba(136, 136, 136, 0.2), rgba(68, 68, 68, 0.2));
    border-color: var(--cycle-color, #888);
    color: var(--cycle-color, #aaa);
    cursor: pointer;
    transition: all 0.3s ease;
}

.stat-badge.cycle-badge:hover {
    background: linear-gradient(135deg, rgba(136, 136, 136, 0.3), rgba(68, 68, 68, 0.3));
    border-color: var(--cycle-color, #aaa);
    transform: translateY(-1px);
}

.stat-badge.cycle-badge .cycle-timer {
    opacity: 0.8;
    font-size: 0.85em;
    margin-left: 2px;
}

/* Normal cycle - Cosmic Equilibrium */
.stat-badge.cycle-badge.normal {
    --cycle-color: #888888;
}

/* Void Storm - Dangerous transit */
.stat-badge.cycle-badge.void_storm {
    --cycle-color: #a855f7;
    background: linear-gradient(135deg, rgba(107, 33, 168, 0.3), rgba(76, 29, 149, 0.2));
    border-color: rgba(168, 85, 247, 0.7);
    animation: void-storm-pulse 2s infinite;
}

@keyframes void-storm-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 0 15px rgba(168, 85, 247, 0.5); }
}

/* Golden Age - Production boost */
.stat-badge.cycle-badge.golden_age {
    --cycle-color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(217, 119, 6, 0.2));
    border-color: rgba(251, 191, 36, 0.7);
    animation: golden-glow 1.5s infinite;
}

@keyframes golden-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(251, 191, 36, 0.3); }
    50% { box-shadow: 0 0 15px rgba(251, 191, 36, 0.6); }
}

/* Dark Era - Stealth & ambush */
.stat-badge.cycle-badge.dark_era {
    --cycle-color: #475569;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.4));
    border-color: rgba(71, 85, 105, 0.6);
}

/* Warp Resonance - Fast travel */
.stat-badge.cycle-badge.warp_resonance {
    --cycle-color: #22d3ee;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(6, 182, 212, 0.2));
    border-color: rgba(34, 211, 238, 0.7);
    animation: warp-pulse 0.8s infinite;
}

@keyframes warp-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(34, 211, 238, 0.3); }
    50% { box-shadow: 0 0 12px rgba(34, 211, 238, 0.6); }
}

/* Crisis Modal */
.crisis-modal .crisis-modal-content {
    background: var(--panel-bg);
    border-radius: 12px;
    border: 2px solid;
    max-width: 500px;
    width: 90vw;
    overflow: hidden;
}

.crisis-modal .crisis-modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.crisis-modal .crisis-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.crisis-modal .crisis-modal-body {
    padding: 20px;
}

.crisis-modal .crisis-desc {
    color: var(--text-dim);
    margin-bottom: 20px;
    line-height: 1.5;
}

.crisis-modal .crisis-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.crisis-modal .crisis-stat {
    flex: 1;
    text-align: center;
    padding: 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.crisis-modal .crisis-stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.crisis-modal .crisis-stat .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
}

.crisis-modal .crisis-progress-section {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.crisis-modal .crisis-progress-section h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.crisis-modal .crisis-progress-section p {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin: 0 0 12px 0;
}

.crisis-modal .crisis-progress-bar {
    height: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.crisis-modal .crisis-progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.crisis-modal .crisis-progress-text {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.crisis-modal .crisis-lore {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.crisis-modal .crisis-lore h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.crisis-modal .crisis-lore p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.5;
}

.crisis-modal .crisis-tip {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.crisis-modal .crisis-warning-info {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

@keyframes crisis-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(220, 38, 38, 0.5); }
    50% { box-shadow: 0 0 25px rgba(220, 38, 38, 0.9), 0 0 40px rgba(220, 38, 38, 0.4); }
}

@keyframes warning-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 18px rgba(245, 158, 11, 0.7); }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESOURCE BAR - Stellaris Top Bar Style
   ═══════════════════════════════════════════════════════════════════════════════ */
.resource-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin: 0 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.resource-empire {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.empire-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.resource-divider {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    cursor: default;
}

.resource-item:hover {
    background: var(--bg-hover);
}

.resource-icon {
    font-size: 14px;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
}

.resource-value {
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
    min-width: 40px;
    text-align: right;
}

/* Resource-specific colors */
.resource-item[title*="Minerals"] .resource-value { color: #60a5fa; }
.resource-item[title*="Energy"] .resource-value { color: #fbbf24; }
.resource-item[title*="Food"] .resource-value { color: #4ade80; }
.resource-item[title*="Research"] .resource-value { color: #a78bfa; }
.resource-item[title*="population"] .resource-value { color: #f472b6; }

/* Resource change animations */
.resource-value.increasing {
    animation: resourceUp 0.5s ease-out;
}

.resource-value.decreasing {
    animation: resourceDown 0.5s ease-out;
}

@keyframes resourceUp {
    0% { color: #4ade80; transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes resourceDown {
    0% { color: #f43f5e; transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Hide resource bar on small screens */
@media (max-width: 900px) {
    .resource-bar {
        display: none;
    }
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.header-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.header-btn:active {
    transform: translateY(0);
}

/* Button icons - AI-generated UI icons */
.btn-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0.9) contrast(1.1);
    transition: filter var(--transition-fast);
    vertical-align: middle;
    margin-right: 4px;
}

.header-btn:hover .btn-icon,
.view-btn:hover .btn-icon {
    filter: brightness(1.2) contrast(1.1) drop-shadow(0 0 3px var(--accent-glow));
}


/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN LAYOUT - Split Panel Design
   ═══════════════════════════════════════════════════════════════════════════════ */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UNIVERSE PANEL (Center - Map View)
   ═══════════════════════════════════════════════════════════════════════════════ */
.universe-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
}

.view-controls {
    display: flex;
    gap: 4px;
    padding: 10px 12px;
    background: linear-gradient(180deg, 
        rgba(10, 15, 28, 0.85) 0%, 
        rgba(8, 12, 24, 0.8) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    animation: controlsFadeIn 0.3s ease-out 0.1s both;
}

@keyframes controlsFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-btn {
    padding: 7px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    color: var(--text-primary);
}

.view-btn.active {
    background: linear-gradient(180deg, 
        rgba(0, 180, 220, 0.25) 0%, 
        rgba(0, 150, 200, 0.18) 100%);
    border-color: var(--accent);
    color: var(--accent-bright);
    box-shadow: 
        0 0 20px rgba(0, 212, 255, 0.3),
        0 0 40px rgba(0, 212, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    animation: activeGlow 2s ease-in-out infinite;
}

@keyframes activeGlow {
    0%, 100% { 
        box-shadow: 
            0 0 20px rgba(0, 212, 255, 0.3),
            0 0 40px rgba(0, 212, 255, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
    50% { 
        box-shadow: 
            0 0 25px rgba(0, 212, 255, 0.4),
            0 0 50px rgba(0, 212, 255, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.zoom-controls button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.zoom-controls button:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 15px var(--accent-dim);
}

.zoom-controls button:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INFO PANEL (Right Side - Outliner Style)
   ═══════════════════════════════════════════════════════════════════════════════ */
.info-panel {
    width: var(--panel-width);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-left: 1px solid var(--glass-border);
    box-shadow: 
        -4px 0 30px rgba(0, 0, 0, 0.5),
        inset 1px 0 0 var(--glass-highlight);
    overflow-y: auto;
    overflow-x: hidden;
    animation: panelSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.panel-section {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-subtle);
    animation: sectionSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.panel-section:nth-child(1) { animation-delay: 0.1s; }
.panel-section:nth-child(2) { animation-delay: 0.15s; }
.panel-section:nth-child(3) { animation-delay: 0.2s; }
.panel-section:nth-child(4) { animation-delay: 0.25s; }

@keyframes sectionSlideIn {
    from {
        opacity: 0;
        transform: translateX(15px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.panel-section:last-child {
    flex: 1;
    border-bottom: none;
}

.panel-section h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-panel-header);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}

.panel-section h2:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.panel-section h2::before {
    content: '▼';
    font-size: 8px;
    color: var(--text-dim);
    transition: transform var(--transition-fast);
}

.panel-section.collapsed h2::before {
    transform: rotate(-90deg);
}

/* Selected Info */
.selected-info {
    padding: 12px 14px;
    max-height: 200px;
    overflow-y: auto;
}

.selected-info .placeholder-text {
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
}

.selected-info .info-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.selected-info .info-item:last-child {
    border-bottom: none;
}

.selected-info .info-label {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
}

.selected-info .info-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Agent Rank Badge */
.agent-rank {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-primary);
    background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
}

/* Agent List */
.agent-search-bar {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
}

.agent-search-bar input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    transition: all var(--transition-fast);
}

.agent-search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.agent-search-bar input::placeholder {
    color: var(--text-dim);
}

.agent-search-bar button {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.agent-search-bar button:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    color: var(--accent);
}

.agent-list {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
    max-height: 400px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-glow) transparent;
}

.agent-list::-webkit-scrollbar {
    width: 6px;
}

.agent-list::-webkit-scrollbar-track {
    background: transparent;
}

.agent-list::-webkit-scrollbar-thumb {
    background: var(--border-glow);
    border-radius: 3px;
}

.agent-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.agent-list .placeholder-text {
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

.agent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.agent-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(0, 212, 255, 0.1) 0%, 
        transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.agent-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.agent-item:hover::before {
    opacity: 1;
}

.agent-item .agent-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 6px currentColor;
}

.agent-item .agent-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-item .agent-status {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-active);
    border-radius: 10px;
    color: var(--text-secondary);
}

.agent-item.verified .agent-status {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EMPIRE LIST (In Modal or Panel)
   ═══════════════════════════════════════════════════════════════════════════════ */
.empire-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.empire-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.empire-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    transform: translateX(4px);
}

.empire-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    box-shadow: 
        0 0 8px currentColor,
        inset 0 0 4px rgba(255, 255, 255, 0.3);
}

.empire-info {
    flex: 1;
}

.empire-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.empire-stats {
    font-size: 11px;
    color: var(--text-secondary);
}

.empire-stats span {
    margin-right: 10px;
}

/* Empire Crests */
.empire-visuals {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.empire-crest {
    flex-shrink: 0;
    width: 36px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform var(--transition-fast);
}

.empire-item:hover .empire-crest {
    transform: scale(1.1);
}

.empire-crest svg {
    width: 100%;
    height: 100%;
}

/* Species Badge on Empire Items */
.empire-species-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.85;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.empire-species-badge img,
.empire-species-badge svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.empire-item:hover .empire-species-badge {
    transform: scale(1.1);
    opacity: 1;
}

/* Empire Sparklines */
.empire-sparkline {
    flex-shrink: 0;
    width: 70px;
    height: 20px;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.empire-item:hover .empire-sparkline {
    opacity: 1;
}

.sparkline {
    overflow: visible;
}

/* Stats graph panel for expanded view */
.stats-graph-panel {
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.stats-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stats-graph-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.stats-graph-metrics {
    display: flex;
    gap: 6px;
}

.stats-metric-btn {
    padding: 2px 8px;
    font-size: 10px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 3px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.stats-metric-btn:hover,
.stats-metric-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.stats-graph-container {
    height: 60px;
    position: relative;
}

.stats-graph-container svg {
    width: 100%;
    height: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MODALS - Stellaris Style Panels
   ═══════════════════════════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 var(--glass-highlight),
        0 0 0 1px rgba(0, 212, 255, 0.1);
    overflow: hidden;
    animation: modalSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(180deg, 
        rgba(15, 22, 40, 0.98) 0%, 
        rgba(10, 15, 30, 0.96) 100%);
    border-bottom: 1px solid var(--border-panel);
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.modal-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
}

.modal-btn {
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-void);
}

.modal-btn.info-btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(79, 70, 229, 0.15));
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

.modal-btn.info-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(79, 70, 229, 0.25));
    border-color: rgba(99, 102, 241, 0.6);
}

.score-info-panel,
#scoreInfoPanel {
    margin: 12px 0;
    padding: 16px;
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 40, 0.98));
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: var(--border-radius-lg);
    animation: slideDown 0.25s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.score-info-panel h4,
#scoreInfoPanel h4 {
    color: #a5b4fc;
    font-size: 13px;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-info-panel h4:not(:first-child),
#scoreInfoPanel h4:not(:first-child) {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.score-info-panel ul,
#scoreInfoPanel ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.9;
}

.score-info-panel li strong,
#scoreInfoPanel li strong {
    color: var(--text-primary);
}

.score-info-panel .info-tip,
#scoreInfoPanel .info-tip {
    margin: 12px 0 0 0;
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.12);
    border-left: 3px solid rgba(34, 197, 94, 0.6);
    border-radius: 0 6px 6px 0;
    color: #86efac;
    font-size: 11px;
}

.modal-btn.primary {
    background: linear-gradient(180deg, 
        rgba(0, 180, 220, 0.3) 0%, 
        rgba(0, 150, 200, 0.25) 100%);
    border-color: var(--accent);
    color: var(--accent-bright);
}

.modal-btn.primary:hover {
    background: var(--accent);
    color: var(--bg-void);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LIST CONTROLS - Search & Pagination (Shared)
   ═══════════════════════════════════════════════════════════════════════════════ */
.list-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 0;
}

.list-search {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.list-search:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.list-search::placeholder {
    color: var(--text-muted);
}

.list-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.pagination-controls:empty {
    display: none;
}

.pagination-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 8px;
}

.sidebar-pagination {
    padding: 8px 0;
    border-top: 1px solid var(--border-subtle);
    margin-top: 4px;
}

.sidebar-pagination .pagination-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.sidebar-pagination .pagination-info {
    font-size: 0.75rem;
}

.agent-count {
    font-size: 0.75rem;
    font-weight: normal;
    color: var(--accent-blue);
    margin-left: 4px;
}

/* Rankings tabs */
.rankings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border-subtle);
    border-bottom-color: var(--bg-card);
}

.rankings-content {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

/* Empire entries in Rankings */
.empire-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.empire-entry:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.empire-crest {
    flex-shrink: 0;
}

.empire-info {
    flex: 1;
    min-width: 0;
}

.empire-name {
    font-weight: 500;
    display: block;
}

.empire-agent {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.empire-agent.online {
    color: var(--accent-success);
}

.empire-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Citizen entries */
.citizen-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    margin-bottom: 4px;
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.online-dot.online {
    background: var(--accent-success);
    box-shadow: 0 0 6px var(--accent-success);
}

.online-dot.offline {
    background: var(--text-muted);
}

.citizen-info {
    flex: 1;
}

.citizen-name {
    font-weight: 500;
}

.citizen-moltbook {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.citizen-moltbook a {
    color: var(--accent-primary);
    text-decoration: none;
}

.citizen-moltbook a:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LEADERBOARD - Ranked List
   ═══════════════════════════════════════════════════════════════════════════════ */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.leaderboard-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
}

.leaderboard-item .rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-active);
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.leaderboard-item.rank-1 .rank {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    color: var(--bg-void);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.leaderboard-item.rank-2 .rank {
    background: linear-gradient(135deg, #e8e8e8 0%, #a8a8a8 100%);
    color: var(--bg-void);
}

.leaderboard-item.rank-3 .rank {
    background: linear-gradient(135deg, #cd7f32 0%, #8b4513 100%);
    color: var(--bg-void);
}

.leaderboard-item .empire-color {
    width: 10px;
    height: 10px;
}

.leaderboard-item .details {
    flex: 1;
}

.leaderboard-item .empire-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-item .agent-name {
    font-size: 11px;
    color: var(--text-secondary);
}

.leaderboard-item .score {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-glow);
}

.leaderboard-item.verified::after {
    content: '✓';
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success);
    border-radius: 50%;
    font-size: 10px;
    color: white;
}

/* Leaderboard Entry (new structure with crests) */
.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.leaderboard-entry:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
    transform: translateX(4px);
}

.leaderboard-rank {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    background: var(--bg-active);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    color: var(--bg-void);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #e8e8e8 0%, #a8a8a8 100%);
    color: var(--bg-void);
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #8b4513 100%);
    color: var(--bg-void);
}

.leaderboard-crest {
    flex-shrink: 0;
    width: 28px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaderboard-crest svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

.leaderboard-empire {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.career-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.15));
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 10px;
    color: #4ade80;
    margin-left: 6px;
    white-space: nowrap;
}

.leaderboard-agent {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
}

.leaderboard-agent.online {
    color: var(--success);
}

.leaderboard-agent.online::before {
    content: '●';
    margin-right: 4px;
}

.leaderboard-sparkline {
    flex-shrink: 0;
    width: 50px;
    opacity: 0.7;
}

.leaderboard-entry:hover .leaderboard-sparkline {
    opacity: 1;
}

.leaderboard-score {
    font-size: 13px;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-glow);
    min-width: 45px;
    text-align: right;
}

.leaderboard-species-portrait {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 0.9;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.leaderboard-species-portrait img,
.leaderboard-species-portrait svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.empire-entry:hover .leaderboard-species-portrait {
    transform: scale(1.1);
    opacity: 1;
}

.agent-species-portrait {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TECH TREE - Research Visualization
   ═══════════════════════════════════════════════════════════════════════════════ */
.tech-tree-modal {
    max-width: 1400px !important;
    max-height: 90vh !important;
    width: 95vw !important;
}

.tech-tree-modal .modal-body {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

/* Tech Tree Controls */
.tech-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
}

.tech-search {
    flex: 0 0 200px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: rgba(30, 30, 50, 0.8);
    color: var(--text);
    font-size: 13px;
    transition: all 0.2s ease;
}

.tech-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.tech-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tech-filter {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    background: rgba(40, 40, 60, 0.6);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tech-filter:hover {
    background: rgba(60, 60, 80, 0.8);
    color: var(--text);
}

.tech-filter.active {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-color: var(--accent);
    color: white;
    font-weight: 500;
}

.tech-view-toggle {
    display: flex;
    margin-left: auto;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.tech-view-btn {
    padding: 6px 14px;
    border: none;
    background: rgba(40, 40, 60, 0.6);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tech-view-btn:first-child {
    border-right: 1px solid var(--border-subtle);
}

.tech-view-btn:hover {
    background: rgba(60, 60, 80, 0.8);
    color: var(--text);
}

.tech-view-btn.active {
    background: var(--accent);
    color: white;
}

.tech-stats {
    padding: 6px 12px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 16px;
    font-size: 12px;
    color: #4ade80;
}

/* Category View */
.tech-category-group {
    margin-bottom: 20px;
}

.category-label {
    font-size: 18px;
    font-weight: 600;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2), transparent);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.category-techs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0 16px;
}

/* Smaller tech cards for the expanded tree */
.tech-card {
    width: 200px;
    min-height: auto;
}

.tech-card .tech-name {
    font-size: 12px;
}

.tech-card .tech-desc {
    font-size: 10px;
    line-height: 1.3;
}

.tech-card .tech-cost {
    font-size: 11px;
}

/* Category badge on tech cards */
.tech-category-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
}

.tech-category-badge.physics { color: #60a5fa; }
.tech-category-badge.engineering { color: #f59e0b; }
.tech-category-badge.biology { color: #4ade80; }
.tech-category-badge.military { color: #ef4444; }
.tech-category-badge.society { color: #a78bfa; }
.tech-category-badge.ascension { color: #f472b6; }
.tech-category-badge.rare { color: #fbbf24; }

/* Hidden tech cards (filtered out) */
.tech-card.hidden {
    display: none !important;
}

.tech-empire-selector {
    margin-left: auto;
    margin-right: 16px;
}

.tech-empire-selector select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.tech-tree {
    display: flex;
    flex-direction: row;
    gap: 20px;
    padding: 16px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 400px;
    align-items: flex-start;
    /* Make scrollbar always visible */
    scrollbar-width: auto;
    scrollbar-color: var(--accent) rgba(255, 255, 255, 0.1);
}

.tech-tree::-webkit-scrollbar {
    height: 12px;
}

.tech-tree::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.tech-tree::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.3);
}

.tech-tree::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, var(--accent-bright), var(--purple));
}

.tech-tier {
    background: linear-gradient(135deg, rgba(30, 30, 45, 0.8), rgba(20, 20, 35, 0.9));
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 14px;
    position: relative;
    flex-shrink: 0;  /* Prevent shrinking - force horizontal scroll */
    overflow: visible;
    flex-shrink: 0;
}

.tech-tier::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--tier-color, #4ade80), transparent);
    opacity: 0.6;
}

.tech-tier[data-tier="1"] { --tier-color: #4ade80; }
.tech-tier[data-tier="2"] { --tier-color: #60a5fa; }
.tech-tier[data-tier="3"] { --tier-color: #a78bfa; }
.tech-tier[data-tier="4"] { --tier-color: #f59e0b; }
.tech-tier[data-tier="5"] { --tier-color: #f43f5e; }

.tier-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--tier-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tier-label::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--tier-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--tier-color);
}

.tier-techs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 220px;
    max-width: 280px;
}

/* Tech tree tier separators */
.tech-tier:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, var(--tier-color, #4ade80), transparent);
    opacity: 0.5;
}

.tech-card {
    background: linear-gradient(135deg, rgba(40, 40, 60, 0.9), rgba(25, 25, 40, 0.95));
    border: 2px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 12px;
    transition: all 0.2s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.tech-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--tier-color), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.tech-card:hover::before {
    opacity: 1;
}

.tech-card:hover {
    background: linear-gradient(135deg, rgba(50, 50, 75, 0.95), rgba(35, 35, 55, 0.98));
    border-color: var(--tier-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px color-mix(in srgb, var(--tier-color) 20%, transparent);
}

.tech-card.researched {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(34, 197, 94, 0.08));
    border-color: rgba(74, 222, 128, 0.5);
    box-shadow: inset 0 0 20px rgba(74, 222, 128, 0.1);
}

.tech-card.researched::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

.tech-card.researched .tech-icon {
    filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.6));
}

.tech-card.available {
    border-color: var(--tier-color);
    box-shadow: 0 0 15px color-mix(in srgb, var(--tier-color) 30%, transparent);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 15px color-mix(in srgb, var(--tier-color) 30%, transparent); }
    50% { box-shadow: 0 0 25px color-mix(in srgb, var(--tier-color) 50%, transparent); }
}

.tech-card.locked {
    opacity: 0.45;
    filter: grayscale(40%);
}

.tech-card.locked:hover {
    opacity: 0.7;
    filter: grayscale(20%);
}

/* Highlight states for interactions */
.tech-card.prereq-highlight {
    border-color: #f59e0b !important;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4) !important;
}

.tech-card.dependent-highlight {
    border-color: #8b5cf6 !important;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4) !important;
}

.tech-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tech-icon {
    font-size: 22px;
    line-height: 1;
}

.tech-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.tech-cost-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.tech-cost {
    font-size: 11px;
    color: #a78bfa;
    font-weight: 600;
}

.tech-tier-badge {
    font-size: 9px;
    padding: 2px 6px;
    background: var(--tier-color);
    color: #000;
    font-weight: 700;
    border-radius: 3px;
}

.tech-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.tech-effects {
    font-size: 10px;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    line-height: 1.4;
}

.tech-prereqs {
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-dim);
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.tech-status {
    margin-top: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.tech-status.researched {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.tech-status.available {
    color: var(--tier-color);
    background: color-mix(in srgb, var(--tier-color) 15%, transparent);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.tech-status.locked {
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RELIQUARY MODAL - Precursor Artifacts
   ═══════════════════════════════════════════════════════════════════════════════ */
.reliquary-modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
}

.reliquary-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 16px;
    max-width: 1000px;
    width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.1);
}

.reliquary-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.reliquary-header h2 {
    color: #f59e0b;
    margin: 0;
    font-size: 24px;
}

.reliquary-subtitle {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.reliquary-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s;
}

.reliquary-close:hover {
    color: #fff;
}

.reliquary-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reliquary-tab {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reliquary-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.reliquary-tab.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #f59e0b;
    color: #000;
}

.reliquary-tab .tab-count {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.reliquary-legend {
    display: flex;
    gap: 20px;
    padding: 12px 24px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reliquary-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Empire sections in Discovered tab */
.relic-empire-section {
    margin-bottom: 24px;
}

.relic-empire-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--empire-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.empire-dot {
    width: 10px;
    height: 10px;
    background: var(--empire-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--empire-color);
}

/* Rarity sections in Catalog tab */
.relic-rarity-section {
    margin-bottom: 24px;
}

.relic-rarity-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--rarity-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rarity-dot {
    width: 8px;
    height: 8px;
    background: var(--rarity-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--rarity-color);
}

/* Relic grids */
.relic-grid,
.relic-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* Relic cards */
.relic-card {
    background: linear-gradient(135deg, rgba(40, 40, 60, 0.9), rgba(25, 25, 40, 0.95));
    border: 2px solid var(--rarity-color);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    transition: all 0.2s ease;
    overflow: hidden;
}

.relic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--rarity-color), transparent);
}

.relic-card.discovered {
    box-shadow: 0 0 20px var(--rarity-glow);
}

.relic-card.discovered:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--rarity-glow), 0 0 30px var(--rarity-glow);
}

.relic-card.locked {
    opacity: 0.5;
    filter: grayscale(50%);
    border-color: #444;
}

.relic-card.locked:hover {
    opacity: 0.7;
    filter: grayscale(30%);
}

.relic-rarity-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 9px;
    font-weight: 700;
    color: var(--rarity-color);
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.relic-discovered-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

.relic-icon {
    font-size: 36px;
    text-align: center;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px var(--rarity-glow));
}

.relic-icon.locked {
    opacity: 0.4;
    filter: grayscale(100%);
}

.relic-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--rarity-color);
    text-align: center;
    margin-bottom: 8px;
}

.relic-desc {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 8px;
}

.relic-bonuses {
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    font-size: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    text-align: center;
    line-height: 1.5;
}

.relic-unique {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
    margin-top: 8px;
}

.relic-unique-tag {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

.relic-locked-text {
    font-size: 10px;
    color: #666;
    text-align: center;
    font-style: italic;
}

.relic-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 14px;
    line-height: 1.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DIPLOMACY MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.diplomacy-modal {
    max-width: 800px !important;
    max-height: 85vh !important;
}

.diplomacy-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 12px;
    margin-bottom: 16px;
}

.diplomacy-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.diplomacy-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.diplomacy-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    padding: 10px 12px;
    transition: all var(--transition-fast);
}

.diplomacy-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
}

.diplomacy-item.war {
    border-left: 3px solid var(--danger);
}

.diplomacy-item.alliance {
    border-left: 3px solid var(--success);
}

.diplomacy-item.proposal {
    border-left: 3px solid var(--warning);
}

.diplomacy-empire {
    display: flex;
    align-items: center;
    gap: 6px;
}

.diplomacy-empire-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.diplomacy-empire-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.diplomacy-vs {
    font-size: 16px;
    color: var(--text-dim);
}

.diplomacy-status {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: var(--border-radius);
}

.diplomacy-status.war {
    background: rgba(244, 63, 94, 0.2);
    color: var(--danger);
}

.diplomacy-status.alliance {
    background: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.diplomacy-status.proposal {
    background: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

.diplomacy-time {
    font-size: 10px;
    color: var(--text-dim);
}

/* Diplomacy Matrix */
.diplomacy-matrix {
    overflow-x: auto;
    padding: 10px 0;
}

.diplomacy-matrix table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 11px;
}

.diplomacy-matrix th,
.diplomacy-matrix td {
    padding: 8px 6px;
    text-align: center;
    background: var(--bg-panel-glass);
    border-radius: var(--border-radius);
}

.diplomacy-matrix th {
    font-weight: 600;
    color: var(--text-secondary);
}

.diplomacy-matrix td.war {
    background: rgba(244, 63, 94, 0.3);
    color: var(--danger);
}

.diplomacy-matrix td.alliance {
    background: rgba(52, 211, 153, 0.3);
    color: var(--success);
}

.diplomacy-matrix td.neutral {
    background: var(--bg-card);
    color: var(--text-dim);
}

.diplomacy-matrix td.self {
    background: var(--bg-input);
    color: var(--text-dim);
}

.diplomacy-matrix .empire-header {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.diplomacy-matrix .empire-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   COUNCIL MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.council-modal {
    max-width: 600px !important;
    max-height: 80vh !important;
}

.council-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.council-status-section,
.council-voting-section,
.council-history-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 12px;
}

.council-status-section h3,
.council-voting-section h3,
.council-history-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.council-current-leader {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, rgba(251, 191, 36, 0.05) 100%);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: var(--border-radius);
}

.council-current-leader .leader-crown {
    font-size: 32px;
}

.council-current-leader .leader-info {
    flex: 1;
}

.council-current-leader .leader-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--warning);
}

.council-current-leader .leader-stats {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.council-no-leader {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-style: italic;
}

.voting-timer {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--warning);
    margin-bottom: 12px;
    animation: pulse 1s ease-in-out infinite;
}

.council-candidates {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.council-candidate {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-panel-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.council-candidate:hover {
    background: var(--bg-hover);
    border-color: var(--accent-line);
}

.council-candidate.voted {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.1);
}

.council-candidate .candidate-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.council-candidate .candidate-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
}

.council-candidate .candidate-votes {
    font-size: 11px;
    color: var(--text-secondary);
}

.council-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.council-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--bg-panel-glass);
    border-radius: var(--border-radius);
    font-size: 11px;
}

.council-history-item .history-winner {
    font-weight: 600;
    color: var(--text-primary);
}

.council-history-item .history-time {
    margin-left: auto;
    color: var(--text-dim);
}

/* Observer Count Style */
.observer-count {
    font-size: 0.75rem;
    color: var(--accent-purple);
    margin-left: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FLEET MOVEMENT VISUALIZATION
   ═══════════════════════════════════════════════════════════════════════════════ */
.fleet-path {
    stroke-dasharray: 8 4;
    animation: fleetDash 1s linear infinite;
}

@keyframes fleetDash {
    to { stroke-dashoffset: -12; }
}

.fleet-marker {
    filter: drop-shadow(0 0 4px currentColor);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCROLLBARS - Minimal Style
   ═══════════════════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
    background: var(--border-panel);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RIPPLE EFFECT - Performance Optimized
   ═══════════════════════════════════════════════════════════════════════════════ */
.ripple {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: rippleEffect 0.6s ease-out forwards;
    pointer-events: none;
    will-change: transform, opacity;
}

@keyframes rippleEffect {
    to {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOOLTIPS
   ═══════════════════════════════════════════════════════════════════════════════ */
[title] {
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════════════════════ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-dim);
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    margin-left: 12px;
    border: 2px solid var(--border-panel);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════════ */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-dim { color: var(--text-dim); }

.glow-accent { text-shadow: 0 0 10px var(--accent-glow); }
.glow-gold { text-shadow: 0 0 10px var(--gold-glow); }

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE - Mobile Support
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --panel-width: 100%;
        --header-height: 44px;
    }
    
    .main-layout {
        flex-direction: column;
    }
    
    .info-panel {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid var(--border-panel);
    }
    
    .header-left .tagline {
        display: none;
    }
    
    .header-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .events-bar {
        min-height: 100px;
        max-height: 120px;
        padding: 6px 12px;
    }
    
    .events-bar-header {
        font-size: 10px;
        padding-right: 8px;
    }
    
    .event-log .event-entry {
        padding: 3px 8px;
        font-size: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PERFORMANCE - Reduce Motion Support
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .game-container::before {
        animation: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FOCUS STATES - Accessibility
   ═══════════════════════════════════════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
    outline: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SPECIES MODAL - Lore & Traits Display
   ═══════════════════════════════════════════════════════════════════════════════ */
.species-modal,
.citizens-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.species-modal-content,
.citizens-modal-content {
    background: var(--bg-panel-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.6), 
        0 0 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 212, 255, 0.1),
        inset 0 1px 0 var(--glass-highlight);
    animation: modalSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.species-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-panel-header);
    flex-shrink: 0;
}

.species-modal-header h3 {
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.species-modal-content .close-btn,
.citizens-modal-content .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.species-modal-content .close-btn:hover,
.citizens-modal-content .close-btn:hover {
    color: var(--danger);
    background: rgba(244, 63, 94, 0.1);
}

.species-intro {
    padding: 16px 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.species-filters {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-btn:hover {
    border-color: var(--accent-line);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.species-grid {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-dim) transparent;
}

.species-grid::-webkit-scrollbar {
    width: 8px;
}

.species-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.species-grid::-webkit-scrollbar-thumb {
    background: var(--accent-dim);
    border-radius: 4px;
}

.species-grid::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.species-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: visible;
    transition: all 0.2s ease;
}

.species-card:hover {
    border-color: var(--accent-line);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.species-header {
    padding: 16px 20px;
    border-left: 4px solid;
    background: rgba(0, 0, 0, 0.3);
}

.species-portrait-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.species-portrait {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.species-portrait-container {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 20px rgba(100, 150, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.8), rgba(15, 15, 30, 0.9));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.species-portrait-container:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6), 0 0 30px rgba(100, 150, 255, 0.25);
}

.species-portrait-container img,
.species-portrait-container svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.species-info {
    flex: 1;
    min-width: 0;
}

.species-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.species-icon {
    font-size: 1.5rem;
}

.species-title h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

.species-category {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.species-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    font-style: italic;
}

.species-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-subtle);
}

.trait-bonus,
.trait-penalty,
.trait-world {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 500;
}

.trait-bonus {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.trait-penalty {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.trait-world {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.species-ability {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(251, 191, 36, 0.08);
    border-top: 1px solid rgba(251, 191, 36, 0.2);
}

.ability-icon {
    font-size: 1.2rem;
}

.ability-name {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.9rem;
}

.ability-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.species-lore-toggle {
    border-top: 1px solid var(--border-subtle);
}

.species-lore-toggle summary {
    padding: 12px 20px;
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease;
    list-style: none;
}

.species-lore-toggle summary::-webkit-details-marker {
    display: none;
}

.species-lore-toggle summary::before {
    content: '▶ ';
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.species-lore-toggle[open] summary::before {
    transform: rotate(90deg);
}

.species-lore-toggle summary:hover {
    background: var(--bg-hover);
}

.species-lore {
    padding: 0 20px 20px;
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-dim) transparent;
}

.species-lore::-webkit-scrollbar {
    width: 6px;
}

.species-lore::-webkit-scrollbar-track {
    background: transparent;
}

.species-lore::-webkit-scrollbar-thumb {
    background: var(--accent-dim);
    border-radius: 3px;
}

.species-lore::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.lore-section {
    margin-bottom: 16px;
}

.lore-section:last-child {
    margin-bottom: 0;
}

.lore-section h5 {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lore-section p {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-line;
}

.lore-section p.philosophy {
    font-style: italic;
    color: var(--accent);
    border-left: 2px solid var(--accent-line);
    padding-left: 12px;
}

/* Citizens Modal */
.citizens-modal-content h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 1.2rem;
    color: var(--accent);
}

.citizen-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.citizen-entry:hover {
    background: var(--bg-hover);
}

.citizen-entry:last-child {
    border-bottom: none;
}

.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.online-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.online-dot.offline {
    background: var(--text-dim);
}

.citizen-info {
    flex: 1;
}

.citizen-name {
    color: var(--text-primary);
    font-weight: 500;
}

.citizen-moltbook {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.citizen-moltbook a {
    color: var(--accent);
    text-decoration: none;
}

.citizen-moltbook a:hover {
    text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .species-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .species-filters {
        flex-wrap: wrap;
    }
    
    .filter-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .species-card {
        margin: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   Real-time event notifications with category-based styling
   ═══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 340px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Hide scrollbar but keep functionality */
.toast-container::-webkit-scrollbar {
    width: 0;
}

.toast {
    pointer-events: auto;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 var(--glass-highlight);
    padding: 14px 18px;
    opacity: 0;
    transform: translateX(100%) scale(0.9);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
}

/* Progress bar for auto-dismiss */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    width: 100%;
    transform-origin: left;
    animation: toastProgress 5s linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.toast:hover .toast-progress {
    animation-play-state: paused;
}

/* Toast header */
.toast-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.toast-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.toast-close:hover {
    opacity: 1;
    color: var(--text-primary);
}

/* Toast content */
.toast-message {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.toast-detail {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.3;
}

.toast-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Toast Categories - Color variants */

/* Combat (red) */
.toast.combat {
    border-left-color: var(--danger);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(244, 63, 94, 0.05) 100%);
}
.toast.combat .toast-category,
.toast.combat .toast-progress { color: var(--danger); background: var(--danger); }
.toast.combat .toast-icon { filter: drop-shadow(0 0 6px var(--danger)); }

/* Diplomacy (purple) */
.toast.diplomacy {
    border-left-color: var(--purple);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(152, 85, 247, 0.05) 100%);
}
.toast.diplomacy .toast-category,
.toast.diplomacy .toast-progress { color: var(--purple); background: var(--purple); }
.toast.diplomacy .toast-icon { filter: drop-shadow(0 0 6px var(--purple)); }

/* Colonization (green) */
.toast.colonization {
    border-left-color: var(--success);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(52, 211, 153, 0.05) 100%);
}
.toast.colonization .toast-category,
.toast.colonization .toast-progress { color: var(--success); background: var(--success); }
.toast.colonization .toast-icon { filter: drop-shadow(0 0 6px var(--success)); }

/* Trade (gold) */
.toast.trade {
    border-left-color: var(--gold);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(245, 200, 66, 0.05) 100%);
}
.toast.trade .toast-category,
.toast.trade .toast-progress { color: var(--gold); background: var(--gold); }
.toast.trade .toast-icon { filter: drop-shadow(0 0 6px var(--gold)); }

/* Fleet (blue) */
.toast.fleet {
    border-left-color: var(--info);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(96, 165, 250, 0.05) 100%);
}
.toast.fleet .toast-category,
.toast.fleet .toast-progress { color: var(--info); background: var(--info); }
.toast.fleet .toast-icon { filter: drop-shadow(0 0 6px var(--info)); }

/* Starbase (cyan) */
.toast.starbase {
    border-left-color: var(--accent);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(0, 212, 255, 0.05) 100%);
}
.toast.starbase .toast-category,
.toast.starbase .toast-progress { color: var(--accent); background: var(--accent); }
.toast.starbase .toast-icon { filter: drop-shadow(0 0 6px var(--accent)); }

/* Research (light purple) */
.toast.research {
    border-left-color: #c084fc;
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(192, 132, 252, 0.05) 100%);
}
.toast.research .toast-category,
.toast.research .toast-progress { color: #c084fc; background: #c084fc; }
.toast.research .toast-icon { filter: drop-shadow(0 0 6px #c084fc); }

/* Agent (orange) */
.toast.agent {
    border-left-color: #fb923c;
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(251, 146, 60, 0.05) 100%);
}
.toast.agent .toast-category,
.toast.agent .toast-progress { color: #fb923c; background: #fb923c; }
.toast.agent .toast-icon { filter: drop-shadow(0 0 6px #fb923c); }

/* Game events (default cyan) */
.toast.game {
    border-left-color: var(--accent);
}

/* Victory (gold with glow) */
.toast.victory {
    border-left-color: var(--gold);
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(245, 200, 66, 0.1) 100%);
    box-shadow: var(--shadow-panel), 0 0 30px rgba(245, 200, 66, 0.2);
}
.toast.victory .toast-category,
.toast.victory .toast-progress { color: var(--gold); background: var(--gold); }
.toast.victory .toast-icon { filter: drop-shadow(0 0 10px var(--gold)); }

/* Invasion (dark red) */
.toast.invasion {
    border-left-color: #dc2626;
    background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(220, 38, 38, 0.08) 100%);
    box-shadow: var(--shadow-panel), 0 0 25px rgba(220, 38, 38, 0.15);
}
.toast.invasion .toast-category,
.toast.invasion .toast-progress { color: #dc2626; background: #dc2626; }
.toast.invasion .toast-icon { filter: drop-shadow(0 0 8px #dc2626); }

/* Toast animations for different priorities */
.toast.priority-high {
    animation: toastPulse 2s ease-in-out infinite;
}

@keyframes toastPulse {
    0%, 100% { box-shadow: var(--shadow-panel), 0 0 20px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: var(--shadow-panel), 0 0 30px rgba(255, 255, 255, 0.1); }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .toast-container {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        max-width: 100%;
    }
    
    .toast {
        padding: 10px 14px;
    }
    
    .toast-message {
        font-size: 0.85rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   COLLAPSIBLE PANELS - Right sidebar sections
   ═══════════════════════════════════════════════════════════════════════════════ */

.panel-section.collapsible .panel-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-section.collapsible .panel-header:hover {
    color: var(--accent);
}

.collapse-icon {
    font-size: 10px;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.panel-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.panel-section.collapsible > *:not(.panel-header):not(h2):not(.agent-list):not(.fleet-activity):not(.battle-activity) {
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
    overflow: hidden;
}

/* Allow scrolling in agent list, fleet activity, and battle activity even in collapsible panels */
.panel-section.collapsible > .agent-list,
.panel-section.collapsible > .fleet-activity,
.panel-section.collapsible > .battle-activity {
    transition: max-height 0.3s ease, opacity 0.2s ease;
    overflow-y: auto !important;
}

.panel-section.collapsed > *:not(.panel-header):not(h2) {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   KEYBOARD SHORTCUTS HINT
   ═══════════════════════════════════════════════════════════════════════════════ */

.shortcuts-hint {
    position: absolute;
    bottom: 16px;
    left: 70px;
    display: flex;
    gap: 12px;
    padding: 6px 12px;
    background: var(--bg-panel-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-size: 10px;
    color: var(--text-dim);
    opacity: 0.6;
    transition: opacity var(--transition-smooth);
    z-index: 5;
    animation: hintFadeIn 0.5s ease-out 0.5s both;
}

@keyframes hintFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 0.6;
        transform: translateY(0);
    }
}

.shortcuts-hint:hover {
    opacity: 1;
}

.shortcuts-hint span {
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

/* Hide on small screens */
@media (max-width: 900px) {
    .shortcuts-hint {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   KEYBOARD SHORTCUTS MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */

.shortcuts-modal {
    max-width: 400px !important;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    padding: 10px 0;
}

.shortcut-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 8px;
    background: var(--bg-active);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.shortcut-desc {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CUSTOM TOOLTIP SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */
.tooltip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-content {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 8px 12px;
    box-shadow: var(--shadow-panel), 0 0 20px rgba(0, 0, 0, 0.5);
    max-width: 280px;
    min-width: 120px;
}

.tooltip-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tooltip-title .tooltip-icon {
    width: 16px;
    height: 16px;
}

.tooltip-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tooltip-shortcut {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
    font-size: 10px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tooltip-shortcut kbd {
    background: var(--bg-active);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 10px;
}

/* Tooltip arrow */
.tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    border: 6px solid transparent;
    border-bottom-color: var(--bg-panel);
}

.tooltip.arrow-right::before {
    left: auto;
    right: 20px;
}

.tooltip.arrow-top::before {
    top: auto;
    bottom: -6px;
    border-bottom-color: transparent;
    border-top-color: var(--bg-panel);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SVG RESOURCE ICONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.resource-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-icon svg {
    width: 16px;
    height: 16px;
    filter: drop-shadow(0 0 3px currentColor);
}

/* Resource icon colors */
.resource-icon.minerals svg { color: #60a5fa; }
.resource-icon.energy svg { color: #fbbf24; }
.resource-icon.food svg { color: #4ade80; }
.resource-icon.research svg { color: #a78bfa; }
.resource-icon.population svg { color: #f472b6; }

/* Pulse animation on hover */
.resource-item:hover .resource-icon svg {
    animation: iconPulse 0.3s ease;
}

@keyframes iconPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Header button icon styling */
.header-btn svg {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DIPLOMACY SUMMARY (Sidebar)
   ═══════════════════════════════════════════════════════════════════════════════ */
.diplomacy-summary-section {
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
}

.diplomacy-summary {
    font-size: 0.85rem;
}

.diplo-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.diplo-label {
    color: var(--text-secondary);
}

.diplo-value {
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.diplo-value.war {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.diplo-value.alliance {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FLEET ACTIVITY PANEL - Track fleets in transit
   ═══════════════════════════════════════════════════════════════════════════════ */

.fleet-activity-section {
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
}

.fleet-activity-section h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fleet-count {
    font-size: 0.75rem;
    font-weight: normal;
    padding: 2px 6px;
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent-primary);
    border-radius: 10px;
}

.fleet-activity {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-glow) transparent;
}

.fleet-activity::-webkit-scrollbar {
    width: 6px;
}

.fleet-activity::-webkit-scrollbar-track {
    background: transparent;
}

.fleet-activity::-webkit-scrollbar-thumb {
    background: var(--border-glow);
    border-radius: 3px;
}

.fleet-activity::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.fleet-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
    font-size: 0.8rem;
    transition: background 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

.fleet-item:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(2px);
}

.fleet-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fleet-item-info {
    flex: 1;
    min-width: 0;
}

.fleet-item-route {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fleet-item-route .arrow {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.fleet-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.fleet-item-ships {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fleet-item-eta {
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 212, 255, 0.2);
    color: var(--accent-primary);
}

.fleet-item-eta.urgent {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    animation: pulse-eta 1s infinite;
}

@keyframes pulse-eta {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.fleet-item-type {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fleet-item-type.intra-system {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.fleet-item-type.inter-system {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.fleet-item-type.inter-galactic {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

/* Progress bar in fleet item */
.fleet-item-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 0 0 6px 6px;
    transition: width 0.5s ease;
}

.fleet-item {
    position: relative;
    overflow: hidden;
}

.fleet-overflow-indicator {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 6px;
    opacity: 0.7;
}

.active-conflicts {
    margin-top: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.conflict-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin: 4px 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
}

.conflict-item.war {
    border-left: 2px solid #ef4444;
}

.conflict-item.alliance {
    border-left: 2px solid #4ade80;
}

.conflict-empire {
    display: flex;
    align-items: center;
    gap: 3px;
}

.conflict-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.conflict-vs {
    color: var(--text-dim);
    font-size: 0.7rem;
}

/* Agent list improvements */
.agent-item .agent-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.agent-empire-name {
    font-weight: 500;
}

.agent-action {
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SHIP DESIGNER MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */

.ship-designer-modal {
    max-width: 900px;
    width: 95%;
}

.ship-designer-layout {
    display: grid;
    grid-template-columns: 200px 1fr 220px;
    gap: 16px;
    min-height: 450px;
}

.sd-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.sd-panel h3 {
    font-size: 14px;
    margin: 0 0 10px 0;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

/* Hull List */
.sd-hull-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

.sd-hull-item {
    padding: 8px 10px;
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sd-hull-item:hover {
    background: rgba(50, 50, 80, 0.8);
    border-color: var(--accent-primary);
}

.sd-hull-item.selected {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.sd-hull-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.sd-hull-item .hull-name {
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sd-hull-item .hull-tier {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sd-hull-item .hull-slots {
    font-size: 10px;
    color: var(--text-dim);
}

/* Preview Panel */
.sd-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sd-ship-name input {
    width: 100%;
    max-width: 200px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
}

.sd-ship-name input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.sd-ship-icon {
    font-size: 64px;
    line-height: 1;
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.4));
}

.sd-ship-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.sd-stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
}

.sd-stat-label {
    color: var(--text-secondary);
    margin-right: 4px;
}

.sd-slots {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sd-slot-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.sd-slot-type {
    color: var(--text-secondary);
}

.sd-cost {
    padding: 8px 16px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 6px;
    font-size: 12px;
}

.sd-cost-label {
    color: var(--text-secondary);
    margin-right: 8px;
}

.sd-installed-modules {
    width: 100%;
}

.sd-installed-modules h4 {
    font-size: 12px;
    margin: 8px 0 6px 0;
    color: var(--text-secondary);
}

.sd-installed-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 30px;
}

.sd-installed-module {
    padding: 4px 8px;
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.4);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.sd-installed-module:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Module List */
.sd-module-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.sd-mod-tab {
    flex: 1;
    padding: 6px;
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.sd-mod-tab:hover {
    background: rgba(50, 50, 80, 0.8);
}

.sd-mod-tab.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
}

.sd-module-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

.sd-module-item {
    padding: 8px;
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.sd-module-item:hover {
    background: rgba(50, 50, 80, 0.8);
    border-color: var(--accent-primary);
}

.sd-module-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.sd-module-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sd-module-item .module-name {
    font-weight: 600;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sd-module-item .module-tier {
    font-size: 9px;
    padding: 1px 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sd-module-item .module-effect {
    font-size: 10px;
    color: #4ade80;
    margin-top: 2px;
}

.sd-module-item .module-cost {
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Blueprints Modal */
.blueprints-modal {
    max-width: 600px;
}

.blueprints-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
}

.blueprint-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s;
}

.blueprint-item:hover {
    background: rgba(50, 50, 80, 0.8);
    border-color: var(--accent-primary);
}

.blueprint-icon {
    font-size: 32px;
}

.blueprint-info {
    flex: 1;
}

.blueprint-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.blueprint-hull {
    font-size: 11px;
    color: var(--text-secondary);
}

.blueprint-stats {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

.blueprint-actions {
    display: flex;
    gap: 6px;
}

.blueprint-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.blueprint-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
}

.blueprint-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* Modal button styles */
.modal-btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: var(--accent-primary);
}

.modal-btn.primary:hover {
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .ship-designer-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .sd-hull-list, .sd-module-list {
        max-height: 150px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FLEET DETAILS MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */

.fleet-details-modal {
    max-width: 700px;
    width: 95%;
}

.fleet-details-header {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fleet-route {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.fleet-route-point {
    display: flex;
    flex-direction: column;
}

.fleet-route-point .label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.fleet-route-point .name {
    font-size: 14px;
    font-weight: 600;
}

.fleet-route-arrow {
    font-size: 24px;
    color: var(--accent-primary);
}

.fleet-progress-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-dim);
}

.fleet-progress-info .value {
    color: var(--text-primary);
    font-weight: 600;
}

.fleet-details-ships {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.ship-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ship-card:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.ship-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ship-card-icon {
    font-size: 24px;
}

.ship-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ship-card-hull {
    font-size: 10px;
    color: var(--text-dim);
}

.ship-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    font-size: 11px;
    margin-bottom: 8px;
}

.ship-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ship-stat-icon {
    font-size: 10px;
}

.ship-stat-value {
    color: var(--text-primary);
}

.ship-card-modules {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 8px;
    margin-top: 4px;
}

.ship-card-modules-title {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ship-module-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ship-module-tag {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    color: var(--accent-primary);
}

.ship-module-tag.weapon { 
    background: rgba(239, 68, 68, 0.2); 
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.ship-module-tag.defense { 
    background: rgba(59, 130, 246, 0.2); 
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.ship-module-tag.propulsion { 
    background: rgba(245, 158, 11, 0.2); 
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.ship-module-tag.utility { 
    background: rgba(16, 185, 129, 0.2); 
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.ship-hp-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.ship-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    border-radius: 2px;
    transition: width 0.3s;
}

.ship-hp-fill.damaged {
    background: linear-gradient(90deg, #eab308, #facc15);
}

.ship-hp-fill.critical {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.fleet-details-cargo {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cargo-title {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.cargo-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cargo-unit {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
}

/* Ship detail expanded view (clicking on a ship) */
.ship-detail-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 25, 0.98);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 20px;
    min-width: 300px;
    max-width: 400px;
    z-index: 10001;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.ship-detail-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

.ship-detail-close:hover {
    color: var(--text-primary);
}

.ship-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ship-detail-icon {
    font-size: 40px;
}

.ship-detail-info h3 {
    margin: 0;
    font-size: 18px;
}

.ship-detail-hull {
    color: var(--text-dim);
    font-size: 12px;
}

.ship-detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.ship-detail-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.ship-detail-stat .label {
    color: var(--text-dim);
}

.ship-detail-stat .value {
    font-weight: 600;
}

.ship-detail-modules h4 {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.ship-detail-module-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ship-detail-module {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
}

.ship-detail-module.weapon { border-color: #f87171; }
.ship-detail-module.defense { border-color: #60a5fa; }
.ship-detail-module.propulsion { border-color: #fbbf24; }
.ship-detail-module.utility { border-color: #34d399; }

.ship-detail-module-icon {
    font-size: 16px;
}

.ship-detail-module-info {
    flex: 1;
}

.ship-detail-module-name {
    font-size: 12px;
    font-weight: 600;
}

.ship-detail-module-effect {
    font-size: 10px;
    color: var(--text-dim);
}

/* -------------------------------------------------------------------------------
   BUILDINGS MODAL - Structure Guide
   ------------------------------------------------------------------------------- */

.buildings-modal {
    max-width: 900px;
    max-height: 85vh;
}

.buildings-guide {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 16px;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

.buildings-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.buildings-section h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: var(--text-bright);
}

.buildings-section .section-desc {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: var(--text-dim);
}

.building-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.building-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.building-card:hover {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.building-card.mega {
    border-color: #f59e0b44;
}

.building-card.mega:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.building-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.building-info {
    flex: 1;
}

.building-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-bright);
}

.building-cost {
    font-size: 11px;
    color: #f59e0b;
    margin-top: 2px;
}

.building-prod {
    font-size: 12px;
    color: #4ade80;
    margin-top: 4px;
}

.building-upgrades {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
    font-style: italic;
}

.building-req {
    font-size: 10px;
    color: #60a5fa;
    margin-top: 4px;
}

.tag-new {
    font-size: 10px;
    background: #4ade80;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
}

.megastructures h3 {
    color: #f59e0b;
}

.fleet-upkeep .upkeep-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 300px;
}

.upkeep-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 12px;
}

.upkeep-row.header {
    background: rgba(59, 130, 246, 0.2);
    font-weight: 600;
    color: var(--text-bright);
}

.upkeep-row span:first-child {
    flex: 1;
}

.upkeep-row span:not(:first-child) {
    width: 60px;
    text-align: center;
}

/* -------------------------------------------------------------------------------
   TILE DETAIL MODAL - Building/Tile inspection
   ------------------------------------------------------------------------------- */

.tile-detail-modal {
    max-width: 500px;
}

.tile-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px;
}

.tile-info-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid var(--border-color);
}

.tile-info-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-bright);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.tile-info-section.future {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
}

.tile-info-section.future h4 {
    color: #a78bfa;
}

.tile-location {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text-dim);
}

.tile-production {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tile-prod-item {
    font-size: 14px;
    color: #4ade80;
    font-weight: 500;
}

.tile-status {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.tile-status .constructing {
    color: #fbbf24;
}

.tile-upgrade {
    padding: 6px 10px;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    font-size: 12px;
    color: #60a5fa;
}

.tile-upgrade.completed {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.tile-buildable {
    font-size: 13px;
    color: var(--text-dim);
}

.tile-build-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-dim);
}

.tile-buildable code {
    display: block;
    margin-top: 6px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    font-size: 11px;
    color: #4ade80;
    overflow-x: auto;
    white-space: nowrap;
}

.tile-future {
    font-size: 12px;
    color: #a78bfa;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* -------------------------------------------------------------------------------
   BUILDING MODULES UI
   ------------------------------------------------------------------------------- */

.tile-info-section.modules {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
}

.tile-info-section.modules h4 {
    color: #a78bfa;
}

.modules-slots {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.modules-installed, .modules-available {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.modules-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.modules-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.module-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid var(--border-color);
}

.module-card.installed {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.3);
}

.module-card.available {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
    cursor: help;
}

.module-icon {
    font-size: 16px;
}

.module-name {
    font-weight: 500;
    color: var(--text-bright);
}

.module-effect {
    font-size: 10px;
    color: #4ade80;
    margin-left: auto;
}

.modules-more {
    font-size: 11px;
    color: var(--text-dim);
    padding: 4px 8px;
}

.modules-full {
    font-size: 12px;
    color: #fbbf24;
    padding: 4px 0;
}

.modules-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.effects-label {
    font-size: 11px;
    color: var(--text-dim);
}

.effect-badge {
    font-size: 10px;
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    padding: 2px 6px;
    border-radius: 3px;
}

.modules-hint {
    margin-top: 8px;
    font-size: 10px;
    color: var(--text-dim);
}

.modules-hint code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 2px;
    color: #60a5fa;
}

.modules-loading, .modules-error {
    font-size: 12px;
    color: var(--text-dim);
    padding: 8px 0;
}

.modules-error {
    color: #f87171;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   FPS PERFORMANCE MONITOR - Client-side performance display
   ═══════════════════════════════════════════════════════════════════════════════ */
.fps-monitor {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(15, 20, 35, 0.9);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    z-index: 1000;
    user-select: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fps-monitor:hover {
    border-color: rgba(0, 212, 255, 0.6);
    background: rgba(15, 20, 35, 0.95);
}

.fps-monitor .fps-value {
    font-size: 18px;
    font-weight: bold;
    min-width: 28px;
    text-align: right;
    color: #4ade80; /* Default green */
}

.fps-monitor .fps-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Performance state colors */
.fps-monitor.fps-good .fps-value {
    color: #4ade80; /* Green - good performance */
}

.fps-monitor.fps-warning .fps-value {
    color: #fbbf24; /* Yellow - moderate performance */
}

.fps-monitor.fps-poor .fps-value {
    color: #ef4444; /* Red - poor performance */
}

/* Pulsing animation for poor performance */
.fps-monitor.fps-poor {
    animation: fps-pulse 1s ease-in-out infinite;
}

@keyframes fps-pulse {
    0%, 100% { border-color: rgba(239, 68, 68, 0.3); }
    50% { border-color: rgba(239, 68, 68, 0.7); }
}

/* Extended info on hover */
.fps-monitor .fps-details {
    display: none;
    font-size: 9px;
    color: #666;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.1);
}

.fps-monitor:hover .fps-details {
    display: block;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .fps-monitor {
        bottom: 10px;
        left: 10px;
        padding: 4px 8px;
    }
    
    .fps-monitor .fps-value {
        font-size: 14px;
    }
}


/* ============================================================================
   ADAPTIVE FRAME RATE SCALING UI
   ============================================================================ */

/* Quality Mode Indicator */
.quality-indicator {
    position: fixed;
    top: 10px;
    right: 70px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 10px;
    font-weight: bold;
    color: #888;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
}

.quality-indicator:hover {
    border-color: rgba(0, 212, 255, 0.6);
    background: rgba(0, 30, 60, 0.8);
}

.quality-indicator.mode-performance {
    border-color: rgba(255, 165, 0, 0.5);
}
.quality-indicator.mode-performance .quality-label {
    color: #ffa500;
}

.quality-indicator.mode-balanced {
    border-color: rgba(0, 212, 255, 0.5);
}
.quality-indicator.mode-balanced .quality-label {
    color: #00d4ff;
}

.quality-indicator.mode-quality {
    border-color: rgba(74, 222, 128, 0.5);
}
.quality-indicator.mode-quality .quality-label {
    color: #4ade80;
}

/* Quality Mode Toast */
.quality-toast {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 20, 40, 0.95);
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 8px;
    padding: 12px 24px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #fff;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.quality-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Inline icons for message rendering */
.inline-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin: 0 2px;
    filter: drop-shadow(0 0 2px rgba(0, 200, 255, 0.5));
}

.event-message .inline-icon {
    width: 16px;
    height: 16px;
}


/* ============================================================================
   EVENT ALERT SYSTEM - Visual notifications for important game events
   ============================================================================ */

/* Alert Container - top right corner */
.event-alert-container {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    max-width: calc(100vw - 40px);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* Individual Alert */
.event-alert {
    position: relative;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
    border: 1px solid var(--alert-color, #00d4ff);
    border-left: 4px solid var(--alert-color, #00d4ff);
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(var(--alert-color, 0, 212, 255), 0.15);
    backdrop-filter: blur(10px);
    cursor: pointer;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease;
    overflow: hidden;
}

.event-alert.show {
    transform: translateX(0);
    opacity: 1;
}

.event-alert.hide {
    transform: translateX(120%);
    opacity: 0;
}

.event-alert:hover {
    transform: translateX(-5px);
    box-shadow: 
        0 6px 25px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(var(--alert-color, 0, 212, 255), 0.25);
}

/* Alert Header */
.event-alert .alert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.event-alert .alert-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 4px var(--alert-color));
}

.event-alert .alert-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--alert-color);
    text-transform: uppercase;
}

.event-alert .alert-tick {
    margin-left: auto;
    font-size: 0.65rem;
    color: #64748b;
    font-family: 'Courier New', monospace;
}

/* Alert Message */
.event-alert .alert-message {
    font-size: 0.85rem;
    color: #e2e8f0;
    line-height: 1.4;
}

/* Progress bar for auto-dismiss */
.event-alert .alert-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: var(--alert-color);
    transform-origin: left;
    animation: alertProgress linear forwards;
}

@keyframes alertProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* System alerts (toggle feedback) */
.event-alert.system-alert {
    padding: 8px 14px;
    border-left-width: 2px;
    --alert-color: #64748b;
}

.event-alert.system-alert .alert-message {
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Category-specific colors */
.event-alert.category-invasion {
    --alert-color: #dc2626;
}

.event-alert.category-combat {
    --alert-color: #f97316;
}

.event-alert.category-conquest {
    --alert-color: #eab308;
}

.event-alert.category-colonization {
    --alert-color: #22c55e;
}

.event-alert.category-research {
    --alert-color: #06b6d4;
}

.event-alert.category-diplomacy {
    --alert-color: #8b5cf6;
}

.event-alert.category-crisis {
    --alert-color: #dc2626;
    animation: alertPulse 1s ease-in-out infinite;
}

.event-alert.category-victory {
    --alert-color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(15, 23, 42, 0.95));
}

.event-alert.category-agent {
    --alert-color: #60a5fa;
}

.event-alert.category-building {
    --alert-color: #22d3ee;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 20px rgba(220, 38, 38, 0.15); }
    50% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 40px rgba(220, 38, 38, 0.35); }
}

/* Alert Toggle Button */
.alert-toggle {
    position: relative;
}

.alert-toggle::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.alert-toggle.has-alerts::after {
    opacity: 1;
    animation: alertDot 1s ease-in-out infinite;
}

@keyframes alertDot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .event-alert-container {
        width: 280px;
        right: 10px;
        top: 70px;
    }
    
    .event-alert {
        padding: 10px 12px;
    }
    
    .event-alert .alert-message {
        font-size: 0.8rem;
    }
}
