/* SGame Center — 像素风界面。场景本身画在 canvas 里，这里只有叠在上面的 UI。 */
@font-face { font-family: "FP12"; src: url(../fonts/fusion-pixel-12px-sc.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "FP8"; src: url(../fonts/fusion-pixel-8px-sc.woff2) format("woff2"); font-display: block; }

:root {
  --ink: #f4efe6;
  --dim: #a99cc4;
  --out: #140c1c;
  --win: #241834;
  --win-hi: #46325f;
  --win-lo: #170f24;
  --pink: #ff5ca8;
  --cyan: #4ff2ff;
  --yellow: #ffd65c;
  --a: var(--pink);
  --px: "FP12", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0712; color: var(--ink); font: 12px/1.5 var(--px); -webkit-font-smoothing: none; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: inherit; padding: 0 4px; color: var(--out); background: var(--ink); box-shadow: 0 2px 0 #8a7fa0; }

/* ------------------------------------------------------------------ 场景 */
#viewport { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#stage.zooming { transition: transform .9s cubic-bezier(.65, 0, .35, 1); }
#room { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(130% 100% at 50% 45%, transparent 60%, rgba(5, 2, 10, .55)); }
#boot { position: fixed; inset: 0; display: grid; place-content: center; font-size: 24px; letter-spacing: 4px; color: var(--pink); background: #0b0712; z-index: 60; }
#boot span { animation: blink 1s steps(2) infinite; }
body.ready #boot { display: none; }

/* ------------------------------------------------------------------ 像素窗口 / 按钮 */
.px-win {
  background: var(--win);
  box-shadow:
    inset 2px 2px 0 var(--win-hi), inset -2px -2px 0 var(--win-lo),
    0 0 0 2px var(--out), 4px 4px 0 2px rgba(0, 0, 0, .45);
}
.px-btn {
  height: 28px; padding: 0 12px; border: 0; background: #33244a; color: var(--ink);
  box-shadow: inset 2px 2px 0 #574077, inset -2px -2px 0 #1d132c, 0 0 0 2px var(--out);
}
.px-btn:hover { background: #3d2b58; }
.px-btn:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 #1d132c, 0 0 0 2px var(--out); }
.px-btn.off { color: #6d6182; }

/* ------------------------------------------------------------------ 顶栏 */
#topbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  pointer-events: none; transition: opacity .3s;
}
#topbar > * { pointer-events: auto; }
.logo { display: flex; align-items: baseline; gap: 10px; }
.logo b { font-weight: 400; font-size: 24px; letter-spacing: 2px; color: #ffd6ec; text-shadow: 2px 0 0 var(--pink), -2px 0 0 var(--pink), 0 2px 0 var(--pink), 0 -2px 0 var(--pink), 4px 4px 0 #3a0f2a; }
.logo span { color: var(--cyan); text-shadow: 2px 2px 0 #0b3a44; }
.actions { display: flex; gap: 12px; }

/* ------------------------------------------------------------------ 机台卡片 */
#card {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; width: min(620px, calc(100vw - 28px));
  animation: pop .18s steps(3);
  box-shadow:
    inset 0 2px 0 var(--a), inset 2px 2px 0 var(--win-hi), inset -2px -2px 0 var(--win-lo),
    0 0 0 2px var(--out), 4px 4px 0 2px rgba(0, 0, 0, .45);
}
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }
.card-thumb { width: 128px; height: 80px; object-fit: cover; flex: none; box-shadow: 0 0 0 2px var(--out), 0 0 0 4px #3a2b52; background: #000; }
.card-body { flex: 1; min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 10px; }
.card-title { font-size: 24px; line-height: 1.2; color: #fff; text-shadow: 2px 2px 0 var(--out); }
.card-plays { color: var(--yellow); }
.card-sub { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.card-tags span, .dir-tags button, #dirList .tags span { padding: 0 6px; color: var(--out); background: var(--a); border: 0; }
.card-controls { color: #8d80a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-play { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; padding: 0 2px; }
.card-play b {
  font-weight: 400; padding: 10px 12px; color: #fff; background: #e8404a; text-shadow: 2px 2px 0 #7a1420;
  box-shadow: inset 2px 2px 0 #ff8a8a, inset -2px -2px 0 #a82030, 0 0 0 2px var(--out), 0 4px 0 2px var(--out);
  animation: glowBtn 1.2s steps(2) infinite;
}
.card-play:active b { transform: translateY(4px); box-shadow: inset 2px 2px 0 #a82030, 0 0 0 2px var(--out); }
.card-play[disabled] b { background: #5a5466; text-shadow: none; box-shadow: inset 2px 2px 0 #7a7488, inset -2px -2px 0 #3a3444, 0 0 0 2px var(--out); animation: none; }
.card-play[disabled] kbd { visibility: hidden; }
@keyframes glowBtn { 50% { background: #ff5662; } }

#hint {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 19;
  padding: 8px 14px; white-space: nowrap; transition: opacity .3s;
}
#hint.gone { opacity: 0; pointer-events: none; }
#hint .touch { display: none; }
@media (max-width: 640px), (pointer: coarse) { #hint .pc { display: none; } #hint .touch { display: inline; } }

body.playing #topbar, body.playing #card, body.playing #hint { opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------------ 目录 */
#directory {
  position: fixed; top: 56px; right: 14px; bottom: 14px; z-index: 30; width: min(360px, calc(100vw - 28px));
  display: flex; flex-direction: column; gap: 10px; padding: 14px; animation: pop .18s steps(3);
}
.dir-head { display: flex; align-items: center; justify-content: space-between; }
.dir-head h2 { margin: 0; font-weight: 400; font-size: 24px; text-shadow: 2px 2px 0 var(--out); }
.dir-close { width: 28px; padding: 0; }
#dirSearch {
  height: 32px; padding: 0 10px; border: 0; font: inherit; color: var(--ink); background: #120b1c; outline: none; user-select: text;
  box-shadow: inset 2px 2px 0 #08040e, 0 0 0 2px var(--out);
}
#dirSearch:focus { box-shadow: inset 2px 2px 0 #08040e, 0 0 0 2px var(--cyan); }
.dir-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dir-tags button { --a: #6d5a8c; padding: 2px 8px; color: var(--ink); }
.dir-tags button.on { --a: var(--cyan); color: var(--out); }
#dirList { list-style: none; margin: 0; padding: 2px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
#dirList li { display: flex; gap: 10px; align-items: center; padding: 6px; cursor: pointer; background: #1b1229; box-shadow: 0 0 0 2px var(--out); }
#dirList li:hover, #dirList li:focus-visible { background: #2d1f42; outline: none; box-shadow: 0 0 0 2px var(--cyan); }
#dirList img { width: 80px; height: 50px; object-fit: cover; flex: none; background: #000; box-shadow: 0 0 0 2px var(--out); }
#dirList .t { font-size: 24px; line-height: 1.1; }
#dirList .s { color: var(--dim); margin: 2px 0; }
#dirList .tags { display: flex; gap: 4px; flex-wrap: wrap; }
#dirList .tags span { --a: var(--yellow); }
#dirList .empty { color: var(--dim); justify-content: center; cursor: default; background: none; box-shadow: none; }

/* ------------------------------------------------------------------ 游戏层 */
#mosaic { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 40; image-rendering: pixelated; }
#arcade { position: fixed; inset: 0; z-index: 41; }
#gameFrame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s steps(5); }
#arcade.loaded #gameFrame { opacity: 1; pointer-events: auto; }
#arcade.leaving #gameFrame { opacity: 0; transition-duration: .25s; }
.loading { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 8px; padding: 12px 20px; background: rgba(11, 7, 18, .8); box-shadow: 0 0 0 2px var(--out); }
#arcade.on:not(.loaded) .loading { display: flex; }
.ld-title { font-size: 24px; }
.ld-txt { color: var(--yellow); letter-spacing: 4px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#exitBtn {
  position: absolute; left: 0; top: 50%; z-index: 2; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 8px; border: 0;
  transform: translate(calc(-100% + 26px), -50%); background: var(--win); opacity: .6; transition: transform .15s steps(3), opacity .15s;
  box-shadow: inset -2px -2px 0 var(--win-lo), inset 0 2px 0 var(--win-hi), 0 0 0 2px var(--out);
}
#exitBtn i { font-style: normal; color: var(--pink); order: 2; }
#exitBtn:hover, #exitBtn:focus-visible { transform: translate(0, -50%); opacity: 1; }
#exitBtn:hover i { order: 0; }
#escRing { position: absolute; left: 50%; top: 24px; transform: translateX(-50%); z-index: 3; width: 180px; padding: 8px 10px; background: var(--win); box-shadow: 0 0 0 2px var(--out); text-align: center; }
#escRing i { display: block; height: 6px; margin-top: 6px; background: linear-gradient(90deg, var(--cyan) calc(var(--p, 0) * 100%), #120b1c 0); box-shadow: 0 0 0 2px var(--out); }

/* ------------------------------------------------------------------ 小屏 */
@media (max-width: 640px) {
  .logo span { display: none; }
  .card-thumb, .card-controls, .card-play kbd { display: none; }
  #card { gap: 10px; }
}
