:root {
    --primary-color: #d2c09e;
    --secondary-color: #603000;
    --primary-dark: #4a2200;
    --primary-light: #e8d8bc;
    --text-on-secondary: #f5ead8;
    --text-on-primary: #3a1800;
    /* Brown-tinted neutrals used to propagate the palette to buttons/tables. */
    --border-brown: #c9b9a0;
    --border-brown-strong: #a98e6a;
    --text-muted-brown: #7a6a52;
    --surface-brown: #f6f0e4;
    --surface-brown-2: #efe6d4;
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: var(--secondary-color);
}

.btn-primary {
    color: var(--text-on-secondary);
    background-color: var(--secondary-color);
    border-color: var(--primary-dark);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    color: var(--text-on-secondary);
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary-color);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.map-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.map-toolbar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}

.map-world-label {
    color: var(--secondary-color);
    font-weight: 600;
}

.map-world-select {
    border: 1px solid var(--border-brown-strong);
    border-radius: 0.35rem;
    padding: 0.3rem 0.55rem;
    background: #fff;
    color: var(--text-on-primary);
}

.map-nuke-input {
    width: 6rem;
    border: 1px solid var(--border-brown-strong);
    border-radius: 0.35rem;
    padding: 0.3rem 0.55rem;
    background: #fff;
    color: var(--text-on-primary);
}

.map-tab {
    border: 1px solid var(--secondary-color);
    background: var(--primary-light);
    color: var(--text-on-primary);
    padding: 0.35rem 0.8rem;
    border-radius: 0.35rem;
    font-weight: 600;
}

.map-tab.active {
    background: var(--secondary-color);
    color: var(--text-on-secondary);
}

.map-shell {
    width: 1000px;
    height: 1000px;
    border: 1px solid #ccd5df;
    background: #f8fbff;
    overflow: hidden;
}

.map-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, rgba(40, 60, 90, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(40, 60, 90, 0.08) 1px, transparent 1px);
    background-size: calc(100% / 20) calc(100% / 20);
}

.village-point {
    position: absolute;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    margin-top: -3px;
    background: #2f4f6f;
    border: 1px solid #0f2032;
    border-radius: 2px;
}

.village-point.recent-conquer {
    border: 2px solid #f4cf00;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.map-caption {
    margin-top: 0.6rem;
    color: #344b61;
}

/* ---- VillageMap component (draggable canvas map) ---- */
.vm-shell {
    position: relative;
    width: 100%;
    height: 100%;
}

.vm-host {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
}

.vm-canvas {
    display: block;
    touch-action: none;
}

.vm-controls {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 5;
}

.vm-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--secondary-color);
    background: rgba(255, 255, 255, 0.92);
    color: var(--secondary-color);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 0.3rem;
    cursor: pointer;
}

.vm-btn:hover {
    background: var(--primary-light);
}

