:root {
  --bg: #050507;
  --bg-2: #0d0d13;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #f5f3ef;
  --muted: rgba(245, 243, 239, 0.64);
  --dim: rgba(245, 243, 239, 0.42);
  --violet: #8b7bff;
  --coral: #ff6b8b;
  --cyan: #3ee0ff;
  --amber: #ffc24b;
  --good: #3ddc97;
  --danger: #ff6b6b;
  --grad: linear-gradient(100deg, #8b7bff 0%, #b06cf0 48%, #ff6b8b 100%);
  --radius: 16px;
  --mh: calc(var(--tb-h) + var(--tb-gap) * 2);
  --gutter: clamp(16px, 3.2vw, 44px);
  --card-w: clamp(128px, 13.5vw, 184px);
  --tap: 44px;
  color-scheme: dark;
  font-family: var(--sh-font);
}
:root.car { --card-w: clamp(168px, 15vw, 230px); --tap: 56px; font-size: 18px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; min-height: 100dvh; line-height: 1.4; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body.playing { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible, .navfocus { outline: 3px solid var(--cyan); outline-offset: 3px; }
img { display: block; }

/* ---------- top bar ---------- */
.gbar { font-family: var(--sh-font); }
body.playing .gbar { display: none; }
.gsearch { position: relative; flex: 0 1 340px; min-width: 0; }
.gsearch input {
  width: 100%; height: 46px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  padding: 0 16px 0 42px; font-size: 15px; outline: none; color: var(--text);
}
.gsearch input::placeholder { color: var(--dim); }
.gsearch input:focus { border-color: rgba(160, 146, 255, 0.7); background: rgba(139, 123, 255, 0.08); }
.gsearch svg { position: absolute; left: 15px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }
.ibtn {
  width: var(--tap); height: var(--tap); flex: none; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; color: var(--text);
}
.ibtn:hover { background: var(--panel-2); }
.ibtn svg { width: 22px; height: 22px; }

/* ---------- buttons & chips ---------- */
.btn {
  height: var(--tap); padding: 0 20px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 15px; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 10px 30px -10px rgba(255, 92, 122, 0.7); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { height: calc(var(--tap) + 10px); padding: 0 28px; font-size: 17px; border-radius: 16px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.3px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.sys { color: #fff; background: rgba(124, 92, 255, 0.22); border-color: rgba(124, 92, 255, 0.45); }
.chip.good { color: var(--good); border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.08); }
.chip.warn { color: var(--amber); border-color: rgba(255, 181, 71, 0.35); background: rgba(255, 181, 71, 0.08); }

main { padding: var(--mh) 0 64px; padding-bottom: max(64px, env(safe-area-inset-bottom)); }
/* The home hero runs under the floating bar. */
main > .hero:first-child { margin-top: calc(-1 * var(--mh)); padding-top: var(--mh); }
.wrap { padding: 0 var(--gutter); }

/* ---------- hero ---------- */
.hero { position: relative; min-height: clamp(380px, 58vh, 640px); display: flex; align-items: flex-end; overflow: hidden; isolation: isolate; }
.hero .bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center right; }
.hero .bg.blur { filter: blur(26px) saturate(1.3); transform: scale(1.15); opacity: 0.55; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(7, 8, 12, 0.96) 0%, rgba(7, 8, 12, 0.75) 42%, rgba(7, 8, 12, 0.15) 75%),
    linear-gradient(0deg, var(--bg) 0%, rgba(7, 8, 12, 0) 45%);
}
.hero .inner { display: flex; align-items: flex-end; gap: clamp(18px, 3vw, 40px); padding: 40px var(--gutter) 34px; width: 100%; }
.hero .cover-lg { width: clamp(130px, 15vw, 210px); flex: none; }
.hero .copy { max-width: 640px; }
.hero .kicker { font-size: 12px; font-weight: 700; letter-spacing: 2.6px; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(34px, 5vw, 72px); line-height: .95; letter-spacing: -0.035em; font-weight: 900; text-wrap: balance; }
.hero p.sub { margin: 0 0 20px; color: var(--muted); font-size: clamp(15px, 1.4vw, 18px); max-width: 52ch; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- system rail ---------- */
.sysrail { display: flex; gap: 10px; overflow-x: auto; padding: 18px var(--gutter) 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.sysrail::-webkit-scrollbar { display: none; }
.syschip {
  flex: none; display: flex; align-items: center; gap: 10px; height: calc(var(--tap) + 12px); padding: 0 16px 0 8px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); scroll-snap-align: start; font-weight: 700; font-size: 14px; color: var(--muted);
}
.syschip img { width: 40px; height: 40px; object-fit: contain; }
.syschip .n { font-size: 12px; color: var(--dim); font-weight: 700; }
.syschip.all { padding: 0 18px; }
.syschip:hover { background: var(--panel-2); color: var(--text); }
.syschip.on { background: rgba(124, 92, 255, 0.18); border-color: rgba(124, 92, 255, 0.55); color: #fff; }
.syschip.on .n { color: #cfc4ff; }

/* ---------- shelves & grid ---------- */
.shelf { margin-top: 26px; }
.shelf h2, .sect h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 var(--gutter) 12px; font-size: 19px; font-weight: 800; letter-spacing: -0.2px; }
.shelf h2 .n, .sect h2 .n { font-size: 13px; color: var(--dim); font-weight: 700; }
.shelf h2 a { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 16px; overflow-x: auto; padding: 4px var(--gutter) 12px; scroll-snap-type: x proximity; scroll-padding: 0 var(--gutter); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.row .gcard { width: var(--card-w); flex: none; scroll-snap-align: start; }
.grid { display: grid; gap: 22px 16px; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); padding: 4px var(--gutter); }

.gcard { display: block; border-radius: var(--radius); outline-offset: 4px; -webkit-tap-highlight-color: transparent; }
.cover {
  position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; background: var(--bg-2);
  border: 1px solid var(--line); box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.9); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.cover .bg { position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover; filter: blur(18px) saturate(1.4); opacity: 0.55; }
.cover .art { position: absolute; inset: 8%; width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6)); }
.cover.noart { background-size: cover; background-position: center; }
.cover.noart .ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 14px; gap: 6px;
  background: linear-gradient(to top, rgba(7, 8, 12, 0.88), rgba(7, 8, 12, 0.05) 70%); }
.cover.noart .ph b { font-size: 16px; line-height: 1.15; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cover.noart .ph img { width: 44px; height: 44px; object-fit: contain; }
.gcard:hover .cover, .gcard.navfocus .cover, .gcard:focus-visible .cover { transform: translateY(-4px); border-color: rgba(124, 92, 255, 0.6); box-shadow: 0 22px 40px -18px rgba(124, 92, 255, 0.55); }
.gcard.navfocus, .gcard:focus-visible { outline: none; }
.gcard.navfocus .cover, .gcard:focus-visible .cover { outline: 3px solid var(--cyan); outline-offset: 3px; }
.cover .badge {
  position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px 5px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.4px; background: rgba(7, 8, 12, 0.78); border: 1px solid var(--line-2); backdrop-filter: blur(6px);
}
.cover .badge svg { width: 12px; height: 12px; color: var(--good); }
.cover .fav { position: absolute; right: 10px; top: 10px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(7, 8, 12, 0.7); color: var(--coral); }
.cover .fav svg { width: 15px; height: 15px; }
.cover .lock { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(7, 8, 12, 0.55); }
.cover .lock span { font-size: 11px; font-weight: 800; padding: 6px 10px; border-radius: 999px; background: rgba(7, 8, 12, 0.8); border: 1px solid var(--line-2); color: var(--amber); }
.morecover { display: grid; place-content: center; justify-items: center; gap: 6px; background: linear-gradient(160deg, rgba(124, 92, 255, 0.25), rgba(255, 92, 122, 0.18)); }
.morecover b { font-size: 30px; font-weight: 850; }
.morecover span { color: var(--muted); font-weight: 700; font-size: 14px; }
.gcard .cap { padding: 10px 2px 0; }
.gcard .cap b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.25; font-weight: 700; }
.gcard .cap span { display: block; margin-top: 3px; font-size: 12px; color: var(--dim); font-weight: 600; }

.sect { margin-top: 26px; }
.syshead { display: flex; align-items: center; gap: 18px; padding: 26px var(--gutter) 6px; }
.syshead img { width: 96px; height: 96px; object-fit: contain; filter: drop-shadow(0 12px 24px rgba(124, 92, 255, 0.35)); }
.syshead h1 { margin: 0; font-size: clamp(26px, 3.2vw, 40px); letter-spacing: -0.6px; }
.syshead p { margin: 4px 0 0; color: var(--muted); }

/* ---------- empty & status ---------- */
.empty { display: grid; grid-template-columns: minmax(200px, 380px) 1fr; gap: clamp(20px, 4vw, 56px); align-items: center; padding: 40px var(--gutter); max-width: 1180px; margin: 0 auto; }
.empty img { width: 100%; border-radius: 28px; box-shadow: 0 30px 80px -30px rgba(124, 92, 255, 0.6); }
.empty h1 { margin: 0 0 10px; font-size: clamp(28px, 3.4vw, 44px); letter-spacing: -0.6px; line-height: 1.05; }
.empty p { color: var(--muted); margin: 0 0 14px; }
.empty code, .detail code { background: var(--panel-2); border: 1px solid var(--line); padding: 2px 7px; border-radius: 7px; font-size: 13px; word-break: break-all; }
.empty .systems { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 22px; }
.status { color: var(--muted); padding: 60px var(--gutter); text-align: center; }
.status.bad { color: var(--danger); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--coral); animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- detail ---------- */
.detail { position: relative; min-height: calc(100vh - 70px); isolation: isolate; overflow: hidden; }
.detail .backdrop { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; filter: blur(30px) saturate(1.3); transform: scale(1.2); opacity: 0.5; }
.detail::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(7, 8, 12, 0.35), var(--bg) 85%); }
.dwrap { display: grid; grid-template-columns: minmax(170px, 300px) 1fr; gap: clamp(22px, 4vw, 54px); padding: clamp(24px, 5vh, 56px) var(--gutter) 40px; max-width: 1280px; margin: 0 auto; align-items: start; }
.dwrap .cover { box-shadow: 0 30px 70px -26px rgba(0, 0, 0, 0.95); }
.dinfo h1 { margin: 10px 0 8px; font-size: clamp(30px, 4vw, 52px); line-height: 1.04; letter-spacing: -0.8px; }
.dinfo .meta { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.dinfo .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.dinfo .note { color: var(--muted); font-size: 14px; margin: 0 0 26px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dinfo h3 { margin: 26px 0 12px; font-size: 16px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.states { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.scard { border-radius: 14px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); text-align: left; padding: 0; }
.scard:hover { border-color: rgba(124, 92, 255, 0.55); }
.scard .shot { aspect-ratio: 4 / 3; background: #000 center / contain no-repeat; }
.scard .shot.none { display: grid; place-items: center; color: var(--dim); font-size: 13px; }
.scard .lbl { padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.scard .lbl b { font-weight: 800; }
.scard .lbl span { color: var(--dim); }
.manage { margin-top: 32px; color: var(--muted); font-size: 14px; }
.manage summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.manage .inner { display: grid; gap: 10px; padding: 10px 0; }

/* ---------- sheets ---------- */
dialog.sheet {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); border: 1px solid var(--line-2); border-radius: 24px; padding: 0;
  background: #10121b; color: var(--text); box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.9);
}
dialog.sheet::backdrop { background: rgba(3, 4, 8, 0.72); backdrop-filter: blur(4px); }
.sheet .shead { display: flex; align-items: center; gap: 12px; padding: 20px 22px 6px; }
.sheet .shead h2 { margin: 0; font-size: 22px; flex: 1; }
.sheet .sbody { padding: 10px 22px 24px; overflow: auto; }
.sheet p { color: var(--muted); }
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 34px 20px; border-radius: 18px; border: 2px dashed rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.06); cursor: pointer; font-weight: 700;
}
.drop.over { background: rgba(124, 92, 255, 0.16); border-color: var(--violet); }
.drop svg { width: 36px; height: 36px; color: var(--violet); }
.drop small { color: var(--muted); font-weight: 500; }
.uplist { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.uplist li { padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 8px; }
.uplist .top { display: flex; gap: 10px; align-items: center; }
.uplist .top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.uplist select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 13px; }
.uplist select option { color: #111; }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.2s ease; }
.uplist .msg { font-size: 12px; color: var(--muted); }
.uplist .msg.bad { color: var(--danger); }
.uplist .msg.good { color: var(--good); }

.toast {
  position: fixed; left: 50%; top: max(18px, env(safe-area-inset-top)); translate: -50% 0; z-index: 90; padding: 11px 18px; border-radius: 999px;
  background: rgba(16, 18, 27, 0.94); border: 1px solid var(--line-2); font-weight: 700; font-size: 14px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
  display: flex; gap: 10px; align-items: center; animation: toastin 0.22s ease; pointer-events: none;
}
.toast svg { width: 18px; height: 18px; color: var(--good); }
@keyframes toastin { from { opacity: 0; translate: -50% -8px; } }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#ejs { position: absolute; inset: 0; z-index: 0; transition: transform 0.2s ease; }
.player .ejs_parent { background: #000 !important; }
.player .ejs_menu_bar, .player .ejs_virtualGamepad_parent, .player .ejs_virtualGamepad_open { display: none !important; }
.player.ejsbar .ejs_menu_bar { display: flex !important; }
.player .ejs_start_button { display: none !important; }

.loader { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #05060a; transition: opacity 0.35s ease; }
.loader .bgart { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(40px) saturate(1.4); opacity: 0.35; transform: scale(1.2); }
.loader .card { position: relative; display: grid; justify-items: center; gap: 18px; text-align: center; padding: 20px; max-width: 520px; }
.loader .card .cover { width: clamp(140px, 18vw, 220px); }
.loader h2 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); }
.loader p { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.loader.gone { opacity: 0; pointer-events: none; }
.loader .tap { margin-top: 6px; }
.loader p.note { margin-top: -10px; font-size: 13px; color: var(--dim); max-width: 34ch; min-height: 0; }

.hud { position: absolute; z-index: 20; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); display: flex; gap: 8px; }
.hud button {
  width: calc(var(--tap) + 4px); height: calc(var(--tap) + 4px); border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 11, 18, 0.55); backdrop-filter: blur(8px); display: grid; place-items: center; color: #fff; opacity: 0.75;
}
.hud button:hover { opacity: 1; }
.hud button svg { width: 24px; height: 24px; }
.hud .pads { display: flex; gap: 6px; align-items: center; padding: 0 6px; }
.hud .pads i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 800; color: #fff; }

.pmenu { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(3, 4, 8, 0.72); backdrop-filter: blur(10px); }
.pmenu .box { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; padding: 22px; border-radius: 26px; background: rgba(16, 18, 27, 0.96); border: 1px solid var(--line-2); }
.pmenu .ptitle { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.pmenu .ptitle .cover { width: 64px; border-radius: 12px; }
.pmenu .ptitle h2 { margin: 0; font-size: 22px; line-height: 1.15; }
.pmenu .ptitle p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pmenu .ptitle .grow { flex: 1; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  min-height: calc(var(--tap) + 40px); border-radius: 18px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column;
  align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px; text-align: left; font-weight: 700; font-size: 15px;
}
.tile svg { width: 26px; height: 26px; color: #cfc4ff; }
.tile small { color: var(--muted); font-weight: 600; font-size: 12px; margin-top: -6px; }
.tile:hover, .tile.navfocus { background: var(--panel-2); border-color: rgba(124, 92, 255, 0.5); }
.tile.primary { background: var(--grad); border: 0; color: #fff; }
.tile.primary svg { color: #fff; }
.tile.on { border-color: rgba(61, 220, 151, 0.5); }
.tile.on small { color: var(--good); }
.tile.danger svg { color: var(--danger); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
.subhead { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; }
.subhead h3 { margin: 0; font-size: 17px; flex: 1; }
.volrow { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.volrow input { flex: 1; accent-color: var(--coral); height: 30px; }
.volrow svg { width: 24px; height: 24px; flex: none; color: #cfc4ff; }

.pairing { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.pairing .qr { width: clamp(170px, 22vw, 240px); padding: 10px; border-radius: 18px; background: #fff; }
.pairing .qr svg { display: block; width: 100%; height: auto; }
.pairing .code { font-size: 40px; font-weight: 850; letter-spacing: 8px; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.pairing ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }
.padlist { display: grid; gap: 8px; margin-top: 14px; }
.padlist .p { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; }
.padlist .p i, .pnum { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; color: #fff; flex: none; }
.padlist select { margin-left: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.padlist select option { color: #111; }
.p1 { background: var(--violet); } .p2 { background: var(--coral); } .p3 { background: #13b5d6; } .p4 { background: #e39a1b; }

.nudge {
  position: absolute; z-index: 30; right: max(14px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); width: min(360px, calc(100vw - 28px));
  display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: center; padding: 14px; border-radius: 20px; background: rgba(16, 18, 27, 0.94);
  border: 1px solid var(--line-2); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
}
.nudge .qr { background: #fff; border-radius: 12px; padding: 6px; }
.nudge .qr svg { display: block; width: 100%; height: auto; }
.nudge > div:nth-child(2) { padding-right: 22px; }
.nudge b { display: block; font-size: 15px; margin-bottom: 4px; }
.nudge p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.nudge .x { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--panel-2); color: var(--muted); }

/* ---------- touch gamepad ---------- */
.tpad { position: absolute; inset: 0; z-index: 15; pointer-events: none; --s: clamp(118px, min(24vw, 34vh), 210px); opacity: var(--tp-alpha, 0.85); }
:root.car .tpad { --s: clamp(150px, min(22vw, 34vh), 240px); }
.tp-zone { position: absolute; display: flex; align-items: center; gap: 14px; }
.tp-left { left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); flex-direction: column-reverse; }
.tp-right { right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); flex-direction: column-reverse; align-items: flex-end; }
.tp-center { left: 50%; translate: -50% 0; bottom: max(10px, env(safe-area-inset-bottom)); gap: 10px; }
.tp-sl { left: max(14px, env(safe-area-inset-left)); bottom: calc(var(--s) + 52px); gap: 10px; }
.tp-sr { right: max(14px, env(safe-area-inset-right)); bottom: calc(var(--s) + 52px); gap: 10px; flex-direction: row-reverse; }
.tp-btn, .tp-dpad, .tp-stick, .tp-face, .tp-rows { pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
.tp-btn { display: grid; place-items: center; color: rgba(255, 255, 255, 0.92); font-weight: 800; background: rgba(20, 22, 34, 0.55); border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 16px -8px rgba(0, 0, 0, 0.8); transition: transform 0.06s ease, background 0.06s ease; }
.tp-btn.on { transform: scale(0.92); background: rgba(124, 92, 255, 0.6); border-color: rgba(200, 188, 255, 0.8); }
.tp-pill { height: 34px; padding: 0 16px; border-radius: 999px; font-size: 12px; letter-spacing: 0.6px; text-transform: uppercase; }
.tp-shoulder { width: calc(var(--s) * 0.42); height: 40px; border-radius: 14px; font-size: 14px; }
.tp-face { position: relative; width: var(--s); height: var(--s); }
.tp-face .tp-round { position: absolute; width: 36%; height: 36%; border-radius: 50%; font-size: calc(var(--s) * 0.13); }
.tp-face .tp-round.big { width: 42%; height: 42%; }
.tp-face .pos-n { left: 32%; top: 0; } .tp-face .pos-s { left: 32%; bottom: 0; }
.tp-face .pos-w { left: 0; top: 32%; } .tp-face .pos-e { right: 0; top: 32%; }
.tp-face .pos-ne { right: 2%; top: 10%; width: 44%; height: 44%; } .tp-face .pos-sw { left: 2%; bottom: 10%; width: 44%; height: 44%; }
.tp-face.n2 .pos-w { left: 2%; top: 30%; width: 44%; height: 44%; } .tp-face.n2 .pos-e { right: 2%; top: 30%; width: 44%; height: 44%; }
.tp-face.n1 .pos-e { right: 20%; top: 20%; width: 60%; height: 60%; }
.tp-face.n2 .big.pos-s { left: 46%; bottom: 0; width: 46%; height: 46%; }
.tp-face.n2 .pos-w.tone-n64b { left: 4%; top: 22%; width: 38%; height: 38%; }
.tp-cbtn { width: calc(var(--s) * 0.72); height: calc(var(--s) * 0.72); }
.tp-cbtn .tp-round { font-size: calc(var(--s) * 0.09); background: rgba(255, 196, 0, 0.18); border-color: rgba(255, 210, 80, 0.5); }
.tone-n64a { background: rgba(38, 120, 255, 0.4); border-color: rgba(120, 170, 255, 0.7); }
.tone-n64b { background: rgba(40, 190, 90, 0.35); border-color: rgba(110, 230, 150, 0.7); }
.tp-snes .pos-n { background: rgba(60, 110, 255, 0.32); } .tp-snes .pos-e { background: rgba(255, 70, 70, 0.32); }
.tp-snes .pos-s { background: rgba(255, 200, 40, 0.3); } .tp-snes .pos-w { background: rgba(50, 200, 100, 0.3); }
.tone-tri { color: #5ef0c8; } .tone-cir { color: #ff7a8a; } .tone-crs { color: #8fb4ff; } .tone-sqr { color: #f59de6; }
.tp-rows { display: grid; gap: 10px; }
.tp-row { display: flex; gap: 10px; }
.tp-rows .tp-round { width: calc(var(--s) * 0.34); height: calc(var(--s) * 0.34); border-radius: 50%; font-size: calc(var(--s) * 0.12); }
.tp-rows .tp-round.small { width: calc(var(--s) * 0.26); height: calc(var(--s) * 0.26); font-size: calc(var(--s) * 0.09); margin: 0 calc(var(--s) * 0.04); }
.tp-dpad { position: relative; width: var(--s); height: var(--s); }
.tp-dpad.small { width: calc(var(--s) * 0.62); height: calc(var(--s) * 0.62); }
.tp-dpad .arm { position: absolute; background: rgba(34, 37, 56, 0.66); border: 1.5px solid rgba(255, 255, 255, 0.26); }
.tp-dpad .arm::after { content: ""; position: absolute; left: 50%; top: 50%; border: calc(var(--s) * 0.045) solid transparent; }
.tp-dpad .arm.up::after { border-bottom-color: rgba(255, 255, 255, 0.6); translate: -50% -80%; }
.tp-dpad .arm.down::after { border-top-color: rgba(255, 255, 255, 0.6); translate: -50% -20%; }
.tp-dpad .arm.left::after { border-right-color: rgba(255, 255, 255, 0.6); translate: -80% -50%; }
.tp-dpad .arm.right::after { border-left-color: rgba(255, 255, 255, 0.6); translate: -20% -50%; }
.tp-dpad .arm.up, .tp-dpad .arm.down { left: 33%; width: 34%; height: 36%; }
.tp-dpad .arm.left, .tp-dpad .arm.right { top: 33%; height: 34%; width: 36%; }
.tp-dpad .arm.up { top: 0; border-radius: 10px 10px 2px 2px; } .tp-dpad .arm.down { bottom: 0; border-radius: 2px 2px 10px 10px; }
.tp-dpad .arm.left { left: 0; border-radius: 10px 2px 2px 10px; } .tp-dpad .arm.right { right: 0; border-radius: 2px 10px 10px 2px; }
.tp-dpad .arm.on { background: rgba(124, 92, 255, 0.65); border-color: rgba(200, 188, 255, 0.8); }
.tp-dpad .hub { position: absolute; left: 33%; top: 33%; width: 34%; height: 34%; background: rgba(20, 22, 34, 0.6); }
.tp-stick { position: relative; width: var(--s); height: var(--s); border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,0.06), rgba(20, 22, 34, 0.55) 70%); border: 1.5px solid rgba(255, 255, 255, 0.2); display: grid; place-items: center; }
.tp-stick.small { width: calc(var(--s) * 0.6); height: calc(var(--s) * 0.6); }
.tp-stick .knob { width: 44%; height: 44%; border-radius: 50%; background: rgba(230, 232, 245, 0.85); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6); }
.tp-stick.live .knob { background: #fff; }

/* ---------- phone controller page ---------- */
body.padpage { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  background: #05060a url("/games/assets/pad-bg.webp") center / cover no-repeat; -webkit-touch-callout: none; }
.padpage #app { position: absolute; inset: 0; }
.padpage .ptop { position: absolute; z-index: 20; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); }
.padpage .pbadge { height: 34px; min-width: 46px; padding: 0 10px; border-radius: 999px; display: grid; place-items: center; font-weight: 850; letter-spacing: 0.5px; color: #fff; }
.padpage .ptitle2 { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.padpage .lat { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.padpage .ibtn { width: 40px; height: 40px; }
.padpage .psurface { position: absolute; inset: 0; }
.padpage .tpad { --s: clamp(130px, min(36vw, 54vh), 250px); opacity: 1; }
.padpage .tp-left { bottom: max(18px, env(safe-area-inset-bottom)); left: max(22px, env(safe-area-inset-left)); }
.padpage .tp-right { bottom: max(18px, env(safe-area-inset-bottom)); right: max(22px, env(safe-area-inset-right)); }
.padpage .tp-sl, .padpage .tp-sr { bottom: auto; top: max(54px, calc(env(safe-area-inset-top) + 46px)); }
.padpage .tp-shoulder { height: 48px; width: calc(var(--s) * 0.5); }
.padpage .tp-center { bottom: max(14px, env(safe-area-inset-bottom)); }
.padpage .tp-pill { height: 40px; padding: 0 20px; }
.padpage .pover { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(5, 6, 10, 0.82); backdrop-filter: blur(6px); }
.padpage .pmsg { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 24px; max-width: 420px; }
.padpage .pmsg p { margin: 0; color: var(--muted); }
.padpage .rotate { display: none; }
@media (orientation: portrait) {
  .padpage .rotate { position: absolute; z-index: 25; left: 0; right: 0; top: 30%; display: grid; justify-items: center; gap: 6px; text-align: center; padding: 0 30px; pointer-events: none; }
  .padpage .rotate p { margin: 0; color: var(--muted); font-size: 14px; }
  .padpage .tpad { --s: clamp(120px, 40vw, 190px); }
}
.padpage .join { position: absolute; inset: 0; overflow: auto; display: grid; align-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; touch-action: auto; user-select: auto; }
.padpage .join img { width: 72px; height: 72px; }
.padpage .join h1 { margin: 0; font-size: 28px; }
.padpage .join p { margin: 0; color: var(--muted); max-width: 360px; }
.padpage .join input { width: 220px; height: 70px; text-align: center; font-size: 38px; font-weight: 850; letter-spacing: 12px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--panel); outline: none; }
.padpage .join input:focus { border-color: var(--violet); }
.padpage .join .err { color: var(--danger); min-height: 1.4em; }

@media (max-width: 760px) {
  body.playing .tabbar { display: none; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .gsearch { flex: 1; }
  .gsearch input { height: 42px; }
  .gbar .tb-brand span { display: none; }
}
@media (max-width: 760px) {
  .dwrap { grid-template-columns: 1fr; }
  .dwrap .cover { width: 62%; max-width: 260px; margin: 0 auto; }
  .empty { grid-template-columns: 1fr; }
  .hero .cover-lg { display: none; }
  .pairing { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}
@media (orientation: portrait) and (max-width: 900px) {
  .tpad { --s: clamp(120px, 34vw, 200px); }
}
@media (prefers-reduced-motion: reduce) {
  .cover, .tp-btn { transition: none; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- sort & filter ---------- */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px var(--gutter) 6px; }
.sect .filters { padding-top: 0; margin-bottom: 16px; }
.fsel { position: relative; display: inline-flex; align-items: center; gap: 8px; height: var(--tap); padding: 0 6px 0 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--dim); }
.fsel select { appearance: none; -webkit-appearance: none; border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%239ea3b8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 4px center / 20px; padding: 0 28px 0 0; height: 100%; font-size: 14px; font-weight: 700; color: var(--text); outline: none; width: auto; max-width: min(220px, 52vw); text-overflow: ellipsis; }
.fsel select option { background: var(--bg-2); color: var(--text); }
.fsel:focus-within { border-color: var(--violet); }
.fchips { display: inline-flex; gap: 6px; padding: 3px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.fchips .fchip { border: 0; height: calc(var(--tap) - 8px); background: transparent; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: var(--tap); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.fchip svg { width: 15px; height: 15px; }
.fchip:hover { color: var(--text); }
.fchip.on { color: #fff; background: rgba(124, 92, 255, 0.28); }
.fchip.on svg { color: var(--amber); }
.fchip.clear { background: transparent; border-style: dashed; }
.stars { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; font-style: normal; color: var(--amber); font-weight: 750; }
.stars svg { width: 12px; height: 12px; }

.dinfo .facts { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 14px; }
.dinfo .facts .chip { font-size: 13px; padding: 5px 12px; }
.chip.rate { color: var(--amber); border-color: rgba(255, 181, 71, 0.4); background: rgba(255, 181, 71, 0.1); font-size: 14px; }
.chip.rate svg { width: 14px; height: 14px; }
.chip.rate small { color: var(--muted); font-weight: 600; margin-left: 2px; }
.dinfo .credits { margin: 0 0 12px; color: var(--muted); font-size: 14px; font-weight: 600; }
.dinfo .overview { margin: 0 0 22px; max-width: 68ch; color: #c9ccdb; font-size: 15px; line-height: 1.55; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.dinfo .overview.open { display: block; -webkit-line-clamp: unset; }

@media (max-width: 760px) {
  .filters { gap: 8px; }
  .fsel { flex: 1 1 140px; min-width: 0; padding-left: 12px; height: 42px; }
  .fsel select { flex: 1; min-width: 0; width: 100%; max-width: none; }
  .fchip { height: 42px; padding: 0 12px; }
  .fchips { order: 3; width: 100%; justify-content: space-between; }
  .fchips .fchip { flex: 1; justify-content: center; height: 36px; padding: 0 6px; }
}

.mystars { display: flex; align-items: center; gap: 2px; margin: -4px 0 14px; }
.mystars .lbl { margin-right: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.mstar { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: rgba(255, 255, 255, 0.22); transition: color .12s, transform .12s; }
.mstar:hover { background: rgba(255, 255, 255, 0.06); }
.mstar:active { transform: scale(.9); }
.mstar svg { width: 30px; height: 30px; }
.mstar.on { color: var(--amber); filter: drop-shadow(0 4px 12px rgba(255, 194, 75, 0.35)); }
.cover .mine { position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 3px; padding: 4px 8px; border-radius: 999px; background: rgba(139, 123, 255, 0.9); color: #fff; font-size: 11px; font-weight: 800; }
.cover .mine svg { width: 12px; height: 12px; }
