:root {
    color-scheme: dark;
    --bg: #080a0f;
    --bg-2: #0d1017;
    --surface: rgba(20, 24, 34, 0.72);
    --surface-solid: #12151d;
    --surface-2: rgba(30, 36, 50, 0.6);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #eef1f6;
    --text-muted: #9aa2ad;
    --text-dim: #6b7280;
    --accent: #2e8af6;
    --accent-2: #1f6fd6;
    --accent-glow: rgba(46, 138, 246, 0.35);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --tip: #14b8a6;

    --diff-easy: #4ade80;
    --diff-medium: #fbbf24;
    --diff-hard: #fb7185;
    --diff-insane: #c084fc;
    --diff-nightmare: #ef4444;

    --radius: 14px;
    --radius-sm: 9px;
    --radius-lg: 20px;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 3px var(--accent-glow);
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-head: 'Outfit', var(--font);
    --header-h: 68px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .font-head, .brand { font-family: var(--font-head); letter-spacing: -0.01em; }

a { color: inherit; }

button, input, select, textarea { font-family: inherit; }
button { color: inherit; }

img { max-width: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.26); background-clip: padding-box; }

::selection { background: var(--accent-glow); color: #fff; }

.bg-wrapper {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: radial-gradient(1100px 620px at 78% -8%, rgba(46, 138, 246, 0.16), transparent 60%),
        radial-gradient(900px 520px at 8% 4%, rgba(168, 85, 247, 0.10), transparent 58%),
        var(--bg);
}

.bg-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('/assets/bg.webp');
    background-size: cover;
    background-position: center;
    opacity: 0.10;
    filter: blur(2px);
    mask-image: linear-gradient(to bottom, #000 0%, transparent 72%);
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 72%);
}

.btn {
    --btn-bg: var(--accent);
    --btn-fg: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid transparent;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(46, 138, 246, 0.28); background: var(--accent-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 1.05em; height: 1.05em; }

.btn.outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.outline:hover { background: rgba(255, 255, 255, 0.06); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #dc2626; box-shadow: 0 8px 22px rgba(239, 68, 68, 0.28); }
.btn.subtle { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.btn.subtle:hover { background: rgba(255, 255, 255, 0.11); box-shadow: none; }
.btn.sm { padding: 0.4rem 0.72rem; font-size: 0.82rem; border-radius: 7px; }
.btn.icon { padding: 0.5rem; aspect-ratio: 1; }
.btn.block { width: 100%; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
}
.badge.accent { color: #bcd8ff; border-color: rgba(46, 138, 246, 0.4); background: rgba(46, 138, 246, 0.14); }
.badge.easy { color: var(--diff-easy); border-color: color-mix(in srgb, var(--diff-easy) 45%, transparent); }
.badge.medium { color: var(--diff-medium); border-color: color-mix(in srgb, var(--diff-medium) 45%, transparent); }
.badge.hard { color: var(--diff-hard); border-color: color-mix(in srgb, var(--diff-hard) 45%, transparent); }
.badge.insane { color: var(--diff-insane); border-color: color-mix(in srgb, var(--diff-insane) 45%, transparent); }
.badge.nightmare { color: var(--diff-nightmare); border-color: color-mix(in srgb, var(--diff-nightmare) 45%, transparent); }
.badge.status-draft { color: #cbd5e1; }
.badge.status-pending { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.badge.status-accepted { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); background: color-mix(in srgb, var(--success) 12%, transparent); }
.badge.status-rejected { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }

header.site {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1rem, 4vw, 3rem);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.5rem; font-weight: 800; color: #fff; text-decoration: none; letter-spacing: 0.2px; }
.brand span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 0.6rem; }
.nav-links a.text-link { color: var(--text-muted); text-decoration: none; font-weight: 600; padding: 0.5rem 0.4rem; transition: color 0.2s; }
.nav-links a.text-link:hover { color: var(--text); }

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 190px;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.4rem;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    box-shadow: var(--shadow);
    z-index: 200;
}
.dropdown-menu.open { display: flex; animation: pop 0.16s var(--ease); }
.dropdown-menu button { text-align: left; width: 100%; justify-content: flex-start; }

.avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7b5cff);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}

.form-group { margin-bottom: 1rem; }
.form-group label, .field-label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.form-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.3rem; }
.input, .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]), .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    background-color: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s, background-color 0.18s;
}
.input:focus, .form-group input:not([type="checkbox"]):not([type="radio"]):focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--accent);
    box-shadow: var(--ring);
    background-color: rgba(255, 255, 255, 0.06);
}
.form-group textarea { resize: vertical; min-height: 72px; }
select, select.input, .form-group select, .custom-dropdown-btn {
    appearance: none; -webkit-appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa2ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1.05em;
    cursor: pointer;
}
option { background: var(--surface-solid); color: var(--text); }

