/* ============================================================
   TẢN VIÊN HÀNH TRÌNH - STYLESHEET
   ============================================================ */

/* === RESET & BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --gold: #FFD700;
    --red: #DC3545;
    --dark-blue: #1a3a5c;
    --green: #2d6a4f;
    --dark: #0d1117;
    --darker: #010409;
    --panel-bg: #161b22;
    --panel-border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #FFD700;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--darker);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* === INTRO SCREEN === */
#intro-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0a0a15 0%, #1a0a0a 50%, #0a150a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 1s ease;
}
#intro-screen.fade-out { opacity: 0; }

.intro-mountain {
    font-size: 80px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.intro-title {
    font-size: 36px;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    margin-bottom: 5px;
    letter-spacing: 3px;
}
.intro-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 40px;
    letter-spacing: 8px;
    text-transform: uppercase;
}

#intro-message {
    font-size: 18px;
    color: var(--text);
    text-align: center;
    min-height: 80px;
    line-height: 1.8;
    font-style: italic;
    max-width: 500px;
}

#enter-btn {
    margin-top: 40px;
    padding: 14px 50px;
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--gold);
    font-size: 16px;
    cursor: pointer;
    letter-spacing: 4px;
    text-transform: uppercase;
    transition: all 0.3s;
    border-radius: 4px;
}
#enter-btn:hover {
    background: var(--gold);
    color: var(--dark);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

/* === MAIN APP LAYOUT === */
#main-app {
    display: none;
    height: 100vh;
    width: 100vw;
}

/* === LEFT SIDEBAR === */
.sidebar {
    width: 300px;
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    overflow-y: auto; /* cho phép cuộn toàn bộ sidebar */
    height: 100vh;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--panel-border);
    background: linear-gradient(135deg, var(--dark) 0%, var(--panel-bg) 100%);
}
.sidebar-logo {
    font-size: 18px;
    font-weight: bold;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo span { font-size: 24px; }
.sidebar-tagline {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 1px;
}

/* === ERA SELECTOR === */
.era-section, .layer-section { padding: 10px 14px; border-bottom: 1px solid var(--panel-border); }
.era-section-title, .layer-section-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
    color: var(--text-muted); margin-bottom: 8px;
}
.era-buttons { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.era-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 6px; border: 1px solid var(--panel-border);
    background: transparent; color: var(--text); cursor: pointer;
    font-size: 12px; text-align: left; transition: all 0.2s;
}
.era-btn:hover { background: #ffffff08; }
.era-btn.active { border-color: var(--gold); background: rgba(255,215,0,0.08); color: var(--gold); }
.era-btn .era-icon { font-size: 16px; }
.era-btn .era-info { flex: 1; }
.era-btn .era-name { font-weight: 600; }
.era-btn .era-years { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.era-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; padding: 6px 8px; background: #0d0805; border-radius: 4px; border-left: 2px solid var(--gold); }

/* === LAYER TOGGLES === */
.layer-buttons { display: flex; gap: 4px; }
.layer-btn {
    flex: 1; padding: 8px 6px; border-radius: 6px; border: 1px solid var(--panel-border);
    background: transparent; color: var(--text-muted); cursor: pointer;
    font-size: 11px; text-align: center; transition: all 0.2s;
}
.layer-btn:hover { background: #ffffff08; }
.layer-btn.active { color: var(--text); border-width: 2px; }
.layer-btn .layer-icon { font-size: 14px; display: block; margin-bottom: 2px; }

/* === TẢN VIÊN SƠN POLYGON LABEL === */
.tan-vien-label { background: none !important; border: none !important; }

/* Node List */
.node-list-header {
    padding: 12px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

#node-list {
    flex: 0 0 auto;
    padding: 0 10px;
    max-height: none;
}

.node-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}
.node-item:hover { background: #ffffff10; }
.node-item.active { background: #ffffff15; border: 1px solid var(--panel-border); }

.node-item-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}
.node-item-content { flex: 1; min-width: 0; }
.node-item-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.node-item-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.node-item-direction {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}

.node-item.root .node-item-name { color: var(--gold); }

/* Sidebar bottom buttons */
.sidebar-actions {
    padding: 12px 10px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-btn:hover {
    background: #ffffff10;
    border-color: var(--accent);
}
.sidebar-btn .icon { font-size: 18px; width: 24px; text-align: center; }

/* === MAP AREA === */
.map-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--dark);
    z-index: 1;
}

/* === MAP ERA STYLES — bản đồ là NỀN (tối, mờ), markers/features nổi rõ === */

/* Văn Lang — Phong Châu style: rất tối + sepia */
.era-van_lang .leaflet-tile-pane {
    filter: sepia(0.9) saturate(0.4) brightness(0.45) hue-rotate(-15deg) contrast(0.85);
    transition: filter 0.6s ease;
}
/* Dark overlay phủ lên map để làm nền tối hơn nữa */
.era-van_lang #map::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(20, 12, 5, 0.35);
    pointer-events: none; z-index: 199;
}

/* Âu Lạc — sepia tối */
.era-au_lac .leaflet-tile-pane {
    filter: sepia(0.75) saturate(0.5) brightness(0.5) hue-rotate(-5deg) contrast(0.9);
    transition: filter 0.6s ease;
}
.era-au_lac #map::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 18, 25, 0.3);
    pointer-events: none; z-index: 199;
}

