@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700;800;900&family=Roboto+Mono:wght@400;500;600;700&display=swap');

:root {
    --background: #10161b;
    --panel: rgba(16, 23, 29, 0.96);
    --panel-light: rgba(34, 45, 53, 0.94);
    --border: rgba(164, 185, 193, 0.2);
    --text: #e7ecee;
    --muted: #8b9ba3;
    --blue: #36a9ed;
    --blue-dark: #176b9f;
    --red: #e45a4f;
    --green: #76c98a;
    --gold: #e7b65d;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: "Roboto Mono", monospace;
}

button,
select {
    font: inherit;
}

button {
    color: var(--text);
    cursor: pointer;
    border: 1px solid var(--border);
    background: rgba(35, 47, 55, 0.95);
    transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover:not(:disabled) {
    background: rgba(60, 78, 89, 0.98);
    border-color: rgba(190, 220, 230, 0.55);
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#game {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #18221f;
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
}

.hidden {
    display: none !important;
}

.topbar {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(12, 18, 23, 0.94);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-family: "Barlow Condensed", sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: white;
    font-size: 13px;
    background: var(--blue-dark);
    border: 1px solid #64c4f4;
    transform: skew(-8deg);
}

.top-status {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #bdcbd0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#turnLabel {
    color: var(--blue);
    font-size: 13px;
}

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

.small-button,
.primary-button {
    min-height: 36px;
    padding: 0 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.7px;
}

.primary-button {
    color: white;
    background: #176b9f;
    border-color: #3ca5df;
}

.primary-button:hover:not(:disabled) {
    background: #218bc9;
}

.overlay {
    position: absolute;
    z-index: 20;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(5, 10, 13, 0.78);
    backdrop-filter: blur(8px);
}

.menu-card,
.game-over-card {
    width: min(650px, 94vw);
    max-height: 94vh;
    overflow-y: auto;
    padding: 32px;
    background: rgba(17, 25, 31, 0.98);
    border: 1px solid rgba(140, 170, 182, 0.3);
    box-shadow: 0 25px 90px rgba(0, 0, 0, 0.5);
}

.menu-eyebrow {
    color: var(--gold);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
}

.menu-card h1,
.game-over-card h1 {
    margin: 13px 0 10px;
    font-family: "Barlow Condensed", sans-serif;
    font-size: clamp(42px, 7vw, 70px);
    line-height: 0.86;
    font-weight: 900;
    letter-spacing: 1px;
}

.menu-card h1 span {
    color: var(--blue);
}

.menu-description {
    max-width: 490px;
    margin: 20px 0 28px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

.menu-card h2,
.shop-header h2 {
    margin: 0 0 12px;
    font-family: "Barlow Condensed", sans-serif;
    font-size: 20px;
    letter-spacing: 1px;
}

.map-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.map-card {
    min-height: 88px;
    padding: 13px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    background: rgba(34, 47, 55, 0.72);
}

.map-number {
    color: var(--gold);
    font-size: 10px;
    margin-bottom: 6px;
}

.map-name {
    font-family: "Barlow Condensed", sans-serif;
    font-size: 20px;
    font-weight: 700;
}

.map-detail {
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
}

.menu-footer {
    margin-top: 24px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    color: #657680;
    font-size: 9px;
    letter-spacing: 1px;
    border-top: 1px solid var(--border);
}

.unit-panel,
.building-panel {
    position: absolute;
    z-index: 6;
    left: 16px;
    bottom: 40px;
    width: 290px;
    padding: 15px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
}

.panel-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-label {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
}

.team-label {
    color: #c6cdd0;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

.blue-text {
    color: var(--blue);
}

.red-text {
    color: var(--red);
}

.unit-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 13px;
}

.unit-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    color: white;
    font-size: 22px;
    background: rgba(54, 169, 237, 0.18);
    border: 1px solid rgba(54, 169, 237, 0.6);
}

.unit-heading h2,
.building-panel h2 {
    margin: 0;
    font-family: "Barlow Condensed", sans-serif;
    font-size: 23px;
    line-height: 1;
}

.unit-heading p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 1px;
}

