/* ============================================================
 * base.css — 設計系統基礎
 * AI許願師－iPAS AI考證大冒險
 * ------------------------------------------------------------
 * 內容：Reset / CSS 變數（主題）/ 版面骨架 / 共用元件
 * 畫風：像素 RPG × 科技霓虹（深藍夜空 + 青紫霓虹光）
 * ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---------- 主題變數（全遊戲唯一色彩來源） ---------- */
:root {
  /* 背景 */
  --bg-deep:    #070b1e;   /* 最深夜空 */
  --bg-mid:     #0d1330;   /* 面板底 */
  --bg-panel:   rgba(16, 24, 58, 0.88);
  --bg-panel-light: rgba(38, 52, 110, 0.6);

  /* 霓虹主色 */
  --neon-cyan:   #29e6ff;
  --neon-purple: #a56bff;
  --neon-blue:   #4d8dff;
  --neon-pink:   #ff6bd6;

  /* 語意色 */
  --gold:    #ffd54a;      /* 獎勵、星星、EXP */
  --success: #3dffa0;      /* 答對 */
  --danger:  #ff5470;      /* 答錯、Boss */
  --hp:      #ff5470;
  --exp:     #ffd54a;

  /* 文字 */
  --text-main: #eaf2ff;
  --text-dim:  #8fa2cc;

  /* 字體：繁中圓體優先，帶像素遊戲感的粗字重 */
  --font-main: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;

  /* 霓虹光暈（標題、按鈕共用） */
  --glow-cyan:   0 0 8px rgba(41, 230, 255, 0.8), 0 0 24px rgba(41, 230, 255, 0.4);
  --glow-purple: 0 0 8px rgba(165, 107, 255, 0.8), 0 0 24px rgba(165, 107, 255, 0.4);
  --glow-gold:   0 0 8px rgba(255, 213, 74, 0.8), 0 0 24px rgba(255, 213, 74, 0.4);

  /* 間距與圓角刻度 */
  --radius: 12px;
  --radius-sm: 8px;
}

/* ---------- 版面骨架 ---------- */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;              /* 遊戲畫面不捲動 */
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-main);
  user-select: none;             /* 遊戲 UI 不給反白選字 */
  -webkit-tap-highlight-color: transparent;
}

/* 背景粒子層：墊底 */
#bg-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* 深空漸層底色畫在 canvas 後面 */
  background: radial-gradient(ellipse at 50% 30%, #101a45 0%, var(--bg-deep) 70%);
}

/* 畫面容器層 */
#screen-root {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* 戰鬥特效粒子層：蓋在 UI 上但不擋滑鼠 */
#fx-particles {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

/* 轉場遮罩：最上層 */
#transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: var(--bg-deep);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}
#transition-overlay.transition--on {
  opacity: 1;
  pointer-events: all;
}

/* ---------- 畫面（Screen）---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;                 /* 未啟用的畫面不佔資源 */
  overflow: hidden;
}
.screen--active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: screen-in 0.4s ease both;   /* 進場淡入上移 */
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 共用元件：按鈕 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-width: 200px;
  padding: 0.85em 1.6em;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
  border: 2px solid var(--neon-cyan);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--glow-cyan), inset 0 0 12px rgba(41, 230, 255, 0.12);
  text-shadow: 0 0 6px rgba(41, 230, 255, 0.6);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.2);
}
.btn:active {
  transform: translateY(1px) scale(0.98);
}

/* 按鈕變體 */
.btn--gold {
  border-color: var(--gold);
  box-shadow: var(--glow-gold), inset 0 0 12px rgba(255, 213, 74, 0.12);
  text-shadow: 0 0 6px rgba(255, 213, 74, 0.6);
}
.btn--purple {
  border-color: var(--neon-purple);
  box-shadow: var(--glow-purple), inset 0 0 12px rgba(165, 107, 255, 0.12);
  text-shadow: 0 0 6px rgba(165, 107, 255, 0.6);
}
.btn--danger {
  border-color: var(--danger);
  box-shadow: 0 0 8px rgba(255, 84, 112, 0.8), inset 0 0 12px rgba(255, 84, 112, 0.12);
}
.btn--small {
  min-width: 0;
  padding: 0.45em 1em;
  font-size: 0.88rem;
}

/* ---------- 共用元件：面板 ---------- */
.panel {
  background: var(--bg-panel);
  border: 2px solid rgba(77, 141, 255, 0.5);
  border-radius: var(--radius);
  box-shadow: 0 0 30px rgba(13, 19, 48, 0.9), inset 0 0 20px rgba(77, 141, 255, 0.06);
  padding: 24px;
  /* 注意：不可使用 backdrop-filter —— 疊在動畫 canvas 上會逼迫瀏覽器
     每幀重新合成背景，實測會讓整頁掉到 0.1fps */
}

/* ---------- 共用元件：霓虹標題 ---------- */
.neon-title {
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow:
    0 0 6px var(--neon-cyan),
    0 0 18px var(--neon-cyan),
    0 0 42px rgba(41, 230, 255, 0.5);
}

/* ---------- 開發測試列（僅骨架階段使用，正式版移除） ---------- */
#debug-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(7, 11, 30, 0.92);
  border-top: 1px solid rgba(41, 230, 255, 0.35);
  font-size: 12px;
}
#debug-bar .btn {
  min-width: 0;
  padding: 4px 10px;
  font-size: 12px;
  letter-spacing: 0.05em;
  border-width: 1px;
  box-shadow: none;
}
#debug-bar .debug-label {
  align-self: center;
  color: var(--text-dim);
  margin-right: 4px;
}
