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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    color: #ffffff;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100vh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Camera background for AR */
.camera-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

.camera-background.hidden {
    display: none;
}

/* AR-specific notices */
.ar-notice, .camera-notice {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.ar-notice.hidden, .camera-notice.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none;
    transition: all 0.3s ease;
}

.ar-notice p, .camera-notice p {
    font-size: 18px;
    margin-bottom: 20px;
    color: #ffffff;
}

#header {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: calc(100vw - 20px);
}

#header h1 {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #FF1493, #00FFFF, #32FF32);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: colorShift 3s ease-in-out infinite;
}

.subtitle {
    font-size: clamp(12px, 3vw, 16px);
    opacity: 0.9;
    color: #cccccc;
}

#controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 280px;
    max-width: calc(100vw - 20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.population-counters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pop-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.pink-dot {
    background: linear-gradient(45deg, #FF1493, #FF69B4);
    box-shadow: 0 0 10px rgba(255, 20, 147, 0.6);
}

.blue-dot {
    background: linear-gradient(45deg, #00FFFF, #87CEEB);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

.green-dot {
    background: linear-gradient(45deg, #32FF32, #90EE90);
    box-shadow: 0 0 10px rgba(50, 255, 50, 0.6);
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    color: white;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
    touch-action: manipulation;
}

.btn:hover, .btn:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn.primary {
    background: linear-gradient(135deg, #FF1493 0%, #00FFFF 50%, #32FF32 100%);
    box-shadow: 0 4px 15px rgba(255, 20, 147, 0.4);
    font-size: 16px;
    padding: 12px 20px;
    animation: rainbowPulse 2s ease-in-out infinite;
}

.btn.primary:hover, .btn.primary:active {
    box-shadow: 0 6px 20px rgba(255, 20, 147, 0.6);
}

label {
    font-size: 13px;
    font-weight: 500;
    color: #cccccc;
    min-width: 60px;
}

input[type="range"] {
    flex: 1;
    min-width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #FF1493, #00FFFF, #32FF32);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 20, 147, 0.4);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #FF1493, #00FFFF, #32FF32);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 20, 147, 0.4);
}

select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    min-width: 100px;
}

select option {
    background: #1a1a2e;
    color: white;
}

input[type="color"] {
    width: 35px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

#scene-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.settings-panel {
    position: absolute;
    top: 120px;
    right: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    min-width: 280px;
    max-width: calc(100vw - 20px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.settings-panel.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.stats-panel {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 15px;
    min-width: 280px;
    max-width: calc(100vw - 20px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.stats-panel.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.stats-panel h3 {
    margin-bottom: 12px;
    color: #ffffff;
    font-size: 15px;
    text-align: center;
}

#statsChart {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    margin-bottom: 12px;
    width: 100%;
    max-width: 280px;
    height: 120px;
}

.stats-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.stats-info div {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#footer {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 10px 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#footer a {
    color: #00ffff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.3s ease;
}

#footer a:hover {
    color: #ff00ff;
}

/* Enhanced animations for AR color wars */
@keyframes colorShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes rainbowPulse {
    0% { 
        transform: scale(1);
        background: linear-gradient(135deg, #FF1493 0%, #00FFFF 50%, #32FF32 100%);
    }
    50% { 
        transform: scale(1.02);
        background: linear-gradient(135deg, #32FF32 0%, #FF1493 50%, #00FFFF 100%);
    }
    100% { 
        transform: scale(1);
        background: linear-gradient(135deg, #FF1493 0%, #00FFFF 50%, #32FF32 100%);
    }
}

/* Enhanced glassmorphism effects for AR */
#header, #controls, .settings-panel, .stats-panel, #footer, .ar-notice, .camera-notice {
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    #header {
        position: fixed;
        top: 5px;
        left: 5px;
        right: 5px;
        padding: 10px 15px;
    }
    
    #controls {
        position: fixed;
        bottom: 5px;
        left: 5px;
        right: 5px;
        top: auto;
        min-width: auto;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .settings-panel {
        position: fixed;
        bottom: 50px;
        left: 5px;
        right: 5px;
        top: auto;
        min-width: auto;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .stats-panel {
        position: fixed;
        bottom: 50px;
        left: 5px;
        right: 5px;
        top: auto;
        min-width: auto;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    #footer {
        display: none; /* Hide footer on mobile for space */
    }
}

/* Prevent zoom and bounce effects on iOS */
@media (max-width: 768px) {
    html, body {
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Custom scrollbar for mobile panels */
.settings-panel::-webkit-scrollbar,
.stats-panel::-webkit-scrollbar,
#controls::-webkit-scrollbar {
    width: 6px;
}

.settings-panel::-webkit-scrollbar-track,
.stats-panel::-webkit-scrollbar-track,
#controls::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.settings-panel::-webkit-scrollbar-thumb,
.stats-panel::-webkit-scrollbar-thumb,
#controls::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #FF1493, #00FFFF, #32FF32);
    border-radius: 3px;
}

/* AR-specific enhancements */
.territorial-glow {
    box-shadow: 0 0 20px rgba(255, 20, 147, 0.8);
    animation: territoralPulse 1.5s ease-in-out infinite;
}

@keyframes territoralPulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

/* High contrast mode for AR visibility */
@media (prefers-contrast: high) {
    #header, #controls, .settings-panel, .stats-panel {
        background: rgba(0, 0, 0, 0.95);
        border: 2px solid rgba(255, 255, 255, 0.5);
    }
    
    .btn {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}