html { min-height: 100%; }

.board-builder-body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Pretendard', sans-serif;
    color: #0f172a;
    background:
        radial-gradient(circle at 12% 4%, rgba(196, 181, 253, .34), transparent 26rem),
        radial-gradient(circle at 88% 12%, rgba(125, 211, 252, .26), transparent 27rem),
        linear-gradient(180deg, #f8fafc 0%, #f5f3ff 48%, #f8fafc 100%);
}

.board-builder-page {
    padding: 92px 0 52px;
}

.board-builder-container {
    width: min(100% - 28px, 1320px);
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
}

/* Grid/Flex 자식의 intrinsic width가 모바일 viewport를 밀어내지 않도록 차단 */
.builder-layout,
.board-panel,
.palette-panel,
.board-scroll,
.field-board {
    min-width: 0;
    max-width: 100%;
}

.board-builder-header {
    max-width: 900px;
    margin: 0 auto 22px;
    text-align: center;
}

.eyebrow,
.section-kicker {
    color: #7c3aed;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .14em;
}

.board-builder-header h1 {
    margin: 7px 0 0;
    color: #3b177d;
    font-size: clamp(2rem, 5.5vw, 3.35rem);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.board-builder-header p {
    max-width: 760px;
    margin: 12px auto 0;
    color: #64748b;
    font-size: 15px;
    line-height: 1.7;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.board-meta {
    padding: 7px 10px;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    background: rgba(255, 255, 255, .8);
    color: #5b21b6;
    font-size: 11px;
    font-weight: 850;
    box-shadow: 0 5px 16px rgba(76, 29, 149, .05);
}

.panel-card {
    border: 1px solid rgba(226, 232, 240, .92);
    border-radius: 22px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 18px 48px rgba(76, 29, 149, .08);
    backdrop-filter: blur(18px);
}

.builder-toolbar {
    display: grid;
    grid-template-columns: minmax(270px, 340px) minmax(260px, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
}


.mode-map-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.difficulty-field {
    display: grid;
    gap: 6px;
}

.difficulty-field label {
    padding-left: 2px;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
}

.difficulty-field select {
    width: 100%;
    min-height: 45px;
    padding: 0 34px 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    color: #334155;
    font: inherit;
    font-size: 13px;
    font-weight: 850;
    outline: none;
}

.difficulty-field select:focus,
.unit-search-wrap:focus-within {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, .11);
}

.selected-unit-box {
    min-width: 0;
    min-height: 57px;
    display: flex;
    align-items: center;
    border: 1px solid #ede9fe;
    border-radius: 14px;
    background: linear-gradient(135deg, #faf5ff, #f8fafc);
    overflow: hidden;
}

.selected-unit-placeholder,
.selected-unit-content {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 11px;
}

.selected-icon,
.selected-unit-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 11px;
}

.selected-icon {
    display: grid;
    place-items: center;
    border: 1px dashed #c4b5fd;
    color: #8b5cf6;
    background: #fff;
    font-size: 20px;
}

.selected-unit-avatar {
    object-fit: contain;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid var(--grade-color, #cbd5e1);
    background: #e2e8f0;
}

.selected-unit-placeholder strong,
.selected-unit-content strong,
.selected-unit-placeholder small,
.selected-unit-content small {
    display: block;
}

.selected-unit-placeholder strong,
.selected-unit-content strong {
    color: #334155;
    font-size: 13px;
    line-height: 1.3;
}

.selected-unit-placeholder small,
.selected-unit-content small {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 750;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.tool-btn {
    min-height: 43px;
    padding: 0 13px;
    border-radius: 11px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.tool-btn:hover {
    transform: translateY(-1px);
}

.tool-btn:active {
    transform: translateY(0);
}

.tool-btn.primary {
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    box-shadow: 0 8px 18px rgba(109, 40, 217, .2);
}

.tool-btn.secondary {
    color: #475569;
    border-color: #e2e8f0;
    background: #fff;
}

.builder-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(340px, .75fr);
    align-items: start;
    gap: 16px;
}

.board-panel,
.palette-panel,
.usage-panel {
    padding: 20px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-heading.compact {
    margin-bottom: 14px;
}

.panel-heading h2 {
    margin: 2px 0 0;
    color: #312e81;
    font-size: 21px;
    line-height: 1.2;
    letter-spacing: -.025em;
}

.board-stats {
    display: flex;
    gap: 7px;
}

.board-stats span {
    padding: 7px 9px;
    border-radius: 9px;
    background: #f5f3ff;
    color: #64748b;
    font-size: 10px;
    font-weight: 850;
}

.board-stats strong {
    color: #6d28d9;
    font-size: 12px;
}

.board-help {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 14px 0 12px;
}

.board-help span {
    padding: 5px 7px;
    border-radius: 7px;
    background: #f8fafc;
    color: #94a3b8;
    font-size: 9px;
    font-weight: 800;
}

.board-scroll {
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: thin;
}

.field-board {
    position: relative;
    min-width: 680px;
    aspect-ratio: 824 / 401;
    overflow: hidden;
    line-height: 0;
    background: #22341f;
}

.board-map-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    user-select: none;
    pointer-events: none;
}

.board-grid-overlay {
    position: absolute;
    top: var(--board-top, 8%);
    right: var(--board-right, 6.5%);
    bottom: var(--board-bottom, 20%);
    left: var(--board-left, 6.5%);
    display: grid;
    grid-template-columns: repeat(var(--board-cols, 6), 1fr);
    grid-template-rows: repeat(var(--board-rows, 3), 1fr);
}

.board-cell {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-right: 2px dashed rgba(0, 0, 0, .27);
    border-bottom: 2px dashed rgba(0, 0, 0, .27);
    background: transparent;
    cursor: pointer;
    outline: none;
    transition: background .14s ease, box-shadow .14s ease;
}

.board-cell:nth-child(6n) { border-right: 0; }
.board-cell:nth-last-child(-n + 6) { border-bottom: 0; }

.board-cell:hover,
.board-cell:focus-visible,
.board-cell.drag-over {
    background: rgba(42, 109, 244, .18);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.55);
}

.board-cell.has-unit {
    background: transparent;
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--grade-color) 48%, transparent);
}

.cell-coordinate {
    position: absolute;
    top: 3px;
    left: 4px;
    z-index: 2;
    padding: 1px 4px;
    border-radius: 5px;
    background: rgba(15, 23, 42, .42);
    color: rgba(255,255,255,.86);
    font-size: 8px;
    font-weight: 900;
    line-height: 1.3;
    pointer-events: none;
}

.board-unit-card {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    user-select: none;
}

.board-unit-image {
    width: 78%;
    height: 78%;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
    pointer-events: none;
}

.board-unit-name {
    position: absolute;
    left: 50%;
    bottom: 3px;
    z-index: 3;
    max-width: 88%;
    overflow: hidden;
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(15,23,42,.62);
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1.35;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,.45);
    white-space: nowrap;
    transform: translateX(-50%);
    pointer-events: none;
}

