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

body {
    font-family: 'JetBrains Mono', monospace;
    background: #0a0a0f;
    color: #e8e8e8;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

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

#scene-container {
    width: 100%;
    height: 100%;
}

#scene-container canvas {
    display: block;
}

/* Menu Screens */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.92);
    z-index: 100;
    backdrop-filter: blur(8px);
}

.menu-screen.hidden {
    display: none;
}

.menu-content {
    text-align: center;
    padding: 3rem;
    background: linear-gradient(135deg, rgba(30, 30, 45, 0.95), rgba(20, 20, 35, 0.98));
    border: 2px solid #c9a227;
    border-radius: 12px;
    box-shadow: 0 0 60px rgba(201, 162, 39, 0.2), inset 0 0 30px rgba(0, 0, 0, 0.5);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.game-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 900;
    background: linear-gradient(180deg, #ffd700, #c9a227, #8b6914);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(201, 162, 39, 0.5);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    color: #888;
    margin-bottom: 2rem;
    font-style: italic;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 1rem 2.5rem;
    background: linear-gradient(180deg, #2a2a3a, #1a1a25);
    border: 2px solid #c9a227;
    color: #ffd700;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu-btn:hover {
    background: linear-gradient(180deg, #3a3a4a, #2a2a35);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(201, 162, 39, 0.4);
}

.menu-btn:active {
    transform: translateY(0);
}

/* Help Content */
.help-content {
    text-align: left;
    max-width: 500px;
}

.help-content h2 {
    font-family: 'Cinzel', serif;
    color: #ffd700;
    margin-bottom: 1.5rem;
    text-align: center;
}

.controls-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.key {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    background: #c9a227;
    color: #1a1a25;
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 100px;
    text-align: center;
}

.desc {
    color: #ccc;
    font-size: 0.9rem;
}

.goal-section {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.goal-section h3 {
    color: #4ade80;
    margin-bottom: 0.5rem;
}

.goal-section p {
    color: #aaa;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#hud.hidden {
    display: none;
}

#hud > * {
    pointer-events: auto;
}

/* Top Bar */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: linear-gradient(180deg, rgba(20, 20, 30, 0.95), rgba(20, 20, 30, 0.8));
    border-bottom: 2px solid #c9a227;
}

.resource-panel {
    display: flex;
    gap: 1.5rem;
}

.resource {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

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

.population-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    color: #4ade80;
}

.pop-icon {
    font-size: 1.2rem;
}

.timer-panel {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    color: #ffd700;
}

/* Minimap */
#minimap-container {
    position: absolute;
    bottom: 120px;
    right: 10px;
    background: rgba(20, 20, 30, 0.9);
    border: 2px solid #c9a227;
    border-radius: 8px;
    padding: 5px;
}

#minimap {
    display: block;
    border-radius: 4px;
}

/* Bottom Panel */
#bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    display: flex;
    background: linear-gradient(0deg, rgba(20, 20, 30, 0.95), rgba(20, 20, 30, 0.85));
    border-top: 2px solid #c9a227;
}

#selection-info {
    width: 200px;
    padding: 0.75rem;
    border-right: 1px solid #444;
}

#selected-portrait {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#portrait-icon {
    font-size: 2.5rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #555;
    border-radius: 4px;
}

#portrait-details {
    flex: 1;
}

#selected-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffd700;
    margin-bottom: 0.5rem;
}

#selected-health-bar {
    height: 12px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

#selected-health-fill {
    height: 100%;
    width: 100%;
    background: #4ade80;
    transition: width 0.2s, background-color 0.2s;
}

#action-panel {
    flex: 1;
    padding: 0.75rem;
    border-right: 1px solid #444;
}

#action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
    max-width: 400px;
}

.action-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    padding: 0.5rem;
    background: linear-gradient(180deg, #2a2a3a, #1a1a25);
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.2;
}

.action-btn small {
    font-size: 0.6rem;
    display: block;
    color: #aaa;
}

.action-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #3a3a4a, #2a2a35);
    border-color: #c9a227;
}

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

#queue-panel {
    width: 150px;
    padding: 0.75rem;
}

#training-queue {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.queue-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 1.2rem;
}

/* End Screen Stats */
#end-stats {
    margin: 1.5rem 0;
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
}

.stat-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.stat-row:last-child {
    border-bottom: none;
}

/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid #c9a227;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 200;
}

#tooltip.hidden {
    display: none;
}

/* Footer */
#game-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0.25rem;
    background: rgba(10, 10, 15, 0.9);
    font-size: 0.75rem;
    color: #666;
    z-index: 1000;
}

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

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

/* Mobile Optimizations */
@media (max-width: 768px) {
    #top-bar {
        padding: 0 0.5rem;
        height: 45px;
    }
    
    .resource {
        font-size: 0.95rem;
        gap: 0.25rem;
    }
    
    .resource-panel {
        gap: 0.75rem;
    }
    
    #bottom-panel {
        height: 90px;
    }
    
    #selection-info {
        width: 120px;
        padding: 0.5rem;
    }
    
    #portrait-icon {
        font-size: 1.8rem;
        width: 40px;
        height: 40px;
    }
    
    #selected-name {
        font-size: 0.75rem;
    }
    
    #action-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .action-btn {
        padding: 0.4rem;
        font-size: 1rem;
    }
    
    .action-btn small {
        display: none;
    }
    
    #queue-panel {
        width: 80px;
    }
    
    #minimap-container {
        bottom: 100px;
        right: 5px;
    }
    
    #minimap {
        width: 100px;
        height: 100px;
    }
    
    .menu-content {
        padding: 1.5rem;
    }
    
    .help-content {
        max-width: 95%;
    }
    
    .controls-grid {
        gap: 0.5rem;
    }
    
    .control-item {
        flex-direction: column;
        text-align: center;
        gap: 0.25rem;
    }
    
    .key {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    #selection-info {
        display: none;
    }
    
    #action-panel {
        border-left: none;
    }
    
    #minimap-container {
        width: 80px;
        height: 80px;
    }
    
    #minimap {
        width: 70px;
        height: 70px;
    }
}