*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #09090c;
    --bg2: #111116;
    --bg3: #18181f;
    --border: #2b1d22;

    --accent: #b91c1c;
    --accent2: #7f1d1d;
    --gold: #d4a017;

    --text: #e7e7eb;
    --muted: #8a8a96;

    --success: #10b981;
    --danger: #ef4444;
    --info: #3b82f6;

    --range-glow: rgba(127, 29, 29, 0.12);
    --mid-glow: rgba(185, 28, 28, 0.22);

    --font-heading: "Bebas Neue", Arial, sans-serif;
    --font-mono: "Share Tech Mono", monospace;
    --font-body: "Barlow", sans-serif;

    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;
    --sp-2xl: 40px;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition-fast: 0.12s ease;
    --transition-base: 0.15s ease;
    --transition-slow: 0.2s ease;

    --z-modal: 1000;
    --z-toast: 2000;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    font-size: 16px;
}

.hidden {
    display: none !important;
}

.header {
    padding: var(--sp-2xl) var(--sp-2xl) var(--sp-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 200px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.logo {
    display: flex;
    align-items: baseline;
    gap: var(--sp-sm);
}

.logo-title {
    font-family: var(--font-display);
    font-size: 3rem;
    letter-spacing: 0.06em;
    line-height: 1;
    background: linear-gradient(135deg, #3a0d12 0%, #5c1118 50%, #12090b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: var(--sp-sm);
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-xs);
    padding: 8px 18px;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition-base);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.btn:hover:not(:disabled) {
    border-color: var(--accent2);
    color: var(--accent2);
    background: rgba(255, 140, 0, 0.08);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: rgba(185, 28, 28, 0.15);
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.2);
}

.btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
}

.btn-success {
    border-color: var(--success);
    color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.08);
}

.btn-warning {
    border-color: var(--gold);
    color: var(--gold);
}

.btn-warning:hover:not(:disabled) {
    background: rgba(212, 160, 23, 0.08);
}

#reset-btn {
    display: none;
}

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp-2xl);
}

.tab-bar {
    display: flex;
    gap: 0;
    margin-bottom: var(--sp-xl);
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: var(--sp-md) var(--sp-lg);
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-slow);
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
    background: rgba(185, 28, 28, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.import-panel {
    margin-bottom: var(--sp-2xl);
    padding: var(--sp-lg);
    background: var(--bg2);
    border: 1px solid var(--border);
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.import-header {
    margin-bottom: var(--sp-xl);
}

.import-header h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.08em;
    color: var(--text);
    margin-bottom: var(--sp-sm);
}

.import-header p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.drop-zone {
    border: 1px dashed var(--border);
    padding: 64px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-slow);
    position: relative;
    background: var(--bg3);
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(185, 28, 28, 0.05);
    box-shadow: inset 0 0 60px rgba(185, 28, 28, 0.06);
}

.dropzone-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: var(--sp-md);
    opacity: 0.5;
}

.dropzone-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: var(--sp-sm);
}

.dropzone-sub {
    font-size: 0.8rem;
    color: var(--muted);
    font-family: var(--font-mono);
    opacity: 0.6;
}

.file-input {
    display: none;
}

.import-divider {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    margin: var(--sp-lg) 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.paste-trigger {
    width: 100%;
    justify-content: center;
}

.paste-area {
    margin-top: var(--sp-md);
}

.paste-area.hidden {
    display: none;
}

.paste-textarea {
    width: 100%;
    height: 180px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: var(--sp-md);
    resize: vertical;
    transition: border-color var(--transition-base);
    outline: none;
}

.paste-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(185, 28, 28, 0.2);
}

.paste-actions {
    display: flex;
    gap: var(--sp-sm);
    margin-top: var(--sp-sm);
    flex-wrap: wrap;
}

.paste-actions .btn {
    flex: 1;
    justify-content: center;
}

.import-error {
    display: none;
    margin-top: var(--sp-md);
    padding: var(--sp-md);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ff6680;
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

.import-error.active {
    display: block;
}

.import-panel-actions {
    margin-top: var(--sp-lg);
    display: flex;
    gap: var(--sp-sm);
}

#session-panel {
    display: block;
}

#session-panel.hidden {
    display: none;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px;
    margin-bottom: var(--sp-xl);
    background: var(--border);
    border: 1px solid var(--border);
}

