:root {
  --bg: #07060f;
  --panel: rgba(14, 12, 30, 0.86);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f1eefc;
  --muted: #a49fc4;
  --accent: #ff6ad5;
  --accent2: #6ee26e;
  --err: #ff7a7a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Rubik, system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.playing { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
canvas#game, canvas#ui, canvas#td3d { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
canvas#game { background: #000; }
canvas#ui { pointer-events: none; z-index: 1; }
.hidden { display: none !important; }

.panel-screen { position: fixed; inset: 0; z-index: 3; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.panel { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0,0,0,.5); margin: auto; }
.logo { font-family: Orbitron, sans-serif; font-weight: 900; font-size: clamp(28px, 8vw, 44px); letter-spacing: 3px; margin: 0 0 6px; text-align: center;
  background: linear-gradient(90deg, #6ee26e, #9feaff, #ff6ad5, #ffe23a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(255,106,213,.35)); }
.tag { text-align: center; color: var(--muted); margin: 0 0 18px; }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input { width: 100%; margin-top: 6px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select { width: 100%; margin-top: 6px; background: #1b1830; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px; font: inherit; font-size: 15px; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
@media (max-width: 480px) { .picks { grid-template-columns: 1fr; } }
#pick-info { margin: -4px 0 4px; min-height: 1.2em; }
#net { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 6; background: #b3203a; color: #fff; font-weight: 700; padding: 8px 16px; border-radius: 0 0 12px 12px; font-size: 14px; }
.row { display: flex; gap: 10px; margin: 10px 0; align-items: stretch; }
.row > * { flex: 1; }
.code-input { margin-top: 0; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-family: Orbitron, sans-serif; }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--text); border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: rgba(255,255,255,.15); }
.btn.primary { background: linear-gradient(90deg, #8a3dff, #ff4fc1); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.small-btn { padding: 8px 12px; font-size: 14px; }
.btn.small { padding: 7px 12px; font-size: 13px; display: block; margin: 0 auto 10px; }
.err { color: var(--err); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.how { margin: 12px 0; color: var(--muted); font-size: 14px; }
.how summary { cursor: pointer; color: var(--text); font-weight: 600; }
.how ul { padding-left: 18px; line-height: 1.5; }
.board h3, .panel h3 { margin: 16px 0 8px; font-size: 15px; }
.board ol { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.6; }
.board li span { color: var(--muted); }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .boards { grid-template-columns: 1fr; } }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode { display: flex; flex-direction: column; gap: 3px; text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); border-radius: 10px; padding: 9px 10px; font: inherit; cursor: pointer; }
.mode b { font-size: 14px; }
.mode span { font-size: 11px; color: var(--muted); line-height: 1.3; }
.mode.sel { border-color: var(--accent); background: rgba(255,106,213,.16); box-shadow: 0 0 0 1px var(--accent) inset; }
.mode:disabled { cursor: default; }
.mode:disabled:not(.sel) { opacity: .5; }
#win-title { font-size: clamp(24px, 7vw, 40px); }
.room-code { font-family: Orbitron, sans-serif; font-size: 44px; overflow-wrap: anywhere; text-align: center; letter-spacing: 10px; margin: 4px 0 10px; }
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.04); margin-bottom: 6px; }
.swatch { width: 16px; height: 16px; border-radius: 5px; flex: none; }
.players .dim { margin-left: auto; font-size: 13px; }

#hud { position: fixed; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); pointer-events: none; font-size: 14px; z-index: 2; }
#hud-level { pointer-events: auto; cursor: pointer; }
#hud-level { position: absolute; left: 16px; top: 12px; max-width: min(460px, 60vw); background: rgba(0,0,0,.45); padding: 10px 14px; border-radius: 12px; }
#lvl-name { font-family: Orbitron, sans-serif; font-weight: 900; font-size: 16px; }
#lvl-obj { color: #ddd; margin-top: 4px; line-height: 1.35; display: none; }
#hud-level.open #lvl-obj { display: block; }
#hud-level:not(.open)::after { content: 'click for goal'; display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
#lvl-progress { color: #ffe23a; margin-top: 4px; font-weight: 600; }
#hud-players { position: absolute; right: 16px; top: 12px; list-style: none; margin: 0; padding: 8px 12px; background: rgba(0,0,0,.45); border-radius: 12px; }
#hud-players li { display: flex; gap: 8px; align-items: center; line-height: 1.7; font-size: 13px; }
#hud-dim { position: absolute; right: 16px; bottom: 14px; text-align: right; background: rgba(0,0,0,.45); padding: 10px 14px; border-radius: 12px; max-width: min(380px, 70vw); }
#dim-name { font-family: Orbitron, sans-serif; font-weight: 900; font-size: 18px; }
#dim-desc { color: #ddd; font-size: 13px; margin-top: 2px; }
#hearts { margin-top: 4px; font-size: 18px; letter-spacing: 2px; }
#hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
#hint:empty { display: none; }

#toasts { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.toast { background: rgba(10,8,24,.85); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; font-weight: 800; font-size: 18px; animation: toast 2.6s forwards; text-align: center; }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px) scale(.95); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }

#fs { position: absolute; right: 16px; bottom: 14px; pointer-events: auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 18px; display: none; }
.touch #fs { display: block; right: auto; left: 50%; top: 8px; bottom: auto; transform: translateX(-50%); width: 34px; height: 34px; font-size: 15px; opacity: .8; }

#touch { position: fixed; inset: 0; z-index: 2; pointer-events: none; touch-action: none; }
/* left half: a joystick that is always visible and jumps to wherever your thumb lands */
#stick-zone { position: absolute; left: 0; top: 28%; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
.stick-tip { position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); color: rgba(255,255,255,.45); font-size: 11px; font-weight: 700; }
#stick-base { position: fixed; left: 0; top: 0; width: 132px; height: 132px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); background: rgba(255,255,255,.1);
  opacity: .55; pointer-events: none; transition: opacity .12s; }
