:root {
    --ink: #120f24;
    --ink-2: #1b1734;
    --ink-3: #241f42;
    --line: #2c2750;
    --line-2: #3d3670;
    --text: #ece9ff;
    --muted: #8e88b5;
    --faint: #5f5986;
    --pink: #ff4f9a;
    --pink-2: #ff7ab3;
    --mint: #4fe3c1;
    --gold: #ffcf4a;
    --danger: #ff5470;
    --team-red: #ff5c7a;
    --team-blue: #5c9dff;
    --radius: 10px;
    --radius-lg: 18px;
    --display: "Bricolage Grotesque", "Onest", system-ui, sans-serif;
    --ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--ink);
    color: var(--text);
    font: 400 14px/1.5 var(--ui);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -0.01em; line-height: 1.1; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 16px;
    border: 1px solid var(--line-2); border-radius: var(--radius);
    background: var(--ink-3); color: var(--text);
    font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #2d2752; border-color: #514896; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 26px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 30px; padding: 0; font-size: 16px; }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #1a0612; }
.btn-primary:hover { background: var(--pink-2); border-color: var(--pink-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--ink-3); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; border-color: #6b2840; color: #ff8aa0; }
.btn-danger:hover { background: #3a1424; border-color: var(--danger); }
.btn-mint { background: var(--mint); border-color: var(--mint); color: #062a22; }
.btn-group { display: inline-flex; gap: 2px; }

.input, .field input, .field select, .field textarea, select {
    width: 100%; height: 34px; padding: 0 10px;
    background: var(--ink); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
    transition: border-color .12s;
}
textarea, .field textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 64px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, select:focus { outline: none; border-color: var(--pink); }
input[type="file"] { height: auto; padding: 6px; font-size: 12px; }
input[type="range"] { accent-color: var(--pink); }
input[type="checkbox"] { accent-color: var(--pink); width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-row { display: flex; gap: 10px; align-items: flex-end; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }

.seg { display: inline-flex; background: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg-btn { border: 0; background: none; color: var(--muted); padding: 0 10px; height: 26px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--ink-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--ink-3); flex: none; }
.avatar-wrap { position: relative; flex: none; }
.avatar-wrap .dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--faint); border: 2px solid var(--ink-2); }
.avatar-wrap .dot.on { background: var(--mint); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--pink); color: #1a0612; font-size: 11px; font-weight: 700; }
.rank { font-family: var(--display); font-weight: 800; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; align-items: center; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--ink-3); border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: min(560px, 92vw); }
.toast.in { opacity: 1; transform: none; }
.toast-ok { border-color: #2e7d6a; }
.toast-error { border-color: #8a2c45; color: #ffc0cc; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,6,18,.72); display: grid; place-items: center; z-index: 900; padding: 20px; animation: fade .15s ease; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal-wide { width: min(720px, 100%); }
.modal-title { font-size: 21px; margin-bottom: 12px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; color: var(--text); }
.modal-body p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }

.glyph { display: block; flex: none; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--pink); }
.brand-mark { display: inline-flex; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -0.02em; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--ink-2), var(--ink-3), var(--ink-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.avatar-initial { display: inline-grid; place-items: center; color: #fff; font-family: var(--display); font-weight: 700; line-height: 1; }

.analytics { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.an-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.an-stat { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--ink); border: 1px solid var(--line); }
.an-stat span { color: var(--muted); font-size: 11.5px; }
.an-stat b { font-family: var(--display); font-size: 20px; font-weight: 800; }
.an-stat small { color: var(--faint); font-size: 11px; }
.an-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.an-box { padding: 12px; border-radius: 14px; background: var(--ink); border: 1px solid var(--line); min-width: 0; }
.an-box h4 { font-family: var(--ui); font-size: 13px; font-weight: 700; margin: 0 0 8px; }
.an-canvas { width: 100%; display: block; }
.an-legend { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.an-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -6px; }
.l-perfect { background: #4fe3c1; } .l-great { background: #6fb6ff; } .l-early { background: #b58cff; } .l-late { background: #ff8a4f; }
.l-mean, .l-acc { background: #ff4f9a; } .l-hp { background: #4fe3c1; } .l-miss { background: #ff5470; }
.an-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 280px; }
.an-cell { aspect-ratio: 1; border-radius: 10px; background: var(--ink-3); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.an-cell b { font-size: 16px; }
.an-cell span { font-size: 10.5px; color: rgba(255,255,255,.7); }
.an-sections { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; height: 150px; align-items: end; }
.an-sec { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.an-sec i { width: 100%; border-radius: 6px 6px 2px 2px; min-height: 0; }
.an-sec span { font-size: 10px; color: var(--faint); }

.mobile-block { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--ink); }
.mobile-block-card { max-width: 420px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.mobile-block-icon { font-size: 54px; }
.mobile-block h1 { font-size: 30px; font-weight: 800; }
.mobile-block p { color: var(--muted); }

@media (max-width: 760px) {
    .an-stats { grid-template-columns: repeat(3, 1fr); }
    .an-row { grid-template-columns: 1fr; }
}
textarea { width: 100%; background: var(--ink); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px 10px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--pink); }

.toast-invite { pointer-events: auto; display: flex; flex-direction: column; gap: 8px; border-color: var(--pink); }
.toast-actions { display: flex; gap: 6px; justify-content: flex-end; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 0 12px 8px; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); }
.table tbody tr:hover { background: var(--ink-2); }
.table tr.me { background: rgba(255,79,154,.07); }
.table .num { text-align: right; }
.table .strong { font-weight: 700; color: var(--pink-2); }
.table .pos { color: var(--muted); font-weight: 700; width: 48px; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.rank-badge { font-size: 15px; text-align: center; }
.uname { text-decoration: none; font-weight: 600; }
.uname:hover { text-decoration: underline; }
.flag { font-size: 15px; line-height: 1; }
.mod-mini { display: inline-flex; gap: 3px; }
.mod-mini span { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; background: var(--ink-3); color: var(--pink-2); }