/* Lê → Nay — Lý/Nguyễn style: tối nhẹ */
.era-le_to_now .leaflet-tile-pane {
    filter: sepia(0.4) saturate(0.7) brightness(0.6) contrast(0.95);
    transition: filter 0.6s ease;
}
.era-le_to_now #map::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 23, 0.25);
    pointer-events: none; z-index: 199;
}

/* Đảm bảo markers và overlays nổi BÊN TRÊN dark overlay */
.leaflet-marker-pane, .leaflet-overlay-pane, .leaflet-tooltip-pane, .leaflet-popup-pane {
    z-index: 600 !important;
}

/* Connection animations */
.connection-line { animation: dash-flow 2s linear infinite; }
@keyframes dash-flow { to { stroke-dashoffset: -36; } }
.connection-glow { animation: pulse-glow 2.5s ease-in-out infinite; }
@keyframes pulse-glow {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}
.connection-arrow div { animation: arrow-pulse 1.5s ease-in-out infinite; }
@keyframes arrow-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Legacy mode CSS (backward compat) */
.mode-hung_vuong .leaflet-tile-pane { filter: sepia(0.85) saturate(0.6) brightness(0.78) hue-rotate(-15deg); }
.mode-medieval .leaflet-tile-pane { filter: sepia(0.5) saturate(0.7) brightness(0.85); }
.mode-present .leaflet-tile-pane { filter: sepia(0.25) saturate(0.85) brightness(0.95); }

/* Natural feature styles */
.natural-mountain { background: none !important; border: none !important; }
.phong-chau-marker { background: none !important; border: none !important; }
.natural-river { stroke-dasharray: none !important; animation: river-flow 60s linear infinite; }
@keyframes river-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 1000; }
}

/* Map Markers */
.node-marker {
    background: none !important;
    border: none !important;
}
.marker-inner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.root-marker .marker-inner {
    width: 50px;
    height: 50px;
}
.marker-icon { font-size: 20px; }
.root-marker .marker-icon { font-size: 26px; }

.marker-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 0 12px rgba(0,0,0,0.9), 0 0 20px rgba(0,0,0,0.8);
    pointer-events: none;
    background: rgba(0,0,0,0.55);
    padding: 2px 8px;
    border-radius: 4px;
    backdrop-filter: blur(2px);
    text-align: center;
}

.marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px solid;
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    pointer-events: none;
}
.root-marker .marker-pulse {
    width: 50px;
    height: 50px;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.node-marker.active .marker-inner {
    transform: scale(1.3);
}

/* Connection lines */
.connection-line {
    animation: dashMove 30s linear infinite;
}
@keyframes dashMove {
    to { stroke-dashoffset: -1000; }
}

/* === TIMELINE PANEL === */
.timeline-panel {
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 25px;
}

.timeline-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.timeline-label .icon { font-size: 16px; margin-right: 5px; }

.timeline-control {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-track {
    position: relative;
    display: flex;
    align-items: center;
}

#timeline-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--panel-border);
    border-radius: 2px;
    outline: none;
}
#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    border: 2px solid white;
}

.timeline-dots {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}
.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--panel-border);
    transition: all 0.3s;
}
.timeline-dot.active { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.timeline-info {
    flex-shrink: 0;
    max-width: 300px;
}
#period-name {
    font-size: 15px;
    font-weight: bold;
    color: var(--gold);
}
#period-year {
    font-size: 12px;
    color: var(--text-muted);
}
#period-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
    display: none;
}
#period-features {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.feature-tag {
    font-size: 10px;
    padding: 2px 8px;
    background: #ffffff10;
    border-radius: 10px;
    color: var(--text-muted);
    border: 1px solid var(--panel-border);
}

/* === DETAIL PANEL (RIGHT) === */
#detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: var(--panel-bg);
    border-left: 1px solid var(--panel-border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 20;
}
#detail-panel.open { transform: translateX(0); }

.detail-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--dark) 0%, var(--panel-bg) 100%);
    border-bottom: 1px solid var(--panel-border);
    position: relative;
}
.detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.detail-close:hover { background: #ffffff10; color: var(--text); }

#detail-name {
    font-size: 22px;
    font-weight: bold;
    color: var(--gold);
}
#detail-subname {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}
.detail-badges {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.detail-badge {
    font-size: 11px;
    padding: 3px 12px;
    border-radius: 12px;
    font-weight: 600;
}
#detail-direction {
    background: var(--gold);
    color: #333;
}
.detail-badge.role {
    background: #ffffff15;
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.detail-body { padding: 20px; }

.detail-section {
    margin-bottom: 24px;
}
.detail-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 6px;
}
.detail-section-title .icon { font-size: 14px; }

#detail-desc {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
}

#detail-deity {
    font-size: 14px;
    font-weight: 600;
    color: var(--gold);
}

/* KPI Table */
.kpi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.kpi-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--panel-border);
}
.kpi-table td:first-child {
    font-weight: 600;
    color: var(--text-muted);
    width: 35%;
    font-size: 12px;
}

/* Historical & Present data */
.data-row {
    font-size: 13px;
    margin-bottom: 6px;
    line-height: 1.5;
}
.data-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
}
.festival-list {
    margin: 4px 0 0 20px;
    font-size: 13px;
}
.festival-list li { margin-bottom: 4px; }

/* === KNOWLEDGE GRAPH PANEL === */
#graph-panel {
    position: fixed;
    top: 0;
    left: 300px;
    right: 0;
    bottom: 0;
    background: #010409;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#graph-panel.open { transform: translateY(0); }

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--panel-border);
}
.graph-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--gold);
}
.graph-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}
.graph-close-btn {
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--text);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.graph-close-btn:hover { background: #ffffff10; }

#knowledge-graph {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 400px;
    background: #060a10;
}
#knowledge-graph canvas {
    display: block;
}

.graph-legend {
    display: flex;
    gap: 20px;
    padding: 12px 25px;
    border-top: 1px solid var(--panel-border);
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* === TACTICAL PANEL === */
#tactical-panel {
    position: fixed;
    top: 0;
    left: 300px;
    right: 0;
    bottom: 0;
    background: #010409;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#tactical-panel.open { transform: translateY(0); }

.tactical-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--panel-border);
}
.tactical-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--red);
}

