:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-2: #111318;
  --card: #16181f;
  --card-2: #1d2029;
  --line: #262a35;
  --fg: #eceef3;
  --muted: #9097a6;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --live: #34d399;
  --radius: 14px;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --shadow: 0 10px 30px -10px rgb(0 0 0 / .6);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body.playing { overflow: hidden; }
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }
.muted { color: var(--muted); }
.center { text-align: center; }
code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .12s, background .15s, border-color .15s, filter .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px -8px rgb(139 92 246 / .8); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--card-2); }
.btn.lg { padding: 12px 22px; font-size: 16px; border-radius: 12px; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.link-btn:hover { color: var(--fg); background: var(--card-2); }
.nav-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-size: 20px; line-height: 1; display: grid; place-items: center; padding: 0 0 2px; }
.nav-btn:hover { background: var(--card-2); }

/* ---- app shell: top bar + sidebar + content ---- */
.app { --top: 60px; --side: 232px; min-height: 100vh;
  background: radial-gradient(1200px 500px at 85% -10%, rgb(139 92 246 / .12), transparent 60%),
              radial-gradient(900px 400px at -10% 0%, rgb(34 211 238 / .06), transparent 60%), var(--bg); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.xl { padding: 14px 26px; font-size: 18px; border-radius: 14px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--card-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 30; display: flex; align-items: center; gap: 18px;
  padding: 0 18px; background: rgb(11 12 16 / .85); backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid rgb(255 255 255 / .06); }
.menu-toggle { display: none; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 19px; letter-spacing: -.02em; flex: none; }
.brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { width: 28px; height: 28px; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 9px; text-decoration: none; font-weight: 600; color: var(--muted); }
.topnav a:hover { color: var(--fg); background: var(--card); }
.topnav a.active { color: var(--fg); }
.search { flex: 1; max-width: 620px; margin: 0 auto; display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: rgb(139 92 246 / .7); box-shadow: 0 0 0 4px rgb(139 92 246 / .15); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--fg); font: inherit; padding: 10px 0; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
.search kbd { font: 12px ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.search:focus-within kbd { display: none; }

.account { position: relative; flex: none; }
.account-btn { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; font-weight: 600; max-width: 220px; }
.account-btn:hover { background: var(--card-2); }
.account-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); flex: none; object-fit: cover; }
.avatar.lg { width: 48px; height: 48px; }
.avatar.xl { width: 72px; height: 72px; }
.avatar:not([src]), .avatar[src=""] { visibility: visible; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 40; }
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu a, .menu button { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.menu a:hover, .menu button:hover { background: var(--card-2); }

.sidebar { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); z-index: 20; overflow-y: auto; padding: 14px 10px;
  display: flex; flex-direction: column; gap: 2px; border-right: 1px solid rgb(255 255 255 / .05); background: rgb(11 12 16 / .6); }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; color: var(--muted); }
.sidebar a:hover { color: var(--fg); background: var(--card); }
.sidebar a.active { color: var(--fg); background: var(--card-2); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.side-me { color: var(--fg) !important; margin-bottom: 6px; }
.side-me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-badge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: #ef4444; color: #fff; border-radius: 999px; padding: 1px 7px; }
.side-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 12px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.scrim { position: fixed; inset: var(--top) 0 0 0; z-index: 15; background: rgb(0 0 0 / .5); }

.content { margin-left: var(--side); padding: calc(var(--top) + 24px) clamp(16px, 3vw, 36px) 48px; max-width: calc(1440px + var(--side)); outline: none; }

/* ---- page pieces ---- */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: clamp(28px, 5vw, 56px); margin-bottom: 32px; border: 1px solid var(--line);
  background: radial-gradient(600px 300px at 100% 0%, rgb(34 211 238 / .18), transparent 70%),
              radial-gradient(700px 300px at 0% 100%, rgb(139 92 246 / .25), transparent 70%), var(--card); }
.hero h1 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 44px); line-height: 1.1; letter-spacing: -.03em; max-width: 16ch; }
.hero p { margin: 0 0 24px; color: var(--muted); font-size: 17px; max-width: 46ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.greeting { display: flex; align-items: center; gap: 18px; margin: 4px 0 28px; }
.greeting h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.02em; }
.greeting p { margin: 2px 0 0; }
.page-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 22px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.page-head p { margin: 2px 0 0; }
.empty { display: grid; place-items: center; gap: 14px; padding: 64px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 0; font-size: 16px; }
.pad { padding: 16px 4px; }

