:root {
    --text-color: #f8fafc;
    --glass-bg: rgba(10, 15, 30, 0.65);
    --glass-border: rgba(59, 130, 246, 0.3);
    --glass-glow: 0 0 20px rgba(59, 130, 246, 0.15);
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: rgba(255, 255, 255, 0.1);
    --secondary-hover: rgba(255, 255, 255, 0.2);
    --bg-color-2d: #060b14;
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background-color: #000;
    transition: background-color 0.3s ease;
}

/* 3D Mode Specifics */
body.mode-3d {
    overflow: hidden;
}

body.mode-3d #canvas-container {
    opacity: 1;
    pointer-events: auto;
}

body.mode-3d .ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none; 
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
}

/* 2D Mode Specifics */
body.mode-2d {
    overflow: auto;
    background-color: var(--bg-color-2d);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
}

body.mode-2d #canvas-container {
    opacity: 0;
    pointer-events: none;
}

body.mode-2d .ui-layer {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

body.mode-2d .top-left-panel {
    max-width: 100%;
}

body.mode-2d .bottom-panel {
    max-width: 100%;
    order: -1; /* Move legend up in 2D mode */
}

/* Utility */
.d-none {
    display: none !important;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.top-left-panel, .bottom-panel {
    pointer-events: auto; 
}

.top-left-panel {
    align-self: flex-start;
    max-width: 500px;
}

.bottom-panel {
    align-self: center;
    width: 100%;
    max-width: 800px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--glass-glow);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.25);
}

header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #60a5fa, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

header p {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn {
    background: var(--primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}
.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.7);
}

.secondary-btn, .toggle-btn, .warning-btn {
    background: var(--secondary);
    border: 1px solid rgba(255,255,255,0.1);
}
.secondary-btn:hover, .toggle-btn:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px) scale(1.02);
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
}
.warning-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.8) !important;
}

.status-message {
    font-size: 0.85rem;
    color: #94a3b8;
    min-height: 20px;
    font-family: monospace;
}

.legend-panel h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.legend-bar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.legend-gradient {
    flex-grow: 1;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, hsl(240, 100%, 50%), hsl(120, 100%, 50%), hsl(60, 100%, 50%), hsl(0, 100%, 50%));
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.legend-label {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
}

.legend-info {
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.75rem;
}

/* Tooltip for 3D */
.tooltip {
    position: absolute;
    background: rgba(10, 15, 30, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-left: 4px solid #60a5fa;
    backdrop-filter: blur(12px);
    padding: 1.2rem;
    border-radius: 4px 8px 8px 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.1s;
    font-size: 0.95rem;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 15px rgba(59, 130, 246, 0.2);
    z-index: 20;
    transform: translate(-50%, -100%) scale(0.95);
    margin-top: -15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tooltip.visible { 
    opacity: 1; 
    transform: translate(-50%, -100%) scale(1);
}
.tooltip div { margin-bottom: 6px; }
.tooltip span { font-weight: 800; color: #93c5fd; }


/* 2D Building Grid Styles */
.building-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    width: 100%;
}

.floor-row {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.floor-label {
    position: absolute;
    left: 2rem;
    font-weight: 700;
    color: #94a3b8;
    font-size: 1.1rem;
}

.apartments-wrapper {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    padding-left: 80px; 
}

.apartment-card {
    width: 110px;
    height: 110px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.15), 0 4px 10px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.apartment-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%);
    pointer-events: none;
}

.apartment-card:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.apartment-card.suspect {
    border: 3px solid #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8), inset 0 0 20px rgba(239, 68, 68, 0.4);
    animation: pulse-suspect 1.5s infinite;
}

@keyframes pulse-suspect {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.apt-no {
    font-size: 1.6rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    z-index: 1;
}

.apt-bill {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    text-shadow: none;
    z-index: 1;
}

@media (max-width: 768px) {
    .floor-row {
        flex-direction: column;
        padding-left: 1rem;
    }
    .floor-label {
        position: static;
        margin-bottom: 0.5rem;
        text-align: center;
    }
    .apartments-wrapper {
        padding-left: 0;
    }
}
