/* Pre-match unit selection surface. */

.loadout-page {
    height: 100svh;
    width: 100%;
    display: grid;
    place-items: center;
    padding: clamp(10px, 2vw, 24px);
    overflow: hidden;
}

.loadout-shell {
    width: min(1120px, 100%);
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    padding: clamp(12px, 2vw, 18px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(18, 22, 29, 0.94);
    box-shadow: 0 18px 52px var(--shadow);
}

.loadout-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
}

.loadout-header h1 {
    margin: 4px 0 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1;
}

.loadout-factions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.loadout-faction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.loadout-faction span:first-child {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1rem;
    line-height: 1;
}

.loadout-faction-divider {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.62rem;
}

.loadout-summary {
    color: var(--muted);
    font-weight: 700;
    text-transform: none;
}

.loadout-summary::before {
    content: " · ";
    color: rgba(255, 255, 255, 0.32);
}

.loadout-status {
    max-width: 44ch;
    color: var(--muted);
    line-height: 1.35;
    text-align: right;
}

.loadout-layout {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 14px;
    align-items: start;
}

.loadout-picker,
.loadout-detail,
.loadout-group,
.loadout-slots,
.loadout-actions {
    min-width: 0;
    min-height: 0;
    display: grid;
    gap: 10px;
}

.loadout-detail {
    grid-template-rows: 260px auto auto;
}

.loadout-group {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
}

.loadout-group h2,
.loadout-slots h2 {
    margin: 0;
    color: var(--accent-light);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.loadout-grid {
    display: grid;
    gap: 8px;
}

.loadout-grid.units {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.loadout-grid.buildings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.loadout-choice,
.loadout-slot {
    min-width: 0;
    min-height: 72px;
    display: grid;
    gap: 6px;
    align-content: center;
    justify-items: center;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--control-bg);
    text-align: center;
}

.loadout-choice.selected,
.loadout-slot.filled {
    border-color: var(--control-selected-border);
    background: var(--control-selected-bg);
}

.loadout-choice.equipped:not(.selected) {
    border-color: rgb(var(--player-one-strong-rgb) / 0.7);
}

.loadout-choice span:last-of-type,
.loadout-slot span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    font-size: 0.86rem;
}

.loadout-choice small {
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1;
}

.loadout-choice-glyph,
.loadout-slot-glyph {
    --control-glyph-bg: rgba(0, 0, 0, 0.24);
}

