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

body {
    background: #0a0500;
    color: #d4a574;
    font-family: 'VT323', monospace;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Title Screen */
#title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1a0a00 0%, #2a1500 50%, #1a0a00 100%);
    z-index: 100;
}

#title-screen.hidden {
    display: none;
}

.title-content {
    text-align: center;
    position: relative;
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 4rem;
    color: #ff6b35;
    text-shadow: 
        0 0 20px #ff6b35,
        0 0 40px #ff4500,
        4px 4px 0 #3a1500;
    letter-spacing: 0.2em;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

.subtitle {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: #d4a574;
    margin-top: 1rem;
    letter-spacing: 0.3em;
    text-shadow: 2px 2px 0 #1a0a00;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 20px #ff6b35, 0 0 40px #ff4500, 4px 4px 0 #3a1500; }
    to { text-shadow: 0 0 30px #ff8c5a, 0 0 60px #ff6b35, 4px 4px 0 #3a1500; }
}

.sand-effect {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 100px;
    background: radial-gradient(ellipse at center, rgba(212,165,116,0.3) 0%, transparent 70%);
    animation: sandPulse 3s ease-in-out infinite;
}

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

.faction-select {
    margin-top: 3rem;
}

.faction-select h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: #d4a574;
    margin-bottom: 1.5rem;
    letter-spacing: 0.2em;
}

.faction-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.faction-btn {
    background: linear-gradient(180deg, #2a1500 0%, #1a0a00 100%);
    border: 2px solid #d4a574;
    padding: 1.5rem 2rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    min-width: 160px;
}

.faction-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255,107,53,0.3);
}

.faction-btn.atreides:hover {
    border-color: #4488ff;
    box-shadow: 0 10px 30px rgba(68,136,255,0.3);
}

.faction-btn.harkonnen:hover {
    border-color: #ff4444;
    box-shadow: 0 10px 30px rgba(255,68,68,0.3);
}

.faction-icon {
    font-size: 2.5rem;
}

.faction-name {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    color: #fff;
}

.faction-motto {
    font-size: 0.9rem;
    color: #888;
}

.loading-status {
    margin-top: 2rem;
    font-size: 1rem;
    color: #ff6b35;
}

/* Game Screen */
#game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#game-screen.hidden {
    display: none;
}

/* Header Bar */
#header-bar {
    height: 50px;
    background: linear-gradient(180deg, #2a1500 0%, #1a0a00 100%);
    border-bottom: 2px solid #5c4033;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 2rem;
}

.resources {
    display: flex;
    gap: 1.5rem;
}

.resource {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    padding: 0.3rem 0.8rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid #5c4033;
}

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

#faction-display {
    flex: 1;
    text-align: center;
}

.atreides-badge {
    color: #4488ff;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
}

.harkonnen-badge {
    color: #ff4444;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
}

#minimap-container {
    border: 2px solid #5c4033;
    background: #0a0500;
}

#minimap {
    display: block;
}

/* Main Area */
#main-area {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    flex: 1;
    background: #1a0a00;
    cursor: crosshair;
}

/* Command Panel */
#command-panel {
    width: 200px;
    background: linear-gradient(180deg, #1a0a00 0%, #2a1500 100%);
    border-left: 2px solid #5c4033;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
    overflow-y: auto;
}

#selection-info {
    background: rgba(0,0,0,0.3);
    border: 1px solid #5c4033;
    padding: 0.5rem;
    min-height: 80px;
}

#selection-portrait {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#selection-portrait img {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

#selection-details {
    text-align: center;
    margin-top: 0.5rem;
}

#selection-name {
    font-size: 1rem;
    color: #fff;
}

#selection-health {
    font-size: 0.9rem;
    color: #44ff44;
}

#action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

#action-buttons button,
.produce-btn {
    flex: 1 1 45%;
    background: linear-gradient(180deg, #3a2000 0%, #2a1500 100%);
    border: 1px solid #5c4033;
    color: #d4a574;
    padding: 0.4rem;
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#action-buttons button:hover,
.produce-btn:hover {
    background: linear-gradient(180deg, #4a3000 0%, #3a2000 100%);
    border-color: #ff6b35;
}

#build-menu {
    background: rgba(0,0,0,0.3);
    border: 1px solid #5c4033;
    padding: 0.5rem;
}

#build-menu h4 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    color: #ff6b35;
    margin-bottom: 0.5rem;
    text-align: center;
}

.build-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: linear-gradient(180deg, #3a2000 0%, #2a1500 100%);
    border: 1px solid #5c4033;
    color: #d4a574;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.3rem;
    font-family: 'VT323', monospace;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.build-btn:hover {
    background: linear-gradient(180deg, #4a3000 0%, #3a2000 100%);
    border-color: #ff6b35;
}

.build-cost {
    color: #ffd700;
    font-size: 0.8rem;
}

/* Status Bar */
#status-bar {
    height: 40px;
    background: linear-gradient(180deg, #1a0a00 0%, #2a1500 100%);
    border-top: 2px solid #5c4033;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 2rem;
    font-size: 0.9rem;
}

#selected-units {
    display: flex;
    gap: 0.5rem;
}

#game-messages {
    flex: 1;
    color: #ff6b35;
    overflow: hidden;
}

#game-messages div {
    animation: fadeIn 0.3s ease;
}

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

#controls-hint {
    color: #666;
    font-size: 0.8rem;
}

/* Game Over Screen */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.9);
    z-index: 200;
}

#game-over-screen.hidden {
    display: none;
}

.game-over-content {
    text-align: center;
}

#game-over-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 30px currentColor;
}

#game-stats {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    line-height: 2;
}

#play-again-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    padding: 1rem 2rem;
    background: linear-gradient(180deg, #ff6b35 0%, #cc5500 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

#play-again-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255,107,53,0.5);
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem;
    background: rgba(26,10,0,0.9);
    border-top: 1px solid #3a2000;
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 0.8rem;
    z-index: 50;
}

footer a {
    color: #ff6b35;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer span {
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 0.6rem;
    }
    
    .faction-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    #command-panel {
        width: 150px;
    }
    
    #minimap-container {
        display: none;
    }
    
    .resources {
        gap: 0.5rem;
    }
    
    .resource {
        padding: 0.2rem 0.4rem;
        font-size: 1rem;
    }
}