:root {
  --glass: rgba(16, 18, 40, 0.42);
  --glass-b: rgba(255, 255, 255, 0.14);
  --txt: #f4f6ff;
  --dim: rgba(230, 235, 255, 0.62);
  --acc: #7ee8ff;
  --acc2: #ff8ad8;
  --danger: #ff4d8a;
  --gold: #ffd36e;
  --font: 'Outfit', system-ui, sans-serif;
  --title: 'Unbounded', 'Outfit', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d22; color: var(--txt); font-family: var(--font); user-select: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
button, input { font-family: inherit; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-b);
  border-radius: 18px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 20, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.glass.slim { border-radius: 14px; padding: 10px 12px; }

kbd {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 6px; font: 600 11px var(--font);
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); border-bottom-width: 2px; text-align: center;
}

/* ============ MENU ============ */
.screen { position: fixed; inset: 0; z-index: 20; }
#menu {
  display: grid; grid-template-columns: minmax(340px, 560px) minmax(280px, 380px); gap: 22px;
  justify-content: center; align-content: center; padding: 24px; overflow-y: auto;
  background: radial-gradient(ellipse at 30% 40%, rgba(10, 10, 40, 0.15), rgba(5, 5, 25, 0.55));
}
.menu-col { display: flex; flex-direction: column; gap: 14px; }
.logo h1 {
  font: 900 clamp(64px, 11vw, 124px)/0.9 var(--title); margin: 0; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff 0%, #bdf3ff 35%, #ff9ee6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 28px rgba(140, 220, 255, 0.55)) drop-shadow(0 6px 0 rgba(40, 20, 90, 0.35));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translateY(-6px); } }
.logo .tag { margin: 8px 0 0 4px; font-size: 18px; color: var(--dim); }
.logo .tag b { color: #fff; }
.block { padding: 16px 18px; }
.block h3 { margin: 0 0 10px; font: 600 15px var(--title); letter-spacing: 0.02em; display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--dim); }
.lbl { display: block; font-size: 12px; color: var(--dim); margin: 14px 0 8px; }
input:not([type]), input[type=text], .code {
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; border-radius: 12px;
  padding: 11px 14px; font-size: 16px; outline: none; transition: border-color .2s, background .2s;
}
input:focus { border-color: var(--acc); background: rgba(255, 255, 255, 0.12); }
.field.hue { width: 130px; }
#hue { -webkit-appearance: none; appearance: none; height: 14px; border-radius: 8px; margin: 12px 0;
  background: linear-gradient(90deg, hsl(0,85%,62%), hsl(60,85%,62%), hsl(120,85%,62%), hsl(180,85%,62%), hsl(240,85%,62%), hsl(300,85%,62%), hsl(360,85%,62%)); }
