/* V4-only accessibility polish; semantic faction colors and uploaded portraits stay intact. */
body.kama-v4 .directory-table .header-cell,
body.kama-v4 table thead th {
    background: #e4eae4 !important;
    background-image: none !important;
    color: #243448 !important;
    border-color: #b8c5bd !important;
    vertical-align: middle;
}
body.kama-v4 [data-is-npc="true"] > td:nth-child(2) > span,
body.kama-v4 [data-is-npc="true"] .name-field > span:not(.field-label),
body.kama-v4 [style*="color: cyan"],
body.kama-v4 [style*="color: deepskyblue"],
body.kama-v4 [style*="color: skyblue"],
body.kama-v4 [style*="color: mediumaquamarine"],
body.kama-v4 [style*="color: darkcyan"],
body.kama-v4 .leadership-bonus {
    color: #12616b !important;
}
/* Match only the server-table footer's legacy legend and its own tool panel. */
body.kama-v4 .gateway-layout div.bg-zinc-900:has(> .profile-table-frame) > [class~="bg-zinc-800/50"] > .grid,
body.kama-v4 .gateway-layout div.bg-zinc-900:has(> div > .open-suggestion-link) {
    display: none !important;
}
body.kama-v4 .gateway-layout div.bg-zinc-900:has(> .profile-table-frame) > [class~="bg-zinc-800/50"]::after {
    content: '카마에르 V4 · 영웅을 생성하거나 기존 영웅으로 대륙에 입장하세요.';
    display: block;
    margin-top: 8px;
    color: #405264;
    line-height: 1.6;
}
/* V4's culture/family names remain readable without widening dense directories. */
body.kama-v4 .general-table tbody > tr > td:nth-child(2),
body.kama-v4 .npc-table tbody > tr > td:first-child {
    max-width: 150px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: keep-all;
    line-height: 1.45;
}
body.kama-v4 .general-card-field.name-field,
body.kama-v4 .general-card-field.name-field > span:not(.field-label) {
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
}
/* The original eight-cell strip had an 18px fixed height and a compound wood background. */
body.kama-v4 .main-page .legacy-game-info {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    height: auto !important;
    min-height: 50px !important;
    background: #e9eee7 !important;
    color: #243448 !important;
    border: 1px solid #bac8b9 !important;
    border-radius: 12px;
    font-size: 16px !important;
    line-height: 1.6 !important;
    overflow: visible !important;
}
body.kama-v4 .main-page .legacy-game-info > span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px !important;
    background: transparent !important;
    color: #243448 !important;
    border-color: #c8d2c5 !important;
    white-space: normal !important;
    overflow: visible !important;
}
body.kama-v4 .legacy-game-info .main-autorun-detail {
    background: #243c35 !important;
    color: #fffefa !important;
}
/* Territory keys and map controls participate in normal layout height. */
body.kama-v4 .main-page .layout-desktop {
    grid-template-rows: auto minmax(125px, auto) auto !important;
}
body.kama-v4 .main-page :is(.layout-desktop,.layout-mobile) [data-main-target="map"] {
    height: auto !important;
    min-height: 0 !important;
    align-self: start;
}
body.kama-v4 .main-page [data-main-target="map"] :is(.panel-body,.map-viewer,.map-body) {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
}
/* City statistics: explicit contrasting surfaces, independent of legacy colors. */
body.kama-v4 [data-city-basic-card] .city-panel__head {
    background: #dce7df !important;
    color: #203b30 !important;
    font-weight: 700;
    font-size: 15px;
    padding: 8px 4px;
}
body.kama-v4 [data-city-basic-card] .city-panel__body {
    background: #fffefa !important;
    color: #243448;
    font-size: 15px;
    min-height: 34px;
}
body.kama-v4 [data-city-basic-card] :is(.city-title,.city-nation) {
    background: #e5ece5;
    color: #203b30;
    padding: 6px 10px;
    font-size: 16px;
}