.row { margin-bottom: 30px; }
.row-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.row-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.row-title { display: flex; align-items: center; gap: 6px; text-decoration: none; }
.row-title .chev { font-size: 24px; line-height: 1; color: var(--muted); transition: transform .15s; }
.row-title:hover .chev { transform: translateX(3px); color: var(--fg); }
.row-head .count, h2 .count { color: var(--muted); font-size: 13px; font-weight: 500; margin-left: 8px; }
.row-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.see-all { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.see-all:hover { color: var(--fg); background: var(--card); }
.track { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(140px, 13vw, 180px); gap: 14px; overflow-x: auto;
  scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px 2px 6px; margin: 0 -2px; }
.track::-webkit-scrollbar { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px 14px; }

/* ---- game card ---- */
.game-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; scroll-snap-align: start; min-width: 0; }
.game-card .thumb { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--card-2); transition: transform .18s, box-shadow .18s; }
.game-card .thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.game-card .thumb img[src] { opacity: 1; }
.game-card:hover .thumb, .game-card:focus-visible .thumb { transform: translateY(-3px); box-shadow: 0 12px 26px -10px rgb(0 0 0 / .8), 0 0 0 2px rgb(139 92 246 / .6); }
.game-card:focus-visible { outline: none; }
.game-name { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.game-meta .live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--live); margin-right: 5px; vertical-align: 1px; }

/* ---- friends ---- */
.friends-track { grid-auto-columns: 96px; }
.friend { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 6px 2px; border-radius: 12px;
  cursor: pointer; text-align: center; min-width: 0; text-decoration: none; color: inherit; }