.stat {
    background: var(--bg2);
    padding: var(--sp-lg) var(--sp-md);
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
    text-align: center;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.2rem;
    letter-spacing: 0.05em;
    line-height: 1;
    color: var(--accent);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.session-top-actions {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-lg);
    flex-wrap: wrap;
}

.session-top-actions .btn {
    flex: 1;
    min-width: 160px;
}

.keyboard-hint {
    padding: var(--sp-md) var(--sp-lg);
    background: rgba(185, 28, 28, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: var(--sp-lg);
    display: flex;
    gap: var(--sp-sm);
    flex-wrap: wrap;
    align-items: center;
}

kbd {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    display: inline-block;
}

#insertion-progress {
    margin-bottom: var(--sp-lg);
}

.arena-controls {
    display: flex;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-lg);
    flex-wrap: wrap;
    align-items: center;
}

.arena-controls .btn {
    flex: 1;
    min-width: 100px;
    justify-content: center;
}

.arena-controls-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
    flex-shrink: 0;
}

#arena {
    display: grid;
    gap: 3px;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    margin-bottom: var(--sp-xl);
    position: relative;
}

.level-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.level-card:hover {
    border-color: var(--accent2);
    box-shadow: 0 0 20px rgba(185, 28, 28, 0.1);
}

.level-thumb {
    height: 140px;
    background: var(--bg3) center / cover no-repeat;
    position: relative;
    overflow: hidden;
}

.level-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(8, 8, 16, 0.9) 100%);
}

.level-thumb:not(.has-thumb) {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.15;
}

.level-thumb:not(.has-thumb)::before {
    content: '🔥';
}

.level-info {
    padding: var(--sp-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
}

.level-name-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    color: var(--text);
    line-height: 1.2;
}

.level-creator-text {
    font-size: 0.8rem;
    color: var(--muted);
}

.level-link {
    font-size: 0.75rem;
    color: var(--info);
    text-decoration: none;
    transition: color var(--transition-fast);
    margin-top: auto;
}

.level-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.vote-btn {
    padding: var(--sp-md) var(--sp-lg);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.vote-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.arena-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.rankings-section {
    margin-top: var(--sp-xl);
}

.rankings-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-lg);
    margin-bottom: var(--sp-lg);
    flex-wrap: wrap;
}

.rankings-header h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-sm);
}

.rank-info {
    font-size: 0.8rem;
    color: var(--muted);
}

.rankings-header-actions {
    flex: 1;
    min-width: 200px;
}

.filter-input {
    width: 100%;
    padding: var(--sp-md);
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition-base);
}

.filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(185, 28, 28, 0.2);
}

.filter-input::placeholder {
    color: var(--muted);
}

#contradiction-panel {
    display: none;
    margin: 0 0 var(--sp-md);
    border: 1px solid var(--gold);
    border-radius: var(--radius-sm);
    background: rgba(212, 160, 23, 0.07);
    padding: var(--sp-md);
    font-size: 0.85rem;
}

#contradiction-panel.active {
    display: block;
}

.contradiction-header {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-md);
    flex-wrap: wrap;
}

.contradiction-icon {
    font-size: 1.1em;
}

.contradiction-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-left: auto;
}

.contradiction-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.contradiction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: var(--sp-sm);
    flex-wrap: wrap;
}

.contradiction-pair {
    line-height: 1.5;
}

.contradiction-level {
    font-weight: 600;
    color: var(--gold);
}

.contradiction-arrow {
    color: var(--muted);
}

.contradiction-actions {
    display: flex;
    gap: var(--sp-xs);
    flex-shrink: 0;
}

.contradiction-more {
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
    margin-top: var(--sp-sm);
}

#rankings-table-wrapper {
    max-height: min(600px, 70vh);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.rankings-table {
    width: auto;
    min-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.rankings-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg3);
}

.rankings-table th {
    padding: var(--sp-md);
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    color: var(--muted);
}

.rankings-table td {
    padding: var(--sp-md);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: center;
}

.rankings-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.rankings-table th[data-sort]:hover {
    color: var(--text);
}