.health-row {
    display: flex;
    justify-content: space-between;
    margin: 10px 0 6px;
    color: #bac7cc;
    font-size: 9px;
}

.health-track {
    width: 100%;
    height: 7px;
    overflow: hidden;
    background: #303b40;
}

.health-fill {
    height: 100%;
    width: 100%;
    background: var(--green);
    transition: width 0.2s ease;
}

.building-health {
    background: var(--gold);
}

.unit-details {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    color: #a9b8be;
    font-size: 9px;
}

.weapon-label {
    display: block;
    margin-top: 13px;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 9px;
}

#weaponSelect {
    width: 100%;
    height: 30px;
    padding: 0 7px;
    color: var(--text);
    background: #27343b;
    border: 1px solid var(--border);
    font-size: 10px;
}

.action-buttons {
    display: flex;
    gap: 7px;
    margin-top: 13px;
}

.action-button {
    flex: 1;
    min-height: 36px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.move-button {
    border-color: rgba(54, 169, 237, 0.55);
}

.attack-button {
    border-color: rgba(228, 90, 79, 0.55);
}

.panel-hint,
.building-description {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.6;
}

.building-panel h2 {
    margin: 7px 0 13px;
}

.shop-panel {
    position: absolute;
    z-index: 10;
    top: 78px;
    right: 16px;
    bottom: 40px;
    width: min(350px, calc(100vw - 32px));
    overflow-y: auto;
    padding: 17px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.4);
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.close-button {
    width: 30px;
    height: 30px;
}

.shop-description {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.6;
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 15px;
}

.shop-item {
    width: 100%;
    padding: 11px;
    display: grid;
    grid-template-columns: 1fr auto;
    text-align: left;
    background: rgba(37, 50, 58, 0.85);
}

.shop-item strong {
    display: block;
    font-family: "Barlow Condensed", sans-serif;
    font-size: 18px;
}

.shop-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.5;
}

.shop-price {
    color: var(--gold);
    font-size: 11px;
    font-weight: 700;
    align-self: center;
}

.mode-banner {
    position: absolute;
    z-index: 4;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 18px;
    color: white;
    background: rgba(17, 28, 35, 0.94);
    border: 1px solid var(--blue);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.7px;
    pointer-events: none;
}

.toast {
    position: absolute;
    z-index: 30;
    top: 82px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(500px, 90vw);
    padding: 11px 17px;
    color: white;
    background: rgba(13, 21, 26, 0.96);
    border: 1px solid rgba(200, 220, 230, 0.3);
    font-size: 10px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.game-over-card {
    width: min(470px, 92vw);
    text-align: center;
}

.game-over-card h1 {
    color: var(--gold);
    margin: 24px 0 15px;
}

.game-over-card p {
    margin-bottom: 25px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.controls-hint {
    position: absolute;
    z-index: 3;
    right: 15px;
    bottom: 12px;
    display: flex;
    gap: 13px;
    color: #a4b3b9;
    font-size: 8px;
    pointer-events: none;
}

.controls-hint span {
    color: #e7ecee;
    font-weight: 700;
}

@media (max-width: 850px) {
    .topbar {
        height: 56px;
        padding: 0 9px;
    }

    .brand {
        font-size: 14px;
    }

    .brand-mark {
        width: 28px;
        height: 28px;
    }

    .top-status {
        gap: 8px;
        font-size: 8px;
    }

    #roundLabel,
    #populationLabel {
        display: none;
    }

    .small-button,
    .primary-button {
        min-height: 32px;
        padding: 0 8px;
        font-size: 9px;
    }

    .unit-panel,
    .building-panel {
        left: 8px;
        bottom: 32px;
        width: 260px;
        padding: 11px;
    }

    .controls-hint {
        display: none;
    }
}

@media (max-width: 520px) {
    .brand {
        font-size: 0;
    }

    .brand-mark {
        font-size: 11px;
    }

    .top-status {
        margin-right: auto;
    }

    .map-list {
        grid-template-columns: 1fr;
    }

    .menu-card {
        padding: 22px;
    }

    .unit-panel,
    .building-panel {
        width: 235px;
    }
}
