/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
}

/* ================================================================
   CUSTOM SCROLLBAR - App-wide styling
   ================================================================ */

/* For Settings Modal and other scrollable areas */
.settings-modal-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.sidebar-section-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.settings-modal-body::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.sidebar-section-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.settings-modal-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.sidebar-section-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.settings-modal-body::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.sidebar-section-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 0 6px rgba(102, 126, 234, 0.6);
}

/* Firefox scrollbar */
.settings-modal-body,
.modal-body,
.sidebar-section-content {
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f1f1;
}

/* Screen Management */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
}

.screen.active {
    display: flex;
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
}

.auth-container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.auth-container h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #667eea;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
}

.tab-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-success {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-success:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-success:disabled {
    background: rgba(160, 174, 192, 0.3);
    border-color: rgba(160, 174, 192, 0.4);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-full {
    width: 100%;
}

.btn-fast-register {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    width: 100%;
    font-size: 18px;
    padding: 14px 24px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}

.btn-fast-register:hover {
    background: linear-gradient(135deg, #e082ea 0%, #e4465b 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

.form-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: #999;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e0e0e0;
}

.form-divider span {
    padding: 0 15px;
    font-size: 14px;
    font-weight: 500;
}

.error-message {
    color: #e53e3e;
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

/* Game Screen */
#game-screen {
    flex-direction: column;
}

.game-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
                0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1000;
}

/* Decorative gradient overlay */
.game-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0) 50%,
        rgba(255, 255, 255, 0.1) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.header-left h1 {
    font-size: 1.6em;
    color: #ffffff;
    margin: 0;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center {
    position: relative;
    z-index: 1;
}

.player-name {
    font-weight: 600;
    color: #666;
}

.resources {
    display: flex;
    gap: 20px;
}

.resource {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 18px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.resource:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.35);
}

.resource::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.resource:hover::before {
    opacity: 1;
}

.resource-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
    animation: pulse-subtle 3s ease-in-out infinite;
}

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

.resource-amount {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    min-width: 50px;
    text-align: right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animated number change effect */
@keyframes resource-increase {
    0% {
        transform: scale(1);
        color: #2d3748;
    }
    50% {
        transform: scale(1.15);
        color: #48bb78;
    }
    100% {
        transform: scale(1);
        color: #2d3748;
    }
}

@keyframes resource-decrease {
    0% {
        transform: scale(1);
        color: #2d3748;
    }
    50% {
        transform: scale(0.9);
        color: #f56565;
    }
    100% {
        transform: scale(1);
        color: #2d3748;
    }
}

.resource-amount.increase {
    animation: resource-increase 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.resource-amount.decrease {
    animation: resource-decrease 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.resource-rate {
    font-size: 11px;
    color: #a7f3d0;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.3);
    padding: 3px 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.resource-rate.negative {
    color: #f56565;
    background: rgba(245, 101, 101, 0.1);
}

.resource-storage {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Storage level indicators */
#wood-amount.storage-full,
#stone-amount.storage-full,
#gold-amount.storage-full {
    color: #ff4444;
    animation: pulse-warning 2s ease-in-out infinite;
}

#wood-amount.storage-high,
#stone-amount.storage-high,
#gold-amount.storage-high {
    color: #ff9f40;
}

#wood-amount.storage-medium,
#stone-amount.storage-medium,
#gold-amount.storage-medium {
    color: #ffed4e;
}

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

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
    z-index: 10000;
}

/* User Menu Dropdown */
.user-menu {
    position: relative;
    z-index: 9999;
}

.user-menu-btn {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    min-width: 180px;
    z-index: 9999;
}

.user-dropdown.active {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

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

.dropdown-item:hover {
    background: #f7fafc;
}

.logout-item:hover {
    background: #fee;
    color: #e53e3e;
}

/* Settings Modal */
.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    color: #333;
    margin-bottom: 8px;
}

.settings-section p {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Color Grid Container */
.color-grid-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.color-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-box.available {
    cursor: pointer;
    border-color: #e0e0e0;
}

.color-box.available:hover {
    transform: scale(1.15);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 10;
}

.color-box.taken {
    opacity: 0.3;
    cursor: not-allowed;
    position: relative;
}

.color-box.taken::after {
    content: '✖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.color-box.current {
    border-color: #48bb78;
    border-width: 4px;
    box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.3);
}

.color-box.current::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.color-box.selected {
    border-color: #4299e1;
    border-width: 4px;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.3);
    transform: scale(1.1);
}

.color-selection-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.selected-color-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #2d3748;
}

.selected-color-preview #selected-color-box {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid #cbd5e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#selected-color-hex {
    font-family: monospace;
    font-size: 14px;
    color: #4a5568;
}

.color-availability-info {
    font-size: 14px;
    color: #718096;
}

.color-availability-info span {
    font-weight: 700;
    color: #48bb78;
}

/* Legacy styles - keep for backwards compatibility */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

#player-color-picker {
    width: 60px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
}

.color-preview-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

#color-preview {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#color-hex {
    font-family: monospace;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* Game Container */
.game-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebars */
.sidebar {
    width: 300px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2),
                inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Custom scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5568d3 0%, #653a91 100%);
}

.sidebar-left {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-left::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(102, 126, 234, 0) 0%,
        rgba(102, 126, 234, 0.3) 50%,
        rgba(102, 126, 234, 0) 100%
    );
    pointer-events: none;
}

.sidebar-right {
    display: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-right::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(102, 126, 234, 0) 0%,
        rgba(102, 126, 234, 0.3) 50%,
        rgba(102, 126, 234, 0) 100%
    );
    pointer-events: none;
}

