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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --accent-primary: #00d9ff;
    --accent-secondary: #58a6ff;
    --accent-glow: rgba(0, 217, 255, 0.3);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --border-color: #30363d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    cursor: default;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d1117 100%);
}

.login-container {
    text-align: center;
    padding: 50px 60px;
    background: rgba(22, 27, 34, 0.9);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
    backdrop-filter: blur(20px);
}

.login-container h1 {
    font-size: 52px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px var(--accent-glow);
}

.login-container h2 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.login-container input {
    width: 280px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    margin-bottom: 20px;
    outline: none;
    transition: all 0.3s ease;
}

.login-container input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
}

.login-container input::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 16px 40px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn.primary:active {
    transform: translateY(-1px);
}

.info {
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 0.5px;
}

#loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d1117 100%);
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 30px var(--accent-glow);
}

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

#loading-screen p {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 1px;
}

#game-screen {
    display: block;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

#minimap-container {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: rgba(13, 17, 23, 0.95);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#minimap {
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

#resources-panel {
    position: absolute;
    top: 60px;
    left: 20px;
    padding: 12px 24px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#units-panel,
#buildings-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 220px;
    max-height: 280px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.panel-header {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

#units-list,
#buildings-list,
#players-list {
    padding: 10px;
    max-height: 220px;
    overflow-y: auto;
}

#units-list::-webkit-scrollbar,
#buildings-list::-webkit-scrollbar,
#players-list::-webkit-scrollbar {
    width: 6px;
}

#units-list::-webkit-scrollbar-track,
#buildings-list::-webkit-scrollbar-track,
#players-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

#units-list::-webkit-scrollbar-thumb,
#buildings-list::-webkit-scrollbar-thumb,
#players-list::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

.unit-item,
.building-item,
.player-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.unit-item:hover,
.building-item:hover,
.player-item:hover {
    background: var(--bg-hover);
    transform: translateX(3px);
}

.unit-item.selected,
.building-item.selected {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(88, 166, 255, 0.2));
    border: 1px solid var(--accent-primary);
}

.unit-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.unit-icon.worker { background: #fbbf24; color: #000; }
.unit-icon.soldier { background: #22c55e; color: #fff; }
.unit-icon.tank { background: #3b82f6; color: #fff; }
.unit-icon.sniper { background: #a855f7; color: #fff; }

#actions-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 280px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#actions-list {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.action-btn {
    padding: 14px 8px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.02);
}

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

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

.action-btn .cost {
    display: block;
    font-size: 9px;
    color: var(--warning);
    margin-top: 4px;
}

#chat-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 450px;
    max-height: 220px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#chat-panel.hidden {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
    pointer-events: none;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

#chat-header span {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

#chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    max-height: 160px;
}

.chat-message {
    font-size: 12px;
    margin-bottom: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    word-wrap: break-word;
}

.chat-message .player {
    color: var(--accent-primary);
    font-weight: 600;
}

.chat-message.system {
    color: var(--text-secondary);
    font-style: italic;
}

#chat-input {
    padding: 14px;
    background: var(--bg-tertiary);
    border: none;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#game-over-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 50px 60px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 100px var(--accent-glow);
}

.modal-content h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.modal-content p {
    margin-bottom: 30px;
    font-size: 18px;
    color: var(--text-secondary);
}

#minimap-controls {
    position: absolute;
    top: 270px;
    right: 20px;
    display: flex;
    gap: 8px;
}

#minimap-controls .btn {
    padding: 8px 16px;
    font-size: 11px;
}

@media (max-width: 900px) {
    #player-list {
        display: none;
    }

    #buildings-panel {
        display: none;
    }

    #minimap-container {
        width: 140px;
        height: 140px;
        top: 10px;
        right: 10px;
    }

    #resources-panel {
        top: 10px;
        left: 10px;
        font-size: 14px;
        padding: 10px 16px;
    }

    #actions-panel {
        width: 200px;
        bottom: 10px;
        left: 10px;
    }

    #chat-panel {
        width: calc(100% - 230px);
        max-height: 150px;
    }

    #minimap-controls {
        top: 160px;
    }
}

@media (max-width: 600px) {
    #actions-panel {
        display: none;
    }

    #chat-panel {
        width: calc(100% - 20px);
        left: 10px;
        transform: none;
    }

    #units-panel {
        width: 160px;
    }
}