.vm-tooltip {
    position: fixed;
    z-index: 50;
    pointer-events: none;
    background: rgba(20, 30, 44, 0.95);
    color: #f2f6fb;
    border: 1px solid #41617f;
    border-radius: 0.35rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.82rem;
    max-width: 240px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.vm-tt-name {
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.vm-tt-coord {
    color: #b8c6d6;
    font-weight: 400;
}

.vm-tt-row {
    line-height: 1.25;
}

.vm-tt-tribe {
    color: #ffd34d;
    margin-left: 0.3rem;
}

.vm-tt-barb {
    color: #c9b89a;
}

.vm-tt-conquer {
    color: #ffd34d;
}

.vm-tt-rel {
    font-weight: 600;
}

.vm-tt-rel-primary {
    color: #6f97ff;
}

.vm-tt-rel-ally {
    color: #7fcbff;
}

.vm-tt-rel-enemy {
    color: #ff7a7a;
}

/* ---- Op planner (target selection wrapper) ---- */
.op-plan-sub {
    color: #445970;
    margin-bottom: 0.75rem;
}

.op-plan-layout {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.op-plan-map {
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
}

/* Make the shared map shell fill the planner column instead of its fixed size. */
.op-plan-map .map-shell {
    width: 100%;
    height: 70vh;
    min-height: 420px;
}

.op-plan-panel {
    flex: 0 0 300px;
    border: 1px solid #ccd5df;
    border-radius: 0.4rem;
    background: #f8fbff;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.op-plan-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.op-plan-panel-head h5 {
    margin: 0;
}

.op-plan-clear {
    padding: 0;
}

.op-plan-empty {
    color: #5a6b7e;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.op-plan-targets {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
    overflow-y: auto;
    flex: 1 1 auto;
}

.op-plan-target {
    position: relative;
    border: 1px solid #d6dee7;
    border-radius: 0.35rem;
    background: #fff;
    padding: 0.4rem 1.6rem 0.4rem 0.5rem;
    margin-bottom: 0.35rem;
}

.op-plan-target-main {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
}

.op-plan-target-coord {
    font-weight: 700;
    color: var(--secondary-color);
}

.op-plan-target-name {
    color: #34495f;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-plan-target-sub {
    font-size: 0.8rem;
    color: #5a6b7e;
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
}

.op-plan-target-tribe {
    color: #b07d00;
    font-weight: 600;
}

.op-plan-target-pts {
    margin-left: auto;
}

.op-plan-barb {
    color: #8a7a5c;
}

.op-plan-remove {
    position: absolute;
    top: 0.3rem;
    right: 0.4rem;
    border: none;
    background: transparent;
    color: #8a3b2f;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.op-plan-add {
    margin-top: 0.5rem;
}

.op-plan-status {
    margin-top: 0.5rem;
    color: #2a6b3f;
    font-size: 0.85rem;
}

/* --- Anchored attack-type selector popup --- */
.op-type-popup {
    position: absolute;
    z-index: 30;
    transform: translate(-50%, calc(-100% - 18px));
    background: #fff;
    border: 1px solid var(--border-brown-strong);
    border-radius: 0.45rem;
    box-shadow: 0 6px 18px rgba(74, 34, 0, 0.25);
    padding: 0.4rem;
    pointer-events: auto;
}

.op-type-popup::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid #fff;
    filter: drop-shadow(0 1px 0 var(--border-brown-strong));
}

.op-type-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.op-type-popup-coord {
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

.op-type-popup-close {
    border: none;
    background: transparent;
    color: #8a3b2f;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.op-type-popup-icons {
    display: flex;
    gap: 0.3rem;
}

.op-type-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    width: 56px;
    padding: 0.3rem 0.2rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.35rem;
    background: var(--surface-brown);
    cursor: pointer;
}

.op-type-icon:hover {
    border-color: var(--secondary-color);
    background: var(--primary-light);
}

.op-type-icon.sel {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    color: var(--text-on-secondary);
}

.op-type-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.op-type-icon span {
    font-size: 0.72rem;
    line-height: 1;
}

.op-type-popup-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.45rem;
    min-width: 230px;
}

.op-type-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted-brown);
}

.op-type-field select,
.op-type-field input {
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.3rem;
    min-width: 150px;
}

.op-type-add {
    align-self: stretch;
}

.op-type-status {
    margin: 0;
    color: #2a6b3f;
    font-size: 0.8rem;
}

/* On phones, the anchored attack-type popup can overflow the map edges. Dock it to the bottom
   of the viewport as a contained sheet so every control stays reachable and on-screen. */
