* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Space Mono', monospace;
    background: #1a1a1a;
    color: #f0f0f0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
    touch-action: manipulation;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Mobile Top Status Bar */
#mobileTopBar {
    background: linear-gradient(135deg, #2c1810 0%, #3d2318 100%);
    border-bottom: 2px solid #8b4513;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    z-index: 1000;
    min-height: 50px;
}

.status-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.mobile-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #d4af37;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

.mobile-population {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    border: 1px solid #8b4513;
}

.mobile-icon {
    font-size: 1.1rem;
}

#mobilePop {
    font-weight: 700;
    font-size: 0.9rem;
    color: #d4af37;
}

/* Mobile Resources Panel */
#mobileResourcesPanel {
    background: rgba(44, 24, 16, 0.95);
    border-bottom: 1px solid #8b4513;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 4px;
    min-height: 60px;
}

.mobile-resource {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    border: 1px solid #654321;
    min-width: 70px;
}

.mobile-resource-icon {
    font-size: 1.2rem;
}

.mobile-resource-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.mobile-resource-info span:first-child {
    font-weight: 700;
    font-size: 0.85rem;
    color: #f0f0f0;
}

.mobile-rate {
    font-size: 0.6rem;
    color: #cccccc;
}

/* Mobile Game Area */
#mobileGameArea {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Enhanced touch controls overlay */
#touchControlsOverlay {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    pointer-events: none;
    z-index: 100;
}

.touch-hint {
    background: rgba(0,0,0,0.8);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.7rem;
    text-align: center;
    opacity: 0.9;
    border: 1px solid rgba(212,175,55,0.3);
    line-height: 1.3;
}

/* Mobile Bottom Panel */
#mobileBottomPanel {
    background: linear-gradient(135deg, #2c1810 0%, #3d2318 100%);
    border-top: 2px solid #8b4513;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.5);
    max-height: 200px;
    overflow: hidden;
    position: relative;
}

/* Mobile Tab Navigation */
#mobileTabNav {
    display: flex;
    border-bottom: 1px solid #8b4513;
    background: rgba(0,0,0,0.2);
}

.mobile-tab {
    flex: 1;
    padding: 12px 6px;
    background: transparent;
    color: #cccccc;
    border: none;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    text-align: center;
}

.mobile-tab.active {
    color: #d4af37;
    background: rgba(212,175,55,0.1);
    border-bottom-color: #d4af37;
}

.mobile-tab:active {
    background: rgba(212,175,55,0.2);
    transform: scale(0.98);
}

/* Mobile Tab Content */
.mobile-tab-content {
    display: none;
    padding: 15px 12px;
    height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
}

.mobile-tab-content.active {
    display: block;
}

/* Mobile Building Grid */
.mobile-building-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 2px;
}

.mobile-building-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: rgba(0,0,0,0.4);
    border: 2px solid #654321;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 85px;
    position: relative;
    overflow: hidden;
}

.mobile-building-card:active {
    background: rgba(212,175,55,0.2);
    border-color: #d4af37;
    transform: scale(0.95);
}

.mobile-building-card.selected {
    border-color: #d4af37;
    background: rgba(212,175,55,0.15);
    box-shadow: 0 0 10px rgba(212,175,55,0.3);
}

.mobile-building-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.mobile-building-name {
    font-weight: 700;
    font-size: 0.75rem;
    color: #f0f0f0;
    text-align: center;
    line-height: 1.1;
    margin-bottom: 2px;
}

.mobile-building-cost {
    font-size: 0.65rem;
    color: #cccccc;
    text-align: center;
    line-height: 1.2;
    font-weight: 400;
}

/* Mobile Stats Grid */
.mobile-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px;
}

.mobile-stat-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-stat-label {
    font-size: 0.8rem;
    color: #f0f0f0;
    font-weight: 700;
}

.mobile-stat-bar {
    height: 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #654321;
}

