/* ============================================================
   基礎樣式：色彩、版面骨架、系統列、頁尾、按鈕、對話框
   ============================================================ */
:root {
  --night: #0b1230;
  --night-2: #111a42;
  --night-3: #182354;
  --ink: #f7f4ff;
  --ink-soft: #c8c5e6;
  --muted: #9a97bb;
  --gold: #ffc857;
  --gold-2: #ffe7a8;
  --pink: #ff5fa2;
  --cyan: #5ee7ff;
  --mint: #4ee1b0;
  --violet: #9a8cff;
  --danger: #ff7a8a;
  --paper: #fbf9ff;
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.3);
  --panel: rgba(19, 28, 68, 0.88);
  --panel-2: rgba(27, 38, 91, 0.9);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --sysbar-h: 58px;
  --footer-h: 66px;
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background: var(--night);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.ready { animation: page-in 0.45s ease both; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
a { color: var(--gold-2); text-underline-offset: 3px; }
a:hover { color: #fff; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.skip-link {
  position: fixed; top: -60px; left: 12px; z-index: 300;
  padding: 10px 16px; border-radius: 0 0 10px 10px; background: var(--gold); color: #14183a;
  font-weight: 800; text-decoration: none;
}
.skip-link:focus { top: 0; }

.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background:
  radial-gradient(1100px 700px at 78% -5%, rgba(154, 140, 255, 0.28), transparent 62%),
  radial-gradient(900px 650px at 8% 10%, rgba(94, 231, 255, 0.18), transparent 60%),
  radial-gradient(900px 700px at 50% 105%, rgba(255, 95, 162, 0.16), transparent 66%),
  linear-gradient(150deg, #080d25 0%, #10183c 48%, #161d48 100%); }
.bg__glow { position: absolute; width: 42vmax; height: 42vmax; border-radius: 50%; filter: blur(12px); opacity: 0.5; }
.bg__glow--a { top: -18vmax; right: -8vmax; background: radial-gradient(circle, rgba(255, 200, 87, 0.22), transparent 68%); }
.bg__glow--b { bottom: -22vmax; left: -14vmax; background: radial-gradient(circle, rgba(94, 231, 255, 0.2), transparent 68%); }
.bg__stars { position: absolute; inset: 0; opacity: 0.7; background-image:
  radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 32% 8%, #ffe7a8, transparent),
  radial-gradient(1px 1px at 49% 24%, #fff, transparent),
  radial-gradient(2px 2px at 67% 12%, #ffe7a8, transparent),
  radial-gradient(1px 1px at 82% 30%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 91% 9%, #fff, transparent),
  radial-gradient(1px 1px at 8% 64%, #fff, transparent),
  radial-gradient(1.5px 1.5px at 23% 82%, #ffe7a8, transparent),
  radial-gradient(1px 1px at 56% 76%, #fff, transparent),
  radial-gradient(2px 2px at 78% 88%, #fff, transparent),
  radial-gradient(1px 1px at 94% 62%, #ffe7a8, transparent); }

/* ---------- 系統列 ---------- */
.sysbar {
  position: fixed; z-index: 60; top: calc(8px + var(--safe-top)); right: max(12px, calc((100vw - 1200px) / 2 + 12px));
  display: flex; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(11, 18, 48, 0.78); backdrop-filter: blur(14px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.06);
  color: var(--ink); font-size: 18px; line-height: 1; transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 23px; height: 23px; fill: currentColor; }
.icon-btn.is-active { background: rgba(255, 200, 87, 0.18); border-color: rgba(255, 200, 87, 0.55); color: var(--gold-2); }
.icon-btn--sm { width: 44px; height: 44px; min-width: 44px; border-radius: 10px; font-size: 16px; }
.icon-btn.has-prompt::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint);
  position: absolute; transform: translate(15px, -15px); box-shadow: 0 0 0 3px var(--night);
}
.sysbar .icon-btn { position: relative; }

.game {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: calc(var(--sysbar-h) + var(--safe-top) + 18px) clamp(14px, 4vw, 36px) calc(24px + var(--safe-bottom));
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.screen { width: 100%; }

/* ---------- 頁尾 ---------- */
.footer {
  position: relative; z-index: 70; flex: 0 0 auto;
  padding: 2px max(12px, calc((100vw - 1200px) / 2 + 20px)) calc(4px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(8, 13, 35, 0.55), rgba(8, 13, 35, 0.96) 55%);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--ink-soft); font-size: 11.5px; line-height: 1.55; text-align: center;
  letter-spacing: 0.01em; backdrop-filter: blur(10px);
}
.footer a { display: inline-flex; align-items: center; min-height: 44px; vertical-align: middle; color: var(--gold-2); }

/* ---------- 通用文字 ---------- */
.eyebrow {
  display: inline-block; color: var(--gold-2); font-size: 12px; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.page-lead { color: var(--ink-soft); max-width: 72ch; margin: 0 0 18px; font-size: 15px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 3px 11px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07);
  color: var(--ink); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.pill b { color: var(--gold-2); }
.pill--combo { border-color: rgba(255, 95, 162, 0.5); background: rgba(255, 95, 162, 0.14); color: #ffd6e7; }
.pill--combo.is-hot { animation: combo-pop 0.45s ease; }
.tag {
  display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px; border-radius: 8px;
  background: rgba(94, 231, 255, 0.14); color: #c9f9ff; border: 1px solid rgba(94, 231, 255, 0.34);
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
}

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 18px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.07); color: var(--ink); font-weight: 800; text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.5); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--primary {
  border: 0; color: #171735; background: linear-gradient(135deg, #ffe08a 0%, #ffc857 45%, #ff9f6e 100%);
  box-shadow: 0 10px 26px rgba(255, 200, 87, 0.28), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.btn--primary:hover { background: linear-gradient(135deg, #fff0b8, #ffd274 50%, #ffad7c); }
.btn--ghost { background: rgba(255, 255, 255, 0.05); }
.btn--small { min-height: 44px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn--xl { min-height: 52px; padding: 12px 26px; font-size: 17px; border-radius: 14px; }
.btn--danger { border-color: rgba(255, 122, 138, 0.55); color: #ffd7dc; background: rgba(255, 122, 138, 0.1); }
.btn--danger:hover { background: rgba(255, 122, 138, 0.2); }
.btn[disabled] { opacity: 0.45; box-shadow: none; }

/* ---------- 對話框 ---------- */
.dlg {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100dvh - var(--footer-h) - var(--sysbar-h) - 32px);
  margin: calc(var(--sysbar-h) + var(--safe-top) + 12px) auto calc(var(--footer-h) + 12px);
  padding: 0; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 20px;
  background: #121a40; color: var(--ink); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.dlg--narrow { width: min(480px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(4, 8, 24, 0.72); backdrop-filter: blur(5px); }
.dlg__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
}
.dlg__head h2 { font-size: 20px; letter-spacing: 0.04em; }
.dlg__body { padding: 16px; overflow-y: auto; max-height: calc(100dvh - var(--footer-h) - var(--sysbar-h) - 102px); }
.dlg__body p { color: var(--ink-soft); font-size: 14px; margin-bottom: 10px; }
.steps-list { list-style: none; counter-reset: step; display: grid; gap: 10px; margin: 12px 0; }
.steps-list li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 8px; color: var(--ink-soft); font-size: 14px; }
.steps-list li::before {
  content: counter(step); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 200, 87, 0.18); color: var(--gold-2); font-weight: 800; font-size: 13px;
}
.setting-group { padding: 12px 0 16px; border-bottom: 1px solid var(--line); }
.setting-group:last-child { border-bottom: 0; }
.setting-group h3 { font-size: 15px; color: var(--gold-2); letter-spacing: 0.08em; margin-bottom: 10px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; font-size: 14px; cursor: pointer; }
.switch input { width: 21px; height: 21px; accent-color: var(--gold); }
.range-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.range-label output { color: var(--gold-2); font-weight: 800; }
.range { width: 100%; height: 44px; accent-color: var(--gold); }
.setting-hint { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.setting-status { font-size: 13px; color: var(--gold-2); min-height: 20px; }
.setting-group .btn { margin: 4px 6px 4px 0; }
.clear-confirm { margin-top: 10px; padding: 10px; border: 1px solid rgba(255, 122, 138, 0.4); border-radius: 10px; background: rgba(255, 122, 138, 0.08); }
.clear-confirm p { font-size: 13px; margin-bottom: 8px; }

/* ---------- 提示與特效 ---------- */
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: calc(var(--footer-h) + 18px + var(--safe-bottom));
  transform: translateX(-50%); width: max-content; max-width: min(92vw, 620px);
  padding: 10px 16px; border-radius: 12px; background: rgba(25, 35, 82, 0.96);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow); color: var(--ink);
  font-size: 14px; font-weight: 700; text-align: center; animation: toast-in 0.25s ease both;
}
.toast--gold { border-color: rgba(255, 200, 87, 0.7); color: #fff2c8; background: rgba(54, 42, 20, 0.97); }
.fx-layer { position: fixed; inset: 0; z-index: 110; pointer-events: none; overflow: hidden; }
.spark {
  position: fixed; color: var(--gold); font-size: 17px; font-weight: 900; text-shadow: 0 0 10px rgba(255, 200, 87, 0.8);
  animation: spark-fly 0.95s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.feedback {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.6;
  border: 1px solid transparent; overflow-wrap: anywhere;
}
.feedback strong { font-size: 16px; }
.feedback--good { background: rgba(78, 225, 176, 0.13); border-color: rgba(78, 225, 176, 0.45); color: #d6fff1; }
.feedback--bad { background: rgba(255, 122, 138, 0.1); border-color: rgba(255, 122, 138, 0.42); color: #ffdfe3; }
.feedback__combo { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 6px; background: rgba(255, 95, 162, 0.24); color: #ffd6e7; }
.feedback__note { color: var(--ink-soft); font-size: 12px; }
.hint-box { margin: 8px 0 0; padding: 10px 12px; border-left: 3px solid var(--gold); background: rgba(255, 200, 87, 0.1); border-radius: 0 8px 8px 0; font-size: 14px; color: #fff2c8; }
.explain-box { margin: 10px 0 0; padding: 12px; border-radius: 12px; background: rgba(94, 231, 255, 0.08); border: 1px solid rgba(94, 231, 255, 0.28); }
.explain-box.is-miss { background: rgba(255, 200, 87, 0.08); border-color: rgba(255, 200, 87, 0.32); }
.explain-box h2 { font-size: 13px; color: var(--cyan); letter-spacing: 0.12em; margin-bottom: 3px; }
.explain-box p { color: var(--ink-soft); font-size: 14px; }
.explain-box__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- 響應式 ---------- */
@media (max-width: 700px) {
  :root { --footer-h: 74px; }
  .game { padding-left: 14px; padding-right: 14px; }
  .footer { font-size: 11px; padding-left: 12px; padding-right: 12px; }
  .sysbar { right: 10px; gap: 6px; padding: 5px; }
  .sysbar .icon-btn { width: 44px; height: 44px; min-width: 44px; }
  .toast { bottom: calc(var(--footer-h) + 12px + var(--safe-bottom)); font-size: 13px; }
}
@media (max-width: 390px) {
  .sysbar .icon-btn { width: 44px; height: 44px; min-width: 44px; }
  .sysbar { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important;
}
