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

:root {
    --bg-color: #1a1a2e;
    --surface-color: #16213e;
    --text-color: #eee;
    --text-muted: #888;
    --border-color: #333;
    --card-size: 80px;
    --tier-label-width: 80px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.title:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
}

.btn:hover {
    background: #1f2b4a;
}

.btn:active {
    transform: scale(0.98);
}

.btn-danger {
    background: #8b0000;
}

.btn-danger:hover {
    background: #a00;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    font-weight: bold;
    font-size: 16px;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-color);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.dropdown-content button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.dropdown-danger {
    color: #ff6b6b !important;
}

.dropdown-danger:hover {
    background: rgba(255, 50, 50, 0.2) !important;
}

/* Tier List */
.tier-list {
    background: var(--surface-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.tier-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    min-height: calc(var(--card-size) + 20px);
}

.tier-row:last-child {
    border-bottom: none;
}

.tier-label {
    width: var(--tier-label-width);
    min-width: var(--tier-label-width);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
    cursor: pointer;
    transition: filter 0.2s;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.tier-label:hover {
    filter: brightness(1.1);
}

.tier-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
    gap: 8px;
    min-height: calc(var(--card-size) + 20px);
    background: rgba(0, 0, 0, 0.2);
}

.tier-items.drag-over {
    background: rgba(255, 255, 255, 0.1);
}

/* Image Cards */
.image-card {
    width: var(--card-size);
    cursor: grab;
    position: relative;
    transition: transform 0.15s;
}

.image-card:hover {
    transform: scale(1.05);
}

.image-card.sortable-ghost {
    opacity: 0.4;
}

.image-card.sortable-drag {
    cursor: grabbing;
}

.image-card img {
    width: var(--card-size);
    height: var(--card-size);
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.image-card .label {
    font-size: 10px;
    text-align: center;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
}

/* Gallery Section */
.gallery-section {
    background: var(--surface-color);
    border-radius: 8px;
    padding: 15px;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 15px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: #666;
    background: rgba(255, 255, 255, 0.05);
}

.upload-zone p {
    color: var(--text-muted);
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 50px;
}

.gallery.drag-over {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    padding: 24px;
    border-radius: 12px;
    min-width: 280px;
    max-width: 90%;
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content label {
    display: block;
    margin-bottom: 12px;
}

.modal-content input[type="text"] {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-top: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
}

.modal-content input[type="color"] {
    display: block;
    width: 60px;
    height: 36px;
    margin-top: 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions-right {
    justify-content: flex-end;
}

.modal-content-wide {
    max-width: 500px;
}

/* Help Modal */
.help-content {
    max-height: 60vh;
    overflow-y: auto;
}

.help-content section {
    margin-bottom: 16px;
}

.help-content section:last-child {
    margin-bottom: 0;
}

.help-content h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #7fbfff;
}

.help-content p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}

.help-content ul {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
    padding-left: 20px;
}

.help-content li {
    margin-bottom: 4px;
}

.help-content strong {
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 600px) {
    :root {
        --card-size: 60px;
        --tier-label-width: 50px;
    }

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

    .tier-label {
        font-size: 1.2rem;
    }
}

/* Utility classes for export */
.exporting .controls,
.exporting .upload-zone,
.exporting .gallery-section {
    display: none !important;
}

.exporting .tier-list {
    margin-bottom: 0;
}
