/* ========================================
   IMPORTS & FONTS
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================================
   RESET & BASE STYLES
   ======================================== */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333; /* Standardtextfarbe dunkelgrau */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    /* ALT: background: #ffffff; */
    background: #1a1a2e; /* Passt zu den dunklen Modals */
    border-radius: 20px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    color: rgba(255, 255, 255, 0.85); /* NEU: Standard-Textfarbe hell */
}

/* ========================================
   HEADER
   ======================================== */

.app-header {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 30px 40px;
    text-align: center;
    position: relative;
}

.app-header h1 {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    color: #f8f9fa;
}

.subtitle {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
    color: #f8f9fa;
}

.status-bar {
    margin-top: 15px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 13px;
    display: inline-block;
    transition: background 0.5s ease;
}

/* ========================================
   MAIN NAVIGATION (4 Tabs)
   ======================================== */

.main-nav {
    display: flex;
    background: #34495e;
    border-bottom: 3px solid #2c3e50;
}

.nav-tab {
    flex: 1;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 20px 15px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-tab.active {
    background: white;
    color: #2c3e50;
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e74c3c;
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   CONTENT WRAPPER
   ======================================== */

.content-wrapper {
    min-height: 600px;
}

.content-section {
    display: none;
    padding: 40px;
    animation: fadeIn 0.3s ease;
}

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

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

/* ========================================
   SECTION HEADERS
   ======================================== */

.section-header {
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1); /* Hellerer Border */
    padding-bottom: 20px;
}

.section-header h2 {
    /* ALT: color: #2c3e50; */
    color: #d4af37; /* NEU: Gold-Akzent */
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.section-header p {
    /* ALT: color: #7f8c8d; */
    color: rgba(255, 255, 255, 0.7); /* NEU: Helleres Grau */
    font-size: 16px;
}

/* ========================================
   FACTION TABS (Sub-Navigation)
   ======================================== */

.faction-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.faction-tab {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
}

.faction-tab:hover {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
    color: #4ecdc4;
}

.faction-tab.active {
    background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
    border-color: #d4af37;
    color: #1a1a2e;
    font-weight: 700;
}

/* ========================================
   REFERENCE TABS (Sub-Navigation)
   ======================================== */

.reference-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #ecf0f1;
}

.reference-tab {
    background: none;
    border: none;
    padding: 15px 25px;
    font-size: 15px;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
}

.reference-tab:hover {
    color: #2c3e50;
}

.reference-tab.active {
    color: #e74c3c;
    border-bottom-color: #e74c3c;
}

.reference-content {
    display: none;
}

.reference-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ========================================
   SEARCH CONTAINER
   ======================================== */

.search-container {
    margin-bottom: 25px;
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
    color: #333; /* Sicherstellen, dass Text dunkel ist */
}

.search-input:focus {
    outline: none;
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* ========================================
   FILTERS ROW
   ======================================== */

.filters-row {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-select {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    color: #333; /* Textfarbe für Select */
}

/* NEU: Styling für Dropdown-Optionen */
.filter-select option {
    background: #2c3e50; /* Dunkler Hintergrund */
    color: #ffffff; /* Weiße Schrift */
    padding: 10px;
}

.filter-select:hover {
    border-color: #bdc3c7;
}

.filter-select:focus {
    outline: none;
    border-color: #e74c3c;
}

.btn-secondary {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #2c3e50;
}

.btn-secondary:hover {
    background: #ecf0f1;
    border-color: #bdc3c7;
}

/* ========================================
   RESULTS CONTAINER & PLACEHOLDER
   ======================================== */

.results-container {
    margin-top: 20px;
    min-height: 300px; /* Mindesthöhe für Ladezustand */
}

.placeholder {
    padding: 40px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    background-color: rgba(26, 26, 46, 0.5);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.results-count {
    padding: 12px 20px;
    background: rgba(26, 26, 46, 0.8);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #4ecdc4;
    margin-bottom: 20px;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

/* ========================================
   QUICK REFERENCE GRID
   ======================================== */

.quick-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.quick-ref-card {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.quick-ref-card:hover {
    border-color: #4ecdc4;
    box-shadow: 0 5px 20px rgba(78, 205, 196, 0.3);
    transform: translateY(-2px);
}

.quick-ref-card h3 {
    color: #d4af37;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-ref-card p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 15px;
    line-height: 1.8;
}

/* ========================================
   INFO BOX (z.B. für Formations-Platzhalter)
   ======================================== */

.info-box {
    background: #fff9e6;
    border: 1px solid #ffeeba;
    border-left: 5px solid #ffc107;
    border-radius: 8px;
    padding: 20px 25px;
    margin-top: 20px;
    color: #856404;
}
.info-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.info-box p, .info-box li { font-size: 15px; line-height: 1.7; }
.info-box ul { margin: 10px 0 0 20px; padding-left: 5px; }
.info-box li { margin-bottom: 5px; }

/* ========================================
   UNIT DISPLAY & CARDS (FACTIONS) - DARK THEME
   ======================================== */
.unit-type-group { margin-bottom: 30px; }
.unit-type-header {
    color: #d4af37; 
    font-size: 24px; 
    font-weight: 700; 
    margin-bottom: 20px;
    padding: 15px 20px; 
    background: rgba(26, 26, 46, 0.8);
    border-radius: 10px;
    border-left: 4px solid #e94560;
}
.units-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.unit-card {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1); 
    border-left: 5px solid #4ecdc4; 
    border-radius: 10px;
    padding: 20px; 
    cursor: pointer; 
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.unit-card:hover {
    border-left-color: #d4af37; 
    transform: translateY(-3px); 
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.3);
    border-color: rgba(212, 175, 55, 0.3);
}
.unit-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
.unit-card-header h4 { 
    font-size: 18px; 
    color: rgba(255, 255, 255, 0.95); 
    margin: 0; 
    flex: 1; 
    line-height: 1.4; 
    font-weight: 600;
}
.unit-points {
    background: #e94560; 
    color: white; 
    padding: 5px 12px; 
    border-radius: 12px;
    font-size: 13px; 
    font-weight: 700; 
    white-space: nowrap; 
    margin-left: 10px;
}
.unit-card-meta { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; font-size: 12px; }
.unit-type-badge, .unit-scale-badge { 
    background: rgba(78, 205, 196, 0.2); 
    color: #4ecdc4; 
    padding: 4px 10px; 
    border-radius: 4px; 
    font-weight: 600; 
    border: 1px solid rgba(78, 205, 196, 0.3);
}
.unit-card-stats {
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 5px 10px; 
    margin-top: 10px;
    font-size: 13px; 
    color: rgba(255, 255, 255, 0.85); 
    padding-top: 10px; 
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.unit-card-weapons { 
    margin-top: 8px; 
    font-size: 13px; 
    color: rgba(255, 255, 255, 0.7); 
}

/* ========================================
   RULE DISPLAY (Search & Category)
   ======================================== */
.search-document-group { 
    background: rgba(26, 26, 46, 0.9); 
    border-radius: 12px; 
    margin-bottom: 20px; 
    overflow: hidden; 
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); 
    border: 2px solid rgba(255, 255, 255, 0.1); 
}
.search-document-header { 
    background: rgba(44, 53, 68, 0.9); 
    padding: 15px 20px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); 
}
.search-document-header .doc-icon { font-size: 18px; color: #4ecdc4; }
.search-document-header .doc-name { font-weight: 700; color: #d4af37; font-size: 16px; }
.search-results-list { padding: 0; }
.search-result-card { 
    padding: 15px 20px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
    cursor: pointer; 
    transition: background 0.2s ease; 
}
.search-result-card:last-child { border-bottom: none; }
.search-result-card:hover { background: rgba(78, 205, 196, 0.1); }
.search-result-card h4 { 
    color: rgba(255, 255, 255, 0.95); 
    font-size: 16px; 
    font-weight: 600; 
    margin-bottom: 5px; 
    line-height: 1.4; 
}
.search-result-card p { 
    color: rgba(255, 255, 255, 0.75); 
    font-size: 14px; 
    line-height: 1.6; 
    margin: 0; 
}
.search-result-card mark { 
    background: rgba(212, 175, 55, 0.3); 
    color: #ffd700; 
    padding: 2px 4px; 
    border-radius: 3px; 
    font-weight: 600; 
}
.show-more-results { 
    padding: 12px 20px; 
    background: rgba(44, 53, 68, 0.9); 
    color: #4ecdc4; 
    text-align: center; 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 600; 
    transition: background 0.2s ease; 
    border-top: 1px solid rgba(255, 255, 255, 0.1); 
}
.show-more-results:hover { background: rgba(78, 205, 196, 0.2); color: #d4af37; }
.rules-category-view { padding: 10px 0; }
.rule-category-section { margin-bottom: 25px; background: rgba(44, 53, 68, 0.3); padding: 20px; border-radius: 12px; }

/* === NEUER BLOCK START: Anpassung für Accordion-Regeln === */
.category-header { 
    color: #d4af37; 
    font-size: 22px; 
    font-weight: 700;
    margin-bottom: 15px; 
    padding: 15px 20px; 
    background: rgba(26, 26, 46, 0.8);
    border-radius: 10px; 
    border-left: 4px solid #e94560;
    
    /* Hinzugefügte Regeln für Accordion: */
    cursor: pointer;
    list-style: none; /* Entfernt den Standard-Pfeil (Firefox) */
    position: relative;
    padding-left: 45px !important; /* Wichtig: Platz für unser + Icon */
}

/* Entfernt den Standard-Pfeil (Chrome/Safari) */
.category-header::-webkit-details-marker {
    display: none; 
}

/* Fügt ein [+] Icon hinzu, wenn geschlossen */
.category-header::before {
    content: '[+]';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: #d4af37; /* Gold-Akzent */
    font-size: 18px;
    transition: content 0.2s ease;
}

/* Ändert das Icon zu [-] wenn die Sektion offen ist */
.rule-category-section[open] > .category-header {
    margin-bottom: 0; /* Entfernt den Margin, wenn geöffnet, für sauberen Übergang */
}

.rule-category-section[open] > .category-header::before {
    content: '[\2012]'; /* \2012 ist ein Minus-Zeichen */
}

/* Fügt einen kleinen Abstand hinzu, wenn die Liste geöffnet wird */
.rule-category-section[open] > .rules-list {
    padding-top: 15px;
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
/* === NEUER BLOCK ENDE === */

.rules-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 15px; }
.rule-item { 
    background: rgba(26, 26, 46, 0.9); 
    border: 2px solid rgba(255, 255, 255, 0.1); 
    border-radius: 8px; 
    padding: 15px; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); 
}
.rule-item:hover { 
    border-color: #4ecdc4; 
    transform: translateY(-2px); 
    box-shadow: 0 4px 10px rgba(78, 205, 196, 0.2); 
}
.rule-item h4 { color: rgba(255, 255, 255, 0.95); font-size: 16px; margin-bottom: 8px; font-weight: 600; }
.rule-item p { color: rgba(255, 255, 255, 0.75); font-size: 14px; line-height: 1.6; margin: 0; }


/* ========================================
   FORMATIONS DISPLAY (Dark Theme Anpassung)
   ======================================== */
.formation-faction-group { 
    margin-bottom: 30px; 
    padding: 0; /* Padding entfernen, da Container jetzt dunkel ist */
    /* ALT: background: #f8f9fa; */
    background: none; 
    border-radius: 0; 
    border: none; 
}

.formation-faction-header { 
    color: #fff; 
    background: linear-gradient(135deg, #546e7a 0%, #455a64 100%); 
    font-size: 20px; 
    padding: 12px 20px; 
    /* ALT: margin: -20px -20px 20px -20px; */
    margin: 0 0 20px 0; /* NEU: Angepasster Margin */
    border-radius: 12px 12px 0 0; 
    font-weight: 700; 
}

.faction-special-rules { 
    /* ALT: background: #e9ecef; */
    background: rgba(26, 26, 46, 0.9); /* NEU: Wie unit-card */
    /* ALT: border: 1px solid #dee2e6; */
    border: 2px solid rgba(255, 255, 255, 0.1); /* NEU: Wie unit-card */
    border-left: 5px solid #6c757d; 
    border-radius: 8px; 
    padding: 15px 20px; 
    margin-bottom: 20px; 
    /* ALT: color: #495057; */
    color: rgba(255, 255, 255, 0.8); /* NEU: Heller Text */
    line-height: 1.7; 
}

.faction-special-rules p { 
    font-size: 15px; 
    margin-top: 10px; 
}

.faction-special-rules.collapsible summary { 
    cursor: pointer; 
    outline: none; 
    list-style-position: inside; 
}

.faction-special-rules.collapsible summary h5 { 
    display: inline; 
    margin: 0; 
    font-size: 16px; 
    font-weight: 700; 
    /* ALT: color: #343a40; */
    color: #4ecdc4; /* NEU: Cyan-Akzent */
}

.faction-special-rules h5 { 
    font-size: 16px; 
    font-weight: 700; 
    margin-bottom: 10px; 
    /* ALT: color: #343a40; */
    color: #4ecdc4; /* NEU: Cyan-Akzent */
}

.formation-card { 
    /* ALT: background: white; */
    background: rgba(26, 26, 46, 0.9); /* NEU: Wie unit-card */
    /* ALT: border: 1px solid #e0e0e0; */
    border: 2px solid rgba(255, 255, 255, 0.1); /* NEU: Wie unit-card */
    border-left: 5px solid #2980b9; 
    border-radius: 8px; 
    padding: 20px; 
    margin-bottom: 20px; 
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05); 
}

.formation-card h4 { 
    font-size: 18px; 
    /* ALT: color: #2c3e50; */
    color: #d4af37; /* NEU: Gold-Akzent */
    margin: 0 0 15px 0; 
}

.formation-slots { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 20px; 
    margin-bottom: 15px; 
}

.formation-slots h5 { 
    font-size: 14px; 
    font-weight: 700; 
    /* ALT: color: #34495e; */
    color: #4ecdc4; /* NEU: Cyan-Akzent */
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    margin-bottom: 8px; 
}

.formation-slots ul { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

.formation-slots li { 
    font-size: 14px; 
    /* ALT: color: #555; */
    color: rgba(255, 255, 255, 0.8); /* NEU: Heller Text */
    margin-bottom: 5px; 
    padding-left: 15px; 
    position: relative; 
}

.formation-slots li::before { 
    content: '•'; 
    position: absolute; 
    left: 0; 
    /* ALT: color: #2980b9; */
    color: #4ecdc4; /* NEU: Cyan-Akzent */
    font-weight: bold; 
}

.formation-card .faction-special-rules { 
    margin-top: 15px; 
    /* ALT: background: #f1f3f5; */
    background: rgba(15, 52, 96, 0.3); /* NEU: Dunklerer Blauton */
    border-left-color: #868e96; 
    /* ALT: color: #495057; */
    color: rgba(255, 255, 255, 0.7); /* NEU: Heller Text */
    font-size: 14px; 
    padding: 10px 15px; 
}

.formation-card .faction-special-rules h5 { 
    font-size: 15px; 
}
.formation-card {
    /* (Bestehende Stile bleiben) */
    padding: 0; /* Padding vom <details> Tag entfernen */
    /* Fügt einen Übergang hinzu, wenn die Karte geöffnet wird */
    transition: all 0.2s ease-out;
}
.formation-card[open] {
    /* Hebt die geöffnete Karte leicht hervor */
    border-color: rgba(212, 175, 55, 0.3); /* Gold-Akzent */
}

.formation-card-summary {
    padding: 20px; /* Das alte Padding der Karte hierher verschieben */
    cursor: pointer;
    list-style: none; /* Pfeil (Firefox) */
    position: relative;
    transition: background 0.2s ease;
}
.formation-card-summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.formation-card-summary::-webkit-details-marker {
    display: none; /* Pfeil (Chrome) */
}

.formation-card-summary h4 {
    margin: 0; /* Standard-Margin von h4 entfernen */
    display: inline-block; /* Sorgt für korrekte Positionierung */
}

/* [+] / [-] Icon */
.formation-card-summary::before {
    content: '[+]';
    font-weight: 700;
    color: #d4af37; /* Gold-Akzent */
    font-size: 16px;
    margin-right: 10px;
    /* Verhindert, dass der Text beim Klicken markiert wird */
    user-select: none;
    display: inline-block;
    width: 20px; /* Feste Breite für Ausrichtung */
}

.formation-card[open] > .formation-card-summary::before {
    content: '[\2012]'; /* Minus-Zeichen */
}

/* Inhalt der Karte */
.formation-card-content {
    padding: 0 20px 20px 20px; /* Padding für den Inhalt */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 20px; /* Sorge für Einzug und Abstand zum Header */
}


/* ========================================
   REFERENCE TABLES STYLING - DARK THEME
   ======================================== */
.reference-table-container {
   overflow-x: auto;
   margin-top: 15px;
}
.reference-table {
    min-width: 100%;
    border-collapse: collapse;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.reference-table th {
    background: rgba(44, 53, 68, 0.9);
    color: #4ecdc4;
    padding: 12px 15px;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(78, 205, 196, 0.3);
    white-space: nowrap;
}
.reference-table td {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    vertical-align: middle;
    font-size: 14px;
    white-space: nowrap;
}
.reference-table td:first-child strong,
.reference-table td strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}
.reference-table tbody tr {
    transition: background 0.2s ease;
}
.reference-table tbody tr:hover {
    background: rgba(78, 205, 196, 0.1);
}
.reference-table tbody tr:last-child td {
    border-bottom: none;
}
/* Spezifische Anpassungen für die Waffentabelle */

/* ========================================
   DETACHMENT REFERENCE STYLING - DARK THEME
   ======================================== */
.detachment-faction-group {
    margin-bottom: 40px;
}

.faction-header {
    color: #d4af37;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: rgba(26, 26, 46, 0.8);
    border-radius: 10px;
    border-left: 4px solid #e94560;
}

.detachment-type-section {
    margin-bottom: 25px;
}

.type-subheader {
    color: #4ecdc4;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: rgba(78, 205, 196, 0.1);
    border-radius: 8px;
    border-left: 3px solid #4ecdc4;
}

.detachment-row {
    cursor: pointer;
}

/* Spezifische Anpassungen für die Waffentabelle */
#weaponsResults .reference-table td:nth-child(n+2):nth-child(-n+5) { /* Spalten Range bis AP zentrieren */
   text-align: center;
}
#weaponsResults .reference-table td:last-child { /* Spalte "Gefunden auf" kleiner */
    font-size: 12px;
    color: #6c757d;
}

/* ========================================
   MODAL STYLES
   ======================================== */

.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8); animation: fadeInModal 0.3s ease;
    align-items: center; justify-content: center; padding: 20px;
}
.modal.active { display: flex; }
@keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }
#ruleModal { z-index: 1100; background-color: rgba(0, 0, 0, 0.85); }
.modal-content {
    background: white; padding: 30px 40px; border-radius: 15px;
    max-width: 900px; width: 100%; max-height: calc(100vh - 40px);
    overflow-y: auto; position: relative; box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    animation: slideUpModal 0.3s ease-out; line-height: 1.7; font-size: 15px; color: #333;
}
@keyframes slideUpModal { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.close-btn {
    position: absolute; top: 15px; right: 15px; background: #e74c3c; color: white; border: none;
    border-radius: 50%; width: 35px; height: 35px; font-size: 22px; cursor: pointer;
    transition: all 0.3s ease; display: flex; align-items: center; justify-content: center;
    line-height: 1; padding: 0; z-index: 1110;
}
.close-btn:hover { background: #c0392b; transform: rotate(90deg) scale(1.1); }
.modal-content p { margin-bottom: 15px; line-height: 1.8; }
.modal-content ul, .modal-content ol { margin: 15px 0; padding-left: 20px; line-height: 1.8; }
.modal-content li { margin-bottom: 8px; padding-left: 5px; }
.modal-content strong { font-weight: 600; color: #2c3e50; }
.modal-content h2 { font-size: 26px; color: #2c3e50; margin-bottom: 15px; line-height: 1.3; }
.modal-content h3 { font-size: 16px; color: white; background: linear-gradient(135deg, #546e7a 0%, #455a64 100%); margin: 25px 0 15px 0; padding: 10px 15px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.modal-content h4 { font-size: 16px; color: #2c3e50; margin-bottom: 10px; font-weight: 700; }
.datasheet-header { background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%); color: white; padding: 20px 30px; margin: -30px -40px 25px -40px; border-radius: 15px 15px 0 0; }
.datasheet-header h2 { color: white; margin-bottom: 10px; font-size: 24px; text-transform: uppercase; letter-spacing: 0.8px; }
.datasheet-header .datasheet-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.datasheet-header .datasheet-meta span, 
.datasheet-header .datasheet-meta .meta-badge { /* Stellt sicher, dass alle Spans/Badges gestylt werden */
    background: rgba(255, 255, 255, 0.15); 
    padding: 5px 12px; 
    border-radius: 15px; 
    font-weight: 600; 
    color: white; /* Standardfarbe weiß */
}
.datasheet-header .datasheet-meta .faction { background: rgba(231, 76, 60, 0.9); color: white; }
.datasheet-header .datasheet-meta .points-badge { background: #2ecc71; color: white; }
.datasheet-table, .stats-table, .weapons-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; background: white; border: 1px solid #dfe6e9; border-radius: 8px; overflow: hidden; font-size: 14px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06); }
.datasheet-table thead, .stats-table thead, .weapons-table thead { background: #f8f9fa; color: #495057; border-bottom: 2px solid #dee2e6; }
.datasheet-table th, .stats-table th, .weapons-table th { padding: 10px 12px; text-align: center; font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; border-right: 1px solid #e9ecef; }
.datasheet-table th:last-child, .stats-table th:last-child, .weapons-table th:last-child { border-right: none; }
.datasheet-table td, .stats-table td, .weapons-table td { padding: 10px 12px; border-bottom: 1px solid #f1f3f5; border-right: 1px solid #f1f3f5; line-height: 1.6; text-align: center; vertical-align: middle; }
.datasheet-table td:last-child, .stats-table td:last-child, .weapons-table td:last-child { border-right: none; }
.datasheet-table tbody tr:last-child td, .stats-table tbody tr:last-child td, .weapons-table tbody tr:last-child td { border-bottom: none; }
.datasheet-table tbody tr:hover, .stats-table tbody tr:hover, .weapons-table tbody tr:hover { background: #fdfdfe; }
.datasheet-table td.name, .weapons-table td:first-child { text-align: left; font-weight: 600; color: #2c3e50; }
.stats-table td { font-weight: 600; color: #2c3e50; }
.nested-weapon-table { width: 100%; margin: -10px -12px; }
.nested-weapon-table td { border: none; padding: 6px 12px; border-bottom: 1px solid #f8f9fa; text-align: center; font-size: 13px; }
.nested-weapon-table tr:last-child td { border-bottom: none; }
.nested-weapon-table td:first-child { text-align: left; }
.upgrades-list { display: flex; flex-direction: column; gap: 8px; }
.upgrade-item { background: #f8f9fa; padding: 12px 15px; border-radius: 6px; border-left: 3px solid #6c757d; }
.upgrade-item strong { color: #343a40; font-size: 14px; display: block; margin-bottom: 3px; }
.upgrade-cost { background: #2ecc71; color: white; padding: 3px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; float: right; }
.upgrade-item p { margin: 5px 0 0 0; color: #6c757d; font-size: 13px; line-height: 1.5; clear: both; }
.special-rules-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-tag, .trait-link { background: #6c757d; color: white; padding: 5px 12px; border-radius: 15px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; text-decoration: none; display: inline-block; }
.rule-tag:hover, .trait-link:hover { background: #e74c3c; transform: scale(1.05); }
.rule-detail-header { border-bottom: 2px solid #e9ecef; padding-bottom: 15px; margin-bottom: 20px; }
.rule-detail-header .rule-category-badge { display: inline-block; background: #6c757d; color: white; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.rule-detail-header h2 { margin-bottom: 5px; }
.rule-detail-header .rule-path { color: #adb5bd; font-size: 13px; margin: 0; }
.rule-detail-content { color: #333; font-size: 15px; line-height: 1.8; }

/* ========================================
   UNIT DETAIL MODAL (Army Lists)
   Override generic .modal-content styles for dark theme
   ======================================== */
#unitDetailModal .modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: rgba(255, 255, 255, 0.9);
}

#unitDetailModal .modal-content h2,
#unitDetailModal .modal-content h4,
#unitDetailModal .modal-content strong {
    color: rgba(255, 255, 255, 0.95);
}

#unitDetailModal .modal-content p,
#unitDetailModal .modal-content li {
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
    .modal-content { padding: 20px; margin: 15px; max-height: calc(100vh - 30px); }
    .unit-detail-header { padding: 15px 20px; margin: -20px -20px 20px -20px; }
    .unit-detail-header h2 { font-size: 20px; }
    .unit-detail-header .unit-meta { font-size: 12px; }
    .datasheet-table, .stats-table, .weapons-table, .reference-table { font-size: 13px; }
    .datasheet-table th, .stats-table th, .weapons-table th, .reference-table th { padding: 8px 10px; font-size: 10px; }
    .datasheet-table td, .stats-table td, .weapons-table td, .reference-table td { padding: 8px 10px; }
    .nested-weapon-table td { padding: 5px 10px; font-size: 12px;}
    .rule-detail-header h2 { font-size: 22px; }
}

@media (max-width: 768px) {
    body { padding: 10px; }
    .container { border-radius: 10px; }
    .app-header { padding: 20px; }
    .app-header h1 { font-size: 28px; letter-spacing: 2px; }
    .subtitle { font-size: 14px; }
    .nav-tab { padding: 12px 8px; font-size: 13px; }
    .nav-label { font-size: 11px; }
    .nav-icon { font-size: 20px; }
    .content-section { padding: 15px; }
    .section-header h2 { font-size: 22px; }
    .section-header p { font-size: 14px; }
    .faction-tabs, .filters-row { flex-direction: column; gap: 8px; align-items: stretch; }
    .filter-select, .btn-secondary { min-width: 0; width: 100%; }
    .units-grid, .rules-list { grid-template-columns: 1fr; }
    .formation-slots { grid-template-columns: 1fr; }
    .formation-faction-group { padding: 15px; }
    .formation-faction-header { margin: -15px -15px 15px -15px; padding: 10px 15px; font-size: 18px; }

.battle-controls {
        /* NEU: Auf Mobilgeräten zu einem Grid wechseln */
        display: grid;
        grid-template-columns: 1fr 1fr; /* 2 Spalten */
        gap: 10px; /* Kleinerer Abstand für Mobile */
    }

    .battle-controls button {
        /* NEU: Flex-Werte für Grid überschreiben */
        flex: none; /* Flex-Verhalten entfernen */
        min-width: 0; /* Min-Breite entfernen */
        width: 100%; /* Button füllt die Grid-Zelle */
        padding: 12px 8px; /* Etwas mehr vertikales Padding, weniger horizontales */
        font-size: 13px; /* Kleinere Schrift, damit Text passt */
    }
}
/* ========================================
   SCROLLBAR STYLING
   ======================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f3f5; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #adb5bd; border-radius: 10px; }

/* ========================================
   PHASE 4: ARMY LISTS SECTION
   ======================================== */

/* KORREKTUR 4: "Neue Liste" Button verstecken */
#newListBtn {
    display: none;
}

/* Action Buttons Container */
.armylist-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.armylist-actions .btn-primary,
.armylist-actions .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.armylist-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.armylist-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.armylist-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.armylist-actions .btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.armylist-actions .btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Army List Card */
.armylist-card {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.armylist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
}

.armylist-header h3 {
    font-size: 24px;
    color: #d4af37;
    margin: 0;
}

.armylist-meta {
    display: flex;
    gap: 12px;
    font-size: 14px;
}

.armylist-meta .meta-badge {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
}

.armylist-meta .points-badge {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
}

/* Detachment in Army List */
.armylist-detachment {
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.armylist-detachment h4 {
    color: #4ecdc4;
    font-size: 18px;
    margin-bottom: 12px;
}

.armylist-units {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.armylist-unit {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.armylist-unit-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.armylist-unit-details {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.armylist-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.armylist-actions-row button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete {
    background: rgba(231, 76, 96, 0.2);
    color: #e74c60;
    border: 1px solid rgba(231, 76, 96, 0.3);
}

.btn-delete:hover {
    background: rgba(231, 76, 96, 0.3);
    color: white;
}

.btn-edit {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.btn-edit:hover {
    background: rgba(78, 205, 196, 0.3);
    color: white;
}

/* ========================================
   PHASE 4: BATTLE TRACKER
   ======================================== */

/* Battle Setup */
.battle-setup {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.battle-setup h3 {
    color: #d4af37;
    margin-bottom: 12px;
}

.battle-setup-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.battle-setup-controls .filter-select {
    flex: 1;
    min-width: 250px;
}

.battle-setup-controls .btn-primary {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Battle Header */
.battle-header {
    background: linear-gradient(135deg, rgba(15, 52, 96, 0.8) 0%, rgba(26, 26, 46, 0.9) 100%);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.battle-info h3 {
    color: #d4af37;
    font-size: 24px;
    margin-bottom: 12px;
}

.battle-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.stat-badge.alive {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    font-weight: 600;
}

.battle-controls button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center; /* Zentriert Text/Icon */
    gap: 8px;
    flex: 1 1 150px; /* Erlaube Buttons zu wachsen/schrumpfen, mit einer Basisbreite */
    min-width: 150px; /* Verhindert, dass sie zu klein werden */
}

/* NEU: Primäre Aktionen (Rot, passend zum App-Header) */
.battle-controls .btn-primary {
    background: #e74c3c;
    color: white;
    border: 1px solid #c0392b;
}
.battle-controls .btn-primary:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* NEU: Sekundäre Aktionen (Dunkelgrau) */
.battle-controls .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.battle-controls .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* NEU: Beibehaltung des gelben Stils für "Vorheriger Turn" (als Warnung/Korrektur) */
#prevTurnBtn {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}
#prevTurnBtn:hover {
    background: rgba(255, 193, 7, 0.3);
    color: #fff;
}
/* Formations Break Point Tracker */
.battle-formations {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
    margin: 24px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    justify-content: center;
}

.formation-card {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(40, 40, 60, 0.95) 100%);
    border: 2px solid rgba(98, 181, 229, 0.3);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.formation-card.warning {
    border-color: rgba(255, 193, 7, 0.6);
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.2);
}

.formation-card.broken {
    border-color: rgba(220, 53, 69, 0.8);
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.3);
    background: linear-gradient(135deg, rgba(60, 20, 20, 0.95) 0%, rgba(80, 30, 30, 0.95) 100%);
}

.formation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.formation-header h4 {
    margin: 0;
    font-size: 18px;
    color: #fff;
    font-weight: 600;
}

.formation-status {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.formation-status:not(.warning):not(.broken) {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.4);
}

.formation-status.warning {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.4);
}

.formation-status.broken {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.4);
}

.formation-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.formation-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.stat-value.warning-value {
    color: #ffc107;
}

.stat-value.broken-value {
    color: #dc3545;
}

.formation-progress-bar {
    height: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}

.formation-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    transition: width 0.3s ease;
    border-radius: 6px;
}

.formation-progress-fill.warning {
    background: linear-gradient(90deg, #ffc107 0%, #ff9800 100%);
}

.formation-progress-fill.broken {
    background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
}

.formation-manual {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.formation-manual label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.manual-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.manual-btn {
    background: rgba(98, 181, 229, 0.2);
    border: 1px solid rgba(98, 181, 229, 0.4);
    color: #62b5e5;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.manual-btn:hover {
    background: rgba(98, 181, 229, 0.3);
    border-color: rgba(98, 181, 229, 0.6);
}

.manual-value {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    min-width: 40px;
    text-align: center;
}

/* Battle Units Grid */
.battle-units {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

/* Battle Unit Card */
.battle-unit-card {
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
}

.battle-unit-card.destroyed {
    opacity: 0.5;
    border-color: rgba(231, 76, 96, 0.5);
}

.battle-unit-card.damaged {
    border-color: rgba(255, 193, 7, 0.5);
}

.battle-unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.battle-unit-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.battle-unit-category {
    font-size: 12px;
    color: #4ecdc4;
    background: rgba(78, 205, 196, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
}

/* HP Bar */
.battle-hp-section {
    margin: 12px 0;
}

.battle-hp-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
}

.battle-hp-bar {
    width: 100%;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.battle-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4 0%, #44b3aa 100%);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.battle-hp-fill.low {
    background: linear-gradient(90deg, #ffd93d 0%, #f6b93b 100%);
}

.battle-hp-fill.critical {
    background: linear-gradient(90deg, #e74c60 0%, #d63447 100%);
}

/* HP Controls */
.battle-hp-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.battle-hp-controls button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hp-btn-minus {
    background: rgba(231, 76, 96, 0.2);
    color: #e74c60;
    border: 1px solid rgba(231, 76, 96, 0.3);
}

.hp-btn-minus:hover {
    background: rgba(231, 76, 96, 0.3);
}

.hp-btn-plus {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.hp-btn-plus:hover {
    background: rgba(78, 205, 196, 0.3);
}

.hp-btn-destroy {
    background: rgba(231, 76, 96, 0.2);
    color: #e74c60;
    border: 1px solid rgba(231, 76, 96, 0.3);
}

.hp-btn-destroy:hover {
    background: rgba(231, 76, 96, 0.4);
    color: white;
}

/* Unit Stats */
.battle-unit-stats {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.battle-unit-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .battle-units {
        grid-template-columns: 1fr;
    }
    
    .battle-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

::-webkit-scrollbar-thumb:hover { background: #868e96; }

/* ============================================
   UNIT DETAIL MODAL
   ============================================ */

.unit-detail-section {
    margin-bottom: 24px;
}

.unit-detail-section h3 {
    color: #d4af37;
    font-size: 18px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 8px;
}

.unit-detail-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.category-badge {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.points-badge {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.model-profile {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.model-profile strong {
    color: #4ecdc4;
    font-size: 16px;
}

.profile-stats {
    margin-top: 8px;
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

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

.upgrade-list li {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrade-list li strong {
    color: rgba(255, 255, 255, 0.9);
}

.upgrade-cost {
    color: #d4af37;
    font-weight: 600;
}

/* Special Rules Styles */
.special-rules-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.special-rule-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.special-rule-item .rule-tag {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: inline-block;
}

.rule-description {
    margin: 8px 0 0 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    line-height: 1.6;
}

/* Stats Table Styles (für Profile-Werte im Modal) */
.unit-detail-section .stats-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.unit-detail-section .stats-table thead {
    background: var(--primary-color);
}

.unit-detail-section .stats-table th {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    color: white !important;  /* WICHTIG: Überschreibe alle anderen Styles */
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--primary-color) !important;
}

.unit-detail-section .stats-table td {
    padding: 10px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

/* Weapons Table Styles */
.unit-detail-section .weapons-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
}

.unit-detail-section .weapons-table thead {
    background: var(--secondary-color);
}

.unit-detail-section .weapons-table th {
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: white !important;  /* WICHTIG: Überschreibe alle anderen Styles */
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--secondary-color) !important;
}

.unit-detail-section .weapons-table td {
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.unit-detail-section .weapons-table td:first-child {
    font-weight: 600;
}

.unit-detail-section .weapons-table .trait-link {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s;
    display: inline-block;
    margin: 2px;
}

.unit-detail-section .weapons-table .trait-link:hover {
    background: rgba(98, 181, 229, 0.2);
    text-decoration: underline;
}

/* NAV: mobile horizontal scroll */
.main-nav{display:flex;gap:8px;overflow-x:auto;white-space:nowrap;-webkit-overflow-scrolling:touch;scrollbar-width:none}
.main-nav::-webkit-scrollbar{display:none}
.nav-tab{flex:0 0 auto}
/* ========================================
   INSTALL BANNER
   ======================================== */

.install-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #2c3e50;
    color: white;
    font-size: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.install-banner-actions {
    display: flex;
    gap: 10px;
}

.install-banner .btn-primary {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.install-banner .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

/* NEU: Update Banner Styling */
.update-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 15px;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

.update-banner p {
    margin: 0;
    font-weight: 600;
}

.update-banner .btn-primary {
    background: white;
    color: #667eea;
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.update-banner .btn-primary:hover {
    transform: scale(1.05);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Sorgt für horizontales Scrollen der Referenz-Tabs auf Mobilgeräten */
@media (max-width: 768px) {
    .reference-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        /* Stellt sicher, dass der Border Bottom mitscrollt */
        border-bottom: 2px solid #ecf0f1; 
        padding-bottom: 2px; /* Verhindert, dass der Border die Tabs überlappt */
    }
    .reference-tabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    .reference-tab {
        flex: 0 0 auto; /* Verhindert, dass Tabs schrumpfen */
    }
}

/* ========================================
   NEU: VP & OBJECTIVE TRACKER (SCHRITT 1 & 2)
   ======================================== */

.battle-score-tracker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.score-card {
    /* Wir nutzen das formation-card Styling wieder */
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(40, 40, 60, 0.95) 100%);
    border: 2px solid rgba(98, 181, 229, 0.3);
    border-radius: 12px;
    padding: 20px;
}

.score-header {
    /* Wir nutzen das formation-header Styling wieder */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.score-header h4 {
    margin: 0;
    font-size: 18px;
    color: #fff;
    font-weight: 600;
}

.score-vp-display {
    font-size: 52px;
    font-weight: 700;
    text-align: center;
    color: #fff;
    margin: 10px 0 20px 0;
}

/* Gold-Highlight für Spieler 1 */
#player1VP {
    color: #d4af37; 
}

.score-controls {
    /* Wir nutzen das battle-hp-controls Styling wieder */
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.score-controls button {
    flex: 1;
}

/* Sekundärziel-Anzeige in der Karte */
.score-secondaries {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.score-secondaries h5 {
    font-size: 14px;
    color: #4ecdc4;
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* .rule-tag ist bereits global gestylt, aber wir passen den Cursor an */
.score-secondaries .rule-tag {
    cursor: pointer;
    display: inline-block;
    margin: 3px;
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

/* Styling für die AUSWAHL-Liste im Setup-Screen */
#secondaryObjectiveList .quick-ref-card {
    cursor: pointer;
    border: 4px solid rgba(255, 255, 255, 0.1); /* Standard-Border */
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

#secondaryObjectiveList .quick-ref-card:hover {
    border-color: #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
}

#secondaryObjectiveList .quick-ref-card.selected {
    border-color: #d4af37; /* Highlight-Farbe (Gold) */
    background: rgba(212, 175, 55, 0.1);
}

#secondaryObjectiveList .quick-ref-card h3 {
    font-size: 16px;
}
#secondaryObjectiveList .quick-ref-card p {
    font-size: 13px;
    line-height: 1.5;
}

/* Responsive Anpassung für den VP-Tracker */
@media (max-width: 768px) {
    .battle-score-tracker {
        grid-template-columns: 1fr; /* Untereinander auf Mobilgeräten */
    }
    .score-vp-display {
        font-size: 44px;
    }
}
/* ========================================
   NEU: WÜRFELRECHNER (PUNKT 4)
   ======================================== */

.dice-roller-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dr-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dr-input-group label {
    font-size: 14px;
    font-weight: 600;
    color: #4ecdc4;
}

.dr-input-group .filter-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0; /* Überschreibt evtl. Standard-Margins */
}

.dice-roller-toggles {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    background: rgba(26, 26, 46, 0.8);
    padding: 15px;
    border-radius: 8px;
}

.dice-roller-toggles label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.dice-roller-actions {
    display: flex;
    gap: 15px;
}

/* Anpassung für Primär-Button im Würfelrechner */
.dice-roller-actions .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.dice-roller-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}


#dr-results-log p {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#dr-results-log p:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
#dr-results-log strong {
    color: #d4af37;
    font-size: 1.1em;
}
#dr-results-log .roll-details {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    margin-left: 10px;
}

/* ========================================
   NEU: MISSIONS-BUTTONS (PUNKT 5)
   ======================================== */

.rule-item .play-mission-btn {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    background: #e74c3c;
    border: none;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    width: 100%;
    margin-top: 15px;
}

.rule-item .play-mission-btn:hover {
    background: #c0392b;
}

#mission-display {
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}
#mission-display h4 {
    color: #4ecdc4;
    margin-bottom: 5px;
    font-size: 14px;
    text-transform: uppercase;
}
#mission-display p {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: white;
}