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

body {
    font-family: 'Press Start 2P', cursive;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #2d5016 0%, #1a3d0a 100%);
}

#top-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: linear-gradient(180deg, #4a3728 0%, #3a2718 100%);
    border-bottom: 4px solid #654321;
    flex-wrap: wrap;
    gap: 10px;
}

#settlement-name input {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    background: #2a1a0a;
    border: 2px solid #654321;
    color: #ffd700;
    padding: 5px 10px;
    width: 180px;
    text-align: center;
}

#resources {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.resource {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 4px;
}

.resource img {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

.resource span {
    font-size: 10px;
    color: #ffd700;
}

#speed-controls {
    display: flex;
    gap: 5px;
}

.speed-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 5px 10px;
    background: #3a2a1a;
    border: 2px solid #654321;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    background: #4a3a2a;
}

.speed-btn.active {
    background: #654321;
    color: #ffd700;
    border-color: #8b7355;
}

#main-area {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

#minimap-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: #2a1a0a;
    border: 3px solid #654321;
    padding: 5px;
}

#minimap {
    display: block;
    image-rendering: pixelated;
    cursor: pointer;
}

#happiness {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    font-size: 12px;
}

#happiness-bar, #coffee-bar {
    width: 80px;
    height: 10px;
    background: #333;
    border: 1px solid #555;
    overflow: hidden;
}

#happiness-fill {
    width: 80%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcb77);
    transition: width 0.3s;
}

#coffee-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6f4e37, #c4a35a);
    transition: width 0.3s;
}

#canvas {
    flex: 1;
    cursor: grab;
    image-rendering: pixelated;
}

#canvas:active {
    cursor: grabbing;
}

#build-menu {
    width: 170px;
    background: linear-gradient(180deg, #3a2a1a 0%, #2a1a0a 100%);
    border-left: 4px solid #654321;
    padding: 10px;
    overflow-y: auto;
    max-height: 100%;
}

#build-menu h3 {
    font-size: 11px;
    color: #ffd700;
    margin-bottom: 10px;
    text-align: center;
}

.build-category {
    margin-bottom: 10px;
}

.category-header {
    font-size: 9px;
    color: #ccc;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    cursor: pointer;
    margin-bottom: 5px;
}

.category-header:hover {
    background: rgba(255,255,255,0.1);
}

.category-items {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.category-items.collapsed {
    display: none;
}

.build-item {
    display: flex;
    gap: 8px;
    padding: 5px;
    background: rgba(0,0,0,0.2);
    border: 2px solid #444;
    cursor: pointer;
    transition: all 0.2s;
}

.build-item:hover {
    background: rgba(255,215,0,0.2);
    border-color: #ffd700;
}

.build-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.build-item.cannot-afford {
    border-color: #8b0000;
}

.build-item img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.item-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.item-name {
    font-size: 8px;
    color: #fff;
}

.item-cost {
    font-size: 7px;
    color: #aaa;
}

#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: linear-gradient(180deg, #3a2718 0%, #2a1708 100%);
    border-top: 4px solid #654321;
}

#activity-feed {
    flex: 1;
    overflow: hidden;
}

#activity-text {
    font-size: 8px;
    color: #ccc;
    white-space: nowrap;
    animation: scroll 20s linear infinite;
}

@keyframes scroll {
    0%, 90% { transform: translateX(0); }
    95%, 100% { transform: translateX(-100%); }
}

#coffee-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

#achievement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, #4a3728 0%, #2a1708 100%);
    border: 4px solid #ffd700;
    padding: 20px 40px;
    z-index: 1000;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s;
}

#achievement-popup.show {
    opacity: 1;
}

#achievement-popup.hidden {
    display: none;
}

#achievement-text {
    font-size: 14px;
    color: #ffd700;
}

#tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    border: 2px solid #654321;
    padding: 8px;
    font-size: 8px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
}

#tooltip.hidden {
    display: none;
}

footer {
    padding: 8px;
    background: #1a1a2e;
    text-align: center;
    font-size: 8px;
    color: #666;
}

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

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

.divider {
    margin: 0 10px;
    color: #333;
}

.tagline {
    font-style: italic;
    color: #555;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #top-hud {
        padding: 5px 10px;
    }
    
    #settlement-name input {
        width: 120px;
        font-size: 8px;
    }
    
    #resources {
        gap: 8px;
    }
    
    .resource {
        padding: 2px 5px;
    }
    
    .resource img {
        width: 16px;
        height: 16px;
    }
    
    .resource span {
        font-size: 8px;
    }
    
    .speed-btn {
        font-size: 8px;
        padding: 4px 6px;
    }
    
    #minimap-container {
        display: none;
    }
    
    #build-menu {
        position: absolute;
        right: 0;
        top: 0;
        width: 140px;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s;
        z-index: 100;
    }
    
    #build-menu:hover,
    #build-menu:focus-within {
        transform: translateX(0);
    }
    
    #build-menu::before {
        content: '🏗️';
        position: absolute;
        left: -30px;
        top: 50%;
        transform: translateY(-50%);
        background: #3a2a1a;
        padding: 10px 5px;
        border: 2px solid #654321;
        border-right: none;
        font-size: 16px;
    }
    
    #status-bar {
        padding: 5px 10px;
    }
    
    #activity-text {
        font-size: 7px;
    }
    
    footer {
        font-size: 6px;
    }
    
    .divider {
        display: none;
    }
    
    .tagline {
        display: none;
    }
}

@media (max-width: 480px) {
    #settlement-name {
        display: none;
    }
    
    #speed-controls {
        position: absolute;
        bottom: 60px;
        left: 10px;
        z-index: 50;
    }
}