:root {
    --bg-1: #0b1a13;
    --bg-2: #1b2f22;
    --panel: rgba(16, 30, 24, 0.84);
    --panel-soft: rgba(28, 47, 38, 0.8);
    --stroke: rgba(173, 224, 162, 0.24);
    --text: #f4f9ee;
    --muted: #b5c6b0;
    --accent: #d9c76a;
    --accent-2: #8cd18e;
    --danger: #ef7c6f;
    --shadow: rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--text);
    font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
    background: radial-gradient(circle at 25% 20%, #34543f 0%, var(--bg-2) 38%, var(--bg-1) 100%);
}

#gameCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: block;
}

.overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, rgba(5, 12, 9, 0.8), rgba(17, 31, 24, 0.76));
    backdrop-filter: blur(5px);
    z-index: 20;
}

.menu-card {
    width: min(520px, calc(100vw - 32px));
    background: linear-gradient(160deg, rgba(32, 54, 43, 0.96), rgba(16, 29, 22, 0.96));
    border: 1px solid var(--stroke);
    border-radius: 16px;
    box-shadow: 0 22px 45px var(--shadow);
    padding: 24px;
    display: grid;
    gap: 14px;
}

.menu-card h1 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2rem);
}

.menu-subtitle,
.menu-hint {
    margin: 0;
    color: var(--muted);
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    color: var(--muted);
    font-size: 0.92rem;
}

select,
button {
    border: 1px solid var(--stroke);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(38, 62, 48, 0.95), rgba(24, 42, 33, 0.95));
    outline: none;
    transition: transform 0.12s ease, background 0.18s ease;
}

button {
    cursor: pointer;
}

button:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, rgba(48, 80, 60, 0.95), rgba(31, 54, 42, 0.95));
}

button:active {
    transform: translateY(0);
}

button.primary {
    border-color: rgba(217, 199, 106, 0.58);
    background: linear-gradient(180deg, rgba(175, 153, 73, 0.95), rgba(112, 97, 43, 0.95));
}

.build-btn.active {
    border-color: rgba(217, 199, 106, 0.82);
    box-shadow: 0 0 0 1px rgba(217, 199, 106, 0.5) inset;
    background: linear-gradient(180deg, rgba(109, 92, 39, 0.95), rgba(74, 63, 29, 0.95));
}

.menu-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
}

.hud {
    position: fixed;
    inset: 0;
    z-index: 12;
    pointer-events: none;
}

.top-bar {
    width: calc(100% - 20px);
    margin: 10px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--stroke);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: auto;
}

.resources {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.resource {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 68px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(6, 14, 10, 0.35);
    border: 1px solid rgba(204, 235, 195, 0.14);
    font-weight: 700;
}

.resource img {
    width: 18px;
    height: 18px;
    image-rendering: auto;
}

.quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.side-panel {
    position: fixed;
    left: 10px;
    bottom: 10px;
    width: min(300px, calc(100vw - 20px));
    max-height: calc(100vh - 94px);
    overflow-y: auto;
    display: grid;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: var(--panel-soft);
    box-shadow: 0 16px 24px var(--shadow);
    pointer-events: auto;
}

.side-panel section {
    border-radius: 10px;
    border: 1px solid rgba(209, 233, 201, 0.16);
    background: rgba(8, 16, 12, 0.3);
    padding: 10px;
    display: grid;
    gap: 8px;
}

.side-panel h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--accent-2);
}

.side-panel p {
    margin: 0;
    line-height: 1.33;
    color: var(--muted);
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

@media (max-width: 760px) {
    .menu-actions {
        grid-template-columns: 1fr;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-actions {
        justify-content: flex-start;
    }

    .side-panel {
        width: calc(100vw - 20px);
        max-height: 44vh;
    }
}