@media (max-width: 640px) {
    .op-type-popup {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        transform: none !important;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 0.9rem 0.9rem 0 0;
        border-bottom: none;
        box-shadow: 0 -8px 24px rgba(74, 34, 0, 0.35);
        padding: 0.5rem 0.9rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }

    /* Grab-handle affordance at the top of the docked sheet. */
    .op-type-popup::before {
        content: "";
        display: block;
        width: 2.75rem;
        height: 0.3rem;
        margin: 0.1rem auto 0.6rem;
        border-radius: 1rem;
        background: var(--border-brown-strong);
    }

    /* Hide the speech-bubble pointer once the popup is docked to the bottom. */
    .op-type-popup::after {
        display: none;
    }

    /* Keep the coord/close header pinned while the sheet body scrolls. */
    .op-type-popup-head {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #fff;
        padding-bottom: 0.4rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid var(--border-brown);
    }

    .op-type-popup-coord {
        font-size: 1rem;
    }

    /* Bigger, easier-to-hit close target. */
    .op-type-popup-close {
        font-size: 1.6rem;
        width: 2.25rem;
        height: 2.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Lay the attack-type icons out as an even, tappable grid. */
    .op-type-popup-icons {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
        gap: 0.5rem;
    }

    .op-type-icon {
        width: auto;
        min-height: 4rem;
        padding: 0.55rem 0.3rem;
        gap: 0.3rem;
    }

    .op-type-icon img {
        width: 34px;
        height: 34px;
    }

    .op-type-icon span {
        font-size: 0.8rem;
    }

    .op-type-popup-body {
        min-width: 0;
        gap: 0.7rem;
        margin-top: 0.7rem;
    }

    /* Stack field label above the control so wide selects get the full row width. */
    .op-type-field {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        font-size: 0.9rem;
    }

    .op-type-field select,
    .op-type-field input {
        min-width: 0;
        width: 100%;
        min-height: 2.75rem;
        font-size: 1rem;
        padding: 0.45rem 0.6rem;
    }

    /* Make the primary action a large, full-width, sticky button at the foot of the sheet. */
    .op-type-add {
        position: sticky;
        bottom: 0;
        min-height: 3rem;
        font-size: 1rem;
        font-weight: 600;
        margin-top: 0.25rem;
    }
}

@media (max-width: 800px) {
    .op-plan-layout {
        flex-direction: column;
    }

    .op-plan-panel {
        flex-basis: auto;
        max-height: none;
    }
}

/* --- Op creation form --- */
.op-create {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    padding: 0.6rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.4rem;
    background: var(--surface-brown);
}

.op-create-name {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.3rem;
    min-width: 180px;
}

.op-create label {
    font-size: 0.85rem;
    color: var(--text-muted-brown);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* --- Command builder --- */
.op-build {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.op-build-mode {
    display: flex;
    gap: 0.4rem;
}

.op-mode-btn {
    flex: 1 1 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-brown);
    background: #fff;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.op-mode-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--text-on-secondary);
}

.op-build-slot {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.35rem;
    background: #fff;
}

.op-build-label {
    flex: 0 0 54px;
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.op-build-val {
    color: var(--text-on-primary);
    font-weight: 600;
}

.op-build-val em {
    color: #5a6b7e;
    font-weight: 400;
    font-style: normal;
    margin-left: 0.3rem;
}

.op-build-empty {
    color: #97a4b3;
    font-size: 0.85rem;
}

.op-build-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted-brown);
}

.op-build-field select,
.op-build-field input {
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.3rem;
    min-width: 120px;
}

.op-landing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-brown);
    font-size: 0.85rem;
    color: var(--text-muted-brown);
}

.op-landing-input {
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-brown);
    border-radius: 0.3rem;
}

.op-status-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-brown);
}

.op-status-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #e2e8f0;
    color: #445970;
}