.panel {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.panel:hover {
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
}

.panel:hover::before {
    opacity: 1;
}

.panel h3 {
    margin-bottom: 18px;
    color: #ffffff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-size: 1.3em;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Sidebar Sections (Buildings & Army) */
.sidebar-section {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 14px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
}

.sidebar-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-section:hover {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-section:hover::before {
    opacity: 1;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    padding: 16px 18px;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.sidebar-section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.sidebar-section-header:hover::after {
    width: 100%;
}

.sidebar-section-header:hover {
    background: rgba(255, 255, 255, 0.25);
}

.section-icon {
    font-size: 24px;
    margin-right: 12px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-section-header:hover .section-icon {
    transform: scale(1.1);
}

.section-title {
    font-weight: 700;
    font-size: 16px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    flex: 1;
    letter-spacing: 0.3px;
}

.section-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 10px;
    min-width: 30px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-section-header:hover .section-count {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.section-arrow {
    color: #667eea;
    font-size: 14px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
}

.sidebar-section.collapsed .section-arrow {
    transform: rotate(-90deg);
}

.sidebar-section-content {
    max-height: 1000px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
    padding: 18px;
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-section.collapsed .sidebar-section-content {
    max-height: 0;
    padding: 0 18px;
    opacity: 0;
    overflow: hidden;
}

.empty-message {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
    font-style: italic;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Building List - Hierarchical */
.building-list {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

/* Custom scrollbar for building list */
.building-list::-webkit-scrollbar {
    width: 6px;
}

.building-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.building-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

/* Category Level (Production, Military, Support) */
.building-category-group {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    overflow: visible;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.building-category-group:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.category-group-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-bottom: 2px solid #e0e0e0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px 8px 0 0;
    position: relative;
}

.category-group-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 8px 0 0 0;
}

.building-category-group.expanded .category-group-header::before {
    opacity: 1;
}

.category-group-header:hover {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(15px);
}

.category-icon {
    font-size: 20px;
    margin-right: 10px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-group-header:hover .category-icon {
    transform: scale(1.1) rotate(5deg);
}

.category-name {
    font-weight: 700;
    font-size: 14px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    flex: 1;
    letter-spacing: 0.3px;
}

.category-count {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
    box-shadow: 0 2px 6px rgba(72, 187, 120, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 24px;
    text-align: center;
}

.category-group-header:hover .category-count {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(72, 187, 120, 0.4);
}

.category-arrow {
    color: #667eea;
    font-size: 12px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
}

.building-category-group.expanded .category-arrow {
    transform: rotate(90deg);
}

.category-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
}

.building-category-group.expanded .category-group-content {
    max-height: 1200px;
    overflow-y: auto;
    opacity: 1;
}

/* Building Type Level (Sawmill, Quarry, etc.) */
.building-type-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    overflow: visible;  /* Prevent overlay issues */
    margin-bottom: 4px;  /* Spacing between type groups */
}

.building-type-group:last-child {
    border-bottom: none;
}

.building-type-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transition: background 0.2s, backdrop-filter 0.2s;
}

.building-type-header:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
}

.type-icon {
    font-size: 20px;
    margin-right: 8px;
}

.type-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.type-name {
    font-weight: 600;
    font-size: 12px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.type-effect {
    font-size: 10px;
    color: #48bb78;
    font-weight: 600;
}

.type-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
}

.status-building {
    color: #ffa500;
    font-weight: 600;
}

.status-complete {
    color: #48bb78;
    font-weight: 600;
}

.type-count {
    color: #667eea;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.type-arrow {
    color: #718096;
    font-size: 9px;
    margin-left: 4px;
    transition: transform 0.3s ease;  /* Smooth arrow rotation */
}

.building-type-group.expanded .type-arrow {
    transform: rotate(90deg);  /* Rotate arrow when expanded */
}

.building-type-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);  /* Smooth professional easing */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 0 12px;
}

.building-type-group.expanded .building-type-content {
    max-height: 400px;  /* Increased for larger lists */
    padding: 8px 12px;
    overflow-y: auto;  /* Allow scrolling if content is large */
}

/* Building Level Group - Groups buildings by level within a type */
.building-level-group {
    margin-bottom: 6px;
    border-radius: 4px;
    overflow: hidden;
}

.building-level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, backdrop-filter 0.2s;
    border-radius: 4px;
}

.building-level-header:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
}

.level-name {
    font-weight: 600;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.level-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-count {
    color: #718096;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-weight: 500;
}

.level-arrow {
    color: #a0aec0;
    font-size: 10px;
    transition: transform 0.2s;
}

.building-level-group.expanded .level-arrow {
    transform: rotate(90deg);
}

.building-level-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    padding: 0 8px;
}

.building-level-group.expanded .building-level-content {
    max-height: 300px;
    padding: 8px 8px;
    overflow-y: auto;
}

/* Individual Building Level */
.building-individual-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 4px;
    font-size: 11px;
    border-left: 3px solid #48bb78;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, backdrop-filter 0.2s;
}

.building-individual-item:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    transform: translateX(2px);
}

.building-individual-item.building {
    border-left-color: #ffa500;
}

.building-number {
    font-weight: 600;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    min-width: 80px;
}

.building-location {
    color: #718096;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 10px;
    flex: 1;
    text-align: center;
}

.building-status {
    color: #666;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 10px;
}

.building-level {
    color: #999;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Army Info - Hierarchical */
.army-info {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

/* Custom scrollbar for army list */
.army-info::-webkit-scrollbar {
    width: 6px;
}

.army-info::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.army-info::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

.army-group {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    overflow: visible;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.army-group::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #f56565 0%, #c53030 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 10px 0 0 10px;
}

.army-group.expanded::before {
    opacity: 1;
}

.army-group:hover {
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.2);
    border-color: #f56565;
}

.army-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
}

.army-group-header:hover {
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
}

.army-group-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.army-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.army-group-header:hover .army-icon {
    transform: scale(1.15) rotate(-5deg);
}

.army-info-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.army-name {
    font-weight: 700;
    font-size: 13px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    letter-spacing: 0.2px;
}

.army-location {
    font-size: 11px;
    color: #4a5568;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 4px;
}

.army-location::before {
    content: '📍';
    font-size: 10px;
}

.army-group-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.army-total {
    font-size: 12px;
    color: white;
    font-weight: 700;
    background: linear-gradient(135deg, #f56565 0%, #c53030 100%);
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(245, 101, 101, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.army-group-header:hover .army-total {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(245, 101, 101, 0.4);
}

.army-arrow {
    color: #f56565;
    font-size: 12px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
}

.army-group.expanded .army-arrow {
    transform: rotate(90deg);
}

.army-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    border-top: 2px solid #edf2f7;
    opacity: 0;
    padding: 0 12px;
}

.army-group.expanded .army-group-content {
    max-height: 400px;
    padding: 12px;
    overflow-y: auto;
    opacity: 1;
}

.army-unit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.army-unit-item:hover {
    border-color: #667eea;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.unit-icon {
    font-size: 20px;
    margin-right: 10px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1));
}

.unit-name {
    flex: 1;
    font-size: 13px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.unit-count-value {
    font-size: 14px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 4px 12px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.army-power {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-top: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.army-power::before {
    content: '💪';
    margin-right: 8px;
    font-size: 16px;
}

/* Statistics */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

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

.stat-item:hover {
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.3);
}

.stat-item span:first-child {
    font-weight: 600;
    color: #2d3748;
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.stat-item span:last-child {
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-item:hover span:last-child {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

/* Leaderboard - Simple & Clean */
.leaderboard {
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    transition: all 0.2s ease;
    gap: 12px;
    min-width: 0; /* Allow flex children to shrink */
}

.leaderboard-item:hover {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.3);
}

.leaderboard-player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Critical for text truncation */
    overflow: hidden;
}

.leaderboard-rank {
    font-weight: 700;
    font-size: 14px;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    flex-shrink: 0; /* Never shrink the rank */
}

.player-color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin: 0 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.leaderboard-name {
    font-weight: 500;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.leaderboard-score {
    font-weight: 600;
    color: #667eea;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 13px;
    flex-shrink: 0; /* Never shrink the score */
    white-space: nowrap;
}

/* Legacy class - keep for backward compatibility */
.leaderboard-player {
    flex: 1;
    margin: 0 10px;
    font-weight: 500;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* Leaderboard Tabs */
.leaderboard-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 4px;
}

.leaderboard-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #4a5568;
    font-weight: 500;
}

.leaderboard-tab .tab-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
}

.leaderboard-tab .tab-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.leaderboard-tab:hover .tab-icon {
    transform: scale(1.15);
}

.leaderboard-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.leaderboard-tab.active .tab-icon {
    transform: scale(1.1);
}

/* Leaderboard Content Sections */
.leaderboard {
    display: none;
}

.leaderboard.active {
    display: flex;
}

/* Current Player Highlight */
.leaderboard-item.current-player {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.15) 0%, rgba(102, 126, 234, 0.15) 100%);
    border: 2px solid #48bb78;
    box-shadow: 0 4px 16px rgba(72, 187, 120, 0.3);
}

.leaderboard-item.current-player .leaderboard-name {
    font-weight: 700;
    color: #2d5016;
}