.rankings-table td {
    padding: var(--sp-md);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.rankings-table tbody tr {
    transition: background-color var(--transition-fast);
}

.rankings-table tbody tr:hover {
    background: rgba(185, 28, 28, 0.05);
}

.rankings-table th:last-child,
.rankings-table td.rank-actions {
    display: none;
}

.row-low-conf {
    background: rgba(41, 128, 185, 0.07) !important;
}

.row-contradiction {
    background: rgba(212, 160, 23, 0.09) !important;
}

.cb-cell {
    width: 48px;
    text-align: center;
    vertical-align: middle;
    padding: 0;
    white-space: nowrap;
}

.cb-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform 0.08s;
}

.cb-cell input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 8px var(--mid-glow);
}

.cb-cell input[type="checkbox"]:active {
    transform: scale(0.95);
}

.rankings-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.rankings-header-actions .filter-input {
    flex: 0 1 320px;
    min-width: 150px;
}

.field-input {
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(185, 28, 28, 0.12);
}

.rankings-header-actions .btn {
    padding: 8px 14px;
    border-radius: 6px;
    min-width: unset;
    white-space: nowrap;
}

@media (max-width:720px) {
    .rankings-header {
        flex-direction: column;
        align-items: stretch;
    }

    .rankings-header-actions {
        justify-content: stretch;
        gap: 6px;
    }

    .rankings-header-actions .filter-input {
        order: 1;
        width: 100%;
    }

    .rankings-header-actions .field-input,
    .rankings-header-actions .btn {
        flex: 1 1 auto;
    }
}

#rankings-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

#rankings-body tr td {
    vertical-align: middle;
}

tbody#rankings-body:empty::before {
    content: 'No results found';
    display: block;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.01));
}

.badge {
    display: inline-block;
    font-size: 0.68em;
    font-weight: 700;
    margin-left: var(--sp-xs);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    vertical-align: middle;
    line-height: 1.4;
}

.badge-contradiction {
    background: var(--gold);
    color: #000;
}

.badge-low-conf {
    background: #2980b9;
    color: white;
}

.rank-level-inner {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
}

.rank-thumb-wrap {
    flex-shrink: 0;
    width: 54px;
    height: 38px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
}

.thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rank-text-block {
    min-width: 0;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.74rem;
    border-radius: var(--radius-sm);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-lg) * 1.25);
    max-width: 620px;
    min-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
    width: min(92vw, 620px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--sp-lg) + 2px) var(--sp-lg);
    border-bottom: 1px solid var(--border);
    gap: var(--sp-md);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    letter-spacing: 0.05em;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.5rem;
    transition: color var(--transition-fast);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    padding: var(--sp-lg);
}

.modal-footer {
    padding: var(--sp-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--sp-sm);
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 100px;
}

.field-group {
    margin-bottom: var(--sp-lg);
}

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-input {
    width: 100%;
    padding: var(--sp-md);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition-base);
    border-radius: var(--radius-sm);
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(185, 28, 28, 0.2);
}

.preset-import {
    margin: var(--sp-md) 0 0;
}

.preset-import-row {
    display: flex;
    gap: var(--sp-sm);
    align-items: center;
}

.preset-import-row .field-input {
    flex: 1;
}

.pending-selector {
    margin-bottom: var(--sp-xl);
}

.pending-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
    margin-bottom: var(--sp-md);
}

.pending-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: var(--text);
}

.pending-grid {
    display: grid;
    gap: var(--sp-md);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.pending-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.pending-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.pending-thumb {
    min-height: 150px;
    background: var(--bg3);
    position: relative;
    overflow: hidden;
}

.pending-thumb.has-thumb {
    background: none;
}

.pending-info {
    padding: var(--sp-md);
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
    flex: 1;
}

.pending-name {
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.2;
    color: var(--text);
}

.pending-creator {
    color: var(--muted);
    font-size: 0.85rem;
}

.pending-card-actions {
    display: flex;
    gap: var(--sp-xs);
    padding: var(--sp-sm);
    border-top: 1px solid var(--border);
    background: var(--bg3);
}

.pending-card-btn {
    flex: 1;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.pending-card-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.no-pending {
    padding: var(--sp-lg);
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--muted);
    text-align: center;
}

.field-input::placeholder {
    color: var(--muted);
}

.field-textarea {
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    min-height: 120px;
}

.thumb-preview {
    margin-top: var(--sp-md);
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.radio-label,
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.checkbox-label:hover {
    background: rgba(185, 28, 28, 0.08);
    border-color: rgba(185, 28, 28, 0.2);
}

.radio-label input,
.checkbox-label input {
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0;
}

.settings-section {
    margin-bottom: var(--sp-xl);
}

.settings-section h4 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-md);
    color: var(--text);
}