/* V4 handheld layout. Keep the map's own coordinate/zoom system unchanged. */
body.kama-v4 {
    --sammo-font-size-normal: 16px;
    --sammo-font-size-small: 15px;
    --sammo-font-size-emphasis: 16px;
    --sammo-font-size-title: 20px;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}
body.kama-v4, body.kama-v4 #app { min-width: 0 !important; }
body.kama-v4 :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    font-size: 16px !important;
    line-height: 1.5;
}
body.kama-v4 :is(button, .legacy-button, .main-menu-link, .quick-link, .kama-nav a, .back-link, .simulator-link) {
    box-sizing: border-box;
    min-height: 44px;
}
body.kama-v4 .legacy-button--fixed-height { --legacy-button-height: 44px; }
body.kama-v4 :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select) { min-height: 44px; }
body.kama-v4 textarea { min-height: 104px; }
body.kama-v4 :is(.profile-table-frame, .map-preview-panel, .panel-card, .panel-body) { min-width: 0; }
body.kama-v4 .v4-map-zoom-controls button { min-width: 44px; min-height: 44px; font-size: 16px; }
body.kama-v4 .v4-territory-actions { flex-wrap: wrap; }
body.kama-v4 .v4-territory-actions :is(button, a) { min-height: 44px; align-content: center; }

