:root {
    --bg: #efe3c5;
    --bg-deep: #d1b98b;
    --panel: rgba(247, 240, 224, 0.92);
    --panel-strong: #f8f0db;
    --ink: #2f2318;
    --accent: #8a4b2c;
    --accent-strong: #5d2d1b;
    --line: rgba(62, 43, 29, 0.18);
    --grass: #7fa15f;
    --water: #5f88a5;
    --stone: #8f8f93;
    --shadow: 0 18px 45px rgba(71, 47, 23, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.35), transparent 28%),
        linear-gradient(180deg, #f7ecd5 0%, var(--bg) 45%, var(--bg-deep) 100%);
}

.page-shell {
    width: min(1440px, calc(100vw - 32px));
    margin: 18px auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 249, 236, 0.7);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.topbar,
.hud-grid,
.main-layout,
.map-meta,
.market-row,
.resource-row {
    display: flex;
}

.topbar,
.map-meta,
.market-row,
.resource-row {
    justify-content: space-between;
}

.topbar,
.hud-grid,
.main-layout {
    gap: 18px;
}

.topbar {
    align-items: center;
    margin-bottom: 18px;
}

.topbar h1,
.panel h2 {
    margin: 0;
}

.topbar h1 {
    font-size: clamp(2rem, 3vw, 3rem);
}

.eyebrow,
.hud-label,
.meta-label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: rgba(47, 35, 24, 0.7);
}

#status-line,
.panel-copy {
    margin: 6px 0 0;
    color: rgba(47, 35, 24, 0.78);
}

.topbar-actions {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.tick-info {
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(93, 45, 27, 0.1);
    font-size: 0.92rem;
}

.hud-grid {
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.hud-card,
.panel,
.map-frame {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.hud-card {
    flex: 1 1 180px;
    padding: 16px;
}

.hud-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 1.8rem;
}

.main-layout {
    align-items: flex-start;
}

.sidebar {
    width: 280px;
    display: grid;
    gap: 18px;
}

.panel {
    padding: 16px;
}

.button-stack,
.resource-list,
.market-list {
    display: grid;
    gap: 10px;
}

button,
select {
    font: inherit;
}

button {
    border: 0;
    border-radius: 12px;
    padding: 11px 14px;
    color: #fff9ef;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 10px 18px rgba(93, 45, 27, 0.18);
}

button:hover {
    transform: translateY(-1px);
}

button.active {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 12px 24px rgba(93, 45, 27, 0.28);
}

button.secondary-action {
    background: linear-gradient(180deg, #5c7f4d 0%, #3a5a30 100%);
}

button.subtle {
    padding: 8px 10px;
    font-size: 0.9rem;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.field-group {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(255, 252, 245, 0.95);
}

.map-panel {
    flex: 1;
}

.map-frame {
    padding: 16px;
    background:
        linear-gradient(180deg, rgba(115, 87, 50, 0.1), transparent 25%),
        var(--panel-strong);
}

#game-map {
    width: 100%;
    max-width: 800px;
    display: block;
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid rgba(49, 34, 22, 0.35);
    background:
        radial-gradient(circle at 50% 18%, rgba(255, 248, 219, 0.9), rgba(255, 248, 219, 0) 30%),
        linear-gradient(180deg, #c0d0ad 0%, #b4c68f 30%, #b79568 80%, #9f7c52 100%);
    box-shadow: inset 0 18px 28px rgba(255, 255, 255, 0.2);
}

.map-meta {
    margin-top: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.map-meta > div {
    flex: 1 1 160px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 250, 241, 0.8);
}

#view-report {
    color: var(--accent-strong);
}

.resource-row,
.market-row {
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 251, 244, 0.84);
}

.resource-row strong,
.market-row strong {
    display: block;
}

.market-buttons {
    display: flex;
    gap: 8px;
}

.building-card {
    text-align: left;
}

.building-card small,
.market-row small,
.resource-row small {
    display: block;
    color: rgba(47, 35, 24, 0.72);
}

.military-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 251, 244, 0.84);
}

@media (max-width: 1180px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: calc(100vw - 20px);
        margin: 10px auto;
        padding: 14px;
        border-radius: 18px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-items: stretch;
    }

    .topbar-actions button {
        width: 100%;
    }
}