/* Guide */
.guide-text {
    font-size: 14px;
    line-height: 1.8;
    color: #4a5568;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.guide-text p {
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.guide-text p:hover {
    border-left-color: #667eea;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, transparent 100%);
    padding-left: 16px;
}

.guide-text strong {
    color: #2d3748;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Utility classes for animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounce-subtle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Apply fade-in animations to sidebar elements */
.sidebar-section {
    animation: fadeIn 0.5s ease-out;
}

.sidebar-section:nth-child(1) {
    animation-delay: 0.1s;
}

.sidebar-section:nth-child(2) {
    animation-delay: 0.2s;
}

.panel {
    animation: fadeIn 0.5s ease-out;
}

.panel:nth-child(1) {
    animation-delay: 0.1s;
}

.panel:nth-child(2) {
    animation-delay: 0.2s;
}

.panel:nth-child(3) {
    animation-delay: 0.3s;
}

/* Smooth loading state */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading-shimmer {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

/* Pulse animation for count badges */
@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.section-count.updated,
.category-count.updated,
.army-total.updated {
    animation: pulse-badge 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Game Main Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.map-controls {
    position: fixed;
    bottom: 20px;
    left: 320px;
    z-index: 800;

    display: flex;
    align-items: center;
    gap: 12px;

    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);

    padding: 12px 20px;
    border-radius: 50px;

    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.08);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-controls:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16),
                0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Zoom controls group */
.map-controls #zoom-in,
.map-controls #zoom-out {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.map-controls #zoom-in:hover,
.map-controls #zoom-out:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.map-controls #zoom-in:active,
.map-controls #zoom-out:active {
    transform: scale(0.95);
}

/* Divider between zoom and other controls */
.map-controls::after {
    content: '';
    width: 1px;
    height: 24px;
    background: linear-gradient(to bottom,
        rgba(102, 126, 234, 0),
        rgba(102, 126, 234, 0.3),
        rgba(102, 126, 234, 0)
    );
    margin: 0 4px;
}

/* Center button */
.map-controls #center-view {
    padding: 8px 16px;
    border-radius: 20px;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.map-controls #center-view:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

/* Mobile-only Center Button - Hide by default (desktop) */
.mobile-center-btn {
    display: none;
}

/* Territory count - REMOVED: duplicates Statistics sidebar */
/* .territory-count {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

.territory-count #territory-count {
    font-size: 15px;
    font-weight: 700;
} */

.game-map {
    flex: 1;
    background: #2d3748;
    position: relative;
    overflow: hidden;
}

#map-canvas {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.tile-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: none;
}

.tile-info.active {
    display: block;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    color: #667eea;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

/* ================================================================
   BUILD MODAL - Modern Design
   ================================================================ */

.build-modal {
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Sticky Header */
.build-modal-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px 30px;
    border-radius: 16px 16px 0 0;
}

.build-modal-header .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

.build-modal-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.build-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
}

.build-icon {
    font-size: 56px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

.build-title-section h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.build-location-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Scrollable Body */
.build-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 30px 30px;
    background: white;
}

/* Custom Scrollbar for Build Modal */
.build-modal-body::-webkit-scrollbar {
    width: 10px;
}

.build-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.build-modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.build-modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* Instructions */
.build-instructions {
    background: linear-gradient(135deg, #f0f4ff 0%, #f8f0ff 100%);
    border-left: 4px solid #667eea;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.build-instructions p {
    margin: 0;
    font-size: 15px;
    color: #4a5568;
    font-weight: 500;
}

/* Building Options - Compact Layout */
.building-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.building-category {
    background: #f7fafc;
    border-radius: 12px;
    padding: 15px;
}

.category-header {
    color: #667eea;
    font-size: 1.1em;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.buildings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.building-option-compact {
    background: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #e0e0e0;
}

.building-option-compact:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.15);
}

.building-compact-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.building-icon {
    font-size: 20px;
}

.building-compact-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
}

.building-effect {
    color: #48bb78;
    font-weight: 600;
}

.building-cost {
    color: #666;
    font-size: 10px;
    display: flex;
    gap: 4px;
}

.building-cost .insufficient {
    color: #e53e3e;
    font-weight: 700;
}

.building-option-compact.insufficient-resources {
    opacity: 0.7;
    border: 3px solid #e53e3e;
    background: #fff5f5;
}

.building-option-compact.insufficient-resources:hover {
    border: 3px solid #c53030;
    transform: none;
    box-shadow: 0 0 10px rgba(229, 62, 62, 0.5);
    cursor: not-allowed;
}

.building-time {
    color: #888;
    font-size: 10px;
}

/* Unit Training */
/* ================================================================
   TRAIN UNITS MODAL - MODERN DESIGN
   ================================================================ */

.train-units-modal {
    max-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Sticky Header */
.train-units-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 30px;
}

.train-units-header .close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 101;
}

.train-units-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.train-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
}

.train-icon {
    font-size: 60px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.train-title-section h2 {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 700;
    color: white;
}

.train-subtitle {
    margin: 0;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

/* Scrollable Body */
.train-units-body {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(90vh - 180px);
    scroll-behavior: smooth;
    padding: 30px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
}

.train-units-body::-webkit-scrollbar {
    width: 10px;
}

.train-units-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.train-units-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.train-units-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Unit Training Grid */
.unit-training-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* Unit Card */
.unit-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.unit-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.unit-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.unit-card:hover::before {
    transform: scaleX(1);
}

/* Unit Card Header */
.unit-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid #edf2f7;
}

.unit-icon-large {
    font-size: 56px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.unit-info {
    flex: 1;
}

.unit-info .unit-name {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 700;
    color: #2d3748;
}

.unit-power {
    display: flex;
    align-items: center;
    gap: 8px;
}

.power-label {
    font-size: 13px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.power-value {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
    padding: 4px 12px;
    border-radius: 8px;
}

/* Unit Description */
.unit-description {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Unit Cost Section */
.unit-cost-section {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 2px solid #e2e8f0;
}

.cost-label {
    font-size: 12px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.cost-items {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cost-item {
    background: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

/* Unit Train Controls */
.unit-train-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quantity-label {
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
}

.unit-card .unit-quantity {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #cbd5e0;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    transition: all 0.3s ease;
    background: white;
}

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

.unit-card .train-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.unit-card .train-btn:active {
    transform: translateY(0);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .train-units-modal {
        max-width: 95vw;
    }

    .train-header-content {
        gap: 15px;
    }

    .train-icon {
        font-size: 48px;
    }

    .train-title-section h2 {
        font-size: 24px;
    }

    .train-subtitle {
        font-size: 14px;
    }

    .train-units-body {
        padding: 20px;
    }

    .unit-training-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .unit-card {
        padding: 20px;
    }

    .unit-icon-large {
        font-size: 48px;
    }

    .unit-info .unit-name {
        font-size: 20px;
    }
}

/* ================================================================
   BUILDING DETAIL MODAL - MODERN PREMIUM DESIGN
   ================================================================ */

/* Modal Container */
.building-detail-modal {
    max-width: 680px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Custom Scrollbar for Modal */
.building-detail-body::-webkit-scrollbar {
    width: 10px;
}

.building-detail-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.building-detail-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.building-detail-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 0 6px rgba(102, 126, 234, 0.5);
}

/* Sticky Header - Always Visible */
.building-detail-sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.building-detail-sticky-header .close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 101;
}

.building-detail-sticky-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Building Header Inside Sticky */
.building-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 30px;
    color: white;
}

.building-icon-large {
    font-size: 80px;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.building-name-section {
    flex: 1;
}

.building-name-section h2 {
    margin: 0 0 12px 0;
    font-size: 28px;
    color: white;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.building-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modern Badges */
.building-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.building-level-badge:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.level-label {
    opacity: 0.9;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-number {
    font-size: 18px;
    font-weight: 700;
}

.building-location-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.building-location-badge:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Scrollable Body */
.building-detail-body {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(90vh - 180px);
    scroll-behavior: smooth;
}

/* ================================================================
   UPGRADE SECTION - THE STAR OF THE SHOW
   ================================================================ */

.building-upgrade-section {
    padding: 0 0 20px 0;  /* Remove top/left/right padding, keep bottom for separation */
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-bottom: 3px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.building-upgrade-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.05) 0%, transparent 70%);
    animation: pulse-bg 4s ease-in-out infinite;
}

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

/* Upgrade Header */
.upgrade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px 20px 0 20px;  /* Add padding for spacing from edges */
    position: relative;
    z-index: 1;
}

.upgrade-header h3 {
    margin: 0;
    font-size: 24px;
    color: #667eea;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.upgrade-time-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    font-size: 15px;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.upgrade-time-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.time-icon {
    font-size: 20px;
}

/* Card-Based Grid Layout */
.upgrade-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    padding: 0 20px;  /* Add horizontal padding for spacing from edges */
    position: relative;
    z-index: 1;
}

/* Benefits Card */
.upgrade-benefits-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.upgrade-benefits-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.upgrade-benefits-card h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #48bb78;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

/* Benefits List */
.benefits-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0fff4 0%, #e6fffa 100%);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    border: 2px solid #48bb78;
    transition: all 0.3s ease;
}

.benefit-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.2);
}

.benefit-arrow {
    color: #48bb78;
    font-weight: 700;
    font-size: 18px;
    min-width: 20px;
}

/* Cost Card */
.upgrade-cost-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.upgrade-cost-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.upgrade-cost-card h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #f6ad55;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

/* Cost Display */
.cost-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cost-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid #48bb78;
    transition: all 0.3s ease;
    color: #2d3748;
}

