:root {
    --cellSize: 64px;
    --gridW: 14;
    --gridH: 10;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: #111;
    color: #eee;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    padding: 10px 12px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
}

.topbar .row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.topbar label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.topbar input,
.topbar select {
    background: #0f0f0f;
    color: #eee;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 6px 8px;
    width: 80px;
}

.topbar button {
    background: #2b2b2b;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.topbar button:hover {
    background: #333;
}

.spacer {
    flex: 1;
}

.status {
    font-size: 13px;
    opacity: .9;
}

.hint {
    font-size: 13px;
    opacity: .9;
}

.toggle {
    user-select: none;
}

.main {
    display: flex;
    min-height: 0;
    flex: 1;
}

.left {
    width: 280px;
    overflow: auto;
    border-right: 1px solid #2a2a2a;
    background: #141414;
    padding: 12px;
}

.center {
    flex: 1;
    overflow: auto;
    padding: 12px;
}

.right {
    width: 420px;
    overflow: auto;
    border-left: 1px solid #2a2a2a;
    background: #141414;
    padding: 12px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(var(--gridW), var(--cellSize));
    grid-template-rows: repeat(var(--gridH), var(--cellSize));
    gap: 1px;
    background: #222;
    padding: 1px;
    width: max-content;
}

.cell {
    width: var(--cellSize);
    height: var(--cellSize);
    position: relative;
    background: #000;
    cursor: pointer;
    outline: 1px solid #000;
}

.cell.selected {
    outline: 2px solid #ff4fd8;
    z-index: 2;
}

.cell img.bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.cell img.it {
    position: absolute;
    width: 50%;
    height: 50%;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
}

.cell img.it.i1 {
    left: 0;
    top: 0;
}

.cell img.it.i2 {
    left: 50%;
    top: 0;
}

.cell img.it.i3 {
    left: 0;
    top: 50%;
}

.cell img.it.i4 {
    left: 50%;
    top: 50%;
}

.panel {
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    background: #111;
}

.panel h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.selectedInfo {
    font-size: 13px;
    opacity: .95;
}

.thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
}

.thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    background: #0d0d0d;
    cursor: pointer;
}

.thumb:hover {
    background: #151515;
}

.thumb.active {
    border-color: #ff4fd8;
    box-shadow: 0 0 0 1px #ff4fd8 inset;
}

.thumb img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    image-rendering: pixelated;
}

.thumb .name {
    font-size: 11px;
    opacity: .9;
    text-align: center;
    word-break: break-word;
}

.enemySettings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.enemySetting {
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    background: #0d0d0d;
}

.enemySetting h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #fff;
}

.commandRow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.commandRow label {
    font-size: 12px;
    min-width: 70px;
    color: #aaa;
}

.commandRow select {
    flex: 1;
    background: #0f0f0f;
    color: #eee;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
}

.commandRow select:hover {
    border-color: #555;
}

.log {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    white-space: pre-wrap;
    color: #cfcfcf;
}

.grid,
.cell {
    user-select: none;
}