:root {
  --ink: #f4f1ff; --muted: #b8aedb; --bg: #1b1530; --panel: rgba(27, 21, 48, 0.86); --line: rgba(255, 255, 255, 0.14);
  --gold: #f2c14d; --pink: #f05d8a; --violet: #9a7cf0; --mint: #7cc48a;
  --common: #b8aedb; --rare: #6fb6ff; --epic: #c58bff; --legendary: #ffcf3f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
body[data-screen="locker"] #view { visibility: hidden; }

.screen { position: fixed; inset: 0; overflow: auto; padding: 16px; }
#menu { display: flex; flex-direction: column; background: linear-gradient(180deg, rgba(27,21,48,0.75), rgba(27,21,48,0.05) 45%, rgba(27,21,48,0.8)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-weight: 800; letter-spacing: 0.02em; font-size: 18px; }
#me { display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); }
.lvl { color: var(--gold); }
.xpbar { width: 90px; height: 7px; background: rgba(255,255,255,0.12); border-radius: 9px; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--pink)); transition: width 1.2s ease; }
.xpbar.big { width: 100%; height: 12px; margin: 6px 0 2px; }
.hero { margin: auto 0; max-width: 560px; padding: 8px 4px; }
.hero h1 { font-size: clamp(44px, 9vw, 88px); line-height: 0.95; margin: 0 0 6px; letter-spacing: -0.02em; text-shadow: 0 4px 0 #5b3f6e, 0 0 40px rgba(240, 93, 138, 0.45); }
.hero .tagline { font-size: 19px; margin: 0 0 18px; color: #ffe6f0; text-shadow: 0 2px 8px #000; }
.menu-buttons { display: grid; gap: 10px; max-width: 380px; }
.bigbtn { display: block; text-align: left; width: 100%; border: 0; border-radius: 16px; padding: 14px 18px; font-weight: 800; font-size: 20px; background: linear-gradient(180deg, #ff7aa6, var(--pink)); box-shadow: 0 5px 0 #a8355f, 0 10px 24px rgba(0,0,0,0.35); color: #fff; transition: transform 0.08s; }
.bigbtn small { display: block; font-weight: 500; font-size: 13px; opacity: 0.9; }
.bigbtn.alt { background: linear-gradient(180deg, #b49bff, var(--violet)); box-shadow: 0 5px 0 #5b4a9a, 0 10px 24px rgba(0,0,0,0.35); }
.bigbtn.alt2 { background: linear-gradient(180deg, #ffd978, var(--gold)); color: #3a2a10; box-shadow: 0 5px 0 #a87a1c, 0 10px 24px rgba(0,0,0,0.35); }
.bigbtn:active { transform: translateY(3px); }
.ghostbtn { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
.ghostbtn:hover { background: rgba(255,255,255,0.16); }
.ghostbtn.small { padding: 4px 10px; font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0 4px; }
.opt { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: #eee; text-shadow: 0 1px 4px #000; }
.opt input[type="text"], .opt input:not([type]) , #name { background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; color: var(--ink); width: 180px; }
.note { color: #ffe0ea; text-shadow: 0 1px 4px #000; max-width: 520px; font-size: 14px; }
.note a { color: var(--gold); }
.foot { font-size: 13px; color: var(--muted); max-width: 760px; text-shadow: 0 1px 4px #000; }

.panel { max-width: 640px; margin: 4vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px; backdrop-filter: blur(6px); }
.panel.wide { max-width: 980px; }
.panel h2 { margin: 0 0 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; align-items: center; }
.row .bigbtn { width: auto; flex: 1 1 200px; }
.join input { background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ink); width: 120px; letter-spacing: 0.2em; text-transform: uppercase; }
.code { font-family: ui-monospace, monospace; color: var(--gold); letter-spacing: 0.15em; }
.list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.list li { background: rgba(255,255,255,0.06); border-radius: 10px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #touch { pointer-events: auto; }
.hud-top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; justify-content: space-between; font-weight: 800; text-shadow: 0 2px 6px #000, 0 0 2px #000; font-size: 17px; }
#hud-big { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-size: clamp(40px, 10vw, 110px); font-weight: 900; color: #fff; text-shadow: 0 6px 0 var(--pink), 0 0 30px rgba(0,0,0,0.6); opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.15s; }
#hud-big.on { opacity: 1; transform: scale(1); }
#hud-big.small { font-size: clamp(26px, 5vw, 54px); top: 12%; }
#hud-blurb { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); max-width: min(620px, 92vw); text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; opacity: 0; transition: opacity 0.3s; }
#hud-blurb.on { opacity: 1; }
#hud-blurb b { display: block; font-size: 26px; color: var(--gold); }
#hud-seats { position: absolute; top: 44px; left: 0; right: 0; display: flex; justify-content: space-around; }
.seat { background: var(--panel); border-radius: 999px; padding: 4px 14px; font-weight: 800; color: var(--gold); }
#hud-feed { position: absolute; right: 16px; top: 48px; text-align: right; font-weight: 700; text-shadow: 0 2px 4px #000; }
#hud-feed div { color: #ffd0e0; }
#hud-help { position: absolute; bottom: 10px; left: 16px; font-size: 13px; color: #ddd; text-shadow: 0 1px 3px #000; }
#hud-leave { position: absolute; bottom: 10px; right: 16px; }
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#tags div { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.tag { margin-left: -40px; width: 80px; text-align: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; }
.tag.me { color: var(--gold); }
.word { margin-left: -60px; width: 120px; text-align: center; font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 3px 0 #5b3f6e, 0 0 8px #000; }
.word.wipe { color: #8affc1; font-size: 28px; }
.word.through { color: var(--gold); font-size: 26px; }
.word.poof { color: #ffd0e0; }
#touch { position: absolute; inset: 0; }
#touch-stick { position: absolute; left: 0; top: 30%; bottom: 0; width: 50%; }
#touch button { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); background: rgba(240, 93, 138, 0.55); font-weight: 900; color: #fff; }
#touch-jump { right: 24px; bottom: 34px; width: 92px; height: 92px; }
#touch-dive { right: 128px; bottom: 22px; width: 70px; height: 70px; background: rgba(154, 124, 240, 0.6) !important; }
#touch-emote { right: 40px; bottom: 140px; width: 52px; height: 52px; background: rgba(242, 193, 77, 0.55) !important; }

/* results */
#results { background: rgba(14, 10, 28, 0.6); }
.res-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
@media (max-width: 760px) { .res-grid { grid-template-columns: 1fr; } }
.places { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 52vh; overflow: auto; }
.places li { display: flex; gap: 8px; align-items: baseline; padding: 5px 10px; border-radius: 9px; background: rgba(255,255,255,0.05); font-size: 15px; }
.places li.me { background: rgba(242, 193, 77, 0.22); border: 1px solid rgba(242,193,77,0.5); }
.places li.human b { color: #ffd0e0; }
.pl { width: 38px; font-weight: 900; color: var(--gold); }
.xpbig { font-size: 44px; font-weight: 900; color: var(--gold); text-shadow: 0 3px 0 #8a5a00; }
.breakdown { list-style: none; padding: 0; margin: 4px 0 10px; font-size: 14px; }
.breakdown li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.up { color: #8affc1; font-size: 20px; }
.cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.cards h3 { width: 100%; margin: 4px 0 0; }
.card { position: relative; width: 150px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.07); border: 2px solid var(--common); display: flex; flex-direction: column; gap: 2px; animation: pop 0.6s cubic-bezier(.2,1.6,.4,1) both; }
.card.rare { border-color: var(--rare); } .card.epic { border-color: var(--epic); box-shadow: 0 0 18px rgba(197,139,255,0.4); } .card.legendary { border-color: var(--legendary); box-shadow: 0 0 26px rgba(255,207,63,0.55); }
.card .slot { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.1em; }
.card .why { font-size: 12px; color: #ffd0e0; }
@keyframes pop { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.challenges li { font-size: 14px; }
.challenges li.done { opacity: 0.6; }
.challenges li.just { background: rgba(138, 255, 193, 0.18); border: 1px solid #8affc1; }
.prog { margin-left: auto; font-weight: 800; color: var(--gold); }
.reward { font-size: 12px; color: #ffd0e0; }

/* locker */
#locker { padding: 0; background: radial-gradient(ellipse at 30% 40%, #3b2a66, #140f26 70%); }
.locker { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 480px); height: 100%; }
@media (max-width: 820px) { .locker { grid-template-columns: 1fr; grid-template-rows: 44vh auto; height: auto; } }
.locker-stage { position: relative; min-height: 300px; }
#locker-view { width: 100%; height: 100%; display: block; cursor: grab; }
.locker-level { position: absolute; left: 16px; top: 16px; background: var(--panel); padding: 8px 14px; border-radius: 14px; border: 1px solid var(--line); }
.locker-level .xpbar { width: 160px; margin: 4px 0; }
#lk-emote { position: absolute; left: 16px; bottom: 16px; }
.locker-side { background: var(--panel); border-left: 1px solid var(--line); padding: 16px; overflow: auto; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tabs button { border: 1px solid var(--line); background: rgba(255,255,255,0.06); border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.tabs button.on { background: var(--violet); border-color: var(--violet); font-weight: 700; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.item { text-align: left; border: 2px solid var(--common); background: rgba(255,255,255,0.06); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-height: 120px; }
.item.rare { border-color: var(--rare); } .item.epic { border-color: var(--epic); } .item.legendary { border-color: var(--legendary); }
.item.on { background: rgba(242, 193, 77, 0.22); box-shadow: 0 0 0 2px var(--gold) inset; }
.item.locked { opacity: 0.55; filter: grayscale(0.5); }
.item .r { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.item .how { font-size: 12px; color: #e6dcff; }
.sw { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 30px; border-radius: 8px; font-size: 20px; margin-bottom: 4px; border: 1px solid var(--line); overflow: hidden; }
.sw.none { background: repeating-linear-gradient(45deg, #333 0 4px, #555 4px 8px) !important; }
.sw img { width: 100%; height: 100%; object-fit: cover; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); background: #2b2148; border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; opacity: 0; transition: 0.25s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