.cost-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.2);
}

.cost-item.insufficient {
    border-color: #f56565;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    color: #f56565;
    animation: shake 0.5s ease;
}

.cost-item.sufficient {
    border-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    color: #48bb78;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Upgrade CTA Button */
.btn-upgrade-cta {
    width: calc(100% - 40px);  /* Account for 20px margin on each side */
    margin: 0 20px;  /* Add horizontal margin for spacing from edges */
    padding: 18px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.btn-upgrade-cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-upgrade-cta:hover::before {
    left: 100%;
}

.btn-upgrade-cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
}

.btn-upgrade-cta:disabled {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ================================================================
   MAX LEVEL NOTICE
   ================================================================ */

.max-level-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 30px;
    margin: 30px;
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    border-radius: 16px;
    color: white;
    box-shadow: 0 8px 24px rgba(246, 173, 85, 0.4);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 8px 24px rgba(246, 173, 85, 0.4); }
    50% { box-shadow: 0 8px 32px rgba(246, 173, 85, 0.6); }
}

.max-level-icon {
    font-size: 48px;
    animation: trophy-bounce 2s ease-in-out infinite;
}

@keyframes trophy-bounce {
    0%, 100% {
        transform: translateY(0px) scale(1);
    }
    50% {
        transform: translateY(-8px) scale(1.05);
    }
}

.max-level-text h4 {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 700;
}

.max-level-text p {
    margin: 0;
    font-size: 16px;
    opacity: 0.95;
}

/* ================================================================
   CURRENT STATISTICS SECTION
   ================================================================ */

.building-stats-section {
    padding: 30px;
    background: white;
    border-bottom: 2px solid #e2e8f0;
}

.building-stats-section h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 3px solid #667eea;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

/* Stats Table - Clean table layout for building stats */
.stats-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.stats-table tr {
    transition: all 0.2s ease;
}

.stats-table tr:hover {
    background: rgba(102, 126, 234, 0.08);
}

.stats-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table .stat-label {
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 50%;
}

.stats-table .stat-value {
    font-size: 15px;
    font-weight: 700;
    color: #667eea;
    text-align: right;
    width: 50%;
}

/* Responsive table */
@media (max-width: 768px) {
    .stats-table td {
        padding: 12px 14px;
        font-size: 13px;
    }

    .stats-table .stat-label {
        font-size: 12px;
    }

    .stats-table .stat-value {
        font-size: 14px;
    }
}