.setting-item {
    padding: var(--sp-md) 0;
    border-bottom: 1px solid rgba(43, 29, 34, 0.5);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    cursor: pointer;
    font-size: 0.9rem;
}

.setting-label input {
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
}

.setting-label span {
    flex: 1;
}

.custom-values-section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-lg);
}

.add-custom-value {
    display: grid;
    grid-template-columns: minmax(160px, 1.5fr) minmax(120px, 1fr) minmax(180px, 1.8fr) repeat(3, minmax(120px, auto)) auto;
    gap: var(--sp-sm);
    align-items: end;
    width: 100%;
}

.add-custom-value .field-input {
    min-width: 0;
    width: 100%;
}

.add-custom-value select {
    min-width: 120px;
    width: 100%;
}

.add-custom-value button {
    align-self: center;
    white-space: nowrap;
}

.custom-values-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    max-height: 320px;
    overflow-y: auto;
    padding-right: 2px;
}

.custom-value-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-sm);
    padding: calc(var(--sp-md) - 2px);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.custom-value-name {
    flex: 1 1 180px;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text);
}

.custom-value-type {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    background: var(--bg3);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.custom-value-remove {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}

.custom-value-remove:hover {
    border-color: var(--danger);
    color: var(--danger);
}

#toast {
    position: fixed;
    bottom: var(--sp-xl);
    right: var(--sp-xl);
    padding: var(--sp-md) var(--sp-lg);
    background: var(--bg3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--success);
    letter-spacing: 0.04em;
    z-index: var(--z-toast);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    pointer-events: none;
    max-width: 320px;
}

#toast.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#toast.toast-danger {
    border-left-color: var(--danger);
    color: var(--danger);
}

#toast.toast-gold {
    border-left-color: var(--gold);
    color: var(--gold);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

@media (max-width: 900px) {
    .main {
        padding: var(--sp-lg);
    }

    .logo-title {
        font-size: 2rem;
    }

    .header {
        padding: var(--sp-lg);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-md);
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    #arena {
        grid-template-columns: 1fr;
    }

    .arena-vs {
        padding: var(--sp-md) 0;
        order: 2;
    }

    .level-card:nth-child(1) {
        order: 1;
    }

    .level-card:nth-child(3) {
        order: 3;
    }

    .rankings-header {
        flex-direction: column;
        align-items: stretch;
    }

    .rankings-header-actions {
        width: 100%;
    }

    .filter-input {
        width: 100%;
    }

    .session-top-actions {
        flex-direction: column;
    }

    .session-top-actions .btn {
        width: 100%;
    }

    .modal {
        width: 95vw;
        max-height: 95vh;
    }
}

@media (max-width: 600px) {
    :root {
        --sp-xl: 20px;
        --sp-2xl: 20px;
    }

    .header {
        padding: var(--sp-lg);
    }

    .main {
        padding: var(--sp-lg);
    }

    .logo-title {
        font-size: 1.5rem;
    }

    .tab {
        padding: var(--sp-md) var(--sp-sm);
        font-size: 0.9rem;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }

    .stat {
        padding: var(--sp-md);
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .drop-zone {
        padding: 40px 20px;
    }

    .import-header h2 {
        font-size: 1.3rem;
    }

    .level-card {
        min-width: 0;
    }

    .level-name-text {
        font-size: 0.95rem;
    }

    .arena-controls {
        flex-direction: column;
    }

    .arena-controls .btn {
        width: 100%;
    }

    .arena-controls-divider {
        width: 100%;
        height: 1px;
    }

    .keyboard-hint {
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.75rem;
    }

    .rankings-header h3 {
        font-size: 1.2rem;
    }

    .rankings-table {
        font-size: 0.75rem;
    }

    .rankings-table th,
    .rankings-table td {
        padding: var(--sp-sm);
    }

    .modal {
        width: 98vw;
        border-radius: var(--radius-sm);
    }

    .modal-header {
        padding: var(--sp-md);
    }

    .modal-body {
        padding: var(--sp-md);
    }

    .modal-footer {
        padding: var(--sp-md);
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    #toast {
        bottom: var(--sp-md);
        right: var(--sp-md);
        left: var(--sp-md);
        max-width: none;
    }
}