* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0a0a1a;
    color: white;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

.loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.loader-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-top-color: #764ba2;
    animation-duration: 1s;
    animation-direction: reverse;
}

.loader-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-top-color: #f093fb;
    animation-duration: 0.8s;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 20px;
    color: rgba(255,255,255,0.9);
    text-align: center;
    font-weight: 300;
    letter-spacing: 2px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

#city-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a1a;
}

#city-canvas {
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
    image-rendering: optimizeQuality;
}

.ui-overlay {
    position: fixed;
    z-index: 100;
    pointer-events: none;
}

.ui-overlay > * {
    pointer-events: auto;
}

#top-bar {
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.logo:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.3);
}

.user-panel {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-info {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.user-emoji {
    font-size: 22px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.user-coins {
    color: #FFD700;
    font-weight: bold;
    background: rgba(255, 215, 0, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
}

.btn {
    background: rgba(102, 126, 234, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 18px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: rgba(102, 126, 234, 0.95);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
}

.btn-success {
    background: rgba(0, 184, 148, 0.8);
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.btn-danger {
    background: rgba(255, 71, 87, 0.8);
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
}

#building-panel {
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    width: 340px;
    max-height: 85vh;
}

#building-panel.collapsed {
    width: 60px;
}

.panel-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.panel-content {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    font-size: 14px;
    background: rgba(0,0,0,0.02);
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.infrastructure-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 15px 0;
}

.infrastructure-btn {
    padding: 12px;
    background: rgba(255,255,255,0.9);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.infrastructure-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.infrastructure-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    padding: 30px;
    border-radius: 24px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6);
}

.building-info {
    position: fixed !important;
    background: rgba(30, 30, 46, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    color: #fff !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 100px rgba(0, 0, 0, 0.6) !important;
    z-index: 300 !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    overflow: hidden !important;
    min-width: 420px !important;
    max-width: 650px !important;
    min-height: 350px !important;
    max-height: 85vh !important;
    resize: both !important;
}

.building-info.show {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.building-info-header {
    padding: 20px 24px !important;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9)) !important;
    color: white !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: move !important;
    user-select: none !important;
}

.building-info-control-btn {
    background: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
    color: white !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s !important;
}

.building-info-content {
    padding: 24px !important;
    max-height: calc(85vh - 80px) !important;
    overflow-y: auto !important;
    color: rgba(255,255,255,0.9) !important;
}

.building-info-content a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.building-info-content a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.building-tabs {
    display: flex !important;
    border-bottom: 2px solid rgba(255,255,255,0.1) !important;
    margin-bottom: 24px !important;
    gap: 8px !important;
    overflow-x: auto !important;
}

.building-tab {
    padding: 12px 18px !important;
    cursor: pointer !important;
    border: none !important;
    background: transparent !important;
    color: rgba(255,255,255,0.6) !important;
    font-weight: 500 !important;
    border-radius: 8px 8px 0 0 !important;
    transition: all 0.3s !important;
    white-space: nowrap !important;
}

.building-tab.active {
    background: rgba(102, 126, 234, 0.2) !important;
    color: #667eea !important;
    border-bottom: 2px solid #667eea !important;
}

.tab-content {
    display: none !important;
}

.tab-content.active {
    display: block !important;
    animation: fadeIn 0.4s ease !important;
}

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

.interaction-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    margin: 24px 0 !important;
}

.interaction-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 14px !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    background: rgba(255,255,255,0.05) !important;
    color: rgba(255,255,255,0.9) !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    transition: all 0.3s !important;
}

.interaction-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    transform: translateY(-2px) !important;
}

.interaction-btn.liked {
    background: rgba(255, 107, 107, 0.15) !important;
    color: #ff6b6b !important;
}

.interaction-btn.following {
    background: rgba(0, 184, 148, 0.15) !important;
    color: #00b894 !important;
}

.building-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
    margin-top: 24px !important;
    padding: 18px !important;
    background: rgba(0, 0, 0, 0.2) !important;
    border-radius: 12px !important;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.4);
    z-index: 10000;
    animation: slideIn 0.4s ease;
    max-width: 400px;
    display: none;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
}

@keyframes slideIn {
    from { transform: translateX(100%) scale(0.9); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}
 
@media (max-width: 768px) {
    .building-info {
        width: 95% !important;
        min-width: 95% !important;
        max-width: 95% !important;
        left: 2.5% !important;
        right: 2.5% !important;
        top: 10% !important;
        resize: none !important;
    }
    
    #building-panel {
        width: 90%;
        left: 5%;
        right: 5%;
        top: auto;
        bottom: 80px;
        transform: none;
    }
}