* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #141824; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #e5e7eb; user-select: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }
.muted { color: #94a3b8; }
.small { font-size: 12px; }
kbd { background: #1f2937; border: 1px solid #475569; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; color: #e5e7eb; }

#hud { position: fixed; inset: 0; pointer-events: none; }
.glass { background: rgba(10,14,24,.6); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; }
#lb { position: absolute; right: 12px; top: 12px; width: 220px; background: rgba(10,14,24,.6); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 8px 12px; }
#lb h3 { margin: 0 0 6px; font-size: 15px; text-align: center; color: #38bdf8; }
#lb ol { margin: 0; padding-left: 22px; font-size: 13px; }
#lb li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lb li .c { color: #64748b; font-size: 11px; }
#lb li.me { color: #fbbf24; font-weight: 600; }
#minimap { position: absolute; right: 12px; bottom: 12px; width: 170px; height: 170px; background: rgba(10,14,24,.92); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; }

#classes { position: absolute; left: 12px; top: 12px; pointer-events: auto; background: rgba(10,14,24,.7); border: 1px solid rgba(56,189,248,.4); border-radius: 12px; padding: 10px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { border-color: rgba(56,189,248,.95); } }
#classes .ttl, #stats .ttl { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: #38bdf8; }
#classList { display: grid; grid-template-columns: repeat(2, 104px); gap: 8px; }
.cls { cursor: pointer; background: #1e293b; border: 2px solid #334155; border-radius: 10px; padding: 4px; text-align: center; font-size: 12px; font-weight: 600; }
.cls:hover { border-color: #38bdf8; background: #263449; }
.cls canvas { width: 92px; height: 70px; display: block; margin: 0 auto; }

#stats { position: absolute; left: 12px; bottom: 12px; width: 250px; pointer-events: auto; background: rgba(10,14,24,.9); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 8px 10px; }
#points { color: #fbbf24; }
.st { display: flex; align-items: center; gap: 6px; height: 21px; margin-top: 3px; cursor: pointer; opacity: .55; }
.st.can { opacity: 1; }
.st .k { width: 14px; font-size: 11px; color: #64748b; text-align: center; }
.st .n { width: 112px; font-size: 12px; white-space: nowrap; }
.st .segs { flex: 1; display: flex; gap: 2px; height: 12px; }
.st .segs i { flex: 1; background: #1f2937; border-radius: 2px; }
.st .segs i.on { background: var(--c); }
.st .plus { width: 20px; height: 18px; border-radius: 4px; background: var(--c); color: #0b1220; font-weight: 800; font-size: 14px; line-height: 18px; text-align: center; visibility: hidden; }
.st.can .plus { visibility: visible; }

#bottom { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(420px, 50vw); text-align: center; }
#nameTag { font-size: 22px; font-weight: 800; text-shadow: 0 2px 4px #000; margin-bottom: 4px; }
.bar { position: relative; height: 20px; background: rgba(10,14,24,.7); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; overflow: hidden; }
#xpFill { height: 100%; width: 0; background: linear-gradient(90deg, #0ea5e9, #38bdf8); transition: width .2s; }
#lvlText { position: absolute; inset: 0; font-size: 13px; font-weight: 700; line-height: 20px; text-shadow: 0 1px 2px #000; }
#hint { font-size: 12px; margin-top: 4px; }

#chat { position: fixed; left: 12px; bottom: 250px; width: min(360px, 60vw); pointer-events: none; }
#chatLog { font-size: 13px; max-height: 180px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
#chatLog div { background: rgba(10,14,24,.55); padding: 2px 8px; border-radius: 6px; margin-top: 3px; width: fit-content; max-width: 100%; word-wrap: break-word; animation: fade 12s forwards; }
#chatLog div.admin { background: rgba(220,38,38,.85); font-weight: 600; animation-duration: 25s; }
#chatLog b { margin-right: 4px; }
@keyframes fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
#chatInput { pointer-events: auto; width: 100%; margin-top: 6px; padding: 7px 10px; border-radius: 8px; border: none; background: rgba(10,14,24,.75); color: #fff; outline: none; opacity: 0; font-size: 14px; }
#chatInput.open { opacity: 1; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5,8,15,.55); backdrop-filter: blur(3px); }
.panel { background: #0f172a; border: 1px solid #1e293b; border-radius: 16px; padding: 28px 30px; width: min(400px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: center; }
.panel h1 { margin: 0 0 4px; font-size: 40px; letter-spacing: -1px; color: #38bdf8; }
.panel h2 { margin: 6px 0 2px; color: #f87171; font-size: 20px; }
.panel input#name { width: 100%; padding: 12px 14px; font-size: 18px; border-radius: 10px; border: 2px solid #1e293b; background: #020617; color: #fff; margin: 14px 0 10px; outline: none; }
.panel input#name:focus { border-color: #38bdf8; }
.hueRow { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #cbd5e1; margin-bottom: 14px; }
.hueRow input { flex: 1; accent-color: #38bdf8; }
#huePreview { width: 26px; height: 26px; border-radius: 50%; display: inline-block; border: 3px solid rgba(0,0,0,.4); }
#play { width: 100%; padding: 12px; font-size: 18px; font-weight: 700; border: none; border-radius: 10px; background: #0ea5e9; color: #fff; cursor: pointer; }
#play:disabled { background: #475569; cursor: default; }
#play:not(:disabled):hover { background: #0284c7; }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 16px; font-size: 13px; color: #94a3b8; text-align: left; }

@media (max-height: 700px) { #stats { transform: scale(.85); transform-origin: bottom left; } #chat { bottom: 215px; } }