.mobile-stat-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37 0%, #ffec8b 100%);
    transition: width 0.5s ease;
    border-radius: 3px;
}

/* Mobile Actions Grid */
.mobile-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mobile-action-btn {
    padding: 12px 8px;
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    color: #f0f0f0;
    border: 2px solid #654321;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.mobile-action-btn:active {
    background: linear-gradient(135deg, #a0522d 0%, #cd853f 100%);
    border-color: #d4af37;
    transform: scale(0.95);
}

/* Mobile Notifications */
#mobileNotifications {
    position: fixed;
    top: 120px;
    left: 10px;
    right: 10px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.mobile-notification {
    background: linear-gradient(135deg, #2c1810 0%, #3d2318 100%);
    color: #f0f0f0;
    padding: 10px 12px;
    border-radius: 6px;
    border: 2px solid #8b4513;
    box-shadow: 0 2px 8px rgba(0,0,0,0.7);
    animation: mobileSlideIn 0.3s ease;
    font-size: 0.8rem;
    pointer-events: auto;
}

.mobile-notification.success { border-color: #4caf50; }
.mobile-notification.warning { border-color: #ff9800; }
.mobile-notification.error { border-color: #f44336; }

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

/* Mobile Modals */
.mobile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mobile-modal.active {
    display: flex;
}

.mobile-modal-content {
    background: linear-gradient(135deg, #2c1810 0%, #3d2318 100%);
    border: 2px solid #8b4513;
    border-radius: 10px;
    max-width: 320px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.7);
}

.mobile-modal-header {
    padding: 15px;
    border-bottom: 1px solid #8b4513;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-modal-header h3 {
    color: #d4af37;
    font-size: 1rem;
    margin: 0;
}

.mobile-modal-close {
    background: none;
    border: none;
    color: #f0f0f0;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-modal-body {
    padding: 15px;
}

.device-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
    font-size: 0.8rem;
}

.device-info-item:last-child {
    border-bottom: none;
}

.device-label {
    color: #cccccc;
    font-weight: 700;
}

.help-section {
    margin-bottom: 16px;
}

.help-section h4 {
    color: #d4af37;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.help-section p {
    color: #f0f0f0;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Scrollbar Styling for Mobile */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 2px;
}

/* Responsive Adjustments */
@media screen and (max-height: 600px) {
    #mobileBottomPanel {
        max-height: 170px;
    }
    
    .mobile-tab-content {
        height: 110px;
        padding: 12px 10px;
    }
    
    .mobile-building-card {
        min-height: 75px;
        padding: 8px 4px;
        gap: 3px;
    }
    
    .mobile-building-icon {
        font-size: 1.2rem;
    }
    
    .mobile-building-name {
        font-size: 0.7rem;
    }
    
    .mobile-building-cost {
        font-size: 0.6rem;
    }
    
    .mobile-tab {
        padding: 10px 4px;
        font-size: 0.7rem;
    }
}

@media screen and (max-width: 360px) {
    .mobile-title {
        font-size: 1rem;
    }
    
    .mobile-building-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .mobile-building-name {
        font-size: 0.7rem;
    }
    
    .mobile-building-cost {
        font-size: 0.6rem;
    }
    
    .mobile-tab {
        font-size: 0.7rem;
        padding: 10px 3px;
    }
    
    .mobile-tab-content {
        padding: 12px 8px;
    }
}

@media screen and (max-height: 500px) {
    #mobileBottomPanel {
        max-height: 150px;
    }
    
    .mobile-tab-content {
        height: 90px;
    }
    
    .mobile-building-card {
        min-height: 65px;
    }
}

/* Orientation Lock Message */
@media screen and (orientation: landscape) {
    body::before {
        content: "Please rotate your device to portrait mode";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #1a1a1a;
        color: #f0f0f0;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10000;
        font-size: 1.2rem;
        text-align: center;
        padding: 20px;
    }
}