/* 掌机小屋 Kit 样式 —— 复古掌机风：像素描边窗口、硬阴影、方块按钮 */
html, body { margin: 0; height: 100%; background: #0b0c18; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; }
.kit-root {
  --ink: #0d0e1c; --win: #252a52; --win2: #1a1e3e; --hi: #4a52a0; --hi2: #343a78;
  --gold: #ffcc4d; --gold-d: #b8741e; --cream: #f7efd9; --mute: #a5a7d0; --ok: #7ee2a0; --bad: #ff7f6e;
  --px: 3px;
  position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden;
  background: #000; color: var(--cream); user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  letter-spacing: .5px;
}
.kit-root.kit-pseudo-fs { position: fixed; inset: 0; z-index: 9999; width: 100vw; height: 100dvh; }
.kit-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.kit-canvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; outline: none; }
.kit-root button { font-family: inherit; letter-spacing: inherit; }

/* ---- 像素窗口：缺角描边 + 内高光 + 硬阴影 ---- */
.kit-splash-box, .kit-menu, .kit-title-help, .kit-toast {
  background: var(--win);
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink),
    inset 0 0 0 var(--px) var(--hi), inset 0 0 0 calc(2 * var(--px)) var(--hi2),
    calc(2 * var(--px)) calc(3 * var(--px)) 0 0 rgba(0, 0, 0, .45);
}

/* ---- 右上角 HUD ---- */
.kit-hud { position: absolute; top: 10px; right: 10px; display: flex; gap: 10px; align-items: center; z-index: 20; transition: opacity .4s; }
.kit-hud.kit-hidden { opacity: 0; pointer-events: none; }
.kit-btn, .kit-cloud {
  background: rgba(26, 30, 62, .78); color: var(--cream); border: 0; border-radius: 0;
  height: 28px; min-width: 28px; padding: 0 7px; font-size: 14px; line-height: 28px; cursor: pointer; box-sizing: border-box;
  box-shadow: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink), inset 0 -3px 0 0 rgba(0,0,0,.35);
  display: inline-flex; align-items: center; justify-content: center;
}
.kit-btn:hover, .kit-cloud:hover { background: var(--hi); }
.kit-btn:active { transform: translateY(1px); }
.kit-cloud { font-size: 12px; gap: 2px; }
.kit-cloud i { font-style: normal; font-weight: bold; }
.kit-cloud[data-s="synced"] { color: var(--ok); }
.kit-cloud[data-s="pending"], .kit-cloud[data-s="syncing"] { color: var(--gold); }
.kit-cloud[data-s="offline"], .kit-cloud[data-s="conflict"], .kit-cloud[data-s="error"] { color: var(--bad); }

.kit-toast {
  position: absolute; left: 50%; top: 16px; transform: translate(-50%, -24px); opacity: 0; z-index: 30;
  color: var(--cream); padding: 10px 20px; font-size: 15px; font-weight: bold;
  pointer-events: none; transition: transform .2s steps(4), opacity .2s steps(4); max-width: 80vw; text-align: center;
}
.kit-toast.show { opacity: 1; transform: translate(-50%, 0); }

