* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: #1a1a2e;
    color: #fff;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

h1 { color: #e94560; font-size: 24px; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    color: white;
    font-size: 14px;
}

.btn-primary { background: #3498db; }
.btn-success { background: #27ae60; }
.btn-warning { background: #e67e22; }
.btn-danger { background: #e74c3c; }
.btn-info { background: #9b59b6; }
.btn-reskin { background: #f39c12; }

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.stats-bar {
    background: #16213e;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stat-item { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: #aaa; }
.stat-value { font-size: 28px; font-weight: bold; color: #e94560; }

.main-container {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.left-panel {
    width: 500px;
    background: #16213e;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 15px 15px 0 15px;
    flex-shrink: 0;
}

.tab {
    padding: 12px 15px;
    background: #0f3460;
    border: none;
    color: #aaa;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s;
    flex: 1;
}

.tab:hover { background: #1a4a7a; color: white; }
.tab.active { background: #e94560; color: white; }

.tab-content { flex: 1; overflow-y: auto; padding: 15px; min-height: 0; }
.tab-pane { display: none; height: 100%; }
.tab-pane.active { display: block; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-content: start;
}

.level-card {
    background: #0f3460;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.level-card:hover { transform: scale(1.02); background: #1a4a7a; }
.level-card.selected { border-color: #e94560; box-shadow: 0 0 15px rgba(233, 69, 96, 0.5); }
.level-card.duplicate { border-color: #f1c40f; }
.level-card.reskin-selected { border-color: #f39c12; box-shadow: 0 0 15px rgba(243, 156, 18, 0.5); }

.duplicate-badge {
    position: absolute; top: 5px; right: 5px;
    background: #f1c40f; color: #000; font-size: 10px;
    font-weight: bold; padding: 2px 6px; border-radius: 10px; z-index: 10;
}

.reskin-badge {
    position: absolute; top: 5px; left: 5px;
    background: #f39c12; color: #000; font-size: 10px;
    font-weight: bold; padding: 2px 6px; border-radius: 10px; z-index: 10;
}

.level-preview {
    display: grid; gap: 1px; background: #333;
    padding: 4px; border-radius: 4px; margin-bottom: 8px; width: 100%;
}

.preview-cell { aspect-ratio: 1; background: #4a69bd; }
.preview-cell.empty { background: #1a1a2e; }

.level-info { font-size: 10px; color: #aaa; text-align: center; line-height: 1.3; }

.groups-list { display: flex; flex-direction: column; gap: 12px; }

.group-card {
    background: #0f3460; border-radius: 8px; padding: 12px;
    cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
}

.group-card:hover { background: #1a4a7a; }
.group-card.expanded { border-color: #27ae60; }

.group-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 8px;
}

.group-title { font-weight: bold; color: #f1c40f; font-size: 14px; }
.group-count { background: #e94560; padding: 3px 10px; border-radius: 15px; font-size: 12px; font-weight: bold; }

.group-preview {
    display: grid; gap: 1px; background: #333; padding: 4px;
    border-radius: 4px; margin-bottom: 8px; width: fit-content; max-width: 100%;
}

.group-files {
    display: none; margin-top: 8px; padding-top: 8px;
    border-top: 1px solid #333; max-height: 200px; overflow-y: auto;
}

.group-card.expanded .group-files { display: block; }

.file-item {
    padding: 6px 10px; background: #1a1a2e; margin-bottom: 3px;
    border-radius: 4px; font-size: 11px; cursor: pointer; transition: all 0.2s;
}

.file-item:hover { background: #2a2a4e; padding-left: 15px; }

.reskin-panel {
    background: #16213e; border-radius: 8px; padding: 20px;
    display: flex; flex-direction: column; gap: 15px;
}

.reskin-row { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.reskin-input-group { display: flex; flex-direction: column; gap: 5px; }
.reskin-input-group label { font-size: 11px; color: #aaa; }

.reskin-input-group input {
    background: #0f3460; border: 1px solid #444; color: white;
    padding: 8px 12px; border-radius: 4px; width: 90px; font-size: 14px;
}

.reskin-info {
    background: #0f3460; padding: 12px; border-radius: 6px;
    font-size: 13px; color: #aaa; line-height: 1.5;
}

.reskin-info strong { color: #f39c12; }

.reskin-levels-list {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-height: 200px; overflow-y: auto; padding: 10px;
    background: #0f3460; border-radius: 6px;
}

.reskin-level-tag {
    background: #f39c12; color: #000; padding: 5px 10px;
    border-radius: 15px; font-size: 12px; font-weight: bold;
    cursor: pointer; transition: all 0.2s;
}

.reskin-level-tag:hover { background: #e67e22; transform: scale(1.1); }

.mapping-textarea {
    width: 100%; height: 150px; background: #0f3460; color: #0f0;
    border: 1px solid #333; padding: 10px; font-family: 'Consolas', monospace;
    font-size: 11px; border-radius: 6px; resize: none;
}

.viewer-panel {
    flex: 1; background: #16213e; border-radius: 8px;
    padding: 20px; display: flex; flex-direction: column; overflow: hidden;
}

.viewer-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px; flex-shrink: 0; flex-wrap: wrap; gap: 10px;
}

.viewer-header h3 { color: #e94560; }
.viewer-controls { display: flex; gap: 10px; align-items: center; }
.viewer-mode { display: flex; gap: 5px; margin-right: 10px; }

.mode-btn {
    padding: 6px 12px; background: #0f3460; border: none; color: #aaa;
    border-radius: 4px; cursor: pointer; font-size: 12px; transition: all 0.2s;
}

.mode-btn:hover { background: #1a4a7a; color: white; }
.mode-btn.active { background: #e94560; color: white; }

.zoom-control { display: flex; gap: 5px; align-items: center; }

.zoom-btn {
    padding: 5px 12px; background: #0f3460; border: none;
    color: white; border-radius: 4px; cursor: pointer; font-size: 16px;
}

.zoom-btn:hover { background: #1a4a7a; }

.viewer-container {
    flex: 1; overflow: auto; display: flex;
    justify-content: center; align-items: center; min-height: 0; padding: 10px;
}

.viewer-grid-wrapper {
    display: inline-block; transform-origin: center center; transition: transform 0.1s;
}

.viewer-grid {
    display: inline-grid; gap: 2px; background: #333;
    padding: 10px; border-radius: 8px; margin: 0;
}

.viewer-cell {
    position: relative; border-radius: 4px;
    display: flex; align-items: center; justify-content: center; font-weight: bold;
}

.viewer-cell.empty { background: #1a1a2e !important; border: 1px solid #333; }

.cell-content {
    position: absolute; inset: 0; display: flex;
    align-items: center; justify-content: center; border-radius: 4px;
}

.cell-bg { position: absolute; inset: 0; background: #4a69bd; border-radius: 4px; z-index: 1; }
.cell-chip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; }
.cell-block { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; border-radius: 4px; font-weight: bold; color: white; text-shadow: 1px 1px 2px black; }
.cell-ice { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: flex-end; z-index: 4; border-radius: 4px; padding: 2px; font-weight: bold; color: white; text-shadow: 1px 1px 2px black; }

.block-10 { background: rgba(127, 140, 141, 0.7) !important; }
.block-12 { background: rgba(142, 68, 173, 0.7) !important; }
.block-13 { background: rgba(192, 57, 43, 0.7) !important; }
.ice-1 { background: rgba(135, 206, 235, 0.6) !important; }
.ice-2 { background: rgba(30, 144, 255, 0.6) !important; }
.ice-3 { background: rgba(70, 130, 180, 0.6) !important; }

.viewer-info {
    margin-top: 15px; padding: 15px; background: #0f3460;
    border-radius: 8px; flex-shrink: 0;
}

.viewer-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.viewer-stat { text-align: center; }
.viewer-stat-label { font-size: 11px; color: #aaa; }
.viewer-stat-value { font-size: 18px; font-weight: bold; color: #e94560; }

.viewer-details {
    margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; font-size: 11px; color: #aaa;
}

.detail-item {
    display: flex; justify-content: space-between;
    padding: 3px 8px; background: #1a1a2e; border-radius: 4px;
}

.empty-state { text-align: center; padding: 40px; color: #666; }

.progress-container { margin-top: 15px; display: none; }
.progress-bar { width: 100%; height: 20px; background: #0f3460; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #27ae60, #2ecc71); transition: width 0.3s; width: 0%; }
.progress-text { text-align: center; margin-top: 5px; font-size: 12px; color: #aaa; }

input[type="file"] { display: none; }

.highlight { animation: pulse 1s; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px #f1c40f; }
    50% { box-shadow: 0 0 20px #f1c40f; }
}

.group-stats-header { margin-bottom: 12px; font-size: 13px; color: #aaa; }
.mode-badge { display: inline-block; padding: 2px 8px; background: #27ae60; border-radius: 12px; font-size: 11px; margin-left: 8px; }