#hue::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid #223; cursor: pointer; }
.classes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cls {
  position: relative; padding: 12px 12px 10px; border-radius: 14px; cursor: pointer; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.04); transition: transform .15s, border-color .2s, background .2s;
}
.cls:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.08); }
.cls.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: 0 0 24px color-mix(in srgb, var(--c) 35%, transparent); }
.cls .ic { font-size: 22px; color: var(--c); text-shadow: 0 0 12px var(--c); }
.cls .nm { font: 600 15px var(--title); margin-left: 6px; }
.cls .rl { font-size: 12px; color: var(--dim); margin: 2px 0 6px; }
.cls .ab { font-size: 12px; line-height: 1.35; margin-top: 4px; color: rgba(255,255,255,0.86); }
.cls .ab kbd { margin-right: 4px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.1); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform .1s, background .2s, box-shadow .2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.18); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(120deg, #4fd8ff, #a77bff 55%, #ff7ad9); border: none; font: 800 19px var(--title); letter-spacing: .03em; padding: 16px;
  box-shadow: 0 8px 30px rgba(170, 120, 255, 0.45);
}
.btn.primary:hover { box-shadow: 0 10px 40px rgba(170, 120, 255, 0.7); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.actions .row .btn { flex: 1; }
.check { display: flex; gap: 6px; align-items: center; color: var(--dim); font-size: 14px; white-space: nowrap; cursor: pointer; }
.code { width: 110px; text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 800; }
.err { color: var(--danger); min-height: 18px; font-size: 14px; }
.mini { background: rgba(255,255,255,0.1); border: none; color: #fff; border-radius: 8px; cursor: pointer; padding: 2px 8px; font-size: 13px; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.05); font-size: 14px; }
.list .item.click { cursor: pointer; }
.list .item.click:hover { background: rgba(255,255,255,0.12); }
.list .item .n { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .empty { color: var(--dim); font-size: 13px; }
.list .rank { font: 900 14px var(--title); width: 26px; color: var(--gold); }
.how ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: rgba(255,255,255,0.86); }
.how li { margin-bottom: 4px; }

@media (max-width: 900px) {
  #menu { grid-template-columns: 1fr; align-content: start; }
}

#loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: #0b0d22; z-index: 50; font-size: 15px; color: var(--dim); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--acc); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud .glass, #hud button, #hud input { pointer-events: auto; }
#vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(5, 0, 25, 0.45) 100%); }
#abyssGlow { position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(ellipse at 50% 120%, rgba(255, 40, 160, 0.55), transparent 60%), radial-gradient(ellipse at center, transparent 50%, rgba(120, 0, 90, 0.5) 100%); }

.hud-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
#height { font: 900 54px/1 var(--title); text-shadow: 0 0 24px rgba(140, 220, 255, 0.6), 0 3px 0 rgba(0,0,0,0.25); letter-spacing: .02em; }
#height small { font-size: 22px; margin-left: 4px; opacity: .8; }
#hSub { font-size: 13px; color: var(--dim); margin-top: 4px; }
#hSub b { color: #fff; }
#abyssDist { margin-top: 6px; font-size: 13px; display: inline-block; padding: 3px 12px; border-radius: 20px; background: rgba(0,0,0,0.25); }
#abyssDist.hot { background: rgba(255, 40, 120, 0.45); animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }

.hud-tl { position: absolute; top: 14px; left: 14px; min-width: 230px; }
.roomline { font-size: 13px; margin-bottom: 8px; color: var(--dim); }
.roomline b { color: #fff; letter-spacing: .15em; }
#team { display: flex; flex-direction: column; gap: 5px; }
.tm { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.tm .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.tm .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm .nm i { font-style: normal; color: var(--dim); font-size: 12px; margin-left: 4px; }
.tm .h { font-weight: 600; font-variant-numeric: tabular-nums; }
.tm.ghost .nm, .tm.ghost .h { color: #b9c7ff; opacity: .8; }
.tm.out { opacity: .45; }
.tm.me .nm { font-weight: 800; }

#altbar { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); width: 10px; height: 46vh; border-radius: 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0.06)); box-shadow: 0 0 0 1px rgba(255,255,255,0.12); }
#altAbyss { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 6px; background: linear-gradient(0deg, #2a0038, #ff3fa4); box-shadow: 0 0 14px #ff3fa4; }
#altMarks .mk { position: absolute; left: 50%; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, 50%); border: 2px solid #fff; transition: bottom .2s linear; }
#altMarks .mk.me { width: 18px; height: 18px; z-index: 2; box-shadow: 0 0 12px #fff; }
#altMarks .mk.sanct { width: 20px; height: 6px; border-radius: 3px; border: none; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.altlbl.top { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--dim); }

.hud-bottom { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: flex-end; }
#abilities { display: flex; gap: 10px; }
.abl { position: relative; width: 78px; height: 78px; border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(10, 12, 35, 0.55); border: 2px solid color-mix(in srgb, var(--c) 70%, transparent); backdrop-filter: blur(10px);
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 40%, transparent); transition: transform .12s; }
.abl .ic { font-size: 28px; color: var(--c); text-shadow: 0 0 14px var(--c); z-index: 2; }
.abl .k { position: absolute; top: 4px; left: 6px; font: 800 13px var(--title); z-index: 2; }
.abl .nm { font-size: 10px; text-align: center; z-index: 2; line-height: 1.1; margin-top: 2px; padding: 0 4px; }
.abl .cd { position: absolute; inset: 0; background: conic-gradient(rgba(0,0,10,0.72) var(--p, 0%), transparent 0); z-index: 1; }
.abl .cdt { position: absolute; z-index: 3; font: 900 22px var(--title); text-shadow: 0 2px 6px #000; }
.abl.ready { animation: ready .5s ease-out; }
.abl.fire { transform: scale(0.9); }
@keyframes ready { 0% { box-shadow: 0 0 50px var(--c); } }
#ult { width: 190px; }
.ult-top { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.ult-top span { flex: 1; font-weight: 600; }
.bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd36e, #fff2b8); box-shadow: 0 0 12px #ffd36e; transition: width .3s; }
#ult.full { border-color: var(--gold); box-shadow: 0 0 30px rgba(255, 211, 110, 0.6); animation: pulse 0.8s ease-in-out infinite alternate; }

#cross { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,0.85); box-shadow: 0 0 6px #000; }
#cross.aim { width: 22px; height: 22px; margin: -11px; background: none; border: 2px solid var(--acc); }

#toasts { position: absolute; top: 140px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { padding: 7px 16px; border-radius: 20px; background: rgba(10, 12, 35, 0.6); backdrop-filter: blur(8px); font-size: 14px; animation: tin .3s ease-out, tout .5s ease-in forwards; animation-delay: 0s, var(--d, 3.5s); border: 1px solid rgba(255,255,255,0.1); }
.toast.gold { color: var(--gold); border-color: rgba(255, 211, 110, 0.4); }
.toast.bad { color: #ff9cc5; border-color: rgba(255, 77, 138, 0.4); }
.toast.big { font: 800 20px var(--title); padding: 10px 22px; }
@keyframes tin { from { opacity: 0; transform: translateY(-10px) scale(.95); } }
@keyframes tout { to { opacity: 0; transform: translateY(-8px); } }

#center { position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%); text-align: center; font: 800 26px var(--title); text-shadow: 0 0 20px rgba(0,0,0,0.5); }
#center .s { display: block; font: 400 16px var(--font); color: var(--dim); margin-top: 6px; }
#center .ring { width: 70px; height: 70px; margin: 10px auto 0; border-radius: 50%; background: conic-gradient(#9fe9ff var(--p), rgba(255,255,255,0.12) 0); -webkit-mask: radial-gradient(circle, transparent 55%, #000 57%); mask: radial-gradient(circle, transparent 55%, #000 57%); }

#chat { position: absolute; left: 14px; bottom: 18px; width: min(380px, 40vw); }
#chatLog { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; font-size: 14px; }
#chatLog .ln { background: rgba(5, 8, 25, 0.45); padding: 3px 10px; border-radius: 8px; width: fit-content; max-width: 100%; animation: tout 1s ease-in forwards; animation-delay: 9s; }
#chatLog .ln b { margin-right: 6px; }
#chatLog .ln.sys { color: var(--dim); font-style: italic; }
#chatIn { width: 100%; }
#chat.open #chatLog .ln { animation: none; }

#lockHint { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); padding: 16px 22px; text-align: center; max-width: 560px; }
#lockHint > b { font: 800 20px var(--title); display: block; margin-bottom: 10px; }
#lockHint .keys { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; font-size: 13px; color: var(--dim); margin-bottom: 12px; }

#over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 0, 25, 0.45); pointer-events: auto; }
.over-card { padding: 28px 34px; text-align: center; min-width: 360px; }
.over-card h2 { font: 800 24px var(--title); margin: 0 0 6px; }
.over-card .big { font: 900 72px/1 var(--title); background: linear-gradient(180deg, #fff, #ff9ee6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.over-card .big small { font-size: 28px; }
#ovStats { margin: 16px 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; text-align: left; }
#ovStats .r { display: grid; grid-template-columns: 1fr 70px 60px 70px; gap: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,0.05); }
#ovStats .r.h { background: none; color: var(--dim); font-size: 12px; }

.nametag { font: 600 13px var(--font); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5); white-space: nowrap; text-align: center; pointer-events: none; }
.nametag .st { display: block; font-size: 11px; opacity: .85; }
.nametag .bubble { display: block; background: rgba(255,255,255,0.92); color: #112; padding: 4px 10px; border-radius: 12px; margin-bottom: 4px; max-width: 220px; white-space: normal; font-weight: 400; text-shadow: none; }
.pinglbl { font: 800 14px var(--title); color: #fff; text-shadow: 0 0 10px currentColor, 0 2px 4px #000; pointer-events: none; text-align: center; }
.pinglbl small { display: block; font: 400 11px var(--font); }

@media (max-width: 760px) {
  #altbar { display: none; }
  .hud-tl { min-width: 0; max-width: 46vw; }
}