.kit-layer { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.kit-layer > * { pointer-events: auto; }

/* ---- 开始画面 / 弹窗底 ---- */
.kit-splash, .kit-modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.kit-splash { background: radial-gradient(ellipse at 50% 45%, rgba(8, 9, 22, .15) 30%, rgba(8, 9, 22, .78) 100%); }
.kit-modal { background: rgba(6, 7, 18, .6); }
.kit-splash-box, .kit-menu {
  padding: 26px 30px; max-width: min(520px, 90vw); max-height: 86vh; overflow: auto; box-sizing: border-box;
  text-align: center; user-select: text; scrollbar-width: thin; scrollbar-color: var(--hi) transparent;
}
.kit-splash-box h1 { margin: 0 0 8px; font-size: 24px; color: var(--gold); }

/* 标题画面 */
.kit-title { flex-direction: column; justify-content: center; gap: 0; }
.kit-title-main { display: flex; flex-direction: column; align-items: center; margin-top: -4vh; }
.kit-logo {
  margin: 0; font-size: clamp(38px, 8vw, 76px); font-weight: 900; letter-spacing: .12em; color: var(--cream); line-height: 1.15;
  text-shadow:
    -4px 0 0 var(--ink), 4px 0 0 var(--ink), 0 -4px 0 var(--ink), 0 4px 0 var(--ink),
    -4px -4px 0 var(--ink), 4px -4px 0 var(--ink), -4px 4px 0 var(--ink), 4px 4px 0 var(--ink),
    0 8px 0 var(--gold-d), -4px 8px 0 var(--ink), 4px 8px 0 var(--ink), 0 12px 0 var(--ink);
  animation: kit-float 2.4s steps(2) infinite;
}
@keyframes kit-float { 50% { transform: translateY(-3px); } }
.kit-sub { margin: 18px 0 0; color: var(--cream); font-size: 15px; text-shadow: 2px 2px 0 var(--ink); opacity: .92; }
.kit-press {
  margin: 34px 0 18px; font-size: 17px; font-weight: bold; color: var(--gold); text-shadow: 2px 2px 0 var(--ink);
  animation: kit-blink 1.1s steps(1) infinite;
}
@keyframes kit-blink { 60% { opacity: 0; } }
.kit-player { margin: 16px 0 0; font-size: 14px; color: var(--mute); text-shadow: 1px 1px 0 var(--ink); display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.kit-player b { color: var(--cream); font-size: 15px; }
.kit-player a, .kit-back { color: var(--mute); font-size: 13px; text-decoration: none; border-bottom: 2px solid currentColor; }
.kit-player a:hover, .kit-back:hover { color: var(--gold); }
.kit-player input, .kit-menu input:not([type]) {
  font: inherit; font-size: 16px; padding: 8px 12px; border-radius: 0; border: 0; outline: 0;
  background: var(--cream); color: var(--ink); width: 200px; user-select: text;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 3px 0 0 rgba(0,0,0,.15);
}
.kit-player input.bad { background: #ffd9d2; }
.kit-title .kit-help { margin: 0; }
.kit-title-help {
  position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%);
  padding: 12px 22px; max-width: 90vw; box-sizing: border-box; text-align: center;
}
.kit-title .kit-back { position: absolute; left: 22px; top: 18px; }

.kit-start-row { display: flex; gap: 16px; justify-content: center; margin: 18px 0 8px; flex-wrap: wrap; }
.kit-start {
  font-size: 17px; padding: 11px 24px; border: 0; border-radius: 0; cursor: pointer; color: var(--ink); font-weight: 900;
  background: var(--gold);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 -4px 0 0 var(--gold-d), inset 0 3px 0 0 #fff2b8, 4px 6px 0 0 rgba(0,0,0,.45);
}
.kit-start:hover { filter: brightness(1.08); }
.kit-start:active { transform: translateY(3px); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 3px 0 0 var(--gold-d); }
.kit-start:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.kit-start.alt {
  background: var(--win); color: var(--cream); font-weight: bold; font-size: 15px;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 -4px 0 0 var(--win2), inset 0 3px 0 0 var(--hi), 4px 6px 0 0 rgba(0,0,0,.45);
}
.kit-small {
  font-size: 13px; padding: 6px 12px; border: 0; border-radius: 0; background: var(--gold); color: var(--ink); font-weight: bold; cursor: pointer; margin-left: 6px;
  box-shadow: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink), inset 0 -3px 0 0 var(--gold-d);
}
.kit-small:focus { outline: 2px solid var(--cream); outline-offset: 3px; }
.kit-help table { margin: 0 auto; border-collapse: collapse; font-size: 13px; }
.kit-title-help table { display: flex; flex-wrap: wrap; gap: 4px 20px; justify-content: center; }
.kit-title-help tbody { display: contents; }
.kit-title-help tr { display: flex; gap: 6px; }
.kit-help th, .kit-menu th { color: var(--gold); font-weight: bold; padding: 3px 12px 3px 0; text-align: right; white-space: nowrap; }
.kit-title-help th { padding: 0; }
.kit-help td, .kit-menu td { color: var(--cream); padding: 3px 0; text-align: left; }
.kit-title-help td { padding: 0; }
.kit-menu table { margin: 4px auto 14px; font-size: 14px; }
.kit-note { color: var(--mute); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }

/* ---- 菜单 ---- */
.kit-menu { min-width: min(360px, 90vw); text-align: left; padding: 20px 22px 22px; }
.kit-menu-head {
  display: flex; justify-content: space-between; align-items: center; margin: -2px 0 14px; padding-bottom: 10px;
  font-size: 17px; color: var(--gold); border-bottom: 3px dashed var(--hi2);
}
.kit-x { background: none; border: 0; color: var(--mute); font-size: 18px; cursor: pointer; padding: 0 4px; }
.kit-x:hover { color: var(--cream); }
.kit-menu-body { display: flex; flex-direction: column; gap: 10px; }
.kit-mbtn {
  position: relative; font-size: 15px; font-weight: bold; padding: 10px 14px 10px 32px; border: 0; border-radius: 0;
  background: var(--win2); color: var(--cream); cursor: pointer; text-align: left; outline: none;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 -3px 0 0 rgba(0,0,0,.35), inset 0 2px 0 0 rgba(255,255,255,.06);
}
.kit-mbtn::before {
  content: ''; position: absolute; left: 12px; top: 50%; margin-top: -6px;
  border-left: 9px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  visibility: hidden; animation: kit-nudge .6s steps(1) infinite;
}
@keyframes kit-nudge { 50% { transform: translateX(3px); } }
.kit-mbtn:hover, .kit-mbtn:focus, .kit-mbtn.kit-sel {
  background: var(--gold); color: var(--ink);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 0 -3px 0 0 var(--gold-d), inset 0 2px 0 0 #fff2b8;
}
.kit-mbtn:hover::before, .kit-mbtn:focus::before, .kit-mbtn.kit-sel::before { visibility: visible; }
.kit-mbtn:active { transform: translateY(2px); }
.kit-mbtn.primary { }
.kit-mbtn small { font-weight: normal; opacity: .7; margin-left: 6px; font-size: 12px; }
.kit-row { display: flex; gap: 14px; justify-content: space-between; padding: 6px 2px; font-size: 14px; color: var(--cream); }
.kit-row label { display: flex; align-items: center; gap: 8px; }

/* 像素滑条 */
.kit-row input[type=range] { -webkit-appearance: none; appearance: none; width: 104px; height: 18px; background: transparent; cursor: pointer; }
.kit-row input[type=range]:focus { outline: none; }
.kit-row input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--ink); box-shadow: inset 0 0 0 2px var(--hi2); }
.kit-row input[type=range]::-moz-range-track { height: 8px; background: var(--ink); box-shadow: inset 0 0 0 2px var(--hi2); }
.kit-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 18px; margin-top: -5px; background: var(--gold); border: 0; border-radius: 0;
  box-shadow: 0 0 0 2px var(--ink), inset 0 -3px 0 0 var(--gold-d);
}
.kit-row input[type=range]::-moz-range-thumb { width: 12px; height: 18px; background: var(--gold); border: 0; border-radius: 0; box-shadow: 0 0 0 2px var(--ink); }
.kit-row input[type=range]:focus::-webkit-slider-thumb { background: var(--cream); }