.op-status-badge.op-status-planned { background: var(--primary-light); color: var(--secondary-color); }
.op-status-badge.op-status-active { background: #dcfce7; color: #15803d; }
.op-status-badge.op-status-completed { background: #ede9fe; color: #6d28d9; }
.op-status-badge.op-status-cancelled { background: #fee2e2; color: #b91c1c; }

.op-build-landhint {
    margin: -0.2rem 0 0.4rem;
    font-size: 0.8rem;
    color: #5a6b7e;
}

/* --- Command list --- */
.op-cmd-list {
    margin-top: 1rem;
}

.op-earliest-landing {
    margin: 0 0 0.6rem;
    padding: 0.45rem 0.7rem;
    background: var(--surface-brown);
    border: 1px solid var(--border-brown);
    border-radius: 0.4rem;
    color: var(--text-on-primary);
}

.op-earliest-sub {
    margin-left: 0.5rem;
    color: var(--text-muted-brown);
    font-size: 0.85rem;
}

.op-cmd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.op-cmd-table th,
.op-cmd-table td {
    text-align: left;
    padding: 0.4rem 0.55rem;
    border-bottom: 1px solid var(--border-brown);
}

.op-cmd-table th {
    color: var(--secondary-color);
    font-weight: 600;
    border-bottom: 2px solid var(--border-brown-strong);
}

.op-cmd-coord {
    font-weight: 700;
    color: var(--secondary-color);
}

.op-cmd-player {
    color: var(--text-muted-brown);
    margin-left: 0.35rem;
}

.op-cmd-kind {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    background: #6b7785;
}

.op-cmd-kind-nuke { background: #e03a3a; }
.op-cmd-kind-fang { background: #ff8a3d; }
.op-cmd-kind-noble { background: #b06bff; }
.op-cmd-kind-nobletrain { background: #b06bff; }
.op-cmd-kind-fake { background: #9aa4b0; }
.op-cmd-kind-support { background: #4ab0ff; }

.op-cmd-remove {
    position: static;
}

/* Tablet-only: keep the still-anchored attack-type popup inside the viewport.
   (At <=640px the popup becomes a full-width bottom sheet handled above.) */
@media (min-width: 641px) and (max-width: 768px) {
    .op-type-popup {
        max-width: calc(100vw - 1.5rem);
    }
}

/* =====================================================================
   Responsive / mobile styles (appended). Breakpoints: 768px tablet,
   480px phone. Only new rules below — nothing above is modified.
   ===================================================================== */
@media (max-width: 768px) {
    /* Tame large content padding on small screens. */
    .content {
        padding-top: 0.75rem;
    }

    /* Map / op toolbars: stack vertically, controls go full width. */
    .map-toolbar,
    .ops-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .map-toolbar .map-world-select,
    .map-toolbar .map-nuke-input {
        width: 100%;
    }

    /* Standalone map page: scale the fixed 1000x1000 shell to the
       viewport instead of forcing horizontal page scroll. The op
       planner keeps its own (more specific) .op-plan-map .map-shell. */
    .map-shell {
        width: 100%;
        height: 70vh;
        min-height: 360px;
    }

    /* Wide command table: let it scroll horizontally inside its list
       wrapper rather than overflowing the viewport. */
    .op-cmd-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .op-cmd-table {
        width: auto;
        min-width: 100%;
        white-space: nowrap;
    }

    /* Op creation form: stack fields and let inputs fill the row. */
    .op-create {
        flex-direction: column;
        align-items: stretch;
    }

    .op-create .op-create-name {
        width: 100%;
        min-width: 0;
    }

    .op-create label {
        justify-content: space-between;
    }

    /* Command builder fields: drop rigid min-widths so selects/inputs
       can shrink to the available width. */
    .op-build-field select,
    .op-build-field input,
    .op-type-field select,
    .op-type-field input {
        min-width: 0;
        flex: 1 1 auto;
    }

    .op-type-popup-body {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    /* Slightly tighter map shell on phones. */
    .map-shell {
        height: 60vh;
        min-height: 300px;
    }

    /* Smaller type / padding for dense tables on phones. */
    .op-cmd-table {
        font-size: 0.8rem;
    }

    .op-cmd-table th,
    .op-cmd-table td {
        padding: 0.3rem 0.4rem;
    }

    /* Reduce banner padding. */
    .op-earliest-landing {
        padding: 0.4rem 0.55rem;
        font-size: 0.92rem;
    }
}
