@font-face { font-family: "Lilita One"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/lilita-one.woff2) format("woff2"); }
@font-face { font-family: "Rubik"; font-style: normal; font-weight: 300 900; font-display: swap; src: url(fonts/rubik.woff2) format("woff2"); }
:root {
  --bg: #0a0620;
  --pink: #ff3d81;
  --cyan: #35e8ff;
  --yellow: #ffe14a;
  --purple: #b06bff;
  --glass: rgba(22, 13, 58, 0.74);
  --line: rgba(255, 255, 255, 0.14);
  --display: "Lilita One", "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #fff; font-family: var(--body); overflow: hidden; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input { font-family: inherit; }
kbd { display: inline-block; min-width: 1.7em; padding: 2px 7px; margin: 0 2px; text-align: center; font: 700 0.82em var(--body); color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28); border-bottom-width: 3px; border-radius: 7px; }

/* ---------- shared bits ---------- */
.card { background: var(--glass); border: 1px solid var(--line); border-radius: 22px; padding: 14px 18px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.card.centered { text-align: center; }
.card label, .small-label { display: block; margin: 9px 0 5px; font-size: 11px; font-weight: 700; letter-spacing: .14em; color: #b9b2e6; text-transform: uppercase; }
.card label:first-child { margin-top: 0; }
.hint { color: #c9c3f0; font-size: 14px; line-height: 1.45; margin: 6px 0 14px; }
.err { color: #ff8aa8; font-weight: 700; font-size: 14px; margin: 10px 2px 0; }
h2 { font: 400 34px/1.1 var(--display); margin: 0 0 4px; letter-spacing: .02em; text-shadow: 0 0 22px rgba(53,232,255,.45); }

.btn {
  appearance: none; border: 2px solid rgba(255,255,255,.22); background: rgba(255,255,255,.1); color: #fff;
  font: 700 17px var(--body); padding: 12px 20px; border-radius: 999px; transition: transform .12s, background .12s, box-shadow .12s, border-color .12s;
}
.btn:hover { background: rgba(255,255,255,.2); transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--pink), #ff8a2b); border-color: rgba(255,255,255,.55); box-shadow: 0 6px 26px rgba(255,61,129,.5); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.primary:hover { box-shadow: 0 10px 34px rgba(255,61,129,.7); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #d6d0fa; }
.btn.big { font-size: 20px; padding: 12px 26px; }
.btn.small { font-size: 14px; padding: 8px 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btns { display: flex; flex-direction: column; gap: 9px; margin-top: 13px; }

/* ---------- menu ---------- */
#menu { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(90deg, rgba(10,6,32,.9) 0%, rgba(10,6,32,.62) 38%, rgba(10,6,32,0) 68%); overflow-y: auto; touch-action: pan-y; }
.menu-inner { width: min(460px, 100%); margin-left: clamp(0px, 5vw, 90px); }
.menu-foot { position: fixed; left: 0; right: 0; bottom: calc(8px + var(--safe-b)); text-align: center; font-size: 12px; color: #8f87c4; pointer-events: none; }
.screen { display: none; animation: rise .35s cubic-bezier(.2,.9,.3,1.2); }
.screen.on { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

.logo { margin: 0; font: 400 clamp(46px, min(14vw, 11.5vh), 94px)/.9 var(--display); letter-spacing: .01em; transform: skew(-6deg); display: flex; flex-direction: row; gap: .22em; flex-wrap: wrap; }
.logo span:nth-child(1) { color: #fff; text-shadow: 0 0 10px var(--cyan), 0 0 34px var(--cyan), 0 5px 0 #1a8fa0; }
.logo span:nth-child(2) { color: #fff; text-shadow: 0 0 10px var(--pink), 0 0 34px var(--pink), 0 5px 0 #a3194d; animation: flick 6s infinite; }
@keyframes flick { 0%, 92%, 96%, 100% { opacity: 1; } 93% { opacity: .55; } 95% { opacity: .85; } }
.tagline { margin: 8px 0 12px; font-size: 17px; font-weight: 500; color: #e6e1ff; }

input#name, input#code, .invite {
  width: 100%; padding: 9px 14px; border-radius: 14px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.28); color: #fff; font: 700 18px var(--body); outline: none; user-select: text; -webkit-user-select: text;
}
input#name:focus, input#code:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(53,232,255,.25); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 33px; height: 33px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); cursor: pointer; transition: transform .12s; padding: 0; }
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: #fff; transform: scale(1.14); box-shadow: 0 0 0 3px rgba(255,255,255,.25), 0 0 18px currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 9px; border-radius: 999px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); font-weight: 700; font-size: 12.5px; }
.chip.on { background: var(--cyan); color: #06222a; border-color: #fff; }

.diffs { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 6px; }
.diff { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 13px 16px; border-radius: 18px; border: 2px solid rgba(255,255,255,.18); background: var(--glass); backdrop-filter: blur(10px); }
.diff b { font: 400 22px var(--display); }
.diff span { font-size: 13px; color: #c1bbe8; }
.diff.on { border-color: var(--cyan); background: rgba(53,232,255,.16); box-shadow: 0 0 22px rgba(53,232,255,.25); }

.invite-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; border-color: var(--cyan); box-shadow: 0 0 26px rgba(53,232,255,.3); padding: 10px 14px; }
.invite-text { font-weight: 700; }
.invite-text b { font: 400 22px var(--display); letter-spacing: .12em; color: var(--yellow); margin-left: 4px; }
.invite-card .err { flex-basis: 100%; margin: 0; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: #9a92cc; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.joinrow { display: flex; gap: 10px; }
input#code { text-transform: uppercase; letter-spacing: .35em; text-align: center; font: 400 28px var(--display); }

.howto .goal { margin: 0 0 12px; font-size: 15px; line-height: 1.5; }
.keys { display: grid; gap: 8px; font-size: 14px; }
.keys span { color: #cfc9f5; margin-left: 6px; }
.howto .small { font-size: 13px; color: #b9b2e6; margin: 12px 0 6px; }
.rules { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: #d9d4fa; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { position: absolute; }
#top { top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); font-size: 13px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.pill b { font: 400 17px var(--display); letter-spacing: .03em; color: var(--yellow); }
.pill.small { padding: 7px 13px; }
.pill.small b { color: #fff; }
#timer { font-variant-numeric: tabular-nums; min-width: 62px; justify-content: center; }

#board { top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); width: 190px; display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; background: rgba(14, 8, 40, .66); border: 1px solid rgba(255,255,255,.1); font-size: 14px; font-weight: 700; }
.row.me { border-color: rgba(255,255,255,.55); background: rgba(40, 24, 96, .8); }
.row.out { opacity: .5; }
.row i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sc { font: 400 17px var(--display); color: var(--yellow); }
.row .sk { font-size: 13px; }

#feed { top: calc(58px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.feeditem { padding: 6px 12px; border-radius: 12px; background: rgba(14, 8, 40, .72); border: 1px solid rgba(255,255,255,.12); font-size: 14px; font-weight: 700; animation: feedin .25s ease-out, feedout .4s ease-in 3.6s forwards; }
@keyframes feedin { from { transform: translateX(40px); opacity: 0; } }
@keyframes feedout { to { opacity: 0; transform: translateY(-6px); } }

#banner { top: 24%; left: 0; right: 0; text-align: center; font: 400 clamp(54px, 12vw, 130px)/1 var(--display); letter-spacing: .02em; color: #fff;
  text-shadow: 0 0 18px var(--pink), 0 0 50px var(--pink), 0 6px 0 rgba(0,0,0,.35); -webkit-text-stroke: 2px rgba(0,0,0,.25); }
#banner.pop { animation: pop .55s cubic-bezier(.2,1.5,.4,1); }
#banner.small { font-size: clamp(34px, 6.5vw, 72px); text-shadow: 0 0 16px var(--cyan), 0 0 40px var(--cyan), 0 5px 0 rgba(0,0,0,.35); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#subbanner { top: calc(24% + clamp(70px, 14vw, 140px)); left: 0; right: 0; text-align: center; font-size: clamp(15px, 2.4vw, 22px); font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.8); padding: 0 16px; }
#ffnote { top: calc(54px + var(--safe-t)); left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: rgba(255,225,74,.9); color: #2a1d00; font-weight: 700; font-size: 13px; }

#topright { top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 8px; align-items: center; pointer-events: auto; }
#pingbadge { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: #9dffb0; }
#pingbadge.bad { color: #ff9a9a; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); font-size: 18px; padding: 0; backdrop-filter: blur(8px); }
.icon-btn.off { opacity: .45; }
.icon-btn:hover { background: rgba(255,255,255,.2); }

#bottom { bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; }
#dashmeter { position: relative; width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--cyan) calc(var(--p, 1) * 360deg), rgba(255,255,255,.14) 0); }
#dashmeter i { position: absolute; inset: 6px; border-radius: 50%; background: #120a34; }
#dashmeter span { position: relative; font: 400 14px var(--display); letter-spacing: .06em; color: #fff; }
#dashmeter.ready { box-shadow: 0 0 22px rgba(53,232,255,.7); }
#dashmeter:not(.ready) span { opacity: .55; }
#buffs { display: flex; gap: 8px; }
.buff { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--glass); border: 2px solid var(--c, #fff); font: 400 17px var(--display); }
.buff small { font: 700 13px var(--body); font-variant-numeric: tabular-nums; }

#emotes { bottom: calc(18px + var(--safe-b)); right: calc(14px + var(--safe-r)); display: flex; gap: 6px; pointer-events: auto; }
#emotes button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); font-size: 21px; padding: 0; }
#emotes button:hover { transform: scale(1.12); background: rgba(255,255,255,.2); }

#specbar { bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-weight: 700; white-space: nowrap; pointer-events: auto; }
#specbar b { color: var(--yellow); }
#specbar small { color: #b9b2e6; font-weight: 500; }

#hint { bottom: calc(100px + var(--safe-b)); left: 50%; transform: translateX(-50%); padding: 9px 18px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); font-weight: 700; font-size: 15px; text-align: center; animation: feedin .4s ease-out; }
#hint.fade { opacity: 0; transition: opacity .8s; }
body.touch #hint { bottom: calc(130px + var(--safe-b)); }

/* touch controls */
#joy, .tbtn { display: none; }
body.touch #joy.on { display: block; }
body.touch .tbtn { display: grid; }
#joy { position: fixed; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.3); }
#joy-knob { position: absolute; left: 36px; top: 36px; width: 58px; height: 58px; border-radius: 50%; background: rgba(53,232,255,.7); box-shadow: 0 0 20px rgba(53,232,255,.8); }
.tbtn { place-items: center; pointer-events: auto; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: rgba(255, 61, 129, .55); backdrop-filter: blur(4px);
  font: 400 19px var(--display); letter-spacing: .05em; color: #fff; padding: 0; touch-action: none; }
.tbtn.down { transform: scale(.9); background: rgba(255, 61, 129, .85); }
#btn-jump { right: calc(20px + var(--safe-r)); bottom: calc(28px + var(--safe-b)); width: 96px; height: 96px; }
#btn-dash { right: calc(128px + var(--safe-r)); bottom: calc(60px + var(--safe-b)); width: 80px; height: 80px; background: rgba(53,232,255,.45); }
#btn-dash.down { background: rgba(53,232,255,.85); }
body.touch #emotes { bottom: auto; top: calc(62px + var(--safe-t)); right: calc(10px + var(--safe-r)); flex-direction: column; }
body.touch #emotes button { width: 38px; height: 38px; font-size: 19px; }
body.touch #feed { right: auto; left: 50%; transform: translateX(-50%); align-items: center; top: calc(50px + var(--safe-t)); }
body.touch #bottom { left: calc(16px + var(--safe-l)); transform: none; bottom: calc(18px + var(--safe-b)); }
body.touch #specbar { bottom: calc(130px + var(--safe-b)); }
body.touch #board { width: 150px; }
body.touch .row { font-size: 12px; padding: 3px 8px; }

/* ---------- lobby ---------- */
#lobby { position: fixed; left: calc(18px + var(--safe-l)); top: 50%; transform: translateY(-50%); width: min(390px, calc(100vw - 36px)); z-index: 6; max-height: calc(100vh - 24px); overflow-y: auto; touch-action: pan-y; }
.lobby-card { background: var(--glass); border: 1px solid var(--line); border-radius: 24px; padding: 18px 20px; backdrop-filter: blur(14px); box-shadow: 0 14px 50px rgba(0,0,0,.45); }
.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.lobby-share { display: flex; flex-direction: column; gap: 6px; }
#roomcode { font: 400 52px/1 var(--display); letter-spacing: .14em; color: #fff; text-shadow: 0 0 22px var(--cyan); }
.invite { margin-top: 10px; font-size: 13px !important; padding: 8px 10px !important; }
#plist { list-style: none; margin: 6px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
#plist li { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-radius: 12px; background: rgba(0,0,0,.25); font-weight: 700; }
#plist li i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
#plist li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#plist li small { color: #b9b2e6; font-weight: 500; }
.seg { display: flex; border: 2px solid rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.seg button { flex: 1; padding: 8px 4px; border: 0; background: transparent; font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--cyan); color: #06222a; }
.seg.locked button { pointer-events: none; }
.lobby-actions { display: flex; gap: 10px; }
.lobby-actions .primary { flex: 1; }
#lobby .hint { margin: 12px 0 0; font-size: 13px; }

/* ---------- results / pause ---------- */
#results { position: fixed; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(10,6,32,.55), rgba(10,6,32,.88)); overflow-y: auto; touch-action: pan-y; }
#results .card { width: min(520px, 100%); animation: rise .45s cubic-bezier(.2,.9,.3,1.2); }
#results h2 { text-align: center; font-size: 44px; }
#results .crown { text-align: center; font-size: 46px; margin-bottom: 2px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(4deg); } }
.standings { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 4px; }
.standings .st { display: grid; grid-template-columns: 34px 14px 1fr auto auto; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 14px; background: rgba(0,0,0,.28); font-weight: 700; }
.standings .st.first { background: linear-gradient(90deg, rgba(255,225,74,.28), rgba(255,61,129,.2)); border: 1px solid rgba(255,225,74,.6); }
.standings .st.me { outline: 2px solid rgba(255,255,255,.5); }
.standings .rk { font: 400 22px var(--display); color: var(--yellow); text-align: center; }
.standings i { width: 14px; height: 14px; border-radius: 50%; }
.standings .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings .ko { color: #c9c3f0; font-size: 13px; font-weight: 500; }
.standings .pts { font: 400 22px var(--display); }
#results .btns { flex-direction: row; justify-content: center; flex-wrap: wrap; }
#results .wait { text-align: center; color: #c9c3f0; font-size: 14px; margin-top: 12px; }

.overlay { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(10,6,32,.7); padding: 16px; }
.overlay .card { width: min(380px, 100%); }
.overlay .btns { margin-top: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(20px); padding: 10px 18px; border-radius: 999px; background: rgba(20, 12, 54, .94); border: 1px solid var(--line); font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 99; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  #menu { justify-content: flex-end; background: linear-gradient(0deg, rgba(10,6,32,.94) 0%, rgba(10,6,32,.8) 55%, rgba(10,6,32,0) 100%); padding-bottom: calc(34px + var(--safe-b)); }
  .menu-inner { margin: 0 auto; max-height: 68vh; overflow-y: auto; }
  .tagline { font-size: 15px; margin: 6px 0 10px; }
  .btn.big { font-size: 18px; padding: 12px 20px; }
  #roomcode { font-size: 40px; }
  #lobby { left: 50%; top: auto; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); max-height: 62vh; }
  #top .pill:first-child { padding: 6px 11px; font-size: 11px; }
  #top .pill b { font-size: 14px; }
}
@media (max-height: 520px) {
  #menu { justify-content: center; background: linear-gradient(90deg, rgba(10,6,32,.92) 0%, rgba(10,6,32,.6) 45%, rgba(10,6,32,0) 70%); padding-bottom: 14px; }
  .menu-inner { max-height: 100%; overflow-y: auto; margin-left: 0; }
  .menu-foot { display: none; }
  #banner { top: 14%; }
  #lobby { top: 50%; bottom: auto; left: calc(10px + var(--safe-l)); transform: translateY(-50%); max-height: calc(100vh - 16px); width: 330px; }
  #roomcode { font-size: 36px; }
  .btns { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