.kit-info { font-size: 13px; color: var(--mute); line-height: 1.8; margin: 0 0 4px; }
.kit-info b { color: var(--cream); }
.kit-warn {
  background: #4a2430; padding: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 2px #8a3a48;
}
.kit-list { max-height: 44vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--cream); padding: 3px; }
.kit-li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 8px; background: var(--win2); box-shadow: inset 0 -2px 0 0 rgba(0,0,0,.3); }

/* ---- 触屏操作 ---- */
.kit-pad { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.kit-pad > * { pointer-events: auto; }
/* 左半边：手指按哪里摇杆就出现在哪里 */
.kit-joy-zone { position: absolute; left: 0; top: 56px; bottom: 0; width: 46%; touch-action: none; }
.kit-joy {
  position: absolute; left: calc(84px + env(safe-area-inset-left)); top: calc(100% - 92px);
  width: 108px; height: 108px; margin: -54px 0 0 -54px; border-radius: 50%; pointer-events: none;
  background: rgba(13, 14, 28, .22); box-shadow: inset 0 0 0 3px rgba(247, 239, 217, .28);
  opacity: .5; transition: opacity .12s;
}
.kit-joy.on { opacity: 1; }
.kit-joy i {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(247, 239, 217, .5); box-shadow: inset 0 -4px 0 rgba(0,0,0,.28), 0 0 0 2px rgba(13,14,28,.45);
}
/* 右边：只放游戏用得到的键 */
.kit-pad-btns {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); top: 50%; transform: translateY(-38%);
  display: flex; flex-direction: column; align-items: center; gap: 14px; touch-action: none;
}
.kit-pbtn {
  width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.55); touch-action: none;
  background: rgba(247, 239, 217, .22); box-shadow: inset 0 -4px 0 rgba(0,0,0,.3), 0 0 0 2px rgba(13,14,28,.5);
}
.kit-pbtn.on { transform: translateY(2px); box-shadow: inset 0 3px 0 rgba(0,0,0,.3), 0 0 0 2px rgba(13,14,28,.5); filter: brightness(1.25); }
.kit-pb-a { width: 68px; height: 68px; font-size: 16px; background: rgba(255, 110, 110, .5); }
.kit-pb-b { background: rgba(255, 204, 77, .45); }
.kit-pb-x, .kit-pb-r { background: rgba(110, 160, 255, .45); }
.kit-pb-y, .kit-pb-l { background: rgba(126, 226, 160, .45); }
.kit-pb-start, .kit-pb-select { width: 50px; height: 34px; border-radius: 17px; font-size: 13px; background: rgba(13, 14, 28, .45); }
.kit-rotate-tip { display: none; }

