/* 基本樣式、按鈕、提示氣泡、無障礙工具 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background: transparent;   /* 讓 z-index:-1 的背景可見；底色由 html 提供 */
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  font-kerning: normal;
}
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--yellow); color: var(--on-yellow); }

/* 遊戲機式焦點：白色光圈 */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 14px; box-shadow: 0 0 22px 2px rgba(255, 255, 255, .35); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 12px; background: var(--yellow); color: var(--on-yellow); text-decoration: none; font-weight: 900; }
.skip-link:focus { top: 12px; }

/* 鍵帽 */
kbd {
  font-family: var(--font-num); font-size: 12px; font-weight: 700; line-height: 1; letter-spacing: .02em;
  min-width: 30px; height: 26px; padding: 0 9px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .08));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 2px 0 rgba(0, 0, 0, .45);
  color: var(--text);
}
kbd svg { width: 16px; height: 16px; }

/* 手掣按鍵（A／B／十字鍵）：通用圓形字母，不模仿任何品牌 */
.pad-glyph {
  font-family: var(--font-num); font-weight: 700; font-size: 13px; line-height: 1;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: var(--on-yellow); background: var(--text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .45);
}
.pad-a { background: var(--yellow); }
.pad-b { background: #e9e2f5; }
.pad-dpad { background: transparent; color: var(--text); box-shadow: none; }
.pad-dpad svg { width: 22px; height: 22px; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 24px;
  border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--stroke-2);
  font-size: 16px; font-weight: 900; letter-spacing: .06em;
  transition: transform .2s var(--ease), background-color .2s, box-shadow .2s, color .2s;
  text-decoration: none;
}
.btn svg { width: 22px; height: 22px; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, #ffe57f, var(--yellow) 55%, #e8bd3c); color: var(--on-yellow); box-shadow: 0 14px 30px -12px rgba(247, 208, 84, .7), inset 0 -3px 0 rgba(120, 70, 0, .18); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #fff09d, #ffd862 55%, #f0c64a); }
.btn-primary:disabled { background: rgba(255, 255, 255, .1); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--stroke); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--surface); }
.btn-xl { min-height: 60px; font-size: 18px; padding: 0 28px; width: 100%; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 0 16px; }
.btn:focus-visible { outline: none; box-shadow: var(--glow-focus); }

.round-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--stroke-2), var(--shadow-1);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: grid; place-items: center;
  transition: transform .2s var(--ease), background-color .2s, box-shadow .2s;
}
.round-btn svg { width: 22px; height: 22px; }
.round-btn:hover { background: rgba(255, 255, 255, .2); }
.round-btn:active { transform: scale(.92); }
.round-btn:focus-visible { outline: none; box-shadow: var(--glow-focus); }

/* 圖示＋短字小標籤 */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 13px; border-radius: 999px;
  border: 0; background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 0 1px var(--stroke);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap;
}
.pill svg { width: 16px; height: 16px; flex: none; }
.pill-preview { background: var(--yellow-100); color: #ffe7a1; box-shadow: inset 0 0 0 1px rgba(247, 208, 84, .35); }
.pill-muted { color: var(--text-2); }
.pill-ok { color: #0d2a1b; background: var(--ok); box-shadow: none; }
.pill-warn { color: #3a0d18; background: var(--danger); box-shadow: none; }
.pill-locked { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--stroke-2); }

/* 滑鼠提示氣泡（只作輔助；按鈕本身有 aria-label） */
[data-tip] { position: relative; }
@media (hover: hover) {
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 12px);
    transform: translate(-50%, 4px); opacity: 0; pointer-events: none;
    padding: 5px 12px; border-radius: 999px; background: var(--text); color: var(--on-yellow);
    font-size: 13px; font-weight: 900; white-space: nowrap; z-index: 30;
    transition: opacity .15s, transform .2s var(--ease);
  }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
  .statusbar [data-tip]::after { bottom: auto; top: calc(100% + 12px); }
}

/* ---------- 共用封面 ---------- */
.cover { position: relative; overflow: hidden; background: var(--surface-solid-2); container-type: size; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.cover-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 62% 38%, color-mix(in srgb, var(--accent) 55%, transparent) 0 34%, transparent 35%), var(--surface-solid-2);
  color: var(--text);
}
.cover-fallback-char { font-size: 48px; font-size: 40cqh; font-weight: 900; line-height: 1; }

/* ---------- 旋轉指示 ---------- */
.spinner { width: 28px; height: 28px; animation: spin 1s linear infinite; }

/* ---------- 啟動失敗 ---------- */
.fatal { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; gap: 14px; text-align: center; background: var(--bg); color: var(--text); padding: 24px; }
.fatal h1 { font-size: 26px; font-weight: 900; }
.fatal button { justify-self: center; padding: 12px 24px; border-radius: 999px; border: 0; background: var(--yellow); color: var(--on-yellow); font-weight: 900; }