/* Desktop map and orders use available content width, including the chat sidebar. */
body.kama-v4 .main-page .layout-desktop {
    grid-template-columns: minmax(0, 1fr) minmax(360px, .6fr);
    gap: 16px !important;
}
body.kama-v4 .layout-desktop > [data-main-target='map'] { grid-column: 1; grid-row: 1; }
body.kama-v4 .layout-desktop > [data-main-target='commands'] { grid-column: 2; grid-row: 1 / 3; width: auto; min-width: 0; margin-left: 0; }
body.kama-v4 .layout-desktop > [data-main-target='city'] { grid-column: 1; grid-row: 2; }
body.kama-v4 .layout-desktop > [data-main-target='nation'] { grid-column: 1; grid-row: 3; }
body.kama-v4 .layout-desktop > [data-main-target='general'] { grid-column: 2; grid-row: 3; }
body.kama-v4 .layout-desktop > :is([data-main-target='commands'], [data-main-target='general']) .panel-body { padding: 12px !important; }
body.kama-v4 .reserved-command-editor :is(button, summary) { word-break: keep-all; overflow-wrap: normal; line-height: 1.5; }
body.kama-v4 .reserved-command-editor .bottom-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.kama-v4 .reserved-command-editor .bottom-shift-menu { flex-basis: 44px; }
body.kama-v4 .reserved-command-editor .bottom-shift-menu > summary { min-height: 44px; }
body.kama-v4 .reserved-command-editor .identity { height: auto; min-height: 44px; flex-wrap: wrap; }
body.kama-v4 .reserved-command-editor .queue-grid { grid-template-columns: 88px 52px minmax(0, 1fr) 44px; }
body.kama-v4 .reserved-command-editor .queue-grid.advanced { grid-template-columns: 44px 88px 52px minmax(0, 1fr); }
body.kama-v4 .reserved-command-editor.compact .queue-grid { grid-template-columns: 52px minmax(0, 1fr) 44px; }
body.kama-v4 .reserved-command-editor.compact .queue-grid.advanced { grid-template-columns: 52px 44px minmax(0, 1fr); }
body.kama-v4 .reserved-command-editor :is(.date-column, .time-column, .action-column, .edit-column, .index-column) { grid-auto-rows: 48px !important; }
body.kama-v4 .reserved-command-editor :is(.date-column > div, .time-column > div, .action-column > div) { line-height: 1.5; }
body.kama-v4 [data-general-basic-card] .general-basic-grid { grid-template-rows: repeat(9, minmax(32px, auto)); }
body.kama-v4 [data-general-basic-card] .general-basic-grid > * { line-height: 1.5; }
body.kama-v4 [data-general-basic-card] .general-title { white-space: normal; overflow-wrap: anywhere; }
body.kama-v4 .main-page :is(.nation-card, .nation-grid) { height: auto; }
body.kama-v4 .main-page .nation-grid { grid-template-rows: repeat(10, minmax(32px, auto)); }
body.kama-v4 .main-page .nation-grid > * { line-height: 1.5; align-content: center; }
/* Category selection is a viewport dialog, independent of the narrow orders card. */
body.kama-v4 .reserved-command-editor.picker-open { z-index: 1200; }
body.kama-v4 [data-main-target='commands']:has(.picker-open),
body.kama-v4 [data-main-target='commands']:has(.picker-open) > .panel-body { overflow: visible; }
body.kama-v4 .reserved-command-editor .command-picker:not(.argument-overlay) {
    position: fixed !important;
    z-index: 1200;
    inset: 16px !important;
    box-sizing: border-box;
    width: min(960px, calc(100vw - 32px)) !important;
    height: fit-content !important;
    max-height: calc(100dvh - 32px) !important;
    margin: auto;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding: 12px;
    box-shadow: 0 0 0 100vmax #172b2270, 0 12px 40px #172b2240;
}
body.kama-v4 .command-picker:not(.argument-overlay) > header { position: sticky; top: -12px; z-index: 2; min-height: 52px; padding: 4px; background: #fffefa; }
body.kama-v4 .command-picker:not(.argument-overlay) > header button { min-width: 44px; min-height: 44px; }
@media (max-width: 600px) {
    body.kama-v4 .kama-nav { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body.kama-v4 .kama-nav a { text-align: center; }
    /* GeneralDirectoryTable already supplies mobile cards; preserve its table toggle. */
    body.kama-v4 .directory-page .general-table { display: none !important; }
    body.kama-v4 .general-card-list .general-card { grid-template-columns: 66px repeat(2, minmax(0, 1fr)); }
    body.kama-v4 .general-card-list .general-card-field { min-height: 44px; line-height: 1.6; font-size: 15px; }
}
body.kama-v4 .directory-page .general-table.layout-card { display: none !important; }
@media (max-width: 480px) {
    body.kama-v4 #main_form { grid-template-columns: minmax(0, 1fr) !important; }
    body.kama-v4 #main_form > * { grid-column: 1 !important; min-width: 0; max-width: 100%; }
    body.kama-v4 #main_form > label { text-align: left !important; }
    body.kama-v4 #main_form :is(button, input[type=submit], .legacy-button) { width: 100%; min-height: 44px; }
}

@media (max-width: 939.98px) {
    /* These are the actual page roots in the V4 Vue views, including legacy pages. */
    body.kama-v4 :is(.main-page, .ref-shell, .city-page, .directory-page, .legacy-info-page,
        .nation-cities-page, .general-page, .secret-page, .legacy-board-page, .chief-page,
        .global-page, .yearbook-page, .dynasty-page, .legacy-ranking-page, .legacy-hall-page,
        .npc-list-page, .traffic-page, .legacy-troop-page, .legacy-office, .page-finance,
        .diplomacy-view, .affairs-view, .scout-view, .select-pool-page, .past-plays-page,
        .battle-simulator, .npc-page, .audit-page) {
        box-sizing: border-box;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto;
        margin-inline: auto;
        font-size: 16px;
        line-height: 1.6;
    }
    body.kama-v4 :is(.main-page, .layout-mobile, .record-zone, .join-flow) { gap: 16px !important; }
    body.kama-v4 .main-page { padding: 8px !important; }
    body.kama-v4 :is(.mobile-panel, .record-zone-mobile, .mobile-message-panel) {
        box-sizing: border-box;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        margin-inline: 0;
    }
    body.kama-v4 .layout-mobile [data-main-target] { min-width: 0; min-height: 0; }
    body.kama-v4 .layout-mobile [data-main-target='commands'] { min-height: 0; }
    body.kama-v4 .layout-mobile [data-main-target='world-history'] { height: auto; overflow: visible; }
    body.kama-v4 .layout-mobile .record-zone-mobile { margin-top: 0; }
    body.kama-v4 .mobile-message-panel { margin-bottom: 0; }
    body.kama-v4 .panel-body { padding: 12px !important; }
    body.kama-v4 [data-main-target='map'] .panel-body { padding: 0 !important; }
    body.kama-v4 .main-page .legacy-game-info { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    body.kama-v4 .main-page .legacy-game-info > span { padding: 8px !important; overflow-wrap: anywhere; }
    body.kama-v4 :is(.record-line, .log-line, .record-list .small_war_log) {
        height: auto !important;
        min-height: 26px;
        overflow: visible;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.65 !important;
        font-size: 15px !important;
    }
    body.kama-v4 .record-zone { grid-template-columns: minmax(0, 1fr); }

    /* Phone navigation fills the available width; popup position is viewport based. */
    body.kama-v4 .main-global-menu { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    body.kama-v4 .main-nation-menu { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important; }
    body.kama-v4 :is(.main-menu-link, .main-menu-button) { white-space: normal; overflow-wrap: anywhere; }
    body.kama-v4 .main-menu-split { grid-template-columns: minmax(0, 1fr) 44px; }
    body.kama-v4 .main-menu-split__toggle { width: 44px; min-width: 44px; }
    body.kama-v4 .main-menu-popup__list { min-width: min(180px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
    body.kama-v4 .main-global-menu > :nth-child(2n) .main-menu-popup__list { left: auto; right: 0; }
    body.kama-v4 .main-mobile-bottom {
        left: 0;
        width: 100%;
        height: auto;
        min-height: 60px;
        grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(104px, 1.15fr);
        transform: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
    body.kama-v4 .main-mobile-bottom :is(.bottom-item, .bottom-refresh-controls) { min-width: 0; width: auto; height: auto; }
    body.kama-v4 .main-mobile-bottom .bottom-trigger {
        width: 100%;
        min-width: 0;
        height: 60px;
        padding: 4px 2px !important;
        font-size: 15px;
        line-height: 1.4;
        white-space: normal;
    }
    body.kama-v4 .bottom-refresh-controls { grid-template-columns: minmax(0, 1fr) 44px; }
    body.kama-v4 .main-mobile-bottom .auto-refresh-trigger { font-size: 14px; }
    body.kama-v4 .dropup-caret { margin-left: 2px; }
    body.kama-v4 .main-mobile-bottom .bottom-popup {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: calc(64px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        columns: 2;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: calc(100dvh - 88px - env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    body.kama-v4 .bottom-popup li { min-width: 0; }
    body.kama-v4 .bottom-popup :is(.main-menu-link, .quick-link) { min-height: 44px; padding: 8px !important; white-space: normal; }
    body.kama-v4 .main-mobile-bottom-spacer { height: calc(80px + env(safe-area-inset-bottom)); }
    body.kama-v4 .survey-notice { bottom: calc(76px + env(safe-area-inset-bottom)); }

    /* The compact queue originally used 109px + 391px columns. */
    body.kama-v4 .reserved-command-editor { font-size: 15px; line-height: 1.5; }
    body.kama-v4 .mobile.compact .editor-layout { display: flex; flex-direction: column; min-height: 0; }
    body.kama-v4 .mobile.compact .control-pad { order: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
    body.kama-v4 .mobile.compact .queue-area { order: 1; padding-top: 8px; }
    body.kama-v4 .mobile.compact .advanced-actions { order: 2; }
    body.kama-v4 .mobile.compact .queue-grid { grid-template-columns: 64px minmax(0, 1fr) 44px; }
    body.kama-v4 .mobile.compact .queue-grid.advanced { grid-template-columns: 64px 44px minmax(0, 1fr); }
    /* Columns are separate grids; equal row heights keep dates/actions aligned. */
    body.kama-v4 .reserved-command-editor :is(.date-column, .time-column, .action-column, .edit-column, .index-column) { grid-auto-rows: 64px !important; }
    body.kama-v4 .reserved-command-editor :is(.action-column > div, .date-column > div, .time-column > div) {
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.5;
        padding: 4px;
    }
    body.kama-v4 .reserved-command-editor :is(.control-pad > .legacy-menu > summary, .advanced-actions .legacy-menu > summary) { min-height: 44px; }
    body.kama-v4 .mobile.compact .command-picker:not(.argument-overlay) { left: 0; right: 0; top: 0; width: 100%; height: auto; max-height: 80dvh; overflow-y: auto; }
    body.kama-v4 :is(.category-btn, .command-item) { min-height: 48px !important; font-size: 15px !important; }
    body.kama-v4 :is(.command-duration, .command-cost) { font-size: 15px; line-height: 1.5; }
    body.kama-v4 .command-picker.argument-overlay { --argument-overlay-header-height: 100px; }
    body.kama-v4 .command-picker.argument-overlay > .argument-overlay-bar { height: auto; min-height: 100px; grid-template-rows: auto 44px; }
    body.kama-v4 .command-picker.argument-overlay > .argument-overlay-bar > button { height: 44px; }
    body.kama-v4 .command-picker.argument-overlay .picker-actions { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    body.kama-v4 .argument-row { grid-template-columns: minmax(76px, .35fr) minmax(0, 1fr); }
    body.kama-v4 .number-options { grid-template-columns: minmax(0, 1fr); }
    body.kama-v4 .dex-conversion-preview { overflow-x: auto; }
    body.kama-v4 .dex-conversion-row { width: max-content; min-width: 100%; }

    /* A single label/value pair per row preserves every general field on phones. */
    body.kama-v4 [data-general-basic-card] .general-basic-grid {
        grid-template-columns: minmax(68px, .32fr) minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: minmax(40px, auto);
    }
    body.kama-v4 [data-general-basic-card] .general-basic-grid > * {
        grid-column: auto;
        grid-row: auto;
        padding: 6px 8px;
        font-size: 15px;
        line-height: 1.6;
        white-space: normal;
        overflow-wrap: anywhere;
        overflow: visible;
    }
    body.kama-v4 [data-general-basic-card] .general-basic-grid > :is(.general-image, .general-title, .experience-bar) { grid-column: 1 / -1; }
    body.kama-v4 [data-general-basic-card] .general-basic-grid > .general-image { justify-self: center; padding: 0; }
    body.kama-v4 [data-general-basic-card] .general-basic-grid > .general-title { font-size: 16px; }
    body.kama-v4 .main-page :is(.nation-card, .nation-grid) { height: auto; }
    body.kama-v4 .main-page .nation-grid {
        grid-template-columns: minmax(54px, .35fr) minmax(0, 1fr) minmax(54px, .35fr) minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-rows: minmax(40px, auto);
    }
    body.kama-v4 .main-page .nation-grid > * { padding: 6px 3px; white-space: normal; overflow-wrap: anywhere; line-height: 1.6; font-size: 15px; }
    body.kama-v4 [data-city-basic-card] .city-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body.kama-v4 [data-city-basic-card] .city-panel--population { grid-column: 1 / -1; }
    body.kama-v4 [data-city-basic-card] .city-panel { grid-template-columns: minmax(46px, .42fr) minmax(0, 1fr); }
    body.kama-v4 [data-city-basic-card] :is(.city-progress__text, .city-officer__name, .city-title, .city-nation) { white-space: normal; overflow: visible; overflow-wrap: anywhere; line-height: 1.6; font-size: 15px !important; }

    /* Dense data stays at reading size in a local horizontal scroll region. */
    body.kama-v4 :is(.city-page, .nation-cities-page, .general-page, .secret-page, .legacy-info-page,
        .diplomacy-view, .dynasty-page, .legacy-ranking-page, .legacy-hall-page,
        .npc-list-page, .traffic-page, .legacy-troop-page) { overflow-x: auto; }
    body.kama-v4 :is(.directory-table, .legacy-table, .legacy-layout-table, .layout) { max-width: 100%; }
    body.kama-v4 :is(.directory-table, .general-table, .npc-table, .city-user-table,
        .legacy-info-page .info-table, .secret-page .list, .secret-page .summary,
        .nation-cities-page .city) {
        display: block;
        box-sizing: border-box;
        width: 100% !important;
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    body.kama-v4 .directory-table:not(.title-table):not(.footer-table) > :is(thead, tbody) { min-width: 700px; }
    body.kama-v4 .directory-table:not(.title-table):not(.footer-table) { table-layout: auto; }
    body.kama-v4 :is(.directory-table, .city-user-table, .secret-page .list, .legacy-info-page .info-table) :is(td, th) { padding: 6px; font-size: 15px; line-height: 1.6; }
    body.kama-v4 .city-page .selector select { min-width: 0; width: calc(100% - 16px); height: auto; }
    body.kama-v4 .city-page .generals { width: 100%; }
    body.kama-v4 .city-page .generals tbody tr {
        grid-template-columns: 64px repeat(4, minmax(0, 1fr));
        grid-template-areas: 'icon name name name name' 'icon lead str intel intel' 'office office office defence defence' 'type type crew train atmos' 'turns turns turns turns turns';
    }
    body.kama-v4 .city-page .generals tbody td { padding: 5px; line-height: 1.6; }
    body.kama-v4 .city-page .generals td.turns { border-top: 1px solid #bac8b9; border-left: 0; }
    body.kama-v4 .city-page .stats tr { grid-template-columns: 48px minmax(0, 1fr); }
    body.kama-v4 .city-page .stats tr:first-child { grid-template-columns: minmax(0, 1fr); }
    body.kama-v4 .city-page .stats :is(td, th) { padding: 6px; }
    body.kama-v4 .legacy-board-page :is(.top-back-bar, .article-submit-row),
    body.kama-v4 .legacy-troop-page .topBackBar { height: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-inline: 0; }
    body.kama-v4 .legacy-board-page .top-back-bar h1,
    body.kama-v4 .legacy-troop-page .topBackBar h2 { grid-column: 1 / -1; grid-row: 1; }
    body.kama-v4 .general-page .top-bar { height: auto; min-height: 100px; flex-wrap: wrap; gap: 6px; }
    body.kama-v4 .general-page :is(.left-actions, .right-actions) { position: static; height: auto; flex-wrap: wrap; }
    body.kama-v4 .ref-shell__topbar { flex-direction: column; }
    body.kama-v4 .ref-shell__actions { position: static; flex-wrap: wrap; }
    body.kama-v4 .join-page { box-sizing: border-box; padding: 12px; }
    body.kama-v4 .join-tabs { flex-wrap: wrap; }
    body.kama-v4 .join-page .nation-card { grid-template-columns: minmax(0, 1fr); }
    body.kama-v4 .join-page :is(.identity-grid, .stat-grid) { grid-template-columns: minmax(0, 1fr); }

    body.kama-v4 .gateway-layout { min-width: 0; }
    body.kama-v4 .kama-header-inner { flex-wrap: wrap; gap: 8px; padding: 12px; }
    body.kama-v4 .kama-nav { flex-wrap: wrap; gap: 4px 12px; }
    body.kama-v4 .kama-nav a { align-content: center; }
    body.kama-v4 .gateway-layout :is(.text-xs, .text-sm, small, .v4-account-note) { font-size: 15px !important; line-height: 1.6 !important; }
    body.kama-v4 .account-navigation-button { font-size: 15px !important; white-space: normal; height: auto; }
    body.kama-v4 .profile-table tbody tr { grid-template-columns: 72px minmax(0, 1fr); grid-template-areas: 'server info' 'portrait general' 'action action'; }
    body.kama-v4 .profile-action-cell :is(button, a) { width: 100%; font-size: 16px; }
    body.kama-v4 #signup-form { padding: 12px; }
    body.kama-v4 #signup-container :is(.form-row, .agreement-row) { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    body.kama-v4 #signup-container :is(.form-row > label, .agreement-row > span) { text-align: left; padding-top: 0; }
    body.kama-v4 #signup-container :is(.verification-notice, .action-row) { margin-left: 0; }
    body.kama-v4 #signup-container .action-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body.kama-v4 .map-preview-panel { padding: 4px; }
    body.kama-v4 :is(.map-title, .map-preview-date) { min-width: 0 !important; font-size: 15px; height: auto; line-height: 1.6; }
    body.kama-v4 .v4-map-pan-hint { font-size: 15px; line-height: 1.5; }
    body.kama-v4 .v4-territory-summary { padding: 10px; }
}

/* Readable command choices in both phone and desktop dialogs. */
body.kama-v4 .command-picker :is(.category-btn,.command-item){background:#edf2ea!important;background-image:none!important;color:#243c35!important;border:1px solid #b9c8b9!important;min-height:48px;padding:8px!important;white-space:normal;line-height:1.5!important}
body.kama-v4 .command-picker .category-btn.active{background:#24583e!important;color:#fff!important}
body.kama-v4 .command-picker :is(.command-cost,.command-duration){color:#4d5d50!important;line-height:1.5!important;font-size:14px!important;white-space:normal}
body.kama-v4 .command-picker .command-item.blocked .command-name{color:#963b31!important}
body.kama-v4:has(.picker-open) #kamael-live-chat{z-index:1000!important}

body.kama-v4 .command-picker.argument-overlay .argument-overlay-bar{background:#e8eee6;color:#243c35;border-color:#aabcae}
body.kama-v4 .command-picker.argument-overlay .argument-overlay-bar .overlay-title small{color:#4d5d50}
@media(max-width:600px){
 body.kama-v4 .command-picker.argument-overlay{--argument-overlay-header-height:140px}
 body.kama-v4 .command-picker.argument-overlay .argument-overlay-bar{grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;height:auto!important;min-height:110px;padding:8px}
 body.kama-v4 .argument-overlay-bar .overlay-title{grid-column:1 / -1!important;grid-row:1;white-space:normal;flex-wrap:wrap;font-size:18px;line-height:1.5}
 body.kama-v4 .argument-overlay-bar>button{grid-row:2;min-width:0!important;min-height:52px;height:auto!important;padding:4px!important;font-size:14px;white-space:normal!important}
 body.kama-v4 .argument-overlay-bar>.overlay-search{grid-column:3!important}
 body.kama-v4 .argument-overlay-bar>.overlay-cancel{grid-column:1}
 body.kama-v4 .argument-overlay-bar>.overlay-reselect{grid-column:2}
}

/* Argument forms are teleported to body, above the raised queue editor. */
body.kama-v4 > .command-picker.argument-overlay {
    z-index: 1300;
    isolation: isolate;
    background: #edf0e9;
}

/* Gateway history uses legacy inline markers independently of the game formatter. */
body.kama-v4 .status-history [style*="color: white;"] { color: #243448 !important; }
body.kama-v4 .status-history [style*="color: yellow;"] { color: #795600 !important; }
body.kama-v4 .status-history [style*="color: magenta;"] { color: #8b287c !important; }
body.kama-v4 .status-history [style*="color: limegreen;"] { color: #256333 !important; }
body.kama-v4 .status-history [style*="color: cyan;"] { color: #086477 !important; }
body.kama-v4 .status-history [style*="color: skyblue;"] { color: #235f86 !important; }
body.kama-v4 .status-history [style*="color: orangered;"] { color: #a83d19 !important; }
body.kama-v4 .status-history [style*="color: red;"] { color: #a52c28 !important; }
body.kama-v4 .status-history [style*="color: blue;"] { color: #254c92 !important; }
body.kama-v4 .status-history [style*="color: green;"] { color: #256333 !important; }