/* 竖屏：画面在上，操作区在下 */
.kit-portrait .kit-stage { bottom: auto; top: calc(env(safe-area-inset-top) + 48px); height: calc(100vw * 9 / 16); }
.kit-portrait .kit-joy-zone { top: calc(env(safe-area-inset-top) + 48px + 100vw * 9 / 16 + 30px); width: 58%; }
.kit-portrait .kit-joy { left: 50%; top: 52%; width: 132px; height: 132px; margin: -66px 0 0 -66px; }
.kit-portrait .kit-joy i { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
.kit-portrait .kit-pad-btns {
  top: auto; transform: none; bottom: calc(env(safe-area-inset-bottom) + 12vh); right: 22px; gap: 18px;
}
.kit-portrait .kit-pbtn { width: 66px; height: 66px; font-size: 16px; }
.kit-portrait .kit-pb-a { width: 78px; height: 78px; }
.kit-portrait .kit-pb-start, .kit-portrait .kit-pb-select { width: 62px; height: 38px; border-radius: 19px; font-size: 14px; }
.kit-portrait .kit-rotate-tip {
  display: block; position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 48px + 100vw * 9 / 16 + 10px);
  text-align: center; font-size: 12px; color: var(--mute); pointer-events: none;
}

/* iPhone：没有真全屏，隐藏全屏按钮，给出"添加到主屏幕"提示 */
.kit-nofs .kit-hud .kit-btn[title^="全屏"] { display: none; }
.kit-ios-tip {
  margin-top: 18px; max-width: min(440px, 86vw); padding: 10px 14px; font-size: 13px; line-height: 1.6; text-align: center;
  color: var(--cream); background: rgba(13, 14, 28, .7); box-shadow: 0 0 0 2px var(--hi2);
}
@media (max-height: 520px) {
  .kit-title-help { display: none; }
  .kit-press { margin: 18px 0 8px; }
}
.kit-cloud:empty { display: none; }
@media (max-height: 520px) {
  .kit-logo { font-size: clamp(30px, 12vh, 56px); }
  .kit-sub { margin-top: 10px; }
  .kit-start-row { margin: 10px 0 4px; }
  .kit-ios-tip { margin-top: 10px; padding: 6px 12px; }
}