.unit-count-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 3;
    min-width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border: 2px solid rgba(255,255,255,.9);
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 9px;
    font-weight: 950;
    box-shadow: 0 4px 10px rgba(15, 23, 42, .22);
    pointer-events: none;
}

.cell-controls {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 3px;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.cell-control {
    height: 18px;
    border: 0;
    border-radius: 5px;
    background: rgba(248, 250, 252, .9);
    color: #475569;
    font: inherit;
    font-size: 9px;
    font-weight: 950;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.cell-control:hover { background: #ede9fe; color: #6d28d9; }
.cell-control.remove:hover { background: #fff1f2; color: #be123c; }
.cell-control:disabled { opacity: .35; cursor: not-allowed; }

.board-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 11px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
}

.board-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.lane-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.lane-dot.front { background: #fb7185; }
.lane-dot.middle { background: #facc15; }
.lane-dot.back { background: #38bdf8; }

.palette-panel {
    position: sticky;
    top: 84px;
}

.palette-heading {
    margin-bottom: 12px;
}

.selection-clear-btn {
    padding: 7px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    font: inherit;
    font-size: 10px;
    font-weight: 850;
    cursor: pointer;
}

.unit-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 43px;
    padding: 0 11px;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.unit-search-wrap > span {
    color: #94a3b8;
    font-size: 20px;
    transform: rotate(-20deg);
}

.unit-search-wrap input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #334155;
    font: inherit;
    font-size: 13px;
}

.grade-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 11px;
}

.grade-filter {
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    font: inherit;
    font-size: 9px;
    font-weight: 900;
    cursor: pointer;
}

.grade-filter.active {
    border-color: #7c3aed;
    background: #7c3aed;
    color: #fff;
    box-shadow: 0 5px 13px rgba(124, 58, 237, .18);
}

.unit-results-meta {
    margin: 10px 2px 6px;
    color: #94a3b8;
    font-size: 9px;
    font-weight: 800;
    text-align: right;
}

.unit-palette {
    max-height: 610px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 2px 3px 3px 1px;
    scrollbar-width: thin;
}

.unit-option {
    position: relative;
    min-width: 0;
    padding: 7px 5px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    background: #fff;
    text-align: center;
    cursor: pointer;
    outline: 0;
    transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease, background .14s ease;
}

.unit-option:hover,
.unit-option:focus-visible {
    transform: translateY(-1px);
    border-color: var(--grade-color);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
}

.unit-option.selected {
    border-color: var(--grade-color);
    background: color-mix(in srgb, var(--grade-color) 8%, #fff);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--grade-color) 25%, transparent);
}

.unit-option.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--grade-color);
    color: #fff;
    font-size: 9px;
    font-weight: 950;
    box-shadow: 0 1px 5px rgba(15,23,42,.18);
}

.unit-option img {
    width: 52px;
    height: 52px;
    max-width: 100%;
    border-radius: 10px;
    object-fit: contain;
    box-sizing: border-box;
    padding: 3px;
    border: 2px solid var(--grade-color);
    background: #e2e8f0;
    pointer-events: none;
}

.unit-option-name {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    color: #334155;
    font-size: 9px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unit-option-grade {
    display: block;
    margin-top: 1px;
    color: var(--grade-color);
    font-size: 8px;
    font-weight: 900;
}

.palette-empty {
    grid-column: 1 / -1;
    padding: 28px 10px;
    border: 1px dashed #cbd5e1;
    border-radius: 11px;
    color: #94a3b8;
    font-size: 11px;
    text-align: center;
}

.usage-panel {
    margin-top: 16px;
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
}

.usage-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px;
    border: 1px solid #ede9fe;
    border-radius: 12px;
    background: #fafafa;
}

.usage-item b {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 12px;
}

.usage-item strong,
.usage-item small {
    display: block;
}

.usage-item strong {
    color: #334155;
    font-size: 11px;
}

.usage-item small {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 9px;
    line-height: 1.45;
}

.source-note {
    margin: 13px 0 0;
    color: #94a3b8;
    font-size: 9px;
    line-height: 1.6;
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 250;
    max-width: min(90vw, 420px);
    padding: 11px 16px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .94);
    color: #fff;
    font-size: 11px;
    font-weight: 850;
    text-align: center;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .22);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* 등급 색상 */
.grade-normal { --grade-color: #64748b; }
.grade-rare { --grade-color: #3b82f6; }
.grade-hero { --grade-color: #a855f7; }
.grade-legend { --grade-color: #f59e0b; }
.grade-mythic { --grade-color: #ef4444; }
.grade-immortal { --grade-color: #ec4899; }

@media (max-width: 1024px) {
    html,
    body.board-builder-body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    body.board-builder-body.mobile-menu-open .board-builder-page {
        width: 100%;
        max-width: 100%;
    }

    body.board-builder-body.mobile-menu-open .board-builder-container,
    body.board-builder-body.mobile-menu-open .builder-layout,
    body.board-builder-body.mobile-menu-open .board-panel,
    body.board-builder-body.mobile-menu-open .board-scroll,
    body.board-builder-body.mobile-menu-open .field-board {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 1100px) {
    .builder-toolbar {
        grid-template-columns: 130px minmax(240px, 1fr);
    }

    .toolbar-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .toolbar-actions .tool-btn {
        flex: 1 1 160px;
    }

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

    .palette-panel {
        position: static;
    }

    .unit-palette {
        max-height: 440px;
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .board-builder-page {
        padding-top: 78px;
    }

    .board-builder-container {
        width: min(100% - 18px, 1320px);
    }

    .panel-card {
        border-radius: 17px;
    }

    .builder-toolbar {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .toolbar-actions {
        grid-column: auto;
    }

    .mode-map-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .difficulty-field {
        grid-template-columns: 46px minmax(0, 1fr);
        align-items: center;
    }

    .difficulty-field label {
        font-size: 11px;
    }

    .board-panel,
    .palette-panel,
    .usage-panel {
        padding: 14px;
    }

    /* 모바일: 맵 전체를 화면 폭 안에 축소해 6×3 필드를 한눈에 표시 */
    .board-scroll {
        width: 100%;
        overflow-x: hidden;
        padding-bottom: 0;
        border-radius: 10px;
    }

    .field-board {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .board-cell {
        border-right-width: 1px;
        border-bottom-width: 1px;
    }

    .board-unit-image {
        width: 82%;
        height: 82%;
    }

    .cell-coordinate {
        top: 2px;
        left: 2px;
        padding: 0 2px;
        border-radius: 3px;
        font-size: clamp(5px, 1.7vw, 7px);
    }

    .board-unit-name {
        bottom: clamp(11px, 3.5vw, 17px);
        max-width: 94%;
        padding: 1px 3px;
        font-size: clamp(5px, 1.75vw, 7px);
    }

    .unit-count-badge {
        top: 2px;
        right: 2px;
        min-width: clamp(14px, 4vw, 18px);
        height: clamp(14px, 4vw, 18px);
        padding: 0 2px;
        border-width: 1px;
        font-size: clamp(6px, 1.8vw, 8px);
    }

    .cell-controls {
        left: 2px;
        right: 2px;
        bottom: 2px;
        gap: 1px;
    }

    .cell-control {
        height: clamp(11px, 3.3vw, 15px);
        padding: 0;
        border-radius: 3px;
        font-size: clamp(6px, 1.8vw, 8px);
    }

    .unit-palette {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

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

@media (max-width: 480px) {
    .board-panel {
        padding: 10px;
    }

    .board-help {
        margin: 10px 0 8px;
        gap: 4px;
    }

    .board-help span {
        padding: 4px 5px;
        font-size: 8px;
    }

    .board-stats {
        gap: 4px;
    }

    .board-stats span {
        padding: 5px 6px;
    }

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

    .board-builder-header h1 {
        font-size: 1.85rem;
    }

    .board-builder-header p {
        font-size: 13px;
    }

    .toolbar-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar-actions .tool-btn.primary {
        grid-column: 1 / -1;
    }

    .panel-heading h2 {
        font-size: 18px;
    }

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

    .usage-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}

/* 2026-10-09: board workflow, touch editor, history controls */
body.board-builder-body .builder-toolbar{
    grid-template-columns:minmax(260px,350px) minmax(0,1fr);
}
body.board-builder-body .toolbar-actions{
    grid-column:1/-1;justify-content:flex-end;
}
body.board-builder-body .tool-btn:disabled{
    opacity:.46;cursor:not-allowed;transform:none;box-shadow:none;
}
body.board-builder-body .tool-btn.danger{
    color:#b42318;border-color:#fecaca;background:#fff7f7;
}
body.board-builder-body .tool-btn.danger:hover{background:#fee2e2}
body.board-builder-body .board-cell.is-inspected{
    box-shadow:inset 0 0 0 3px #facc15,0 0 0 1px rgba(0,0,0,.45);
    background:rgba(250,204,21,.14);
}
body.board-builder-body .board-cell:focus-visible,
body.board-builder-body .tool-btn:focus-visible,
body.board-builder-body .board-editor-actions button:focus-visible,
body.board-builder-body .board-palette-jump:focus-visible,
body.board-builder-body .board-return-button:focus-visible{
    outline:3px solid #a78bfa;outline-offset:2px;
}
body.board-builder-body .board-panel,
body.board-builder-body .palette-panel{scroll-margin-top:76px}
body.board-builder-body .board-cell-editor{
    display:flex;align-items:center;justify-content:space-between;
    min-height:76px;gap:10px;margin-top:13px;padding:11px 13px;
    border:1px solid #e1d9f4;border-radius:14px;
    background:linear-gradient(135deg,#faf8ff,#fff);
}
body.board-builder-body .board-editor-empty{
    display:flex;flex-direction:column;gap:4px;
}
body.board-builder-body .board-editor-empty strong{
    color:#43347c;font-size:13px;font-weight:900;
}
body.board-builder-body .board-editor-empty span{
    color:#8190a4;font-size:11px;line-height:1.45;
}
body.board-builder-body .board-editor-unit{
    display:flex;align-items:center;gap:10px;min-width:0;
}
body.board-builder-body .board-editor-unit img{
    width:48px;height:48px;flex:none;object-fit:contain;
    border:1px solid #e4e4f0;border-radius:11px;background:#f1effa;
}
body.board-builder-body .board-editor-unit>span{
    display:flex;flex-direction:column;min-width:0;gap:5px;
}
body.board-builder-body .board-editor-unit strong{
    color:#30274e;font-size:13px;font-weight:900;line-height:1.3;
    overflow-wrap:anywhere;
}
body.board-builder-body .board-editor-unit em{
    color:#7334b7;font-style:normal;font-weight:950;
}
body.board-builder-body .board-editor-unit small{color:#8994a5;font-size:11px}
body.board-builder-body .board-editor-actions{
    display:flex;align-items:center;gap:7px;flex-shrink:0;
}
body.board-builder-body .board-editor-actions button{
    min-width:67px;min-height:42px;padding:8px 11px;
    border:1px solid #d7cff0;border-radius:10px;background:#fff;
    font:inherit;font-size:12px;font-weight:900;color:#5c35a5;cursor:pointer;
}
body.board-builder-body .board-editor-actions button:not(:disabled):hover{background:#ede9fe}
body.board-builder-body .board-editor-actions button:disabled{color:#a1a1aa;opacity:.55;cursor:not-allowed}
body.board-builder-body .board-editor-actions .board-editor-remove{color:#b42318;border-color:#fecaca}
body.board-builder-body .board-editor-actions .board-editor-remove:hover{background:#fff1f2}
body.board-builder-body .board-mobile-jump{display:none}
body.board-builder-body .board-return-button{display:none}
body.board-builder-body .board-palette-jump,
body.board-builder-body .board-return-button{
    min-height:43px;padding:9px 16px;border:1px solid #c4b5fd;
    border-radius:11px;background:#f5f3ff;color:#5936a2;
    font:inherit;font-size:12px;font-weight:900;cursor:pointer;
}
body.board-builder-body .board-help{gap:7px}
body.board-builder-body .board-help span{font-size:10px;line-height:1.3}
body.board-builder-body .board-stats span{font-size:11px}
body.board-builder-body .unit-search-wrap input{min-height:44px}
body.board-builder-body .grade-filter{min-height:34px;font-size:11px;padding:4px 11px}
body.board-builder-body .unit-results-meta{font-size:11px}
body.board-builder-body .unit-option-name{
    font-size:11px;white-space:normal;overflow-wrap:anywhere;line-height:1.3;
}
body.board-builder-body .unit-option-grade{font-size:10px;margin-top:3px}
body.board-builder-body .selection-clear-btn{min-height:35px}
@media(max-width:1100px){
    body.board-builder-body .builder-toolbar{grid-template-columns:minmax(220px,350px) minmax(0,1fr)}
    body.board-builder-body .toolbar-actions{grid-column:1/-1}
}
@media(max-width:760px){
    body.board-builder-body .builder-toolbar{grid-template-columns:1fr}
    body.board-builder-body .toolbar-actions{grid-column:auto}
    body.board-builder-body .board-cell-editor{
        flex-direction:column;align-items:stretch;min-height:80px;
        padding:12px;margin-top:12px;gap:11px;
    }
    body.board-builder-body .board-editor-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%}
    body.board-builder-body .board-editor-actions button{width:100%;min-width:0;min-height:44px}
    body.board-builder-body .board-mobile-jump{display:block;margin-top:11px}
    body.board-builder-body .board-palette-jump{width:100%}
    body.board-builder-body .board-return-button{display:block;width:100%;margin-top:12px}
    /* Native board cell controls are too small on 320px maps: the 44px editor takes over. */
    body.board-builder-body .field-board .cell-controls{display:none}
    body.board-builder-body .board-unit-name{bottom:2px}
    body.board-builder-body .board-help .board-desktop-hint{display:none}
    body.board-builder-body .unit-search-wrap input{font-size:16px}
    body.board-builder-body .grade-filter{min-height:38px}
    body.board-builder-body .unit-option{min-height:88px}
    body.board-builder-body .unit-option-name{font-size:11px}
    body.board-builder-body .palette-panel{scroll-margin-top:72px}
}
@media(max-width:480px){
    body.board-builder-body .toolbar-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
    body.board-builder-body .toolbar-actions .tool-btn{width:100%;padding:6px;font-size:11px;min-height:44px}
    body.board-builder-body .toolbar-actions .tool-btn.primary{grid-column:1/-1}
    body.board-builder-body .board-editor-unit strong{font-size:12px}
    body.board-builder-body .board-editor-actions button{font-size:12px}
    body.board-builder-body .board-help span{font-size:9px}
    body.board-builder-body .unit-option{min-height:93px}
}

/* 2026-10-09: safe board rearrangement and touch drag affordances. */
body.board-builder-body .board-move-status {
    display:flex;align-items:center;flex-wrap:wrap;gap:9px;
    padding:10px 12px;margin:0 0 11px;
    border:1px solid #c4b5fd;border-radius:11px;
    background:#f5f3ff;color:#5b21b6;
}
body.board-builder-body .board-move-status[hidden]{display:none!important}
body.board-builder-body .board-move-status>span {
    display:grid;place-items:center;flex:0 0 25px;height:25px;
    border-radius:8px;background:#e9d5ff;font-size:19px;font-weight:900;
}
body.board-builder-body .board-move-status>strong {
    flex:1 1 200px;min-width:0;line-height:1.5;
    font-size:12px;font-weight:850;word-break:keep-all;
}
body.board-builder-body .board-move-status>button {
    flex:0 0 auto;min-height:37px;padding:7px 12px;
    border:1px solid #a78bfa;border-radius:9px;
    color:#5b21b6;background:#fff;
    font:inherit;font-size:12px;font-weight:850;cursor:pointer;
}
body.board-builder-body .board-move-status>button:hover{background:#ede9fe}
body.board-builder-body .board-move-status>button:focus-visible,
body.board-builder-body .board-editor-replace>button:focus-visible{
    outline:3px solid #a78bfa;outline-offset:2px;
}
body.board-builder-body .board-cell.has-unit{cursor:grab}
body.board-builder-body .board-cell.has-unit:active{cursor:grabbing}
body.board-builder-body .board-cell.is-move-source {
    background:rgba(196,181,253,.26)!important;
    box-shadow:inset 0 0 0 4px #c084fc,0 0 0 2px rgba(0,0,0,.42)!important;
}
body.board-builder-body .board-cell.is-move-source::after {
    content:'이동 중';position:absolute;inset:auto 2px 4px auto;
    z-index:8;padding:3px 4px;border-radius:5px;
    background:#6d28d9;color:#fff;font-size:10px;font-weight:900;
    pointer-events:none;line-height:1.1;
}
body.board-builder-body .board-cell.is-move-target:hover,
body.board-builder-body .board-cell.drag-over {
    background:rgba(109,40,217,.21)!important;
    box-shadow:inset 0 0 0 3px #c084fc!important;
}
body.board-builder-body .field-board.is-touch-dragging .board-cell {cursor:grabbing}
body.board-builder-body .board-cell.has-unit .board-unit-card {user-select:none;-webkit-user-select:none}
body.board-builder-body .board-cell-editor .board-editor-replace {
    flex:1 1 100%;display:flex;flex-wrap:wrap;align-items:center;
    justify-content:flex-end;gap:7px;margin-top:7px;
    padding-top:9px;border-top:1px solid #ede9fe;
}
body.board-builder-body .board-editor-replace>span {
    flex:1 1 175px;min-width:0;color:#64748b;
    font-size:11px;line-height:1.5;word-break:keep-all;
}
body.board-builder-body .board-editor-replace>button {
    flex:0 0 auto;min-height:40px;max-width:100%;padding:7px 11px;
    background:#fff;border:1px solid #a78bfa;border-radius:10px;
    color:#5b21b6;font:inherit;font-size:12px;font-weight:850;
    cursor:pointer;overflow-wrap:anywhere;
}
body.board-builder-body .board-editor-replace>button:hover{background:#f5f3ff}
/* The editor may show the source unit, its 3 count actions and explicit replacement. */
body.board-builder-body .board-cell-editor:has(.board-editor-replace){flex-wrap:wrap}
/* Swipe the field to scroll normally; only the small drag grip locks
   native touch gestures while an intentional unit drag is in progress. */
body.board-builder-body .board-drag-handle { display:none; }
body.board-builder-body .board-touch-hint { display:none; }
body.board-builder-body .board-cell.drag-over[data-drop-action] {
    background:rgba(109,40,217,.25)!important;
    box-shadow:inset 0 0 0 3px #a78bfa!important;
}
body.board-builder-body .board-cell.drag-over[data-drop-action]::before {
    content:'';position:absolute;left:50%;top:50%;z-index:10;
    transform:translate(-50%,-50%);pointer-events:none;
    min-width:36px;text-align:center;line-height:1.1;
    padding:6px 7px;border-radius:8px;
    background:#6d28d9;color:#fff;font-size:11px;font-weight:900;
    box-shadow:0 2px 9px rgba(15,23,42,.28);
}
body.board-builder-body .board-cell.drag-over[data-drop-action="move"]::before{content:'이동'}
body.board-builder-body .board-cell.drag-over[data-drop-action="swap"]::before{content:'교환'}
body.board-builder-body .board-cell.drag-over[data-drop-action="place"]::before{content:'배치'}
body.board-builder-body .board-cell.drag-over[data-drop-action="blocked"] {
    background:rgba(220,38,38,.20)!important;
    box-shadow:inset 0 0 0 3px #f87171!important;
}
body.board-builder-body .board-cell.drag-over[data-drop-action="blocked"]::before {
    content:'교체 불가';min-width:55px;background:#b91c1c;
}
body.board-builder-body .board-drag-preview {
    position:fixed;z-index:9999;pointer-events:none;
    display:flex;align-items:center;gap:7px;
    max-width:148px;min-height:45px;padding:6px 8px;
    border:2px solid #a78bfa;border-radius:12px;
    background:rgba(250,245,255,.97);color:#4c1d95;
    box-shadow:0 8px 20px rgba(15,23,42,.25);
    font-size:11px;font-weight:900;line-height:1.3;
}
body.board-builder-body .board-drag-preview[hidden]{display:none!important}
body.board-builder-body .board-drag-preview img {
    width:30px;height:30px;flex:0 0 30px;object-fit:contain;
}
body.board-builder-body .board-drag-preview span{overflow-wrap:anywhere;min-width:0}
@media(pointer:coarse){
    body.board-builder-body .board-touch-hint { display:inline-flex; }
    body.board-builder-body .board-cell.has-unit {touch-action:pan-x pan-y;}
    body.board-builder-body .board-drag-handle {
        position:absolute;left:2px;top:20px;z-index:9;
        display:grid;place-items:center;width:29px;height:30px;
        padding:0;border:0;border-radius:8px;
        isolation:isolate;background:transparent;
        color:#fff;font-size:17px;font-weight:900;line-height:1;
        cursor:grab;touch-action:none;user-select:none;
        -webkit-user-select:none;
    }
    body.board-builder-body .board-drag-handle::before {
        content:'';position:absolute;inset:4px;z-index:-1;
        border:1px solid rgba(255,255,255,.8);border-radius:6px;
        background:rgba(76,29,149,.90);
        box-shadow:0 1px 4px rgba(15,23,42,.22);
        pointer-events:none;
    }
    body.board-builder-body .board-cell.is-move-source .board-drag-handle::before,
    body.board-builder-body .field-board.is-touch-dragging .board-drag-handle::before {
        background:#7c3aed;
    }
}
@media(max-width:760px){
    body.board-builder-body .board-touch-hint { display:inline-flex; }
    body.board-builder-body .board-drag-handle {
        position:absolute;left:2px;top:18px;z-index:9;
        display:grid;place-items:center;width:25px;height:26px;
        border:0;border-radius:7px;
        background:transparent;color:#fff;
        font-size:16px;cursor:grab;touch-action:none;
        user-select:none;-webkit-user-select:none;
    }
}
@media(max-width:760px){
    body.board-builder-body .board-move-status {gap:7px}
    body.board-builder-body .board-move-status>strong {font-size:11px;flex-basis:170px}
    body.board-builder-body .board-editor-replace>button {width:100%;min-height:44px}
    body.board-builder-body .board-cell.is-move-source::after {font-size:8px;padding:2px 3px}
}

/* Pending click/keyboard move: show the exact destination before confirmation. */
body.board-builder-body .board-cell.is-move-preview-target {
    background:rgba(109,40,217,.23)!important;
    box-shadow:inset 0 0 0 3px #8b5cf6,0 0 0 2px rgba(91,33,182,.55)!important;
}
body.board-builder-body .board-cell.is-move-preview-target::after {
    content:'이동';
    position:absolute;
    z-index:11;
    left:50%;
    bottom:4px;
    transform:translateX(-50%);
    pointer-events:none;
    padding:4px 7px;
    border-radius:7px;
    background:#6d28d9;
    color:#fff;
    font-size:10px;
    line-height:1;
    font-weight:900;
    white-space:nowrap;
    box-shadow:0 2px 6px rgba(15,23,42,.2);
}
body.board-builder-body .board-cell.is-move-preview-target[data-preview-action="swap"]::after {
    content:'교환';
}
@media(max-width:760px) {
    body.board-builder-body .board-cell.is-move-preview-target::after {
        font-size:9px;
        padding:3px 5px;
        bottom:2px;
    }
}

/* Hide the browser broken-image X during bounded retry/fallback.
   Parent slot stays mounted; the load event restores the original image. */
body.board-builder-body img.is-image-retrying { opacity:0; }

/* APK 2.0.14 genuine UnitSkin portrait browser — appearance only. */
body.board-builder-body .apk-skin-library{
  margin:12px 0;border:1px solid #ddd6fe;border-radius:12px;background:#fff;
  overflow:hidden;min-width:0
}
body.board-builder-body .apk-skin-library>summary{
  cursor:pointer;padding:12px 13px;color:#532799;font-weight:900;font-size:12px;
  background:linear-gradient(100deg,#faf7ff,#f5f8ff);list-style:none;
  display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap
}
body.board-builder-body .apk-skin-library>summary::-webkit-details-marker{display:none}
body.board-builder-body .apk-skin-library>summary span{
  font-size:10px;font-weight:750;color:#7669a0
}
body.board-builder-body .apk-skin-library>summary:focus-visible{outline:3px solid #8b5cf6;outline-offset:-3px}
body.board-builder-body .apk-skin-library-content{padding:12px}
body.board-builder-body .apk-skin-library-content>label{
  display:grid;gap:7px;color:#55517b;font-size:11px;font-weight:850
}
body.board-builder-body .apk-skin-library-content select{
  width:100%;max-width:100%;height:41px;border:1px solid #c4b5fd;
  border-radius:8px;background:#fff;padding:7px 10px;color:#442681;
  font:inherit;font-size:12px
}
body.board-builder-body .apk-skin-card-list{
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;min-width:0;margin:12px 0
}
body.board-builder-body .apk-skin-tile{
  display:flex;flex-direction:column;align-items:center;min-width:0;
  padding:9px 5px;background:#fcfcff;border:1px solid #e1e4ef;
  border-radius:9px;color:#475569;cursor:pointer;font:inherit;text-align:center
}
body.board-builder-body .apk-skin-tile:hover{
  border-color:#a78bfa;background:#f6f3ff
}
body.board-builder-body .apk-skin-tile.is-active{
  border:2px solid #7c3aed;background:#f5f0ff;padding:8px 4px
}
body.board-builder-body .apk-skin-tile:focus-visible{
  outline:3px solid #8b5cf6;outline-offset:2px
}
body.board-builder-body .apk-skin-tile img{
  width:70px;height:70px;max-width:95%;aspect-ratio:1/1;
  object-fit:contain;background:#f1eff9;border-radius:8px
}
body.board-builder-body .apk-skin-tile b{
  display:block;font-size:10px;font-weight:900;line-height:1.55;
  overflow-wrap:anywhere;margin-top:7px
}
body.board-builder-body .apk-skin-tile small{
  font-size:9px;color:#8a779f;line-height:1.55;overflow-wrap:anywhere
}
body.board-builder-body #apkSkinStatus{
  font-size:11px;font-weight:800;line-height:1.6;color:#6046a5;margin:6px 0
}
body.board-builder-body .apk-skin-library-content>small{
  display:block;color:#798297;font-size:10px;line-height:1.6
}
@media(max-width:385px){
  body.board-builder-body .apk-skin-card-list{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* The unit label sits at the bottom while editing is closed.
   Opening a selected hero swaps its label for the 3 editing actions. */
body.board-builder-body .board-cell.is-move-source:has(.cell-controls) {
    z-index: 16;
}
body.board-builder-body .board-cell.is-move-source:has(.cell-controls) .board-unit-name {
    visibility: hidden;
}
body.board-builder-body .board-cell.is-move-source:has(.cell-controls)::after {
    display: none; /* The "이동 중" marker would cover the quantity controls. */
}
body.board-builder-body .board-cell.is-move-source .cell-controls {
    z-index: 20;
}
@media (max-width: 760px) {
    /* The 6-column mobile board has extremely narrow tiles. Keep the
       controls strictly inside their own tile, so neighbors remain tappable.
       The 44px inspector buttons below provide larger touch targets. */
    body.board-builder-body .field-board .board-cell.is-move-source .cell-controls {
        display: grid;
        left: 0;
        right: 0;
        bottom: 1px;
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1px;
        padding: 1px;
        border-radius: 4px;
        background: rgba(15, 23, 42, .88);
        box-shadow: 0 1px 4px rgba(15, 23, 42, .28);
        transform: none;
    }
    body.board-builder-body .field-board .board-cell.is-move-source .cell-control {
        height: clamp(12px, 3.2vw, 20px);
        min-width: 0;
        border-radius: 2px;
        font-size: clamp(7px, 2.4vw, 12px);
        line-height: 1;
        padding: 0;
    }
}


/* 2026-10-10: palette navigation. Keep the full APK skin gallery open by
   default; make repeated placement and finding used heroes much quicker. */
body.board-builder-body .board-recent {
    padding: 10px 11px 11px;
    margin: 10px 0 5px;
    border: 1px solid #e6e1fa;
    border-radius: 13px;
    background: linear-gradient(120deg, #faf9ff, #f8fbff);
    min-width: 0;
}
body.board-builder-body .board-recent[hidden],
body.board-builder-body .board-mobile-dock[hidden] { display: none !important; }
body.board-builder-body .board-recent-heading {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 9px;
    align-items: center;
    margin-bottom: 8px;
}
body.board-builder-body .board-recent-heading strong {
    font-size: 11px; font-weight: 900; color: #443081;
}
body.board-builder-body .board-recent-heading span {
    font-size: 10px; color: #80768f; font-weight: 650;
}
body.board-builder-body .board-recent-items {
    display: flex;
    gap: 7px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 2px 1px 4px;
}
body.board-builder-body .board-recent-unit {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    max-width: 148px;
    min-height: 44px;
    padding: 5px 9px 5px 5px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #475569;
    font: inherit;
    font-size: 10px;
    font-weight: 850;
    cursor: pointer;
}
body.board-builder-body .board-recent-unit img {
    flex: 0 0 32px;
    width: 32px; height: 32px;
    border-radius: 7px;
    object-fit: contain;
    background: #f1f0fa;
}
body.board-builder-body .board-recent-unit span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.board-builder-body .board-recent-unit.is-active {
    color: #5b21b6;
    border-color: #8b5cf6;
    background: #f6f2ff;
    box-shadow: 0 0 0 1px rgba(139,92,246,.2);
}
body.board-builder-body .palette-quick-filters {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 7px;
    margin: 10px 0 1px;
}
body.board-builder-body .palette-quick-filters button {
    min-height: 39px;
    padding: 8px 11px;
    border: 1px solid #ddd6fe;
    border-radius: 10px;
    font: inherit;
    font-size: 11px;
    font-weight: 850;
    cursor: pointer;
}
body.board-builder-body .placed-filter-btn {
    background: #f9f7ff;
    color: #6841a4;
}
body.board-builder-body .placed-filter-btn span {
    display: inline-grid;
    min-width: 21px;
    min-height: 19px;
    place-items: center;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 8px;
    background: #ede9fe;
    color: #6d28d9;
    font-variant-numeric: tabular-nums;
}
body.board-builder-body .placed-filter-btn.is-active {
    background: #6d28d9;
    border-color: #6d28d9;
    color: white;
}
body.board-builder-body .placed-filter-btn.is-active span {
    background: #fff;
}
body.board-builder-body .reset-palette-btn {
    background: white;
    color: #64748b;
}
body.board-builder-body .reset-palette-btn:disabled {
    opacity: .42;
    cursor: default;
}
body.board-builder-body .palette-empty {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 25px 10px;
    line-height: 1.5;
}
body.board-builder-body .palette-empty strong {
    font-size: 12px;
    color: #64748b;
}
body.board-builder-body .palette-empty span {
    font-size: 10px;
    color: #94a3b8;
}
body.board-builder-body .palette-empty button {
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid #c4b5fd;
    border-radius: 10px;
    background: #f5f3ff;
    color: #5b21b6;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
}
body.board-builder-body .board-recent-unit:focus-visible,
body.board-builder-body .palette-quick-filters button:focus-visible,
body.board-builder-body .palette-empty button:focus-visible,
body.board-builder-body .board-mobile-dock button:focus-visible {
    outline: 3px solid #a78bfa;
    outline-offset: 2px;
}
body.board-builder-body .board-mobile-dock { display: none; }
@media (max-width: 760px) {
    body.board-builder-body .board-builder-page { padding-bottom: 92px; }
    body.board-builder-body .board-mobile-dock:not([hidden]) {
        position: fixed;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: calc(11px + env(safe-area-inset-bottom, 0px));
        z-index: 90;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 9px;
        padding: 9px 10px 9px 13px;
        border: 1px solid #d8ccf3;
        border-radius: 16px;
        background: rgba(255,255,255,.97);
        box-shadow: 0 7px 28px rgba(55,36,103,.19);
        backdrop-filter: blur(14px);
    }
    body.board-builder-body .board-mobile-dock-label {
        flex: 1;
        min-width: 0;
        color: #443081;
        font-size: 11px;
        line-height: 1.4;
        font-weight: 850;
        overflow-wrap: anywhere;
    }
    /* Toast confirmations sit above the fixed board-return action rather
       than covering its hero label or touch target. */
    body.board-builder-body:has(.board-mobile-dock:not([hidden])) .toast {
        bottom: calc(94px + env(safe-area-inset-bottom, 0px));
    }
    body.board-builder-body:has(.board-mobile-dock:not([hidden])) .unit-palette {
        padding-bottom: 75px;
        scroll-padding-bottom: 75px;
    }
    body.board-builder-body .board-mobile-dock button {
        flex: 0 0 auto;
        min-height: 45px;
        padding: 0 14px;
        border: 0;
        border-radius: 10px;
        background: #6d28d9;
        color: white;
        font: inherit;
        font-size: 12px;
        font-weight: 900;
        cursor: pointer;
    }
}
@media (max-width: 385px) {
    body.board-builder-body .board-recent-heading span { display: none; }
    body.board-builder-body .board-mobile-dock-label { font-size: 10px; }
    body.board-builder-body .board-mobile-dock button { padding-inline: 10px; }
}


/* 2026-10-10: desktop workspace tuning.
   Keep the field large, the unit shortlist immediately available and the
   (still-open) APK skin gallery reachable without a very tall sidebar. */
body.board-builder-body .apk-skin-extra {
    margin-top: 7px;
    border-top: 1px solid #ede9fe;
    padding-top: 7px;
    font-size: 11px;
    color: #766796;
}
body.board-builder-body .apk-skin-extra > summary {
    display: list-item;
    padding: 3px 0;
    color: #69529c;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
}
body.board-builder-body .apk-skin-extra > small {
    display: block;
    padding: 5px 2px 3px;
    color: #738092;
    font-size: 10px;
    line-height: 1.65;
}
body.board-builder-body .apk-skin-extra > summary:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}
@media (min-width: 990px) {
    body.board-builder-body .board-builder-container {
        width: min(100% - 40px, 1500px);
    }
    body.board-builder-body .builder-layout {
        grid-template-columns: minmax(0, 1.8fr) minmax(330px, .88fr);
        align-items: start;
        gap: 16px;
    }
    body.board-builder-body .palette-panel {
        display: flex;
        flex-direction: column;
        min-width: 0;
        /* The complete unit list follows the document's natural scroll.
           Only the LEFT field tracks the viewport while editing. */
        max-height: none;
        overflow: visible;
        position: static;
    }
    body.board-builder-body .palette-heading { order: 0; }
    body.board-builder-body .unit-search-wrap { order: 1; flex-shrink: 0; }
    body.board-builder-body .board-recent { order: 2; flex-shrink: 0; }
    body.board-builder-body .grade-filters { order: 3; flex-shrink: 0; }
    body.board-builder-body .palette-quick-filters { order: 4; flex-shrink: 0; }
    body.board-builder-body .unit-results-meta { order: 5; flex-shrink: 0; }
    body.board-builder-body .unit-palette {
        order: 6;
        min-height: 0;
        max-height: none;
        overflow: visible;
        grid-template-columns: repeat(3, minmax(0,1fr));
        flex-shrink: 0;
    }
    body.board-builder-body .apk-skin-library {
        order: 7;
        flex: 0 0 auto;
        margin: 15px 0 0;
    }
    body.board-builder-body .board-return-button { order: 8; }
    body.board-builder-body .apk-skin-card-list {
        display: grid;
        grid-template-columns: repeat(3, minmax(0,1fr));
        overflow: visible;
        padding: 2px 1px 7px;
        gap: 8px;
        margin: 9px 0 6px;
    }
    body.board-builder-body .apk-skin-tile {
        min-width: 0;
        padding: 8px 5px;
    }
    body.board-builder-body .apk-skin-tile.is-active {
        padding: 7px 4px;
    }
    body.board-builder-body .apk-skin-tile img {
        width: 67px;
        height: 67px;
    }
    body.board-builder-body .apk-skin-card-list:has(.apk-skin-tile:nth-child(4)) {
        padding-bottom: 10px;
    }
    body.board-builder-body .board-panel {
        position: sticky;
        top: 75px;
    }
    body.board-builder-body .board-help span {
        font-size: 10px;
    }
    body.board-builder-body .unit-palette .unit-option {
        min-height: 100px;
    }
    body.board-builder-body .unit-palette .unit-option img {
        width: 54px;
        height: 54px;
    }
}
@media (min-width: 1101px) {
    body.board-builder-body .builder-toolbar {
        grid-template-columns: minmax(250px, 305px) minmax(230px, 1fr) minmax(465px, 535px);
        align-items: center;
        gap: 12px;
        padding: 13px 15px;
    }
    body.board-builder-body .toolbar-actions {
        grid-column: auto;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: stretch;
        gap: 7px;
    }
    body.board-builder-body .toolbar-actions .tool-btn {
        width: 100%;
        min-width: 0;
        padding: 0 6px;
        font-size: 11px;
    }
    body.board-builder-body .selected-unit-box {
        min-height: 70px;
        max-width: 100%;
    }
    body.board-builder-body .mode-map-controls {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }
}
@media (min-width: 990px) and (max-width: 1100px) {
    body.board-builder-body .builder-layout {
        grid-template-columns: minmax(0, 1.64fr) minmax(320px,.95fr);
    }
    body.board-builder-body .board-panel,
    body.board-builder-body .palette-panel { padding: 14px; }
    body.board-builder-body .unit-palette {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }
    body.board-builder-body .board-help span { font-size: 9px; }
    body.board-builder-body .board-stats { flex-wrap: wrap; }
}
@media (min-width: 1600px) {
    body.board-builder-body .board-builder-container {
        max-width: 1520px;
    }
    body.board-builder-body .builder-layout {
        grid-template-columns: minmax(0, 1.78fr) minmax(450px,.88fr);
        gap: 20px;
    }
    body.board-builder-body .unit-palette {
        grid-template-columns: repeat(4,minmax(0,1fr));
    }
    body.board-builder-body .apk-skin-tile {
        flex-basis: 111px;
    }
}

/* Fit the complete field inside the left-hand column on 1024px laptops. */
@media (min-width:990px) and (max-width:1100px) {
    body.board-builder-body .board-scroll {
        width: 100%;
        overflow-x: hidden;
    }
    body.board-builder-body .field-board {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}

/* On mobile, selecting a hero is inspection only. An explicit, comfortable
   move/transfer control separates moving a hero from tapping a blank cell
   to dismiss the field selection. Keep quantity controls on the first row. */
@media (max-width: 760px) {
    body.board-builder-body .board-editor-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    body.board-builder-body .board-editor-actions .board-editor-cancel {
        grid-column: 1 / -1;
        min-height: 44px;
        background: #f4f4fb;
        color: #4b5563;
        border-color: #d4d4e3;
    }
    body.board-builder-body .board-editor-actions .board-editor-remove {
        grid-column: 1 / -1;
        min-height: 44px;
    }
    body.board-builder-body .board-editor-actions .board-editor-move {
        grid-column: 1 / -1;
        min-height: 44px;
        background: #ede9fe;
        color: #5b21b6;
        border-color: #c4b5fd;
    }
}


/* Desktop: let the skin library sit immediately below the field while the
   full unit palette stays to the right. One DOM instance is moved on resize. */
body.board-builder-body .board-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: stretch;
}
body.board-builder-body .board-column > .board-panel { min-width: 0; }
body.board-builder-body .board-skin-slot:empty { display: none; }
@media (min-width: 990px) {
    /* Stick the field and skin selector together. A responsive top offset
       lets an over-height stack scroll naturally instead of hiding the skins. */
    body.board-builder-body .board-column {
        position: sticky;
        top: var(--board-column-sticky-top, 75px);
        align-self: start;
    }
    body.board-builder-body .board-column > .board-panel {
        position: static;
        align-self: stretch;
    }
    body.board-builder-body .board-skin-slot {
        min-width: 0;
    }
    body.board-builder-body .board-skin-slot > .apk-skin-library {
        margin: 0;
        box-shadow: 0 5px 22px rgba(51, 29, 99, .07);
    }
    body.board-builder-body .board-skin-slot .apk-skin-card-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