.friend:hover { background: var(--card); }
.friend-avatar { position: relative; width: 68px; height: 68px; }
.friend-avatar img { width: 100%; height: 100%; border-radius: 50%; background: var(--card-2); }
.friend.playing .friend-avatar img { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--live); }
.friend.offline .friend-avatar img { filter: grayscale(.85) brightness(.75); }
.friend .dot { position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--bg); background: #4b5160; }
.friend.online .dot { background: #60a5fa; }
.friend.studio .dot { background: #f59e0b; }
.friend.playing .dot { background: var(--live); }
.friend-name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend.offline .friend-name { color: var(--muted); }
.friend-status { font-size: 11.5px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend.playing .friend-status { color: var(--live); }
.add-circle { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 300;
  border: 2px dashed var(--line); color: var(--muted); transition: border-color .15s, color .15s; }
.add-friend:hover .add-circle { border-color: var(--accent); color: var(--fg); }
.badge, .tab-badge { position: absolute; top: -2px; right: -4px; font-style: normal; font-size: 11px; font-weight: 700; background: #ef4444; color: #fff;
  border-radius: 999px; padding: 1px 6px; border: 2px solid var(--bg); }
.tab-badge { position: static; margin-left: 6px; border: 0; }
.friend-group { margin-bottom: 26px; }
.friend-group h2 { font-size: 16px; margin: 0 0 10px; }
.friend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { position: relative; padding: 10px 16px; background: none; border: 0; cursor: pointer; font-weight: 600; color: var(--muted); text-decoration: none; }
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad); }
.filter { width: 100%; max-width: 440px; padding: 10px 14px; margin-bottom: 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit; outline: none; }
.filter:focus { border-color: rgb(139 92 246 / .7); box-shadow: 0 0 0 3px rgb(139 92 246 / .15); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 760px; }
.person { display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.person-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-info strong, .person-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-info span { font-size: 13px; }
.person-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill-tag { font-size: 13px; font-weight: 600; color: var(--muted); padding: 5px 12px; border-radius: 999px; background: var(--card-2); }
.action-note { flex-basis: 100%; text-align: right; font-size: 12.5px; color: var(--muted); }
.action-note.error { color: #f87171; }
.link-btn.inline { padding: 0; font-size: inherit; color: var(--accent-2); text-decoration: underline; }

/* ---- game page ---- */
.game-top { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 28px; margin-bottom: 26px; }
.media-main { aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: var(--card-2); box-shadow: var(--shadow); }
.media-main img { width: 100%; height: 100%; object-fit: cover; }
.media-main img:not([src]) { visibility: hidden; }
.media-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.media-thumbs button { flex: none; width: 104px; aspect-ratio: 16 / 9; padding: 0; border: 2px solid transparent; border-radius: 9px; overflow: hidden;
  background: var(--card-2); cursor: pointer; opacity: .6; transition: opacity .15s, border-color .15s; }
.media-thumbs button:hover { opacity: 1; }
.media-thumbs button.active { opacity: 1; border-color: var(--accent); }
.media-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.game-side { display: flex; flex-direction: column; gap: 10px; }
.game-side h1 { margin: 0; font-size: clamp(24px, 2.6vw, 34px); line-height: 1.15; letter-spacing: -.02em; }
.creator { color: var(--muted); }
.creator strong { color: var(--fg); }
.verified { color: #60a5fa; margin-left: 5px; }
.play-wrap { margin: 14px 0 6px; }
.play-btn { width: 100%; }
.play-btn svg { width: 22px; height: 22px; fill: currentColor; }
.votes { display: grid; gap: 6px; }
.vote-bar { height: 6px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.vote-bar i { display: block; height: 100%; background: var(--grad); }
.vote-counts { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.tab-pane h2 { font-size: 18px; margin: 0 0 10px; }
.desc { margin: 0 0 22px; color: #c9cdd6; white-space: pre-line; line-height: 1.6; max-width: 90ch; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 17px; }
.servers-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.servers-head h2 { margin: 0; }
.servers { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.server { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.server .btn { grid-row: 1 / 3; grid-column: 2; }
.server-count { font-size: 14px; color: var(--muted); }
.server-count strong { color: var(--fg); font-size: 16px; }
.fill-bar { height: 5px; border-radius: 5px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.fill-bar i { display: block; height: 100%; background: var(--live); }
.server-meta { font-size: 12.5px; }
.servers li.pad { grid-column: 1 / -1; }

/* ---- skeletons ---- */
.skel { background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear; border-radius: 8px; }
.skel-title { width: 180px; height: 22px; }
.skel-line { height: 14px; width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- dialogs ---- */
dialog { color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(5 6 9 / .7); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.small-dialog { width: min(440px, calc(100vw - 32px)); }
.small-dialog form { padding: 22px; display: grid; gap: 12px; }
.small-dialog h2 { margin: 0; font-size: 20px; }
.small-dialog p { margin: 0; font-size: 14px; }
.small-dialog input { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .game-top { grid-template-columns: 1fr; }
  .topnav { display: none; }
}
@media (max-width: 900px) {
  .menu-toggle { display: grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; background: var(--bg-2); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; }
}
@media (max-width: 640px) {
  .brand span, .search kbd { display: none; }
  .topbar { gap: 10px; padding: 0 10px; }
  .account-btn span { display: none; }
  .account-btn { padding: 4px; }
}

/* ---- player ---- */
#player, #canvas { position: fixed; inset: 0; width: 100%; height: 100%; }
#canvas { display: block; outline: none; }
#input-container { position: fixed; left: -9999px; top: 0; }
#loading-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; }
#loading-background-image { position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); object-fit: cover;
  opacity: .28; filter: blur(24px) saturate(1.2); }
#loading-background-image:not([src]) { display: none; }
.loading-center, .loading-error-panel { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
#loading-icon-shell img { width: 132px; height: 132px; border-radius: 26px; box-shadow: var(--shadow); }
#loading-icon-shell img:not([src]) { visibility: hidden; }
#loading-experience-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; max-width: 80vw; }
.creator-line { color: var(--muted); }
#status { color: var(--muted); min-height: 1.4em; max-width: 80vw; }
.spinner { width: 28px; height: 28px; margin-top: 8px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent-2);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay:has(.loading-error-panel:not([hidden])) .loading-center { display: none; }
.loading-error-panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; max-width: 420px; box-shadow: var(--shadow); }
.loading-error-panel h2 { margin: 0; }
.loading-error-panel p { margin: 0; color: var(--muted); }
#debug-info { position: fixed; bottom: 4px; left: 6px; font-size: 11px; color: var(--muted); }

/* proxy status */
.proxy-pill { margin: auto 12px 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.proxy-pill + .side-foot { margin-top: 0; }
.proxy-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px rgb(245 158 11 / .18); }
.proxy-pill.ok .dot { background: #22c55e; box-shadow: 0 0 0 3px rgb(34 197 94 / .18); }
.proxy-pill.bad .dot { background: #ef4444; box-shadow: 0 0 0 3px rgb(239 68 68 / .18); }