.stat-item {
    padding: 20px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-item:hover::before {
    transform: scaleX(1);
}

.stat-item:hover {
    border-color: #667eea;
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
}

.stats-grid .stat-item .stat-label,
.building-stats-section .stat-label,
.stat-label {
    display: block;
    font-size: 12px;
    color: #718096 !important;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-grid .stat-item .stat-value,
.building-stats-section .stat-value,
.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #667eea !important;
    text-shadow: none;
}

/* ================================================================
   BUILDING DESCRIPTION SECTION
   ================================================================ */

.building-description-section {
    padding: 30px;
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
}

.building-description-section h3 {
    margin: 0 0 16px 0;
    color: #2d3748;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 3px solid #cbd5e0;
}

.description-text {
    margin: 0;
    color: #4a5568;
    line-height: 1.8;
    font-size: 15px;
}

/* ================================================================
   CANCEL BUILDING SECTION
   ================================================================ */

.building-cancel-section {
    padding: 30px;
    background: #fffbeb;
    border-top: 2px solid #fbd38d;
    margin-bottom: 20px;
}

.cancel-header h3 {
    margin: 0 0 12px 0;
    color: #ed8936;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cancel-description {
    margin: 0 0 20px 0;
    color: #718096;
    font-size: 14px;
    line-height: 1.6;
}

.cancel-refund-info {
    margin-bottom: 20px;
}

.cancel-refund-info h4 {
    margin: 0 0 12px 0;
    color: #2d3748;
    font-size: 16px;
    font-weight: 600;
}

.refund-display {
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #fbd38d;
}

.refund-amounts {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.refund-item {
    padding: 8px 16px;
    background: #f7fafc;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.btn-warning {
    background: #ed8936;
    color: white;
}

.btn-warning:hover {
    background: #dd6b20;
}

.btn-cancel-cta {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 10px;
    transition: all 0.3s ease;
}

/* ================================================================
   DESTROY SECTION
   ================================================================ */

.building-destroy-section {
    padding: 30px;
    background: #fff5f5;
    border-top: 2px solid #fed7d7;
}

.building-destroy-section h4 {
    margin: 0 0 12px 0;
    color: #f56565;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.building-destroy-section p {
    margin: 0 0 16px 0;
    color: #718096;
    font-size: 14px;
    line-height: 1.6;
}

.destroy-refund {
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #fed7d7;
    margin-bottom: 20px;
}

.destroy-warning {
    background: #fffbeb;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #ed8936;
    margin-bottom: 16px;
}

/* ================================================================
   RESPONSIVE DESIGN FOR BUILDING MODAL
   ================================================================ */

@media (max-width: 768px) {
    .building-detail-modal {
        max-width: 95vw;
        max-height: 95vh;
    }

    .building-header {
        padding: 20px;
        gap: 15px;
    }

    .building-icon-large {
        font-size: 60px;
    }

    .building-name-section h2 {
        font-size: 22px;
    }

    .upgrade-content-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .upgrade-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .upgrade-header h3 {
        font-size: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Legacy compatibility - keep btn-large for backward compatibility */
.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    font-weight: 700;
    border-radius: 10px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px;
    }
}

@media (max-width: 968px) {
    .sidebar-right {
        display: none;
    }
}

@media (max-width: 768px) {
    /* CRITICAL: Hide desktop map controls on mobile */
    .map-controls {
        display: none !important;
        visibility: hidden !important;
    }

    .game-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 30vh;
    }

    .sidebar-left {
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    .game-header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-left h1 {
        font-size: 1.3em;
    }

    .resources {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .resource {
        padding: 8px 14px;
        font-size: 14px;
        border-radius: 12px;
    }

    .resource-icon {
        font-size: 20px;
    }

    .resource-amount {
        font-size: 16px;
        min-width: 40px;
    }

    .resource-rate {
        font-size: 10px;
        padding: 2px 6px;
    }

    .header-right {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    #claim-free-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    /* Mobile-only center button */
    .mobile-center-btn {
        display: flex;
        position: fixed;
        bottom: 80px;
        left: 15px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        font-size: 24px;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        z-index: 900;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mobile-center-btn:hover,
    .mobile-center-btn:active {
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
    }

    /* REMOVED: .territory-count - duplicates Statistics sidebar */
    /* .territory-count {
        padding: 5px 12px;
        font-size: 12px;
    }

    .territory-count #territory-count {
        font-size: 13px;
    } */

    .map-controls::after {
        height: 20px;
        margin: 0 2px;
    }
}

/* ================================================================
   BATTLE MODAL - EPIC COMBAT ANIMATIONS
   ================================================================ */

/* Battle Modal Container */
.battle-modal {
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
}

/* Battle Header */
.battle-header {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    padding: 24px 30px;
    border-radius: 16px 16px 0 0;
    position: relative;
    overflow: hidden;
}

.battle-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: battle-glow 3s ease-in-out infinite;
}

@keyframes battle-glow {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
}

.battle-header h2 {
    margin: 0;
    color: white;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* Battle Body */
.battle-body {
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    padding: 24px;
}

/* Battle Arena (Canvas Container) */
.battle-arena {
    background: #2d3748;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
                inset 0 0 60px rgba(0, 0, 0, 0.2);
    border: 4px solid #1a202c;
    position: relative;
}

.battle-arena::before {
    content: '⚔️ BATTLEFIELD ⚔️';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    z-index: 1;
    pointer-events: none;
}

#battle-canvas {
    display: block;
    width: 100%;
    height: 400px;
    cursor: default;
}

/* Battle Armies Info */
.battle-armies-info {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 24px;
    align-items: center;
}

/* Army Panels */
.battle-army-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 3px solid #e2e8f0;
    transition: all 0.3s ease;
}

/* Attacker Panel (Player - Green) */
.battle-army-panel.attacker-panel {
    border: 4px solid #48bb78;
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
}

.battle-army-panel.attacker-panel h3 {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.battle-army-panel.attacker-panel .army-power {
    color: white;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.battle-army-panel.attacker-panel .unit-count,
.battle-army-panel.attacker-panel .army-composition {
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Defender Panel (Enemy - Red) */
.battle-army-panel.defender-panel {
    border: 4px solid #f56565;
    background: linear-gradient(135deg, #e53e3e 0%, #f56565 100%);
}

.battle-army-panel.defender-panel h3 {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.battle-army-panel.defender-panel .army-power {
    color: white;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.battle-army-panel.defender-panel .unit-count,
.battle-army-panel.defender-panel .army-composition {
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.battle-army-panel.attacker {
    border-color: #4299e1;
}

.battle-army-panel.defender {
    border-color: #f56565;
}

.battle-army-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.15);
}

.army-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.battle-army-panel.attacker .army-panel-header {
    border-bottom-color: #4299e1;
}

.battle-army-panel.defender .army-panel-header {
    border-bottom-color: #f56565;
}

.army-panel-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

.battle-army-panel.attacker .army-panel-header h4 {
    color: #4299e1;
}

.battle-army-panel.defender .army-panel-header h4 {
    color: #f56565;
}

.army-power-badge {
    background: linear-gradient(135deg, #fbd38d 0%, #f6ad55 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(246, 173, 85, 0.3);
}

.army-units-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.army-unit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    transition: all 0.2s ease;
}

.army-unit-row:hover {
    transform: translateX(4px);
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
}

.unit-icon {
    font-size: 20px;
    margin-right: 8px;
}

.unit-count {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

/* VS Divider */
.battle-vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 36px;
    font-weight: 900;
    color: #2d3748;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: vs-pulse 2s ease-in-out infinite;
}

@keyframes vs-pulse {
    0%, 100% {
        transform: scale(1);
        color: #2d3748;
    }
    50% {
        transform: scale(1.15);
        color: #e53e3e;
    }
}

.vs-icon {
    font-size: 48px;
    animation: vs-pulse 2s ease-in-out infinite;
}

@keyframes vs-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px rgba(229, 62, 62, 0.5));
    }
    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 12px rgba(229, 62, 62, 0.8));
    }
}

.vs-label {
    font-size: 20px;
    font-weight: 700;
    color: #e53e3e;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Battle Log */
.battle-log {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid #e2e8f0;
    max-height: 200px;
    overflow-y: auto;
}

.battle-log h4 {
    margin: 0 0 16px 0;
    color: #2d3748;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

#battle-log-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.battle-log-entry {
    padding: 10px 14px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 6px;
    font-size: 14px;
    color: #4a5568;
    border-left: 3px solid #667eea;
    animation: log-entry-appear 0.3s ease;
}

@keyframes log-entry-appear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.battle-log-entry.important {
    border-left-color: #e53e3e;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    font-weight: 600;
}

/* Custom Scrollbar for Battle Log */
.battle-log::-webkit-scrollbar {
    width: 8px;
}

.battle-log::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.battle-log::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

/* Battle Results */
.battle-results {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 3px solid #e2e8f0;
}

.battle-results.show {
    display: block;
    animation: results-appear 0.5s ease;
}

@keyframes results-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.battle-results.victory {
    border-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
}

.battle-results.defeat {
    border-color: #f56565;
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
}

.battle-result-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.battle-result-icon {
    font-size: 64px;
    margin-bottom: 12px;
    animation: result-bounce 1s ease;
}

@keyframes result-bounce {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    70% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.battle-result-header h3 {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 700;
}

.battle-results.victory .battle-result-header h3 {
    color: #48bb78;
    text-shadow: 0 2px 4px rgba(72, 187, 120, 0.2);
}

.battle-results.defeat .battle-result-header h3 {
    color: #f56565;
    text-shadow: 0 2px 4px rgba(245, 101, 101, 0.2);
}

.battle-result-message {
    font-size: 16px;
    color: #4a5568;
    font-weight: 500;
}

/* Casualties Section */
.battle-casualties {
    margin-top: 20px;
}

.battle-casualties h4 {
    margin: 0 0 16px 0;
    color: #2d3748;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.casualties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.casualty-panel {
    background: white;
    border-radius: 10px;
    padding: 16px;
    border: 2px solid #e2e8f0;
}

.casualty-panel h5 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 700;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 6px;
}

.casualty-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.casualty-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 6px;
    font-size: 14px;
}

.casualty-item.lost {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border-left: 3px solid #f56565;
}

.casualty-count {
    font-weight: 700;
    font-size: 16px;
    color: #e53e3e;
}

/* Battle Actions */
.battle-actions {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.btn-battle-close {
    padding: 14px 40px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-battle-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

/* Battle Animation Keyframes */
@keyframes march-forward {
    from { transform: translateX(0); }
    to { transform: translateX(50px); }
}

@keyframes march-backward {
    from { transform: translateX(0); }
    to { transform: translateX(-50px); }
}

@keyframes combat-shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 2px); }
    50% { transform: translate(2px, -2px); }
    75% { transform: translate(-2px, -2px); }
}

@keyframes unit-death {
    0% { opacity: 1; transform: scale(1) rotate(0deg); }
    50% { opacity: 0.5; transform: scale(1.2) rotate(180deg); }
    100% { opacity: 0; transform: scale(0) rotate(360deg); }
}

/* Responsive Battle Modal */
@media (max-width: 768px) {
    .battle-modal {
        max-width: 95vw;
        max-height: 95vh;
    }

    .battle-header h2 {
        font-size: 22px;
    }

    #battle-canvas {
        height: 300px;
    }

    .battle-armies-info {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .battle-vs {
        order: -1;
        flex-direction: row;
        gap: 12px;
        padding: 12px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .vs-icon {
        font-size: 32px;
    }

    .casualties-grid {
        grid-template-columns: 1fr;
    }

    .battle-result-header h3 {
        font-size: 24px;
    }

    .battle-result-icon {
        font-size: 48px;
    }
}

/* ================================================================
   ARMY DETAILS MODAL
   ================================================================ */

.army-modal {
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
}

.army-detail-header {
    background: linear-gradient(135deg, #4299e1 0%, #2b6cb0 100%);
    padding: 24px 30px;
    border-radius: 16px 16px 0 0;
    position: relative;
}

.army-detail-header .close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.army-detail-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.army-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
}

.army-icon-large {
    font-size: 56px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

.army-title-section h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.army-position-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.army-detail-body {
    padding: 30px;
    background: white;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
}

/* Army Stats Section */
.army-stats-section {
    margin-top: 60px;
    margin-bottom: 30px;
}

.army-stats-section h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 3px solid #4299e1;
}

.army-units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.army-unit-card {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.army-unit-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(66, 153, 225, 0.2);
    border-color: #4299e1;
}

.unit-type-icon {
    font-size: 40px;
}

.unit-type-info {
    text-align: center;
}

.unit-type-name {
    font-size: 14px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.unit-type-count {
    font-size: 32px;
    font-weight: 700;
    color: #4299e1;
    margin-top: 4px;
}

.unit-power {
    font-size: 12px;
    color: #a0aec0;
    background: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
}

.army-total-power {
    background: linear-gradient(135deg, #fbd38d 0%, #f6ad55 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 10px;
    text-align: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(246, 173, 85, 0.3);
}

.army-total-power strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.army-total-power span {
    font-size: 32px;
    font-weight: 700;
}

/* Army Actions Section */
.army-actions-section {
    padding: 24px 24px 12px 24px;
    background: linear-gradient(135deg, #f0f4ff 0%, #f8f0ff 100%);
    border-radius: 12px;
    border: 2px solid #e0e7ff;
}

.army-actions-section h3 {
    margin: 0 0 16px 0;
    color: #2d3748;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.army-action-btn {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 10px;
    background: linear-gradient(135deg, #4299e1 0%, #2b6cb0 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(66, 153, 225, 0.4);
    margin-bottom: 12px;
}

.army-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(66, 153, 225, 0.5);
}

.army-action-hint {
    margin: 0;
    font-size: 14px;
    color: #718096;
    text-align: center;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .army-modal {
        max-width: 95vw;
    }

    .army-units-grid {
        grid-template-columns: 1fr;
    }

    .army-header-content {
        gap: 15px;
    }

    .army-icon-large {
        font-size: 44px;
    }

    .army-title-section h2 {
        font-size: 22px;
    }
}

/* ========================================
   MODERN BATTLE LOG & RESULTS STYLING
   ======================================== */

/* Modern Battle Log */
.battle-log-modern {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid #dee2e6;
    max-height: 220px;
    overflow-y: auto;
}

.battle-log-content-modern {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-entry-modern {
    padding: 12px 16px;
    background: white;
    border-radius: 10px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    animation: log-slide-in 0.3s ease;
    border-left: 4px solid #6c757d;
}

@keyframes log-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-entry-modern .log-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.log-entry-modern .log-text {
    color: #212529;
    font-weight: 500;
    flex: 1;
}

.log-entry-modern.log-start {
    border-left-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
}

.log-entry-modern.log-attacker {
    border-left-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #dcfce7 100%);
}

.log-entry-modern.log-defender {
    border-left-color: #e53e3e;
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
}

.log-entry-modern.log-clash {
    border-left-color: #ff6b35;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    font-weight: 600;
}

.log-entry-modern.log-victory {
    border-left-color: #48bb78;
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    font-weight: 700;
}

.log-entry-modern.log-defeat {
    border-left-color: #e53e3e;
    background: linear-gradient(135deg, #fff5f5 0%, #fecaca 100%);
    font-weight: 700;
}

/* Custom scrollbar for modern battle log */
.battle-log-modern::-webkit-scrollbar {
    width: 10px;
}

.battle-log-modern::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 10px;
}

.battle-log-modern::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

/* Modern Battle Results */
.battle-results-modern {
    display: none;
    margin-top: 24px;
    animation: results-fade-in 0.6s ease;
}

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

.battle-result-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    margin-bottom: 24px;
}

.battle-results-modern.victory-result .battle-result-banner {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 10px 30px rgba(72, 187, 120, 0.3);
}

.battle-results-modern.defeat-result .battle-result-banner {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 10px 30px rgba(229, 62, 62, 0.3);
}

.result-icon {
    font-size: 72px;
    margin-bottom: 16px;
    animation: icon-bounce 1.2s ease;
    display: inline-block;
}

@keyframes icon-bounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.15) rotate(-10deg); }
    50% { transform: scale(1.05) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
}

.battle-result-banner h2 {
    margin: 0 0 12px 0;
    font-size: 38px;
    font-weight: 800;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

.battle-result-banner p {
    margin: 0;
    font-size: 17px;
    font-weight: 500;
    opacity: 0.95;
}

/* Modern Casualties Section */
.battle-casualties-modern {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
}

.casualties-divider {
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    padding-top: 40px;
}

.casualties-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    border: 2px solid #e9ecef;
}

.casualties-card.your-casualties {
    border-top: 4px solid #48bb78;
}

.casualties-card.enemy-casualties {
    border-top: 4px solid #e53e3e;
}

.casualties-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e9ecef;
}

.casualties-icon {
    font-size: 28px;
}

.casualties-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #212529;
}

.casualty-summary {
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.casualty-total {
    font-size: 48px;
    font-weight: 800;
    color: #e53e3e;
    line-height: 1;
    margin-bottom: 8px;
}

.casualty-total-label {
    font-size: 14px;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.casualty-breakdown {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.casualty-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px;
}

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

.casualty-unit-icon {
    font-size: 22px;
}

.casualty-unit-name {
    font-weight: 600;
    color: #212529;
    flex: 1;
}

.casualty-numbers {
    font-weight: 700;
    color: #e53e3e;
    font-size: 15px;
}

.casualty-bar-container {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #dee2e6;
    margin-bottom: 8px;
}

.casualty-bar-lost {
    background: linear-gradient(90deg, #e53e3e 0%, #fc8181 100%);
    transition: width 1s ease;
}

.casualty-bar-survived {
    background: linear-gradient(90deg, #48bb78 0%, #68d391 100%);
    transition: width 1s ease;
}

.casualty-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

.label-lost {
    color: #e53e3e;
}

.label-survived {
    color: #48bb78;
}

.battle-continue-btn {
    width: 100%;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.battle-continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
}

/* Responsive design for casualties */
@media (max-width: 768px) {
    .battle-casualties-modern {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .casualties-divider {
        display: none;
    }

    .battle-result-banner h2 {
        font-size: 32px;
    }

    .result-icon {
        font-size: 56px;
    }

    .casualty-total {
        font-size: 36px;
    }
}

/* ========================================
   GUIDE SECTION STYLING
   ======================================== */

.guide-text {
    font-size: 14px;
    line-height: 1.6;
}

.guide-section {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.guide-section h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.guide-section p {
    margin: 6px 0;
    color: #2d3748;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

.guide-section p strong {
    color: #1a202c;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.guide-tip {
    background: rgba(245, 158, 11, 0.2);
    backdrop-filter: blur(10px);
    border-left: 3px solid #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 8px 10px;
    margin: 8px 0;
    border-radius: 6px;
    font-weight: 600;
    color: #1a202c;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-size: 13px;
}

.guide-section:nth-child(1) {
    border-left-color: #48bb78;
}

.guide-section:nth-child(2) {
    border-left-color: #f59e0b;
}

.guide-section:nth-child(3) {
    border-left-color: #667eea;
}

.guide-section:nth-child(4) {
    border-left-color: #e53e3e;
}

.guide-section:nth-child(5) {
    border-left-color: #38b2ac;
}

.guide-section:nth-child(6) {
    border-left-color: #9f7aea;
}

/* Make guide scrollable if content is long */
.guide-text {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
}

.guide-text::-webkit-scrollbar {
    width: 6px;
}

.guide-text::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.guide-text::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

/* ==================== Market Exchange Section ==================== */
.market-exchange-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
    border: 2px solid #7dd3fc;
}

.exchange-header {
    text-align: center;
    margin-bottom: 24px;
}

.exchange-header h3 {
    font-size: 1.5rem;
    color: #0c4a6e;
    margin-bottom: 8px;
}

.exchange-description {
    color: #0e7490;
    font-size: 0.95rem;
    margin: 0;
}

.exchange-controls {
    max-width: 600px;
    margin: 0 auto;
}

.exchange-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.exchange-input-group {
    flex: 1;
    max-width: 200px;
}

.exchange-input-group label {
    display: block;
    font-weight: 600;
    color: #0c4a6e;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.exchange-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #7dd3fc;
    border-radius: 8px;
    background: white;
    color: #0c4a6e;
    cursor: pointer;
    transition: all 0.2s;
}

.exchange-select:hover {
    border-color: #0ea5e9;
}

.exchange-select:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.exchange-arrow {
    font-size: 2rem;
    color: #0284c7;
    font-weight: bold;
}

.exchange-amount-group {
    margin-bottom: 24px;
}

.exchange-amount-group label {
    display: block;
    font-weight: 600;
    color: #0c4a6e;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.exchange-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1rem;
    border: 2px solid #7dd3fc;
    border-radius: 8px;
    background: white;
    color: #0c4a6e;
    transition: all 0.2s;
}

.exchange-input:hover {
    border-color: #0ea5e9;
}

.exchange-input:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.exchange-preview {
    margin-top: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    text-align: center;
    color: #0c4a6e;
    font-size: 1rem;
    border: 2px solid #e0f2fe;
}

.exchange-preview strong {
    color: #0284c7;
    font-size: 1.2rem;
}

#exchange-resources-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

#exchange-resources-btn:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(14, 165, 233, 0.3);
}

/* ================================================================
   MOBILE RESPONSIVE DESIGN - Comprehensive Mobile Support
   ================================================================ */

/* Mobile Bottom Tab Navigation */
.mobile-tabs {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(102, 126, 234, 0.98) 0%, rgba(118, 75, 162, 0.98) 100%);
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

.mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 6px 4px;
    transition: all 0.2s ease;
    min-height: 56px; /* Touch-friendly */
    min-width: 44px;
}

.mobile-tab-icon {
    font-size: 22px;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

.mobile-tab-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-tab.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
}

.mobile-tab.active .mobile-tab-icon {
    transform: scale(1.1);
}

.mobile-tab:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
}

/* Mobile-specific media queries */
/* Mobile Fullscreen Views - Hidden on desktop */
.mobile-fullscreen-view {
    display: none;
}

@media (max-width: 768px) {
    /* Show mobile tabs */
    .mobile-tabs {
        display: flex;
    }

    /* Body adjustments for mobile */
    body {
        overflow: hidden;
        touch-action: pan-x pan-y;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile Fullscreen Views */
    .mobile-fullscreen-view {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        z-index: 1000;
        overflow: hidden;
    }

    .mobile-fullscreen-view.active {
        display: flex;
        flex-direction: column;
    }

    .mobile-view-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        border-bottom: none;
    }

    .mobile-view-header h2 {
        margin: 0;
        color: white;
        font-size: 1.3em;
        font-weight: 700;
    }

    .mobile-view-close {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: white;
        font-size: 24px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }

    .mobile-view-close:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }

    .mobile-view-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px;
        background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    }

    /* Game screen layout */
    #game-screen {
        flex-direction: column;
    }

    /* Header - Ultra-compact on mobile */
    .game-header {
        height: auto;
        min-height: 40px;
        padding: 4px 8px;
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
    }

    /* Hide logo completely on mobile - not important */
    .header-left {
        display: none;
    }

    /* Resources take center stage - most important */
    .header-center {
        order: 1;
        width: auto;
        flex: 1;
        margin: 0;
    }

    .resources {
        justify-content: flex-start;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        padding: 2px 0;
    }

    .resources::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .resource {
        flex-shrink: 0;
        padding: 4px 6px;
        min-width: 60px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 6px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .resource-icon {
        font-size: 18px;
        line-height: 1;
    }

    .resource span {
        font-size: 11px;
        font-weight: 600;
        line-height: 1.2;
    }

    /* Hide rate text on mobile to save space */
    .resource-rate {
        display: none;
    }

    /* Compact storage */
    .resource-storage {
        font-size: 9px;
        opacity: 0.8;
    }

    /* Header buttons - compact icons only */
    /* Hide header-right completely on mobile - moved to bottom tab panel */
    .header-right {
        display: none !important;
    }

    .btn-small {
        min-height: 36px;
        min-width: 36px;
        padding: 6px;
        font-size: 16px;
    }

    /* Username text - hide on small screens, show only icon */
    .user-menu-btn #header-username {
        display: none;
    }

    .user-menu-btn {
        min-height: 36px;
        min-width: 36px;
        padding: 6px;
        font-size: 14px;
    }

    .user-menu-btn::before {
        content: "👤";
        font-size: 16px;
    }

    /* Game Container - Full height */
    .game-container {
        flex-direction: row;
        height: calc(100vh - 48px - 72px); /* Compact header + tabs */
        overflow: hidden;
    }

    /* Hide sidebars completely on mobile - we use fullscreen views instead */
    .sidebar {
        display: none;
    }

    /* Mobile view content styling */
    .mobile-view-content .building-list,
    .mobile-view-content .army-info {
        max-height: none;
        padding-right: 0;
        margin-bottom: 16px;
    }

    /* Stats categories in mobile view */
    .mobile-view-content .stats-category {
        margin-bottom: 20px;
    }

    .mobile-view-content .stats-category:last-child {
        margin-bottom: 0;
    }

    .mobile-view-content .stats-category h4 {
        font-size: 1.1em !important;
        margin: 16px 0 12px 0 !important;
        color: #2d3748 !important;
        text-shadow: none !important;
    }

    /* Touch-friendly buttons in mobile views */
    .mobile-view-content .btn-full {
        min-height: 52px;
        font-size: 17px;
        margin-top: 16px;
        font-weight: 600;
    }

    /* Building and army cards - better touch targets */
    .mobile-view-content .building-category,
    .mobile-view-content .army-group {
        margin-bottom: 14px;
    }

    .mobile-view-content .army-group-header {
        min-height: 60px;
        padding: 14px;
    }

    .mobile-view-content .building-card {
        min-height: 60px !important;
        padding: 14px !important;
    }

    /* Leaderboard tabs in mobile view - touch-friendly */
    .mobile-view-content .leaderboard-tabs {
        margin-bottom: 20px;
    }

    .mobile-view-content .leaderboard-tab {
        min-height: 60px;
        padding: 12px 10px;
    }

    .mobile-view-content .leaderboard-tab .tab-icon {
        font-size: 22px;
    }

    .mobile-view-content .leaderboard-tab .tab-label {
        font-size: 13px;
    }

    /* Leaderboard items in mobile view - better spacing */
    .mobile-view-content .leaderboard {
        gap: 12px;
    }

    .mobile-view-content .leaderboard-item {
        padding: 16px 14px;
        min-height: 60px;
    }

    .mobile-view-content .leaderboard-rank {
        font-size: 17px;
        min-width: 36px;
    }

    .mobile-view-content .leaderboard-name {
        font-size: 16px;
    }

    .mobile-view-content .leaderboard-score {
        font-size: 16px;
    }

    /* Stat items in mobile view - IMPORTANT: Never use white text on white background! */
    .mobile-view-content .stat-item {
        padding: 14px 16px;
        min-height: 56px;
        background: rgba(255, 255, 255, 0.95) !important;
        border: 2px solid rgba(102, 126, 234, 0.3) !important;
    }

    .mobile-view-content .stat-item span:first-child {
        color: #2d3748 !important;
        font-weight: 600;
        font-size: 14px;
    }

    .mobile-view-content .stat-item span:last-child {
        color: white !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        padding: 6px 14px;
        border-radius: 8px;
        font-weight: 700;
        font-size: 15px;
    }

    /* Mobile User View Styles */
    .mobile-user-section {
        margin-bottom: 24px;
    }

    .mobile-user-info-card {
        display: flex;
        align-items: center;
        gap: 20px;
        padding: 24px;
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border: 2px solid rgba(102, 126, 234, 0.2);
    }

    .mobile-user-avatar {
        font-size: 60px;
        width: 80px;
        height: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }

    .mobile-user-details {
        flex: 1;
    }

    .mobile-user-details h3 {
        margin: 0 0 4px 0;
        font-size: 24px;
        color: #2d3748;
        font-weight: 700;
    }

    .mobile-user-subtitle {
        margin: 0;
        font-size: 14px;
        color: #718096;
    }

    .mobile-action-btn {
        width: 100%;
        padding: 18px;
        margin-bottom: 12px;
        background: white;
        border: 2px solid rgba(102, 126, 234, 0.3);
        border-radius: 12px;
        font-size: 17px;
        font-weight: 600;
        color: #2d3748;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .mobile-action-btn:active {
        transform: scale(0.98);
    }

    .mobile-action-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none;
    }

    .mobile-action-btn:disabled:active {
        transform: none;
    }

    .mobile-claim-btn {
        background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
    }

    .mobile-claim-btn:active {
        box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
    }

    .mobile-claim-btn:disabled {
        background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
        opacity: 0.7;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        cursor: not-allowed;
    }

    .mobile-chat-btn {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    }

    .mobile-chat-btn:active {
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    }

    .mobile-logout-btn {
        background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(245, 101, 101, 0.3);
    }

    .mobile-logout-btn:active {
        box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
    }

    .mobile-fullscreen-btn {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        font-size: 16px;
        font-weight: 700;
    }

    .mobile-fullscreen-btn:active {
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }

    .mobile-fullscreen-btn.active-fullscreen {
        background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
        box-shadow: 0 4px 12px rgba(237, 137, 54, 0.3);
    }

    .mobile-fullscreen-btn.active-fullscreen:active {
        box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
    }

    /* Main canvas area - Full screen */
    main {
        flex: 1;
        width: 100%;
        height: 100%;
        position: relative;
    }

    .game-canvas-container {
        width: 100%;
        height: 100%;
    }

    #map-canvas {
        width: 100%;
        height: 100%;
        touch-action: none; /* Prevent default touch behaviors */
    }

    /* Tile info - Floating overlay on mobile */
    .tile-info {
        position: fixed;
        bottom: 80px; /* Above mobile tabs */
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100% - 24px);
        width: auto;
        z-index: 200;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    }

    /* Buttons - Touch-friendly sizes */
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .btn-full {
        padding: 16px;
        font-size: 15px;
    }

    /* Modals - Full screen on mobile, no borders, no rounded corners */
    .modal-content,
    .build-modal,
    .settings-modal,
    .building-detail-modal,
    .train-units-modal,
    .battle-modal,
    .army-details-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        display: flex;
        flex-direction: column;
    }

    .modal-header,
    .build-modal-header,
    .settings-modal-header,
    .building-detail-sticky-header,
    .battle-header,
    .army-detail-header {
        position: sticky;
        top: 0;
        z-index: 10;
        flex-shrink: 0;
        padding: 16px;
        border-radius: 0 !important;
        border: none !important;
    }

    .close-modal {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
        font-size: 24px;
    }

    .modal-body,
    .build-modal-body,
    .settings-modal-body,
    .building-detail-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        border-radius: 0 !important;
        border: none !important;
    }

    /* Building cards - Larger on mobile */
    .building-category {
        margin-bottom: 20px;
    }

    .building-card {
        min-height: 80px;
        padding: 16px;
    }

    .building-icon {
        font-size: 36px;
        min-width: 50px;
    }

    .building-name {
        font-size: 16px;
    }

    /* Training modal */
    .train-unit-card {
        min-height: 90px;
        padding: 16px;
    }

    .unit-icon {
        font-size: 42px;
        min-width: 60px;
    }

    /* Quantity selector - Larger */
    .quantity-selector {
        gap: 12px;
    }

    .quantity-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 20px;
    }

    .quantity-input {
        min-height: 48px;
        font-size: 18px;
        min-width: 80px;
    }

    /* Settings - Stack inputs */
    .setting-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .setting-label {
        width: 100%;
    }

    .setting-input {
        width: 100%;
    }

    /* Notifications - Full width on mobile */
    .notification {
        max-width: calc(100% - 32px);
        left: 16px;
        right: 16px;
    }

    /* Leaderboard tables */
    .leaderboard-table {
        font-size: 13px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-item {
        padding: 12px;
    }

    /* Battle modal */
    #battle-canvas {
        width: 100%;
        height: 250px;
    }

    /* User dropdown */
    .user-dropdown {
        position: fixed;
        top: 60px;
        right: 12px;
        left: auto;
        min-width: 200px;
    }

    /* Auth screen - Adjust for mobile */
    .auth-container {
        max-width: calc(100% - 32px);
        padding: 24px;
        margin: 16px;
    }

    .auth-container h1 {
        font-size: 2em;
    }

    .auth-form input {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Hide desktop-only elements on mobile */
    .sidebar-section-arrow {
        display: none; /* No collapse arrows on mobile */
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .header-left h1 {
        font-size: 1em;
    }

    .resource {
        min-width: 70px;
        padding: 4px 6px;
    }

    .resource-icon {
        font-size: 14px;
    }

    .resource span {
        font-size: 11px;
    }

    .mobile-tab-label {
        font-size: 10px;
    }

    .mobile-tab-icon {
        font-size: 20px;
    }

    .tile-info {
        font-size: 13px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        height: calc(100vh - 36px - 56px);
    }

    .game-header {
        min-height: 36px;
        padding: 3px 8px;
    }

    .mobile-tabs {
        padding: 3px 0;
    }

    .mobile-tab {
        min-height: 44px;
    }

    .mobile-tab-icon {
        font-size: 18px;
    }

    .mobile-tab-label {
        font-size: 9px;
    }

    .sidebar {
        top: 36px;
        bottom: 56px;
    }

    .resource {
        min-width: 54px;
        padding: 3px 4px;
    }

    .resource-icon {
        font-size: 16px;
    }
}

/* PWA Safe Area Support */
@supports (padding: max(0px)) {
    .game-header {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .mobile-tabs {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ==================== Compact Online Players in Chat ==================== */

.chat-online-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-online-compact:hover {
    background: linear-gradient(135deg, #7c8ef0 0%, #8659b0 100%);
}

.online-icon {
    width: 8px;
    height: 8px;
    background: #48bb78;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.3),
                0 0 6px rgba(72, 187, 120, 0.6);
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.3),
                    0 0 6px rgba(72, 187, 120, 0.6);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 0 2px rgba(72, 187, 120, 0.4),
                    0 0 10px rgba(72, 187, 120, 0.8);
    }
}

.online-count {
    font-weight: 700;
    font-size: 15px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.online-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    flex: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.online-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.online-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.online-toggle-btn.active {
    transform: rotate(180deg);
}

.online-players-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f7fafc;
}

.online-players-dropdown.show {
    max-height: 250px;
    border-bottom: 2px solid #e2e8f0;
}

.online-players-list {
    background: white;
    margin: 8px;
    border-radius: 6px;
    max-height: 230px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
}

.online-player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.online-player-item:last-child {
    border-bottom: none;
}

.online-player-item:hover {
    background-color: #f9fafb;
}

.player-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px white, 0 0 8px currentColor;
}

.online-player-name {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    flex: 1;
}

.loading-players {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.no-players {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* ==================== Chat Panel ==================== */

.btn-chat {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 18px;
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

.btn-chat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.chat-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    color: white;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-loading {
    text-align: center;
    color: #9ca3af;
    padding: 20px;
    font-size: 14px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeInMessage 0.3s ease;
}

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

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-username {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-username-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-timestamp {
    font-size: 11px;
    color: #9ca3af;
}

.chat-message-text {
    background: white;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 16px 16px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

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

.chat-send-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 10px;
}

/* Desktop: Hide mobile gift button, show dropdown gift item */
.claim-free-mobile {
    display: none;
}

.claim-free-desktop {
    display: block;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-panel {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        height: 450px;
    }

    /* Mobile: Show mobile gift button, hide dropdown gift item */
    .claim-free-mobile {
        display: inline-flex;
    }

    .claim-free-desktop {
        display: none;
    }
}