.loadout-detail .unit-card {
    width: 100%;
    height: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.loadout-detail .unit-card-stats {
    min-height: 84px;
}

.loadout-detail .unit-card-description {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.loadout-slots {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
}

.loadout-slots-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.loadout-slots-heading span {
    color: var(--muted);
    font-family: Consolas, "Liberation Mono", monospace;
    font-weight: 800;
}

.loadout-slot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.loadout-slot.empty {
    border-style: dashed;
    color: var(--muted);
}

.loadout-actions {
    grid-template-columns: minmax(0, 1fr) minmax(130px, auto);
    align-items: center;
}

.loadout-actions .primary {
    min-height: 46px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.loadout-actions .primary.ready,
.loadout-actions .primary.ready:disabled {
    background: #1f5a32;
    color: rgba(255, 255, 255, 0.82);
    box-shadow: inset 0 0 0 1px rgba(80, 200, 120, 0.55), inset 0 2px 6px rgba(0, 0, 0, 0.45);
    filter: brightness(0.85);
    cursor: default;
    opacity: 1;
}

.loadout-warning {
    margin: 0;
    color: rgb(var(--danger-rgb));
    font-weight: 800;
    line-height: 1.3;
}

.loadout-warning.loadout-error {
    padding: 6px 10px;
    border: 1px solid rgb(var(--danger-rgb) / 0.75);
    border-radius: 6px;
    background: rgb(var(--danger-rgb) / 0.14);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (max-width: 860px) {
    .loadout-page {
        place-items: start center;
        padding: 8px;
    }

    .loadout-layout {
        grid-template-columns: 1fr;
    }

    .loadout-grid.units {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .loadout-status {
        max-width: none;
        text-align: left;
    }
}

@media (max-width: 520px) {
    .loadout-page {
        padding: 4px;
    }

    .loadout-shell {
        height: 100%;
        gap: 5px;
        padding: 6px;
        border-radius: 0;
    }

    .loadout-header {
        display: grid;
        gap: 2px;
    }

    .loadout-header .eyebrow {
        font-size: 0.56rem;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .loadout-header h1 {
        margin: 0;
        font-size: 1.05rem;
        line-height: 1.05;
    }

    .loadout-factions {
        gap: 5px;
        margin-top: 3px;
        font-size: 0.55rem;
    }

    .loadout-faction {
        gap: 3px;
    }

    .loadout-faction span:first-child {
        width: 20px;
        height: 20px;
        border-radius: 6px;
        font-size: 0.78rem;
    }

    .loadout-status {
        font-size: 0.68rem;
        line-height: 1.15;
        max-height: 2.3em;
        overflow: hidden;
    }

    .loadout-layout {
        grid-template-columns: minmax(126px, 0.45fr) minmax(0, 0.55fr);
        gap: 6px;
        align-items: stretch;
    }

    .loadout-picker {
        grid-template-rows: minmax(0, 1.55fr) minmax(0, 1fr);
        gap: 6px;
    }

    .loadout-detail {
        grid-template-rows: minmax(0, 1fr) auto auto;
        gap: 6px;
    }

    .loadout-group,
    .loadout-slots {
        gap: 5px;
        padding: 6px;
        overflow: hidden;
    }

    .loadout-group h2,
    .loadout-slots h2 {
        font-size: 0.62rem;
        line-height: 1;
    }

    .loadout-grid {
        gap: 5px;
        min-height: 0;
    }

    .loadout-grid.units {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .loadout-grid.buildings {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .loadout-choice,
    .loadout-slot {
        min-height: 0;
        gap: 3px;
        padding: 4px 3px;
        align-content: center;
    }

    .loadout-choice span:last-of-type,
    .loadout-slot span:last-child {
        font-size: 0.58rem;
        line-height: 1;
    }

    .loadout-choice small {
        display: none;
    }

    .loadout-choice-glyph,
    .loadout-slot-glyph {
        width: 22px;
        height: 22px;
        border-radius: 6px;
        font-size: 0.78rem;
    }

    .loadout-detail .unit-card {
        gap: 5px;
        padding: 6px;
        overflow: hidden;
    }

    .loadout-detail .unit-card-body {
        gap: 6px;
    }

    .loadout-detail .unit-card-preview {
        flex-basis: 46px;
        height: 46px;
        border-radius: 6px;
    }

    /* Keep mobile previews square; otherwise the desktop narrow-width Paladin rule carries over. */
    .loadout-detail .unit-card-preview.unit-paladin {
        flex-basis: 46px;
    }

    .loadout-detail .unit-card-info {
        gap: 3px;
    }

    .loadout-detail .unit-card-header {
        gap: 5px;
    }

    .loadout-detail .unit-card-name {
        font-size: 0.82rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .loadout-detail .unit-card-cost {
        font-size: 0.62rem;
        white-space: nowrap;
    }

    .loadout-detail .unit-card-stats {
        gap: 1px 6px;
        font-size: 0.68rem;
        min-height: 48px;
    }

    .loadout-detail .unit-card-description {
        padding: 6px 7px;
        font-size: 0.76rem;
        line-height: 1.3;
        max-height: none;
        overflow: hidden;
    }

    .loadout-slots-heading {
        gap: 6px;
    }

    .loadout-slots-heading span {
        font-size: 0.65rem;
    }

    .loadout-slot-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .loadout-actions {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .loadout-actions .primary {
        min-height: 34px;
        padding: 0 10px;
        font-size: 0.84rem;
    }

    .loadout-warning {
        min-height: 0;
        font-size: 0.66rem;
        line-height: 1.1;
    }
}