.tactical-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.tactical-viz {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.tactical-viz canvas {
    flex: 1;
    width: 100%;
    min-height: 300px;
    background: #0d111780;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
}

.tactical-info {
    width: 350px;
    padding: 25px;
    border-left: 1px solid var(--panel-border);
    overflow-y: auto;
}

.formation-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.formation-btn {
    flex: 1;
    padding: 10px;
    background: #ffffff10;
    border: 1px solid var(--panel-border);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: all 0.2s;
}
.formation-btn.active {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.1);
    color: var(--gold);
}
.formation-btn:hover { background: #ffffff15; }

.formation-detail {
    font-size: 13px;
    line-height: 1.7;
}
.formation-detail .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 15px;
    margin-bottom: 4px;
}
#formation-name {
    font-size: 20px;
    font-weight: bold;
    color: var(--gold);
}
#formation-en {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* === NOTIFICATIONS === */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
}
.notification.show { transform: translateX(-50%) translateY(0); }
.notification.success {
    background: rgba(45, 106, 79, 0.9);
    border: 1px solid #2d6a4f;
    color: white;
}
.notification.info {
    background: rgba(26, 58, 92, 0.9);
    border: 1px solid var(--dark-blue);
    color: white;
}

/* === BINH THƯ PANEL === */
#binhthu-panel {
    position: fixed;
    top: 0; left: 300px; right: 0; bottom: 0;
    background: linear-gradient(180deg, #1a1108 0%, #0a0405 100%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#binhthu-panel.open { transform: translateY(0); }
.binhthu-body { flex: 1; overflow-y: auto; padding: 25px 35px; max-width: 1200px; margin: 0 auto; width: 100%; }
.binhthu-intro h3 { color: #FFD700; font-size: 20px; margin-bottom: 10px; }
.binhthu-intro p { color: #ccc; line-height: 1.7; margin-bottom: 10px; font-size: 14px; }
.binhthu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.binhthu-card {
    background: #0d0805; border: 1px solid #30363d; border-left: 4px solid #FFD700;
    border-radius: 8px; padding: 16px; transition: all 0.2s;
}
.binhthu-card:hover { border-color: #FFD700; transform: translateY(-2px); }
.bt-header { color: #FFD700; font-weight: 700; font-size: 15px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #30363d; }
.binhthu-card blockquote {
    background: #1a1108; border-left: 3px solid #8B6914; padding: 10px 14px;
    margin: 10px 0; font-style: italic; color: #e6edf3; font-size: 13px; line-height: 1.7;
}
.binhthu-card blockquote::before { content: '"'; color: #FFD700; font-size: 24px; vertical-align: top; line-height: 1; }
.binhthu-card blockquote::after { content: '"'; color: #FFD700; font-size: 24px; vertical-align: bottom; line-height: 1; }
.bt-mapping { color: #aaa; font-size: 12px; line-height: 1.6; padding: 8px; background: #161b22; border-radius: 4px; }
.bt-mapping strong { color: #4ECDC4; }
@media (max-width: 900px) { .binhthu-grid { grid-template-columns: 1fr; } }

/* === GAME PANEL — Tản Viên Trấn Thủ === */
#game-panel {
    position: fixed;
    top: 0; left: 300px; right: 0; bottom: 0;
    background: linear-gradient(180deg, #1a0f08 0%, #0a0405 100%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#game-panel.open { transform: translateY(0); }
.game-body { flex: 1; display: flex; overflow: hidden; }
.game-canvas-wrap { flex: 1; position: relative; background: #000; }
#game-canvas { display: block; width: 100%; height: 100%; }

#game-hud {
    width: 320px;
    background: #1a1108;
    border-left: 1px solid #FFD70040;
    overflow-y: auto;
    padding: 12px;
    color: #e6edf3;
    font-size: 13px;
}
.game-stages {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 12px;
}
.game-stage-btn {
    padding: 8px 4px;
    border-radius: 6px;
    border: 1px solid #30363d;
    background: #161b22;
    color: #e6edf3;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}
.game-stage-btn small { font-size: 9px; color: #8b949e; display: block; margin-top: 2px; font-weight: normal; }
.game-stage-btn:hover:not(:disabled) { border-color: #FFD700; }
.game-stage-btn.active { border-color: #FFD700; background: #FFD70022; color: #FFD700; }
.game-stage-btn.locked { opacity: 0.4; cursor: not-allowed; }

.game-stats { background: #0d0805; border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.hero-info { display: flex; gap: 12px; align-items: center; }
.hero-icon { font-size: 36px; }
.hero-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.hp-bar, .mana-bar { position: relative; height: 14px; background: #000; border-radius: 7px; overflow: hidden; margin-bottom: 3px; }
.hp-fill { background: linear-gradient(90deg, #DC3545, #22c55e); height: 100%; transition: width 0.2s; }
.mana-fill { background: linear-gradient(90deg, #4169E1, #5BA4E6); height: 100%; transition: width 0.2s; }
.hp-bar span, .mana-bar span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 10px; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; }
.game-info { display: flex; justify-content: space-around; margin-top: 10px; padding-top: 10px; border-top: 1px solid #FFD70022; font-size: 13px; }

.hero-switch { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; font-size: 11px; }
.switch-btn { padding: 4px 8px; border-radius: 4px; border: 1px solid #30363d; background: #161b22; color: #ccc; cursor: pointer; font-size: 11px; }
.switch-btn.active { border-color: #FFD700; color: #FFD700; }

.game-controls { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: #0d0805; border-radius: 6px; margin-bottom: 10px; font-size: 11px; color: #aaa; }
.game-controls kbd { background: #30363d; padding: 2px 6px; border-radius: 3px; font-family: monospace; font-size: 10px; color: #FFD700; margin-right: 6px; }

.game-actions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.game-btn { padding: 10px 16px; border-radius: 6px; border: 1px solid #30363d; background: #161b22; color: #fff; cursor: pointer; font-size: 13px; }
.game-btn.primary { background: #FFD70033; border-color: #FFD700; color: #FFD700; font-weight: 700; }
.game-btn:hover { background: #FFD70022; }

.knowledge-cards { margin-top: 14px; padding-top: 12px; border-top: 1px solid #FFD70022; }
.knowledge-cards strong { color: #FFD700; font-size: 12px; display: block; margin-bottom: 8px; }
.card { background: #0d0805; border-left: 3px solid #FFD700; padding: 8px 10px; border-radius: 0 6px 6px 0; margin-bottom: 6px; font-size: 11px; }
.card-title { color: #FFD700; font-weight: 700; margin-bottom: 3px; }
.card-text { color: #ccc; line-height: 1.5; }
.card-source { color: #6b7280; font-size: 10px; margin-top: 4px; font-style: italic; }

/* === SA BÀN 3D PANEL === */
#sandbox-panel {
    position: fixed;
    top: 0; left: 300px; right: 0; bottom: 0;
    background: #0a0e17;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#sandbox-panel.open { transform: translateY(0); }

/* === AR PANEL === */
#ar-panel {
    position: fixed;
    top: 0; left: 300px; right: 0; bottom: 0;
    background: #010409;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
#ar-panel.open { transform: translateY(0); }
.ar-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; border-bottom: 1px solid var(--panel-border);
}
.ar-panel-title { font-size: 17px; font-weight: 700; color: #22c55e; }
.ar-panel-body { flex: 1; display: flex; overflow: hidden; }

/* AR Sidebar */
.ar-sidebar {
    width: 260px; background: var(--panel-bg); border-right: 1px solid var(--panel-border);
    overflow-y: auto; flex-shrink: 0;
}
.ar-sidebar-section { padding: 12px 14px; border-bottom: 1px solid var(--panel-border); }
.ar-sidebar-title { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 8px; }

/* Pipeline steps */
.ar-pipe {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
    margin-bottom: 4px; font-size: 12px; background: #ffffff05;
}
.ar-pipe small { color: var(--text-muted); }
.ar-pipe-num {
    width: 24px; height: 24px; border-radius: 50%; background: var(--panel-border);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.ar-pipe.done .ar-pipe-num { background: #22c55e; color: white; }
.ar-pipe.active .ar-pipe-num { background: var(--gold); color: var(--dark); }
.ar-pipe.active { border: 1px solid rgba(255,215,0,0.2); }

/* Kieu buttons */
.ar-kieu-btn {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--panel-border); background: transparent; color: var(--text);
    cursor: pointer; font-size: 13px; text-align: left; width: 100%; margin-bottom: 4px; transition: all 0.2s;
}
.ar-kieu-btn:hover { background: #ffffff08; }
.ar-kieu-btn.active { border-color: #22c55e; background: rgba(34,197,94,0.08); }
.ar-kieu-btn small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.ar-kieu-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* State buttons in sidebar */
.ar-state-btn {
    padding: 7px 12px; border-radius: 6px; border: 1px solid var(--panel-border);
    background: transparent; color: var(--text); cursor: pointer; font-size: 12px; text-align: left; transition: all 0.2s;
}
.ar-state-btn:hover { background: #ffffff08; }
.ar-state-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(255,215,0,0.08); }

/* Trigger rules */
.ar-trigger {
    padding: 6px 10px; border-radius: 4px; background: #ffffff05; margin-bottom: 3px;
    font-size: 11px; line-height: 1.5; border-left: 3px solid var(--panel-border);
}
.ar-trigger.active { border-left-color: #22c55e; background: #0f1a0f; }
.ar-trigger code { color: var(--gold); font-family: monospace; }

/* AR Viewport */
.ar-viewport-inner { flex: 1; position: relative; background: #080c14; overflow: hidden; }
#ar-main-canvas { display: block; width: 100%; height: 100%; }
.ar-hud-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.ar-hud-tl {
    position: absolute; top: 12px; left: 12px;
    background: rgba(0,0,0,0.7); border: 1px solid #22c55e40; border-radius: 6px;
    padding: 6px 12px; font-size: 12px;
}
.ar-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; margin-right: 4px; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.ar-hud-tr {
    position: absolute; top: 12px; right: 12px;
    background: rgba(0,0,0,0.7); border: 1px solid #ffffff20; border-radius: 6px;
    padding: 6px 12px; font-size: 12px;
}
.ar-hud-bottom {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.85); border: 1px solid var(--gold); border-radius: 8px;
    padding: 10px 24px; color: var(--gold); font-size: 15px; font-weight: 700;
    letter-spacing: 2px; text-shadow: 0 0 15px rgba(255,215,0,0.4); white-space: nowrap;
}

/* Generals panel */
.ar-generals {
    width: 280px; background: var(--panel-bg); border-left: 1px solid var(--panel-border);
    overflow-y: auto; flex-shrink: 0; padding: 14px;
}
.ar-gen-card { margin-bottom: 10px; border: 1px solid var(--panel-border); border-radius: 8px; overflow: hidden; }
.ar-gen-header {
    display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer;
    border-left: 3px solid; transition: background 0.2s;
}
.ar-gen-header:hover { background: #ffffff05; }
.ar-gen-header small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.ar-gen-body { display: none; padding: 0 12px 12px; }
.ar-gen-card.open .ar-gen-body { display: block; }
.ar-gen-row {
    display: flex; justify-content: space-between; padding: 5px 0;
    border-bottom: 1px solid var(--panel-border); font-size: 12px;
}
.ar-gen-row span:first-child { color: var(--text-muted); }

@media (max-width: 1200px) {
    .ar-sidebar { width: 220px; }
    .ar-generals { width: 240px; }
}
@media (max-width: 900px) {
    .ar-sidebar, .ar-generals { display: none; }
    #ar-panel { left: 60px; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .sidebar { width: 260px; }
    #detail-panel { width: 340px; }
    .tactical-info { width: 280px; }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header .sidebar-tagline,
    .node-list-header,
    .node-item-content,
    .node-item-direction,
    .sidebar-btn span { display: none; }
    .sidebar-logo { font-size: 14px; justify-content: center; }
    #detail-panel { width: 100%; }
    .timeline-info { display: none; }
    #graph-panel, #tactical-panel { left: 60px; }
}