.switch { position: relative; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.14); border-radius: 999px; transition: background 0.2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(19px); }

.search-bar { display: flex; align-items: center; gap: 0.6rem; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.15rem 0.8rem; transition: border-color 0.18s, box-shadow 0.18s; }
.search-bar:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-bar svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.search-bar input { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); outline: none; font-family: inherit; font-size: 0.95rem; padding: 0.5rem 0; }
.search-bar input::placeholder { color: var(--text-dim); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s var(--ease);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: translateY(14px) scale(0.99);
    transition: transform 0.22s var(--ease);
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-content h2 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.modal-close { position: absolute; top: 0.9rem; right: 1rem; background: transparent; border: none; color: var(--text-muted); font-size: 1.6rem; line-height: 1; cursor: pointer; transition: color 0.2s; }
.modal-close:hover { color: var(--text); }

.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.loading-wrap { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 4rem 1rem; color: var(--text-muted); }

.skeleton { background: linear-gradient(100deg, rgba(255,255,255,0.04) 30%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }

.empty-state { text-align: center; padding: 4rem 1.5rem; color: var(--text-muted); grid-column: 1 / -1; }
.empty-state svg { width: 46px; height: 46px; color: var(--text-dim); margin-bottom: 1rem; }
.empty-state h3 { color: var(--text); font-size: 1.15rem; margin-bottom: 0.4rem; }

.notifications { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.6rem; max-width: min(360px, calc(100vw - 2rem)); }
.note { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.8rem 0.95rem; border-radius: var(--radius-sm); background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 0.9rem; animation: slide-in 0.24s var(--ease); }
.note.out { opacity: 0; transform: translateX(24px); transition: opacity 0.24s, transform 0.24s; }
.note svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.note.success svg { color: var(--success); }
.note.error svg { color: var(--danger); }
.note.info svg { color: var(--accent); }
.note p { flex: 1; min-width: 0; }
.note button { background: none; border: none; color: var(--text-dim); font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0; }
.note button:hover { color: var(--text); }

.tower-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.6rem 0.28rem 0.32rem; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.tower-chip img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; background: rgba(0, 0, 0, 0.35); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

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

.custom-dropdown-wrap {
    position: relative;
    display: inline-block;
    width: 100%;
}
.custom-dropdown-wrap:has(> .filter-select),
.custom-dropdown-wrap:has(> .rt-select),
.custom-dropdown-wrap[style*="width:auto"],
.custom-dropdown-wrap:has(> .custom-dropdown-btn[style*="width:auto"]),
.custom-dropdown-wrap:has(> .custom-dropdown-btn[style*="width: auto"]) {
    width: auto;
}
.custom-dropdown-btn {
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-dropdown-value {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 0.35rem;
}
.custom-dropdown-menu.open {
    display: flex;
    animation: fade-up 0.16s var(--ease);
}
.custom-dropdown-option {
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-size: 0.92rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
}
.custom-dropdown-option:hover {
    background: rgba(255, 255, 255, 0.06);
}
.custom-dropdown-option.selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}