#stick-base.on { opacity: 1; }
#stick-base { transition: opacity .15s; will-change: transform; }
#stick-knob { will-change: transform; position: absolute; left: 38px; top: 38px; width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.6); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
/* right half: tap anywhere to jump */
#jump-zone { position: absolute; right: 0; top: 28%; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
.jump-hint { position: absolute; right: max(26px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); background: rgba(138,61,255,.35); color: #fff; font-size: 38px; font-weight: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }
.jump-hint small, .tb small { font-size: 9px; font-weight: 800; letter-spacing: .5px; opacity: .85; margin-top: 2px; }
#jump-zone.down .jump-hint { background: rgba(138,61,255,.7); transform: scale(.94); }
#tbtns { position: absolute; right: max(140px, calc(env(safe-area-inset-right) + 140px)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.tb { width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.16); color: #fff; font-size: 26px; font-weight: 800;
  touch-action: none; user-select: none; -webkit-user-select: none; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.tb.small { width: 52px; height: 52px; font-size: 18px; }
#tb-fire { background: rgba(255,79,193,.45); }
#tb-dash { background: rgba(255,255,255,.3); }
.tb.chip { font-size: 11px; font-weight: 900; background: rgba(0,0,0,.35); color: rgba(255,255,255,.6); }
.tb.chip.on { background: rgba(57,255,136,.4); color: #fff; border-color: #39ff88; }
.tb.down { background: rgba(255,255,255,.45); transform: scale(.94); }

#rotate { display: none; position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 4; background: rgba(10,8,24,.88); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; pointer-events: none; animation: toast 5s forwards; }
@media (orientation: portrait) { .touch.playing #rotate { display: block; } }

/* compact HUD on phones and small screens */
.touch #lvl-obj { display: none; }
.touch #hud-level.open #lvl-obj { display: block; }
.touch #hud-level { left: 8px; top: 8px; padding: 6px 10px; max-width: 42vw; font-size: 12px; }
.touch #hud-level:not(.open)::after { content: 'tap for goal'; font-size: 10px; }
.touch #lvl-name { font-size: 12px; }
.touch #hud-players { right: 8px; top: 8px; padding: 4px 8px; }
.touch #hud-players li { font-size: 11px; line-height: 1.5; }
.touch #hud-dim { left: 50%; right: auto; top: 48px; bottom: auto; transform: translateX(-50%); padding: 4px 10px; text-align: center; max-width: 40vw; }
.touch #dim-name { font-size: 13px; }
.touch #dim-desc { display: none; }
.touch #hearts { font-size: 13px; margin-top: 0; }
.touch #hint { bottom: auto; top: 96px; font-size: 12px; white-space: normal; max-width: 70vw; text-align: center; }
.touch .toast { font-size: 15px; padding: 8px 14px; }
.touch #toasts { top: 26%; }

@media (max-width: 720px) {
  #hud-level { max-width: 58vw; font-size: 12px; }
  #lvl-obj { display: none; }
  #hud-level.open #lvl-obj { display: block; }
  #hud-players li { font-size: 11px; }
  .room-code { font-size: 36px; }
  .panel { padding: 18px; }
}
@media (max-height: 460px) {
  .panel { padding: 16px; }
  .logo { font-size: 26px; }
  .tag { margin-bottom: 8px; font-size: 13px; }
  .board { display: none; }
  .tb { width: 62px; height: 62px; font-size: 22px; }
  .tb.small { width: 46px; height: 46px; }
  .jump-hint { width: 88px; height: 88px; }
  #tbtns { right: max(122px, calc(env(safe-area-inset-right) + 122px)); }
}

/* ---------- story ---------- */
#cutscene { position: fixed; inset: 0; z-index: 8; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 20px; }
.cut-stage { position: relative; width: min(820px, 100%); height: 280px; border-radius: 18px; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 46px;
  background: linear-gradient(#7cc9ff, #e4f6ff 70%, #5fbf5f 70%); transition: background 1.2s, filter 1.2s; }
.cut-stage.dark { background: linear-gradient(#14042a, #3a1050 70%, #2a1a3a 70%); }
.cut-stage.tear { background: linear-gradient(90deg, #6ee26e 0 14%, #ff6ad5 14% 28%, #9feaff 28% 42%, #efe7a6 42% 56%, #ff8a3a 56% 70%, #b48cff 70% 85%, #3ad1c4 85%); }
.cut-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 92%; z-index: 1; }
.cut-friend { display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform 1.6s cubic-bezier(.2,.8,.2,1), opacity 1.6s; }
.cut-friend.split { transform: translate(var(--dx), var(--dy)) scale(.9); }
.cut-body { width: 34px; height: 42px; border-radius: 9px; box-shadow: 0 4px 0 rgba(0,0,0,.25); position: relative; }
.cut-body::after { content: '• •'; position: absolute; top: 9px; width: 100%; text-align: center; color: #111; font-weight: 900; letter-spacing: 2px; }
.happy .cut-body { animation: hop .7s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translateY(-14px); } }
.cut-name { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; }
.cut-dim { font-size: 11px; font-weight: 800; text-shadow: 0 1px 3px #000; }
.cut-spectre { position: absolute; width: 110px; height: 120px; top: -160px; left: 50%; transform: translateX(-50%); border-radius: 75px 75px 20px 20px;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.95), rgba(200,190,255,.55) 60%, rgba(120,90,200,0)); filter: drop-shadow(0 0 30px #b48cff);
  display: flex; gap: 22px; justify-content: center; padding-top: 34px; transition: top 1.6s ease, opacity 1.2s; z-index: 2; }
.cut-spectre.in { top: 8px; animation: float 2s ease-in-out infinite alternate; }
.cut-spectre.out { opacity: 0; }
@keyframes float { to { margin-top: 14px; } }
.cut-eye { width: 16px; height: 20px; border-radius: 50%; background: #ff2244; box-shadow: 0 0 18px #ff2244; }
.cut-caption { font-family: Orbitron, sans-serif; font-size: clamp(16px, 3.4vw, 24px); text-align: center; max-width: 760px; min-height: 2.6em; color: #f1eefc; margin: 0; }
#cut-skip { position: absolute; right: 18px; bottom: 18px; }

#offer { position: fixed; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.45); }
.offer-panel { text-align: center; border-color: #b48cff; box-shadow: 0 0 60px rgba(180,140,255,.5); }
.offer-panel h2 { font-family: Orbitron, sans-serif; font-size: 20px; margin: 6px 0 10px; }

.decision-panel { text-align: center; }
.decision-panel .reveal { font-size: 18px; color: #ffe23a; }
.decision-row { flex-wrap: wrap; }

#crash { position: fixed; inset: 0; z-index: 20; background: #0000aa; color: #fff; font-family: ui-monospace, Menlo, monospace; display: flex; align-items: center; justify-content: center; }
#crash .crash-box { opacity: 0; max-width: 90vw; }
#crash.fatal .crash-box { opacity: 1; }
#crash .crash-title { font-size: 22px; font-weight: 700; }
#crash pre { white-space: pre-wrap; font-size: 15px; }
#crash.glitching { background: transparent; }
#crash.glitching .crash-glitch { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,0,80,.5) 0 3px, rgba(0,255,200,.4) 3px 6px, transparent 6px 14px); animation: glitch .12s steps(2) infinite; }
@keyframes glitch { 0% { transform: translate(-8px, 4px); } 50% { transform: translate(10px, -6px); filter: hue-rotate(90deg); } 100% { transform: translate(-4px, 0); } }
#crash.black { background: #000; }
#crash.black .crash-box { opacity: 0; transition: opacity .6s; }

#death { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(60,0,0,0); transition: background 2s; text-align: center; }
#death.play { background: rgba(60,0,0,.94); }
#death h1 { font-family: Orbitron, sans-serif; font-size: clamp(40px, 12vw, 90px); color: #ff2244; margin: 0 0 10px; letter-spacing: 6px; animation: deathIn 2.4s ease forwards; text-shadow: 0 0 30px #ff2244; }
@keyframes deathIn { from { opacity: 0; transform: scale(1.6); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
#death p { font-size: 18px; opacity: 0; animation: fadeUp 1s 1.6s forwards; }
#death button { opacity: 0; animation: fadeUp 1s 2.6s forwards; margin-top: 12px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.save-line { font-size: 13px; color: var(--muted); text-align: center; margin: 4px 0 0; }
.cut-stage.code { background: linear-gradient(#02060a, #06261a 70%, #0f2a1d 70%); }
.cut-stage.glitchy { animation: stageGlitch .25s steps(2) 6; }
@keyframes stageGlitch { 50% { filter: hue-rotate(90deg) contrast(1.4); transform: translateX(4px); } }
.cut-unicoder { position: absolute; left: 50%; top: 22px; width: 0; height: 0; z-index: 2; }
.cut-unicoder .glyph { position: absolute; font: 900 22px monospace; color: #39ff88; text-shadow: 0 0 10px #39ff88; opacity: 0;
  transform: translate(var(--sx), var(--sy)) rotate(90deg); transition: transform 1.4s cubic-bezier(.2,.8,.2,1), opacity 1s; }
.cut-unicoder.in .glyph { opacity: 1; transform: translate(var(--gx), var(--gy)); animation: glyphFlicker 1.2s steps(2) infinite; }
@keyframes glyphFlicker { 50% { opacity: .55; } }
.cut-friend.frozen .cut-body { animation: none !important; filter: saturate(.5); outline: 2px dashed #39ff88; outline-offset: 3px; }
.cut-floatter { position: absolute; top: -120px; left: 50%; transform: translateX(-50%); width: 170px; height: 54px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, #eef2ff, #8d97b0 70%); box-shadow: 0 0 30px rgba(255,90,58,.6), inset 0 -8px 0 rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: space-around; transition: top 1.6s ease; z-index: 2; }
.cut-floatter.in { top: 24px; animation: float 2.2s ease-in-out infinite alternate; }
.cut-speaker { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle, #7fe7ff 0 30%, #2a2f3a 32%); animation: thump .25s infinite alternate; }
.cut-feye { width: 22px; height: 22px; border-radius: 50%; background: #ff5a3a; box-shadow: 0 0 16px #ff5a3a; }
@keyframes thump { to { transform: scale(1.18); } }
.cut-missile, .cut-rocket { position: absolute; top: 70px; left: 50%; width: 10px; height: 22px; border-radius: 5px; background: #ff5a3a; box-shadow: 0 0 12px #ff5a3a;
  animation: shoot 1.4s ease-in forwards; opacity: 0; z-index: 1; }
.cut-rocket { width: 16px; height: 16px; border-radius: 50%; background: #7fe7ff; box-shadow: 0 0 18px #7fe7ff; }
@keyframes shoot { 0% { opacity: 1; transform: translate(0, 0); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--tx), 170px) scale(2.4); } }
.cut-friend.shake .cut-body { animation: shake .12s infinite alternate !important; }
@keyframes shake { to { transform: translateX(3px) rotate(4deg); } }

/* ---------- coins, shop, records, daily, banner, emotes ---------- */
.menu-top { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 8px 0 4px; flex-wrap: wrap; }
.menu-top .btn { flex: none; }
.coins { font-weight: 800; color: #ffd23a; font-size: 16px; padding: 6px 10px; background: rgba(255,210,58,.12); border-radius: 10px; }
.daily-btn { width: 100%; margin: 6px 0; background: linear-gradient(90deg, rgba(255,210,58,.25), rgba(255,106,213,.25)); text-align: left; }
.daily-btn span { color: var(--muted); font-weight: 400; font-size: 13px; }
.boards { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px) { .boards { grid-template-columns: 1fr; } }
.mode.party { background: rgba(255,210,58,.08); }
.win-coins { text-align: center; font-weight: 800; color: #ffd23a; min-height: 1.2em; }
.shop-panel { width: min(640px, 100%); }
.shop-head { display: flex; align-items: center; gap: 10px; }
.shop-head h2 { margin: 0; flex: 1; font-family: Orbitron, sans-serif; }
.tabs { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.tab.sel { background: var(--accent); border-color: var(--accent); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 50vh; overflow-y: auto; padding: 2px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.item .ic { font-size: 30px; height: 38px; display: flex; align-items: center; }
.item .nm { font-weight: 700; font-size: 13px; }
.item .btn { padding: 6px 10px; font-size: 13px; width: 100%; }
.item.eq { border-color: #39ff88; box-shadow: 0 0 0 1px #39ff88 inset; }
.item .swatch-big { width: 30px; height: 30px; border-radius: 8px; }
#records-list h3 { margin: 14px 0 6px; }
.ollama { margin: 6px 0; font-size: 13px; }
.ollama summary { cursor: pointer; opacity: .85; }
.ollama .check { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.ollama code { background: rgba(255,255,255,.1); padding: 1px 4px; border-radius: 4px; }
.shop-note { grid-column: 1 / -1; margin: 0 0 4px; }
.public-check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.rooms-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 50vh; overflow-y: auto; }
.room-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.room-row .info { flex: 1; }
.room-row .info small { display: block; opacity: .7; }
.solo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.solo-list h3 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 14px; opacity: .8; }
.solo-list .mode { text-align: left; }
.rec { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.04); margin-bottom: 4px; font-size: 14px; }
.rec .st { color: #ffd23a; letter-spacing: 2px; }
.rec .bt { color: var(--muted); min-width: 56px; text-align: right; }
#banner { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 6; text-align: center; pointer-events: none;
  background: rgba(10,8,24,.88); border: 1px solid rgba(255,210,58,.6); border-radius: 18px; padding: 14px 26px; box-shadow: 0 0 40px rgba(255,210,58,.3); }
#banner.show { animation: bannerIn 3.8s forwards; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.9); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -10px); } }
#banner-title { font-family: Orbitron, sans-serif; font-weight: 900; font-size: 14px; letter-spacing: 2px; color: var(--muted); }
#banner-stars { font-size: 44px; color: #ffd23a; letter-spacing: 6px; text-shadow: 0 0 18px rgba(255,210,58,.6); }
#banner-line { font-weight: 800; font-size: 18px; }
#banner-sub { color: var(--muted); font-size: 13px; }
#banner-coins { color: #ffd23a; font-weight: 900; font-size: 20px; margin-top: 4px; }
#chat { position: fixed; left: 12px; bottom: 70px; z-index: 6; width: min(360px, 60vw); pointer-events: none; }
#chat-log { display: flex; flex-direction: column; gap: 3px; max-height: 34vh; overflow: hidden; justify-content: flex-end; }
#chat-log div { background: rgba(0,0,0,.55); padding: 4px 9px; border-radius: 8px; font-size: 13px; width: fit-content; max-width: 100%; word-break: break-word; transition: opacity .6s; }
#chat-log div.old { opacity: 0; }
#chat.open #chat-log div.old { opacity: 1; }
#chat.open #chat-log { overflow-y: auto; pointer-events: auto; background: rgba(10,8,24,.6); border-radius: 10px; padding: 6px; }
#chat-log b { margin-right: 4px; }
#chat-form { display: flex; gap: 6px; margin-top: 6px; pointer-events: auto; }
#chat-input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10,8,24,.92); color: #fff; font: inherit; }
#skip { position: absolute; left: calc(50% + 64px); top: 8px; pointer-events: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 15px; }
.gallery-panel { max-width: 980px; }
#gallery-tabs { flex-wrap: wrap; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; max-height: 62vh; overflow-y: auto; }
.lvl-card { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.lvl-card canvas { width: 100%; border-radius: 8px; image-rendering: pixelated; background: #000; }
.lvl-card b { font-size: 14px; }
.lvl-card p { margin: 0; font-size: 11px; opacity: .75; flex: 1; }
#chat-btn { position: fixed; z-index: 6; top: 8px; left: calc(50% - 110px); border: 1px solid var(--line); background: rgba(10,8,24,.75); color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 18px; }
body:not(.playing) #chat { bottom: 12px; }
.touch #chat { bottom: auto; top: 140px; width: 46vw; }
#emote-bar { position: fixed; right: 12px; bottom: 120px; z-index: 5; display: grid; grid-template-columns: repeat(4, auto); gap: 8px; background: rgba(10,8,24,.9);
  padding: 10px; border-radius: 14px; border: 1px solid var(--line); }
#emote-bar button { border: 1px solid var(--line); background: rgba(255,255,255,.1); color: #fff; border-radius: 10px; padding: 10px 8px; font: inherit; font-weight: 700; font-size: 14px; min-width: 54px; }
#mute { position: absolute; left: calc(50% + 24px); top: 8px; pointer-events: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 15px; }

.cut-stage.war { background: linear-gradient(#1a0a0a, #4a1a12 70%, #2a1410 70%); }
.cut-stage.red { background: linear-gradient(#3a0008, #8a1020 70%, #3a0a10 70%); }
.cut-stage.factory { background: linear-gradient(#2a3140, #6a7488 70%, #3a404c 70%); }
.cut-stage.dark { background: linear-gradient(#05030c, #1a1030 70%, #120a20 70%); }
.cut-stage.shake { animation: stageGlitch .2s steps(2) 8; }
.cut-stage.flash::after { content: ''; position: absolute; inset: 0; background: #fff; animation: flashOut 1s forwards; }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }
.cut-stage.fade-out .cut-spectre, .cut-stage.fade-out .cut-uni-static { animation: fadeAway 3s forwards; }
.cut-stage.fade-in .cut-spectre { animation: fadeIn 2.5s forwards; opacity: 0; }
@keyframes fadeAway { to { opacity: 0; transform: translateX(-50%) scale(1.6); filter: blur(10px); } }
@keyframes fadeIn { to { opacity: .6; } }
.cut-stage.fall .cut-floatter { animation: fallDown 2.6s ease-in forwards; }
@keyframes fallDown { to { top: 320px; transform: translateX(-50%) rotate(40deg); } }
.cut-uni-static { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); white-space: pre; text-align: center; font: 900 20px/1.1 monospace; color: #39ff88; text-shadow: 0 0 10px #39ff88; z-index: 2; }
.cut-troppa { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); width: 70px; height: 120px; z-index: 2; animation: float 2s ease-in-out infinite alternate; }
.cut-troppa > div { position: absolute; }
.tp-helmet { left: 12px; top: 0; width: 46px; height: 34px; border-radius: 22px 22px 6px 6px; background: #3b4a3a; box-shadow: inset 0 -6px 0 rgba(0,0,0,.3); }
.tp-visor { left: 18px; top: 14px; width: 34px; height: 10px; border-radius: 4px; background: #ff3333; box-shadow: 0 0 12px #ff3333; }
.tp-collar { left: 14px; top: 34px; width: 42px; height: 9px; border-radius: 5px; background: #b48cff; box-shadow: 0 0 14px #b48cff; }
.tp-body { left: 10px; top: 42px; width: 50px; height: 56px; border-radius: 8px; background: #4f5f46; }
.tp-pack { left: -6px; top: 46px; width: 16px; height: 40px; border-radius: 6px; background: #2c2f36; }
.cut-stage.angry .tp-visor { animation: thump .2s infinite alternate; }
.cut-stage.freed .tp-collar { display: none; }
.cut-stage.freed .tp-visor { background: #7fe7ff; box-shadow: 0 0 12px #7fe7ff; }
.cut-planets { position: absolute; top: 40px; left: 0; right: 0; display: flex; justify-content: space-around; align-items: center; padding: 0 20px; z-index: 2; }
.cut-planet { border-radius: 50%; box-shadow: 0 0 14px rgba(255,255,255,.35); animation: float 2s ease-in-out infinite alternate; }
.cut-planet:last-child { box-shadow: 0 0 0 4px #ff8a3a, 0 0 24px #ff8a3a; }

.cut-clock { position: absolute; top: 30px; left: 50%; width: 90px; height: 90px; margin-left: -45px; border-radius: 50%; border: 6px solid #ffd23a; background: #fff8e0; z-index: 2; box-shadow: 0 0 24px #ffd23a; }
.cut-hand { position: absolute; left: 50%; top: 50%; width: 4px; height: 36px; margin-left: -2px; background: #222; transform-origin: 50% 0; animation: clockback 1s linear infinite; }
@keyframes clockback { from { transform: rotate(180deg); } to { transform: rotate(-180deg); } }
.cut-waves { position: absolute; left: 0; right: 0; bottom: 0; height: 45%; background: repeating-linear-gradient(170deg, #1a7ad8 0 18px, #2a9aff 18px 36px); opacity: .75; z-index: 1; animation: waves 3s ease-in-out infinite alternate; }
@keyframes waves { from { transform: translateY(6px); } to { transform: translateY(-6px); } }
/* cleaner main menu */
.menu-panel { width: min(560px, 100%); }
.menu-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.menu-bar .coins { margin-left: auto; }
.chip-btn { border: 1px solid var(--line); background: rgba(255,255,255,.08); color: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; }
.chip-btn:hover { background: rgba(255,255,255,.16); }
.big-play { width: 100%; font-size: 20px; padding: 16px; margin: 4px 0 10px; }
.play-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.07); color: #fff; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; min-height: 74px; }
.tile i { font-style: normal; font-size: 24px; }
.tile:hover { background: rgba(255,255,255,.14); }
.join-tile { cursor: default; gap: 6px; }
.join-tile .code-input { width: 100%; text-align: center; padding: 6px; font-size: 15px; }
.join-tile .btn { width: 100%; }
.more-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 10px; }
.mini-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.2); color: #fff; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }
.mini-tile i { font-style: normal; font-size: 20px; }
.mini-tile:hover { background: rgba(255,255,255,.12); }
.name-field.hidden { display: none; }
@media (max-width: 520px) { .play-grid, .more-grid { grid-template-columns: repeat(2, 1fr); } }

/* level maker */
.maker-panel { width: min(1100px, 100%); }
.maker-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.maker-name { flex: 1; min-width: 140px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: #fff; font: inherit; font-weight: 700; }
.maker-pal { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.maker-tool { display: flex; flex-direction: column; align-items: center; width: 64px; padding: 4px 2px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; font: inherit; }
.maker-tool i { font-style: normal; font-size: 18px; }
.maker-tool small { font-size: 9px; opacity: .8; white-space: nowrap; overflow: hidden; max-width: 60px; }
.maker-tool.sel { background: rgba(138,61,255,.55); border-color: #c9a0ff; }
.maker-canvas { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); touch-action: none; }
.maker-canvas canvas { display: block; cursor: crosshair; touch-action: none; }
.lvl-meta { font-size: 11px; opacity: .75; }
.lvl-btns { display: flex; gap: 6px; }
.lvl-btns .btn { flex: 1; }

.mg-only .not-mg { display: none; }

/* ---------- settings ---------- */
.style-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 14px; }
.style-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border: 2px solid var(--line); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; border-radius: 14px; font: inherit; }
.style-card.sel { border-color: var(--accent); background: rgba(255,106,213,.15); }
.style-card small { opacity: .75; font-size: 12px; }
.sc-retro { font-family: 'Press Start 2P', monospace; font-size: 14px; color: #ffe23a; text-shadow: 3px 3px 0 #ff3d8b; }
.sc-modern { font-family: Rubik, sans-serif; font-weight: 800; font-size: 18px; background: linear-gradient(90deg, #6ee26e, #ff6ad5); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- pixel icons (replace emojis) ---------- */
.px-ic { display: inline-block; line-height: 1; }
.px-ic img { width: 1.15em; height: 1.15em; vertical-align: -0.18em; image-rendering: pixelated; image-rendering: crisp-edges; }
.tile i .px-ic img, .mini-tile i .px-ic img { width: 1.3em; height: 1.3em; }
html:not(.r-px) .px-ic img { display: none; }
html:not(.r-px) .px-ic::after { content: attr(data-e); }

/* ---------- RETRO style: each part is its own class so the easter egg can peel them off one by one ---------- */
html.r-pal { --panel: #1b0f3a; --line: #ffffff; --accent: #ff3d8b; --muted: #b8b0e0; }
html.r-font body, html.r-font input, html.r-font select, html.r-font button { font-family: VT323, monospace; }
html.r-font body { font-size: 19px; }
html.r-font .logo, html.r-font h2, html.r-font h3, html.r-font .btn, html.r-font .tile, html.r-font .mini-tile, html.r-font .mode b, html.r-font .tab, html.r-font #lvl-name, html.r-font #dim-name, html.r-font .room-code, html.r-font .chip-btn, html.r-font .coins { font-family: 'Press Start 2P', monospace; letter-spacing: 0; }
html.r-font .logo { font-size: clamp(18px, 6vw, 34px); }
html.r-font h2 { font-size: 16px; }
html.r-font h3 { font-size: 11px; }
html.r-font .btn, html.r-font .tile, html.r-font .tab, html.r-font .chip-btn, html.r-font .coins { font-size: 10px; }
html.r-font .mini-tile { font-size: 8px; }
html.r-font .big-play { font-size: 16px; }
html.r-font .mode b { font-size: 9px; line-height: 1.5; }
html.r-font .mode span, html.r-font .muted, html.r-font small { font-size: 16px; }
html.r-font .logo { text-shadow: 4px 4px 0 #ff3d8b, 8px 8px 0 #3a8aff; }
html.r-box .panel, html.r-box .btn, html.r-box .tile, html.r-box .mini-tile, html.r-box .chip-btn, html.r-box .tab, html.r-box .mode, html.r-box input, html.r-box select,
html.r-box .item, html.r-box .lvl-card, html.r-box .room-row, html.r-box .style-card, html.r-box .coins, html.r-box .toast, html.r-box #hud-level, html.r-box #hud-dim, html.r-box #hud-players,
html.r-box .tb, html.r-box #chat-log div, html.r-box #chat-input, html.r-box .maker-tool, html.r-box .daily-btn, html.r-box .board, html.r-box #emote-bar, html.r-box #emote-bar button, html.r-box #mute, html.r-box #skip, html.r-box #fs {
  border-radius: 0 !important; backdrop-filter: none !important; }
html.r-box .panel { border: 4px solid #fff; box-shadow: 8px 8px 0 #000; background: var(--panel); }
html.r-box .btn, html.r-box .tile, html.r-box .mini-tile, html.r-box .chip-btn, html.r-box .tab, html.r-box .mode, html.r-box .style-card, html.r-box .maker-tool, html.r-box .daily-btn {
  border: 3px solid #fff; box-shadow: 4px 4px 0 #000; background: #2a1a55; transition: none; }
html.r-box .btn:active, html.r-box .tile:active, html.r-box .mini-tile:active, html.r-box .mode:active, html.r-box .tab:active { transform: translate(4px, 4px); box-shadow: none; }
html.r-box .btn.primary, html.r-box .tab.sel, html.r-box .mode.sel, html.r-box .style-card.sel, html.r-box .maker-tool.sel { background: #ff3d8b; color: #fff; }
html.r-box .big-play { background: #39ff88 !important; color: #10202a !important; text-shadow: none; }
html.r-box .daily-btn { background: #3a8aff; }
html.r-box .tile:hover, html.r-box .mini-tile:hover, html.r-box .btn:hover { filter: brightness(1.2); }
html.r-box input, html.r-box select { border: 3px solid #fff; background: #000; }
html.r-box #hud-level, html.r-box #hud-dim, html.r-box #hud-players { border: 3px solid #fff; background: #1b0f3a; box-shadow: 4px 4px 0 #000; }
html.r-box .toast { border: 3px solid #fff; background: #000; box-shadow: 4px 4px 0 #000; }
/* CRT scanlines over everything */
html.r-scan body::after { content: ''; position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px), radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.45) 100%);
  transition: opacity 3s; }
html.in3d body::after, body.hub:not(.hub-classic)::after { display: none; }
html.r-pix canvas#game { image-rendering: pixelated; image-rendering: crisp-edges; }
/* the easter egg fades between the two looks */
html.drift * { transition: border-radius 4s, box-shadow 4s, background-color 4s, border-color 4s, color 4s; }
.public-check { justify-content: flex-start; text-align: left; }
.public-check input { width: auto !important; flex: none; margin: 0; accent-color: var(--accent); transform: scale(1.3); }

.cut-bananas { position: absolute; top: 30px; left: 0; right: 0; display: flex; justify-content: space-around; font-size: 34px; z-index: 2; }
.cut-banana { animation: float 1s ease-in-out infinite alternate; }
.cut-skull { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font-size: 64px; z-index: 2; animation: float 1.4s ease-in-out infinite alternate; filter: drop-shadow(0 0 12px #ff3355); }

#pause-btn { position: absolute; left: calc(50% + 104px); top: 8px; pointer-events: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 15px; }
#pause { background: rgba(0,0,0,.45); }
.pause-panel { display: flex; flex-direction: column; gap: 10px; text-align: center; width: min(340px, 100%); }
.pause-panel .btn { width: 100%; }
.pause-title { margin: 0; font-size: 28px; }
html.r-font .pause-title { font-size: 20px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

.cut-conductor { position: absolute; left: 50%; top: 18px; width: 90px; height: 150px; transform: translateX(-50%); z-index: 2; animation: float 1s ease-in-out infinite alternate; }
.cond-hat { position: absolute; left: 25px; top: 0; width: 40px; height: 34px; background: #111; box-shadow: 0 30px 0 -12px #111, 0 0 12px #ff2bd6; }
.cond-head { position: absolute; left: 22px; top: 30px; width: 46px; height: 40px; border-radius: 50%; background: #2a0a4a; box-shadow: inset 10px -6px 0 #ff2bd6, 0 0 16px #ff2bd6; }
.cond-body { position: absolute; left: 15px; top: 68px; width: 60px; height: 80px; background: linear-gradient(#1a0a3a, #08001a); clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%); }
.cond-baton { position: absolute; left: 70px; top: 60px; width: 4px; height: 56px; background: #fff; transform-origin: bottom; animation: baton 0.47s ease-in-out infinite alternate; box-shadow: 0 0 8px #fff; }
@keyframes baton { from { transform: rotate(-40deg); } to { transform: rotate(30deg); } }
.cond-note { position: absolute; left: 90px; top: 40px; color: #ffe23a; font-size: 24px; animation: note 1.2s linear infinite; text-shadow: 0 0 8px #ffe23a; }
@keyframes note { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(60px, -50px); opacity: 0; } }

.cut-ship { position: absolute; left: 50%; top: 40px; width: 200px; height: 120px; transform: translateX(-50%); z-index: 2; animation: shipRock 3s ease-in-out infinite alternate; }
.ship-hull { position: absolute; left: 0; bottom: 0; width: 200px; height: 40px; background: #4a3420; clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%); box-shadow: inset 0 6px 0 #6a4a2c; }
.ship-mast { position: absolute; left: 96px; bottom: 38px; width: 8px; height: 80px; background: #2e2014; }
.ship-sail { position: absolute; left: 62px; bottom: 56px; width: 76px; height: 54px; background: #8a8270; clip-path: polygon(0 0, 100% 0, 90% 100%, 10% 100%); }
@keyframes shipRock { from { transform: translateX(-50%) rotate(-3deg); } to { transform: translateX(-50%) rotate(3deg); } }

/* skin maker */
.sm-wrap { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; margin: 8px 0 12px; }
#sm-preview { width: 180px; height: 180px; border-radius: 16px; background: #1b1830; image-rendering: pixelated; }
.sm-controls { display: flex; flex-direction: column; gap: 8px; min-width: 200px; flex: 1; }
.sm-col { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.sm-col input[type=color] { width: 54px; height: 34px; padding: 0; border: 2px solid var(--line); background: none; margin: 0; }
.sm-pats { flex-wrap: wrap; }
.sm-pats button { flex: 1 0 30%; }
/* phone control settings */
.tset { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin: 6px 0 4px; font-size: 14px; }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; padding: 6px 4px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #fff; font: inherit; font-size: 12px; cursor: pointer; }
.seg button.sel { background: var(--accent); border-color: var(--accent); }
html.r-box .seg button { border-radius: 0; border: 2px solid #fff; }
#touch { --stick: 1; --btn: 1; --alpha: 1; opacity: var(--alpha); }
#stick-base { width: calc(132px * var(--stick)); height: calc(132px * var(--stick)); }
#stick-knob { width: calc(56px * var(--stick)); height: calc(56px * var(--stick)); left: calc(38px * var(--stick)); top: calc(38px * var(--stick)); }
.jump-hint { width: calc(104px * var(--btn)); height: calc(104px * var(--btn)); }
.tb { width: calc(74px * var(--btn)); height: calc(74px * var(--btn)); }
.tb.small { width: calc(52px * var(--btn)); height: calc(52px * var(--btn)); }
#tbtns { right: calc(max(140px, calc(env(safe-area-inset-right) + 140px)) * var(--btn)); }
/* left-handed: stick on the right, jump and buttons on the left */
#touch.lefty #stick-zone { left: auto; right: 0; }
#touch.lefty #jump-zone { right: auto; left: 0; }
#touch.lefty .jump-hint { right: auto; left: max(26px, env(safe-area-inset-left)); }
#touch.lefty #tbtns { right: auto; left: calc(max(140px, calc(env(safe-area-inset-left) + 140px)) * var(--btn)); flex-direction: row-reverse; }
#touch.lefty .stick-tip { left: auto; right: max(22px, env(safe-area-inset-right)); }

/* easter eggs */
.logo.wobble { animation: wobble .35s; }
@keyframes wobble { 25% { transform: rotate(-3deg) scale(1.03); } 75% { transform: rotate(3deg) scale(1.03); } }
.logo.smash { animation: smash 2.6s forwards; }
@keyframes smash { 0% { transform: none; } 15% { transform: translateY(20px) rotate(8deg) scale(1.2); filter: hue-rotate(90deg); } 40% { transform: translateY(160px) rotate(-30deg) scale(.6); opacity: .2; } 70% { transform: translateY(-40px) rotate(380deg); opacity: 1; } 100% { transform: none; } }
html.konami body { animation: konami 4s linear; }
@keyframes konami { 0% { filter: hue-rotate(0); } 100% { filter: hue-rotate(720deg); } }
#game.flipped { transform: rotate(180deg); transition: transform .6s; }

/* Imposter meeting */
.meeting { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; width: min(560px, 94vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 16px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.meeting h2 { margin: 0 0 6px; font-size: 18px; }
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.vote-btn { width: 100%; }
html.r-box .meeting { border-radius: 0; border: 4px solid #fff; box-shadow: 8px 8px 0 #000; }

/* phones: never zoom the page (double-tap, pinch, or tapping a small text box) */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .tile, .mini-tile, .mode, .tb, #stick-zone, #jump-zone { touch-action: manipulation; }
#stick-zone, #jump-zone, .tb, #touch { touch-action: none; }
@media (pointer: coarse) {
  input, select, textarea, #chat-input, .code-input, .join-tile .code-input { font-size: 16px !important; }
}
#skinmaker { z-index: 6; }

/* roleplay: chat stays on screen */
#chat.rp #chat-log div.old { opacity: .85; }
#chat.rp #chat-log { max-height: 40vh; }
#rp-panel .vote-btn { display: flex; flex-direction: column; gap: 2px; }
#rp-panel .vote-btn small { font-size: 11px; }

#chat.rp #chat-form { display: flex; }
#chat.rp #chat-input { background: rgba(10,8,24,.85); }
.touch #chat.rp { top: auto; bottom: 150px; width: 52vw; }

/* Level Creator 2.0 */
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 14px; }
.kind-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 10px; border-radius: 14px; border: 2px solid var(--line); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; font: inherit; }
.kind-card i { font-style: normal; font-size: 40px; }
.kind-card b { font-size: 18px; }
.kind-card small { opacity: .75; font-size: 12px; }
.kind-card:hover { border-color: var(--accent); }
.kind-chip { padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.1); font-weight: 700; font-size: 13px; }
.color-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 2px solid rgba(255,255,255,.3); cursor: pointer; padding: 0; }
.swatch.sel { border-color: #fff; transform: scale(1.15); }
.sprite-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; align-items: center; }
.sprite-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; }
.sprite-item.sel { border-color: var(--accent); background: rgba(255,106,213,.15); }
.sprite-item canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.pixel-pad { width: 288px; height: 288px; max-width: 80vw; max-height: 80vw; image-rendering: pixelated; border-radius: 10px; touch-action: none; cursor: crosshair; display: block; margin: 6px auto; }
.rule { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.block { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 10px; color: #fff; font-weight: 700; }
.block.when { background: #c88a1a; }
.block.do { background: #3a6ad8; }
.block b { font-family: inherit; letter-spacing: 1px; }
.block-sel, .block-in { width: auto !important; margin: 0 !important; padding: 5px 8px !important; border-radius: 8px; border: none; font-size: 14px !important; background: rgba(255,255,255,.92) !important; color: #111 !important; }
.block-in { width: 140px !important; }
html.r-box .block, html.r-box .kind-card, html.r-box .swatch, html.r-box .sprite-item, html.r-box .block-sel, html.r-box .block-in { border-radius: 0 !important; }

/* friends */
.friend-add { display: flex; gap: 8px; margin: 8px 0 12px; }
.friend-add input { margin: 0; }
.friend { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; margin: 6px 0; background: rgba(255,255,255,.05); }
.friend .nm { flex: 1; font-weight: 700; }
.friend .st { font-size: 12px; opacity: .75; display: block; font-weight: 400; }
.invite-pop { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 9; background: var(--panel); border: 2px solid var(--accent); border-radius: 14px; padding: 12px 16px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
html.r-box .friend, html.r-box .invite-pop { border-radius: 0; }

/* the 3D view of the top-down games sits under the 2D canvas */
canvas#td3d { visibility: hidden; background: #8fc8ff; }
#view-btn { position: absolute; left: calc(50% + 144px); top: 8px; pointer-events: auto; min-width: 34px; padding: 0 6px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 15px; }
html.r-box #view-btn { border-radius: 0; }

/* All / 3D / 2D game tabs */
.game-tabs { margin: 6px 0 4px; }
.f-3d .mode:not([data-kind="3d"]), .f-2d .mode[data-kind="3d"], .f-3d h3, .f-2d h3 { display: none !important; }
#cam-btns { position: absolute; left: calc(50% + 206px); top: 8px; display: flex; gap: 4px; pointer-events: auto; }
#cam-btns button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); color: #fff; font-size: 17px; touch-action: none; user-select: none; -webkit-user-select: none; }
#cam-btns.hidden { display: none; }
@media (max-width: 700px) { #cam-btns { left: auto; right: 8px; top: 96px; flex-direction: column; } #cam-btns button { width: 40px; height: 40px; } }
/* the dimension card can shrink to just your hearts and coins, so it doesn't hide what's in front of you */
#dim-toggle { float: left; margin: -4px 8px 0 -6px; width: 24px; height: 24px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.4); color: #fff; font-size: 12px; line-height: 1; pointer-events: auto; cursor: pointer; padding: 0; }
#hud-dim.mini { padding: 6px 10px; }
#hud-dim.mini #dim-name, #hud-dim.mini #dim-desc { display: none; }
#hud-dim.mini #hearts { margin-top: 0; display: inline-block; }
#hud-dim.mini #dim-toggle { margin: 0 8px 0 0; }

/* pixel skin editor + community skins */
.pe-wrap { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#pe-grid { width: min(320px, 82vw); height: min(320px, 82vw); image-rendering: pixelated; border-radius: 8px; touch-action: none; cursor: crosshair; background: #222; }
.pe-side { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 160px; }
#pe-prev { align-self: center; image-rendering: pixelated; }
.pe-pal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.pe-pal button { aspect-ratio: 1; border-radius: 4px; border: 2px solid rgba(255,255,255,.2); padding: 0; min-width: 18px; }
.pe-pal button.sel { border-color: #fff; transform: scale(1.12); }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.field-input { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--text); font: inherit; margin: 6px 0; }
.swatch-big.px { image-rendering: pixelated; background-size: 100% 100% !important; }
.sc-card canvas { image-rendering: pixelated; }
.guy-ic { width: 56px; height: 56px; image-rendering: pixelated; }

/* servers */
.srv-codebox { display: flex; gap: 6px; margin: 8px 0; }
.srv-codebox .code-input { width: 110px; }
.srv-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.srv-row { display: flex; gap: 8px; align-items: center; }
.srv-info { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.srv-form { display: flex; flex-direction: column; gap: 6px; }

/* ---------- the lobby world ---------- */
canvas#hub { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; display: none; z-index: 2; touch-action: none; background: #9fdcff; }
#hub-btns { display: none; }
body.hub #hub-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin: 8px auto 0; }
body.hub #hub-toggle { font-size: 15px; padding: 8px 14px; }
.hub-hint { font-size: 12px; opacity: .85; }
body.hub-classic .hub-hint { display: none; }
body.hub:not(.hub-classic) #menu { pointer-events: none; align-items: flex-end; }
body.hub:not(.hub-classic) #menu .menu-panel { background: transparent; border: 0; box-shadow: none; backdrop-filter: none; width: 100%; max-width: none; padding: 0; margin: 0; }
body.hub:not(.hub-classic) #menu .menu-panel > :not(.menu-bar):not(#hub-btns) { display: none !important; }
body.hub:not(.hub-classic) #menu .menu-bar, body.hub:not(.hub-classic) #hub-btns { pointer-events: auto; background: rgba(20, 16, 40, .72); border-radius: 16px; padding: 6px 10px; width: fit-content; margin-left: auto; margin-right: auto; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
body.hub-classic #menu { background: rgba(10, 8, 24, .35); }
.hub-stick { position: fixed; z-index: 4; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; border: 3px solid rgba(255,255,255,.6); background: rgba(255,255,255,.12); pointer-events: none; display: grid; place-items: center; }
.hub-stick i { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.8); box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.hub-jump { position: fixed; z-index: 4; right: max(22px, env(safe-area-inset-right)); bottom: max(150px, env(safe-area-inset-bottom)); width: 78px; height: 78px; border-radius: 50%; border: 3px solid #fff; background: rgba(255, 106, 213, .8); font-size: 32px; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.hub-stick.hidden, .hub-jump.hidden { display: none; }
/* Roblox-style lobby HUD: menu buttons top-left, players top-right, chat bottom-left, and a game catalog */
.hub-hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; font-family: Rubik, sans-serif; }
.hub-hud.hidden { display: none; }
body:not(.hub) .hub-hud, body.hub-classic .hub-hud { display: none; }
.hub-tl { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; gap: 8px; pointer-events: auto; }
.hub-tl button { width: 46px; height: 46px; border-radius: 12px; border: 0; background: rgba(20, 20, 30, .62); color: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.hub-tl button:hover { background: rgba(20, 20, 30, .82); }
.hub-list { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); width: 180px; background: rgba(20, 20, 30, .58); border-radius: 12px; color: #fff; font-size: 13px; overflow: hidden; pointer-events: auto; }
.hub-list-h { padding: 7px 10px; font-weight: 800; background: rgba(0,0,0,.25); }
.hub-list-b div { padding: 4px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-chat { position: absolute; left: max(12px, env(safe-area-inset-left)); top: 70px; width: min(340px, 60vw); pointer-events: auto; }
.hub-log { max-height: 160px; overflow-y: auto; background: rgba(20, 20, 30, .45); border-radius: 12px 12px 0 0; padding: 8px 10px; color: #fff; font-size: 13px; line-height: 1.4; text-shadow: 0 1px 2px #000; }
.hub-chat form input { width: 100%; box-sizing: border-box; border: 0; border-radius: 0 0 12px 12px; padding: 9px 10px; background: rgba(20, 20, 30, .7); color: #fff; font: 600 13px Rubik, sans-serif; outline: none; }
.hub-hud.chat-off .hub-chat { display: none; }
@media (max-width: 700px) { .hub-list { width: 130px; font-size: 11px; } .hub-chat { width: 58vw; } .hub-log { max-height: 90px; font-size: 11px; } .hub-hint { display: none; } }
.hub-disc { z-index: 6; background: rgba(10, 8, 24, .55); }
.hub-disc-box { width: min(980px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #f4f5f8; color: #1a1a2a; border-radius: 18px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.45); margin: auto; font-family: Rubik, sans-serif; }
.hub-disc-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px; background: #fff; border-bottom: 1px solid #e2e4ea; }
.hub-disc-head h2 { margin: 0; font: 800 22px Rubik, sans-serif; color: #1a1a2a; white-space: nowrap; }
.hub-disc-head input { flex: 1; min-width: 0; border: 1px solid #d0d3dc; border-radius: 10px; padding: 9px 12px; font: 500 15px Rubik, sans-serif; background: #f4f5f8; color: #1a1a2a; }
.hub-disc-body { overflow-y: auto; padding: 4px 16px 18px; }
.hub-disc-body h3 { margin: 16px 0 8px; font: 800 18px Rubik, sans-serif; color: #1a1a2a; }
.hub-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.hub-card { text-align: left; border: 0; background: none; padding: 0; cursor: pointer; color: #1a1a2a; font-family: Rubik, sans-serif; }
.hub-thumb { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; font-size: 56px; box-shadow: 0 4px 10px rgba(0,0,0,.12); transition: transform .12s; }
.hub-card:hover .hub-thumb { transform: translateY(-3px) scale(1.03); }
.hub-card b { display: block; margin-top: 6px; font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-card small { display: block; font-size: 12px; color: #5a5e6e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.hub:not(.hub-classic) #menu .menu-panel { display: flex; flex-direction: column-reverse; gap: 8px; }
.hub-disc, .hub-disc *, .hub-hud, .hub-hud * { font-family: Rubik, system-ui, sans-serif !important; }
.hub-disc-head .btn { border-radius: 10px; }
.hub-disc-head input { background: #f4f5f8 !important; color: #1a1a2a !important; border: 1px solid #d0d3dc !important; box-shadow: none !important; }
