/* ══════════════════════════════════════════════════════════
   字詞勇者塔 — 原型樣式
   深色遊戲 UI。所有尺寸用 clamp() 令手機／平板／桌面都夠大。
   ══════════════════════════════════════════════════════════ */

:root {
  --bg:        #12100e;
  --panel:     #1e1b18;
  --panel-2:   #272320;
  --line:      #3a352f;
  --line-2:    #4d463d;
  --text:      #f1efe8;
  --text-dim:  #a8a29a;
  --text-dim2: #756f66;
  --amber:     #EF9F27;
  --amber-dim: #633806;
  --hp:        #E24B4A;
  --hp-dim:    #791F1F;
  --green:     #639922;
  --green-lt:  #C0DD97;
  --green-dim: #27500A;
  --blue:      #378ADD;
  --blue-dim:  #0C447C;
  --red:       #E24B4A;
  --red-dim:   #791F1F;
  --purple:    #7F77DD;

  --font-ui: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  --font-en: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overscroll-behavior: none;
}

body { user-select: none; }

#stage {
  position: fixed; inset: 0;
  display: flex;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #1c1916 0%, var(--bg) 70%);
}

/* ── 畫面切換 ────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
}
.screen.is-active { display: flex; }

/* ── 通用元件 ────────────────────────────────────────────── */
.btn {
  font-family: inherit;
  font-size: clamp(14px, 2.2vmin, 18px);
  font-weight: 500;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 0.7em 1.3em;
  cursor: pointer;
  transition: transform .06s, background .12s, border-color .12s;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary {
  background: var(--amber);
  border-color: #c47f16;
  color: #23190a;
  font-weight: 700;
}
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-danger {
  background: var(--hp-dim);
  border-color: var(--hp);
  color: #F7C1C1;
  font-weight: 600;
}
.btn-icon {
  padding: .35em .6em;
  font-size: clamp(14px, 2vmin, 17px);
  min-width: 2.6em;
}
.btn-small { font-size: clamp(12px, 1.7vmin, 15px); }

.bar {
  position: relative;
  flex: 1;
  height: clamp(9px, 1.5vmin, 14px);
  background: #0c0a09;
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
  min-width: 0;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width .18s ease-out;
}
.bar-hp > i    { background: linear-gradient(180deg, #f0716f, var(--hp)); }
.bar-power > i { background: linear-gradient(180deg, #ffc45e, var(--amber)); }
.bar-power.is-full > i { animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.7); } }
/* ★ .bar 預設 flex:1 係為咗 HUD 橫向撐闊。倒數條住喺 .qcard（直向 flex），
   flex:1 會變成「向高撐」—— 手機直立題目卡一拉高就會爆成一條藍色巨柱。
   所以倒數條一定要 flex: 0 0 auto 鎖死高度。 */
.bar-timer { flex: 0 0 auto; height: clamp(6px, 1vmin, 9px); border: none; background: #0c0a09; }
.bar-timer > i { background: var(--blue); transition: none; }
.bar-timer.is-low > i { background: var(--red); }

/* ── 標題 ────────────────────────────────────────────────── */
.title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.2vmin, 14px);
  padding: 5vmin 6vmin;
  text-align: center;
}
.title-art { width: clamp(80px, 16vmin, 140px); height: clamp(80px, 16vmin, 140px); }
.title-art canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.game-title {
  font-size: clamp(30px, 7vmin, 60px);
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--text);
  text-shadow: 0 3px 0 #000, 0 0 26px rgba(239,159,39,.28);
}
.game-sub {
  font-family: var(--font-en);
  font-size: clamp(10px, 1.7vmin, 15px);
  letter-spacing: .42em;
  color: var(--amber);
  margin-bottom: clamp(8px, 2vmin, 20px);
}
.title-menu { display: flex; flex-direction: column; gap: clamp(8px, 1.6vmin, 14px); width: min(320px, 72vw); }
.title-menu .btn { width: 100%; }
.title-menu em { font-style: normal; font-size: .78em; opacity: .7; }
.title-foot {
  margin-top: clamp(10px, 2vmin, 22px);
  font-size: clamp(10px, 1.5vmin, 13px);
  color: var(--text-dim2);
  line-height: 1.7;
  white-space: pre-line;
}
/* ★ v0.14：資料來源提示（獨行，唔好撈埋落 .title-foot） */
.title-source {
  margin-top: clamp(6px, 1.2vmin, 12px);
  font-size: clamp(9px, 1.35vmin, 12px);
  color: var(--text-dim2);
  opacity: .78;
  line-height: 1.5;
}

/* ── 頂欄 ────────────────────────────────────────────────── */
.bar-top, header.bar {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.6vmin, 16px);
  padding: clamp(10px, 2vmin, 18px) clamp(12px, 2.4vmin, 22px);
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  flex: 0 0 auto;
}
header.bar h2 { font-size: clamp(15px, 2.6vmin, 22px); font-weight: 600; flex: 1; }
.bar-right { font-size: clamp(11px, 1.8vmin, 15px); color: var(--text-dim); white-space: nowrap; }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(12px, 2.4vmin, 24px);
}
.hint {
  font-size: clamp(11px, 1.8vmin, 14px);
  color: var(--text-dim2);
  margin-bottom: clamp(10px, 2vmin, 18px);
  line-height: 1.7;
  /* 設定畫面嘅提示會用 \n 分行（解釋「開咗都唔會多咗字」） */
  white-space: pre-line;
}

/* ── 塔清單 ──────────────────────────────────────────────── */
.tower-list { display: flex; flex-direction: column; gap: clamp(10px, 1.8vmin, 16px); }
.tower-card {
  display: flex; align-items: center; gap: clamp(12px, 2.2vmin, 20px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(12px, 2.2vmin, 20px);
  cursor: pointer;
  transition: border-color .15s, transform .08s;
}
.tower-card:active { transform: scale(.985); }
.tower-card:hover { border-color: var(--line-2); }
.tower-card.is-locked { opacity: .45; cursor: default; }
.tower-icon { width: clamp(44px, 8vmin, 68px); height: clamp(44px, 8vmin, 68px); flex: 0 0 auto; }
.tower-icon canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.tower-body { flex: 1; min-width: 0; }
.tower-name { font-size: clamp(15px, 2.5vmin, 21px); font-weight: 600; margin-bottom: .3em; }
.tower-meta { font-size: clamp(11px, 1.7vmin, 14px); color: var(--text-dim); margin-bottom: .6em; white-space: pre-line; }
.tower-mastery { display: flex; align-items: center; gap: 8px; max-width: 420px; }
.tower-mastery .bar { height: clamp(7px, 1.2vmin, 11px); }
.tower-mastery .bar > i { background: var(--green); }
/* 難度計用暖色 —— 同「掌握度」（綠色）區分開 */
.tower-mastery .bar-diff > i { background: linear-gradient(90deg, var(--green), var(--amber) 60%, var(--hp)); }
.tower-pct { font-size: clamp(10px, 1.6vmin, 13px); color: var(--text-dim); white-space: nowrap; }

/* ── 樓層格 ──────────────────────────────────────────────── */
.floor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(72px, 15vmin, 116px), 1fr));
  gap: clamp(8px, 1.6vmin, 14px);
}
.floor-btn {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .25em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: transform .08s, border-color .15s;
}
.floor-btn:active:not(:disabled) { transform: scale(.95); }
.floor-btn:disabled { opacity: .35; cursor: default; }
.floor-num { font-size: clamp(18px, 3.4vmin, 30px); font-weight: 700; line-height: 1; }
.floor-lbl { font-size: clamp(8px, 1.4vmin, 12px); color: var(--text-dim2); white-space: nowrap; }
.floor-stars { font-size: clamp(10px, 1.6vmin, 14px); letter-spacing: .1em; color: var(--amber); height: 1em; }
.floor-btn.is-cleared { border-color: var(--green-dim); }
.floor-btn.is-boss { border-color: var(--amber-dim); }

/* ── 生字設定：分類開關 ─────────────────────────────────── */
.notice {
  font-size: clamp(11px, 1.8vmin, 14px);
  line-height: 1.6;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid var(--amber-dim);
  border-radius: var(--r-md);
  padding: clamp(8px, 1.6vmin, 12px) clamp(10px, 2vmin, 14px);
  margin-bottom: clamp(10px, 2vmin, 16px);
}
.cat-list { display: flex; flex-direction: column; gap: clamp(8px, 1.6vmin, 12px); max-width: 620px; }
.cat-row {
  display: flex; align-items: center; gap: clamp(10px, 2vmin, 18px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(10px, 2vmin, 15px) clamp(12px, 2.4vmin, 18px);
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}
.cat-row:active { transform: scale(.99); }
.cat-row.is-on { border-color: var(--green-dim); background: var(--panel-2); }
.cat-row.is-empty { opacity: .5; cursor: default; }
.cat-main { flex: 1 1 auto; min-width: 0; }
.cat-name { font-size: clamp(15px, 2.6vmin, 21px); font-weight: 700; }
.cat-meta { font-size: clamp(10px, 1.7vmin, 13px); color: var(--text-dim); margin-top: .25em; }
.cat-right { flex: 0 0 auto; display: flex; align-items: center; gap: clamp(8px, 1.6vmin, 14px); }
.cat-right .bar { width: clamp(48px, 12vmin, 90px); height: clamp(6px, 1.1vmin, 9px); }
.cat-right .bar-cat > i { background: var(--green); }
.cat-row:not(.is-on) .cat-right .bar { opacity: .25; }

/* 撥掣 */
.switch {
  flex: 0 0 auto;
  width: clamp(40px, 9vmin, 54px);
  height: clamp(22px, 5vmin, 30px);
  border-radius: 999px;
  background: var(--line);
  border: 1px solid var(--line-2);
  position: relative;
  transition: background .18s, border-color .18s;
}
.switch > i {
  position: absolute; top: 50%; left: 2px;
  transform: translateY(-50%);
  width: calc(clamp(22px, 5vmin, 30px) - 6px);
  height: calc(clamp(22px, 5vmin, 30px) - 6px);
  border-radius: 50%;
  background: var(--text-dim);
  transition: left .18s, background .18s;
}
.cat-row.is-on .switch { background: var(--green-dim); border-color: var(--green); }
.cat-row.is-on .switch > i { left: calc(100% - clamp(22px, 5vmin, 30px) + 4px); background: var(--green-lt); }

/* ── 戰鬥：HUD ───────────────────────────────────────────── */
#screen-battle { background: #0a0908; }
.hud {
  flex: 0 0 auto;
  display: flex; align-items: center;
  gap: clamp(10px, 1.8vmin, 20px);
  padding: clamp(8px, 1.5vmin, 14px) clamp(10px, 2vmin, 20px);
  background: rgba(0,0,0,.4);
  border-bottom: 1px solid var(--line);
}
.stat { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.stat-label { font-size: clamp(9px, 1.5vmin, 12px); color: var(--text-dim); white-space: nowrap; }
.stat-num { font-size: clamp(10px, 1.5vmin, 12px); color: var(--text-dim); font-family: var(--font-en); white-space: nowrap; min-width: 2.6em; text-align: right; }
.hud-right { display: flex; align-items: center; gap: clamp(8px, 1.4vmin, 14px); font-size: clamp(10px, 1.6vmin, 13px); color: var(--text-dim); white-space: nowrap; }

/* ── ★ v0.13／v0.17：HUD 徽章（共用底）──
   `DPS: xx` / `分數: xxx` / 樓層 三粒都用同一個 pill：深色底 + outline + 描邊，
   令數字喺場景邊緣都讀得到。

   ★ 顏色係**語意**，唔可以亂用：
       樓層 floor-chip → 中性（夾喺中間唔搶眼）
       DPS  dps-chip   → 綠 = 夠力；低過本層所需 → 紅框紅字（紅綠燈）
       分數 score-chip → **金**（得分，同 ⭐ 一致）
     ★ 分數唔可以用綠色 —— 綠色已經係 DPS 嘅「夠力／唔夠力」訊號，
       兩粒都用綠就會失去意義（verify.mjs §22-a2 會斷言兩者顏色唔同）。

   ★ 所有數字都用 tabular-nums：分數會由 0 跳到幾千，
     唔等寬嘅話每加一個位數就會推郁隔籬嘅徽章。 */
.hud-chip {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: clamp(10px, 1.6vmin, 13px);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  background: rgba(10, 12, 10, .72);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: .22em .7em .26em;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  white-space: nowrap;
}
/* 分數嘅內層數字：同 chip 一樣粗，唔要 <b> 嘅預設視覺差異 */
.hud-chip > b { font-weight: 700; }

/* DPS：綠 = 夠力 */
.dps-chip { color: var(--green-lt, #8fd694); border-color: rgba(143, 214, 148, .55); }
.dps-chip.is-under {
  color: #ff8f85;
  border-color: rgba(226, 75, 74, .75);
  box-shadow: 0 0 0 2px rgba(226,75,74,.22), 0 2px 8px rgba(0,0,0,.35);
}

/* ★ v0.17：分數 —— 金（--amber） */
.score-chip { color: var(--amber, #EF9F27); border-color: rgba(239, 159, 39, .5); }

/* ★ v0.17：樓層 —— 中性色，唔同兩粒功能性徽章爭 */
.floor-chip { color: var(--text-dim); border-color: var(--line-2); font-weight: 600; }

/* ★ v0.17：窄屏（≤560px）→ HUD 分兩行。
   ── 點解要（實測過，唔係估）──
   同一行而家有「第 N 層 + DPS: xx + 分數: xxx + 📊 + ❚❚」，
   三粒 pill 實測共 154px、兩個掣約 70px。喺 390px 手機度，
   剩返畀左邊兩條 flex:1 嘅 HP／必殺條只有 **2px** ——
   血條完全睇唔到，而舊測試係過得（只驗水平溢出）。
   → 與其偷偷壓扁，不如老實分兩行：
       第一行 = HP 條 + 必殺條（flex:1 各佔一半，兩條都夠闊睇）
       第二行 = 徽章 + 掣（靠右）
   HUD 係 flex:0 0 auto，高多 ~22px 只會食場景上下嘅 letterbox，唔會擠到題目卡。
   ★ 呢個由 verify.mjs 守住（hpBarW ≥ 80px）。 */
@media (max-width: 560px) {
  .hud { flex-wrap: wrap; row-gap: 7px; }
  .stat { flex: 1 1 40%; }
  .hud-right { flex: 1 1 100%; justify-content: flex-end; gap: 6px; }
  .hud-chip { padding: .18em .5em .22em; letter-spacing: 0; }
}

/* ── 戰鬥：狀態 box（預設 hidden，📊 掣開） ──
   absolute 釘喺場景右上，唔影響 canvas 置中（canvas 喺 .scene-wrap 入面獨立置中）。
   z-index 16：高過場景（預設 0），低過升級／教學 overlay（z-index 20）。 */
.status-box {
  position: absolute;
  top: clamp(52px, 8.4vmin, 78px);
  right: clamp(8px, 1.6vmin, 16px);
  width: min(248px, 72vw);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: clamp(8px, 1.4vmin, 12px) clamp(10px, 1.8vmin, 14px);
  z-index: 16;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  font-size: clamp(11px, 1.7vmin, 14px);
}
.status-box[hidden] { display: none; }
.status-head {
  font-size: clamp(10px, 1.6vmin, 13px);
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--amber);
  margin-bottom: .5em;
  padding-bottom: .4em;
  border-bottom: 1px solid var(--line);
}
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8em;
  padding: .28em 0;
  color: var(--text-dim);
}
.status-row > span { white-space: nowrap; }
.status-row > b {
  font-family: var(--font-en);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
/* 最終攻擊力（重點）用琥珀色突顯 */
.status-row.st-eap { border-top: 1px solid var(--line); margin-top: .3em; padding-top: .55em; }
.status-row.st-eap > b { color: var(--amber); font-size: 1.08em; }
.status-row.st-req > b { color: var(--blue); }
/* ★ v0.13：DPS 格加 outline（深色描邊）， Values 喺場景上面都讀得到 */
.status-row > b {
  text-shadow:
    -1px -1px 0 rgba(0,0,0,.85), 1px -1px 0 rgba(0,0,0,.85),
    -1px  1px 0 rgba(0,0,0,.85), 1px  1px 0 rgba(0,0,0,.85),
    0 2px 4px rgba(0,0,0,.5);
}
.status-row.st-eap > b { font-size: 1.12em; letter-spacing: .02em; }

/* ── ★ v0.11 怪物屬性區塊 ────────────────────────────────── */
.status-head-mon {
  color: var(--red);
  margin-top: .9em;
  padding-top: .6em;
  border-top: 1px solid var(--line);
}
.status-head-mon::after {
  content: ' ← 呢隻';
  font-weight: 400;
  letter-spacing: 0;
  opacity: .55;
}
.status-row > span > .st-note {
  font-style: normal;
  font-size: .82em;
  opacity: .6;
  margin-left: .35em;
}
/* EAP 低過本層所需 → 紅框紅字，提醒要升攻 */
.status-box.is-under { border-color: var(--red); box-shadow: 0 0 0 2px rgba(226,75,74,.25), 0 8px 24px rgba(0,0,0,.45); }
.status-box.is-under .status-head { color: var(--red); }
.status-box.is-under .status-row.st-eap > b { color: var(--red); }

/* ── 戰鬥：場景 ──────────────────────────────────────────── */
.scene-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
/* canvas 由 JS 依 16:9 計出實際大細再置中，避免拉伸變形 */
#scene {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: block;
  image-rendering: pixelated;
}

.scene-toast {
  position: absolute; left: 50%; top: 12%;
  transform: translateX(-50%);
  font-size: clamp(12px, 2.1vmin, 18px);
  font-weight: 700;
  padding: .35em .9em;
  border-radius: 99px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.scene-toast.is-on { opacity: 1; }
.scene-toast.is-good { background: var(--green-dim); color: var(--green-lt); border: 1px solid var(--green); }
.scene-toast.is-bad  { background: var(--red-dim);   color: #F7C1C1;          border: 1px solid var(--red); }
.scene-toast.is-crit { background: var(--amber-dim); color: #FAC775;          border: 1px solid var(--amber); }

/* ── 戰鬥：題目卡 ────────────────────────────────────────── */
.qcard {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 2px solid var(--line-2);
  padding: clamp(10px, 1.8vmin, 18px) clamp(12px, 2.2vmin, 22px) clamp(12px, 2vmin, 20px);
  display: flex; flex-direction: column;
  gap: clamp(8px, 1.4vmin, 13px);
  transition: opacity .2s;
}
.qcard.is-waiting { opacity: .45; pointer-events: none; }
.qcard-meta {
  display: flex; justify-content: space-between; align-items: center;
  gap: .6em;
  font-size: clamp(10px, 1.6vmin, 13px);
  color: var(--text-dim2);
  min-height: 1.4em;
}
/* 提示技能嘅線索（首字母 / 詞性），只有用咗技能先出現 */
#q-clue {
  color: var(--amber);
  opacity: 0;
  transition: opacity .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#q-clue.is-on { opacity: 1; }
.qcard-prompt {
  text-align: center;
  font-family: var(--font-en);
  font-size: clamp(22px, 5.2vmin, 44px);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.15;
  word-break: break-word;
  min-height: 1.2em;
}
.qcard-prompt.is-zh { font-family: var(--font-ui); }

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(7px, 1.2vmin, 11px);
}
.opt {
  font-family: inherit;
  font-size: clamp(14px, 2.4vmin, 20px);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: clamp(11px, 2vmin, 18px) clamp(8px, 1.4vmin, 14px);
  cursor: pointer;
  min-height: clamp(46px, 8vmin, 64px);
  transition: transform .06s, background .12s, border-color .12s;
  display: flex; align-items: center; justify-content: center; gap: .4em;
  text-align: center;
  word-break: break-word;
}
.opt:active:not(:disabled) { transform: translateY(2px); }
.opt:disabled { cursor: default; }
.opt.is-correct { background: var(--green-dim); border-color: var(--green); color: var(--green-lt); }
.opt.is-wrong   { background: var(--red-dim);   border-color: var(--red);   color: #F7C1C1; }
.opt.is-dim     { opacity: .32; }
.opt.is-removed { opacity: .18; text-decoration: line-through; }
.opt-mark { font-size: .85em; }

.skills { display: flex; flex-wrap: wrap; align-items: center; gap: clamp(6px, 1vmin, 10px); }
.skills-label {
  font-size: clamp(10px, 1.5vmin, 12px);
  color: var(--text-dim2);
  letter-spacing: .1em;
}
.skill {
  font-family: inherit;
  font-size: clamp(11px, 1.7vmin, 14px);
  color: var(--text-dim);
  background: transparent;
  border: 1px dashed var(--line-2);
  border-radius: 99px;
  padding: .35em .9em;
  cursor: pointer;
  transition: transform .06s, color .12s, border-color .12s, opacity .15s;
}
.skill:active:not(:disabled) { transform: translateY(2px); }
/* 有次數但暫時撳唔到（例如啱啱答完、仲喺結算動畫）→ 微微暗，唔好閃 */
.skill:disabled { cursor: default; opacity: .55; }
.skill:not(:disabled):hover { color: var(--amber); border-color: var(--amber-dim); }
.skill b { color: var(--amber); font-weight: 600; margin-left: .35em; }

/* 0 次 / 未解鎖 → 淡出但仍然顯示（玩家要知有呢個技能存在） */
.skill.is-empty { opacity: .34; border-style: dotted; }
.skill.is-locked { opacity: .28; border-style: dotted; }
/* 啱啱抽到嘅技能閃一閃，話俾玩家聽「呢個係新嘅」 */
.skill.is-gained {
  border-color: var(--amber);
  border-style: solid;
  color: var(--amber);
  animation: gained .5s ease-out 4;
}
@keyframes gained {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,159,39,0); }
  50% { box-shadow: 0 0 0 4px rgba(239,159,39,.4); }
}

/* ── 升級卡 ──────────────────────────────────────────────── */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,5,4,.86);
  padding: clamp(14px, 3vmin, 32px);
  z-index: 20;
  backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }
.overlay-inner { width: min(720px, 100%); text-align: center; }
.overlay-kicker {
  font-size: clamp(11px, 1.8vmin, 15px);
  letter-spacing: .3em;
  color: var(--amber);
  margin-bottom: .6em;
}
.overlay-title {
  font-size: clamp(18px, 3.4vmin, 30px);
  font-weight: 700;
  margin-bottom: clamp(14px, 2.6vmin, 26px);
}
.overlay-note { font-size: clamp(11px, 1.8vmin, 14px); color: var(--text-dim); line-height: 1.7; }
.overlay .title-menu { margin: 0 auto; }

.card-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.6vmin, 16px);
}
.ucard {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: clamp(12px, 2.2vmin, 22px) clamp(8px, 1.6vmin, 16px);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(6px, 1.2vmin, 12px);
  transition: transform .08s, border-color .15s, box-shadow .15s;
  font-family: inherit; color: var(--text);
}
.ucard:active { transform: scale(.96); }
.ucard:hover { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(239,159,39,.15); }
.ucard.is-rare { border-color: var(--purple); }
.ucard-icon { width: clamp(34px, 6.5vmin, 56px); height: clamp(34px, 6.5vmin, 56px); }
.ucard-icon canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.ucard-name { font-size: clamp(13px, 2.1vmin, 18px); font-weight: 600; }
.ucard-desc { font-size: clamp(10px, 1.6vmin, 13px); color: var(--text-dim); line-height: 1.6; }

/* ── 揀完卡之後嘅「你得到咗咩」面板 ──
   單欄，佔晒成個 card-row，確保玩家一定睇到（尤其隨機抽技能）。 */
.card-row.is-result { grid-template-columns: 1fr; }
.ucard-result {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--amber);
  border-radius: var(--r-lg);
  padding: clamp(16px, 3vmin, 30px) clamp(12px, 2.4vmin, 24px);
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(5px, 1.1vmin, 11px);
  animation: cardPop .3s cubic-bezier(.2, 1.5, .4, 1);
  box-shadow: 0 0 0 4px rgba(239,159,39,.14), 0 10px 34px rgba(0,0,0,.5);
}
@keyframes cardPop {
  from { transform: scale(.82); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.ucard-result-kicker {
  font-size: clamp(10px, 1.7vmin, 14px);
  letter-spacing: .34em;
  color: var(--amber);
}
.ucard-result .ucard-icon { width: clamp(48px, 9.5vmin, 80px); height: clamp(48px, 9.5vmin, 80px); }
.ucard-result-name { font-size: clamp(20px, 3.8vmin, 34px); font-weight: 800; }
.ucard-result-detail { font-size: clamp(12px, 1.9vmin, 16px); color: var(--text-dim); }

/* ── 學習窗口：答錯之後嘅教學卡（GDD §6.4） ──
   設計要點：
   - 用藍色而唔係紅色 —— 呢張卡係「學嘢」，唔係「罰你」。
     紅色會令小朋友怕答錯；怕答錯就會亂揀，反而學少咗。
   - 由上到下一個視線流：英文大字（要學嘅嘢）→ 中文（意思）→ 例句（用法）。
   - 例句入面嘅目標字用 <b> 標黃，令小朋友一眼睇到「呢個字喺句子邊度」。
   - 唔顯示倒數數字。倒數造成壓力，同「慢慢睇」嘅目的相反；
     淨係喺卡底出一條慢慢填滿嘅幼條，話俾玩家知佢識自己走就夠。 */
.learn-card {
  max-width: min(560px, 100%);
  margin: 0 auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--blue-dim);
  border-radius: var(--r-lg);
  padding: clamp(18px, 3.4vmin, 34px) clamp(16px, 3vmin, 32px) 0;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(4px, 1vmin, 10px);
  animation: cardPop .28s cubic-bezier(.2, 1.5, .4, 1);
  overflow: hidden;
}
.learn-kicker {
  font-size: clamp(10px, 1.7vmin, 14px);
  letter-spacing: .3em;
  color: var(--blue);
  margin-bottom: .2em;
}
.learn-word {
  font-family: var(--font-en);
  font-size: clamp(30px, 7vmin, 62px);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
  word-break: break-word;
}
.learn-zh {
  font-size: clamp(18px, 3.6vmin, 34px);
  font-weight: 700;
  color: var(--amber);
}
.learn-pos {
  font-size: clamp(10px, 1.7vmin, 14px);
  color: var(--text-dim2);
  letter-spacing: .1em;
}
.learn-ex {
  font-family: var(--font-en);
  font-size: clamp(13px, 2.2vmin, 19px);
  color: var(--text-dim);
  line-height: 1.7;
  margin-top: clamp(6px, 1.4vmin, 14px);
  padding: clamp(8px, 1.6vmin, 14px) clamp(12px, 2.2vmin, 20px);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  border-left: 2px solid var(--blue-dim);
  border-radius: var(--r-sm);
  text-align: left;
}
.learn-ex b { color: var(--amber); font-weight: 700; }
.learn-actions {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(8px, 1.6vmin, 14px);
  margin-top: clamp(14px, 2.6vmin, 26px);
  width: 100%;
}
.learn-actions .btn { min-width: clamp(92px, 18vmin, 158px); }
/* 「聽一次」用 inline SVG 而唔用 emoji：呢個掣嘅圖示就係佢嘅全部識別，
   唔應該靠系統有冇裝 emoji 字體。全遊戲零外部檔案嘅方針下，畫出嚟最穩。 */
.btn-speak {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .45em;
  background: var(--panel-2); color: var(--blue); border-color: var(--blue-dim);
}
.ico-speak { width: 1.15em; height: 1.15em; flex: none; }
.learn-bar { width: 100%; height: 3px; margin-top: clamp(14px, 2.6vmin, 26px); background: var(--line); }
.learn-bar > i { display: block; height: 100%; width: 0; background: var(--blue-dim); }

/* ── 結算 ────────────────────────────────────────────────── */
.result-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(10px, 2vmin, 20px);
  text-align: center;
  /* safe center：內容高過畫面時唔會被「置中」推到頂部之外睇唔到。
     舊瀏覽器唔支援 safe → 整句無效 → 退回上一句 center。 */
  justify-content: center;
  justify-content: safe center;
}
.result-stars { font-size: clamp(34px, 9vmin, 74px); letter-spacing: .08em; color: var(--amber); line-height: 1; }
.result-stars .dim { color: #3a352f; }
/* 挑戰模式結算嗰個位係文字（「第 47 題」）而唔係星星，要細返 */
.result-stars.is-text { font-size: clamp(26px, 6vmin, 50px); font-weight: 800; letter-spacing: .02em; }
.result-title { font-size: clamp(22px, 4.4vmin, 40px); font-weight: 800; }
.result-title.is-fail { color: var(--hp); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(90px, 17vmin, 150px), 1fr));
  gap: clamp(8px, 1.5vmin, 14px);
  width: min(560px, 100%);
}
.result-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(9px, 1.7vmin, 16px);
}
.result-cell .k { font-size: clamp(10px, 1.6vmin, 13px); color: var(--text-dim2); margin-bottom: .35em; }
.result-cell .v { font-size: clamp(17px, 3vmin, 26px); font-weight: 700; font-family: var(--font-en); }
.result-wrong {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(10px, 1.8vmin, 16px);
  text-align: left;
}
.result-wrong h3 { font-size: clamp(11px, 1.8vmin, 14px); color: var(--text-dim2); font-weight: 500; margin-bottom: .6em; }
.result-wrong ul { list-style: none; display: flex; flex-direction: column; gap: .35em; }
.result-wrong li { font-size: clamp(12px, 1.9vmin, 16px); display: flex; justify-content: space-between; gap: 1em; }
.result-wrong li span:first-child { font-family: var(--font-en); }
.result-wrong li span:last-child { color: var(--text-dim); }
.result-note {
  margin-top: .7em;
  font-size: clamp(10px, 1.6vmin, 13px);
  color: var(--amber);
  line-height: 1.6;
}
.result-empty { font-size: clamp(12px, 1.9vmin, 16px); color: var(--green-lt); }

/* ── 裝備：角色／背包（v0.9） ──────────────────────── */
.equip-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 30vmin, 200px), 1fr));
  gap: clamp(8px, 1.6vmin, 14px);
  margin-bottom: clamp(14px, 2.6vmin, 22px);
}
.equip-cell {
  display: flex; align-items: center; gap: clamp(8px, 1.6vmin, 14px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: clamp(10px, 2vmin, 16px);
}
.equip-cell.is-clickable { cursor: pointer; }
.equip-cell.is-clickable:active { transform: scale(.98); }
.equip-info { flex: 1; min-width: 0; }
.equip-name { font-size: clamp(13px, 2.2vmin, 18px); font-weight: 700; }
.equip-val { font-size: clamp(11px, 1.8vmin, 14px); color: var(--text-dim); margin-top: .2em; }
.equip-val.is-empty { color: var(--text-dim2); }

/* 裝備圖示：同形狀，背景 + 爆光按稀有度 */
.equip-icon {
  position: relative;
  flex: 0 0 auto;
  width: clamp(44px, 9vmin, 64px);
  height: clamp(44px, 9vmin, 64px);
  border-radius: var(--r-md);
  border: 2px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  background: #14110f;
}
.equip-icon svg { width: 62%; height: 62%; }
.equip-icon .equip-rar {
  position: absolute; right: 2px; bottom: 1px;
  font-size: clamp(8px, 1.4vmin, 11px);
  font-weight: 700; line-height: 1;
  padding: 1px 3px; border-radius: 4px;
  background: rgba(0,0,0,.5); color: #fff;
}
.equip-icon.is-empty { border-style: dashed; opacity: .4; color: var(--text-dim2); }
/* 7 級稀有度配色：背景 = 顏色淡版，邊框 + 爆光 = 顏色 */
.equip-icon.rarity-white   { background: #2a2a2a; border-color: #d2d6db; box-shadow: 0 0 8px rgba(210,214,219,.35); }
.equip-icon.rarity-green   { background: #16331a; border-color: #74d36a; box-shadow: 0 0 10px rgba(116,211,106,.45); }
.equip-icon.rarity-blue    { background: #122b44; border-color: #5aa9f0; box-shadow: 0 0 12px rgba(90,169,240,.5); }
.equip-icon.rarity-red     { background: #3a1717; border-color: #f06a6a; box-shadow: 0 0 12px rgba(240,106,106,.5); }
.equip-icon.rarity-purple  { background: #2a1840; border-color: #b98af0; box-shadow: 0 0 14px rgba(185,138,240,.55); }
.equip-icon.rarity-gold    { background: #3a2e0f; border-color: #f0c453; box-shadow: 0 0 16px rgba(240,196,83,.6); }
.equip-icon.rarity-rainbow { background: linear-gradient(135deg,#3a0f33,#0f2a3a); border-color: #f06ad0; box-shadow: 0 0 18px rgba(240,106,208,.7); }

/* 角色頁「進入遊戲數值」細標題 */
.panel-h {
  font-size: clamp(13px, 2.1vmin, 17px);
  color: var(--text-dim); font-weight: 600;
  margin: clamp(6px, 1.4vmin, 12px) 0;
}

/* 背包 */
.inv-list { display: flex; flex-direction: column; gap: clamp(8px, 1.6vmin, 12px); max-width: 640px; }
.inv-row {
  display: flex; align-items: center; gap: clamp(10px, 2vmin, 16px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: clamp(10px, 2vmin, 14px) clamp(12px, 2.4vmin, 18px);
}
.inv-info { flex: 1; min-width: 0; }
.inv-name { font-size: clamp(13px, 2.2vmin, 18px); font-weight: 700; }
.inv-val { font-size: clamp(11px, 1.8vmin, 14px); color: var(--text-dim); margin-top: .2em; }
.inv-acts { display: flex; align-items: center; gap: clamp(6px, 1.2vmin, 10px); flex: 0 0 auto; }
.inv-acts .btn { min-width: clamp(56px, 12vmin, 84px); }
/* 部位頁：現裝 + 背包可換（v0.9.1） */
.slot-box { margin-bottom: clamp(12px, 2.4vmin, 20px); max-width: 640px; }
.slot-sub {
  font-size: clamp(11px, 1.8vmin, 14px);
  color: var(--text-dim2);
  letter-spacing: .08em;
  margin-bottom: .5em;
}
.inv-row.is-equipped { border-color: var(--amber-dim); background: var(--panel-2); }
.inv-empty {
  font-size: clamp(12px, 1.9vmin, 16px);
  color: var(--text-dim2);
  padding: clamp(10px, 2vmin, 16px);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
#inv-back { align-self: flex-start; margin-bottom: clamp(8px, 1.6vmin, 14px); }

/* 結算掉落 */
.result-drops {
  width: min(560px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: clamp(10px, 1.8vmin, 16px); text-align: left;
}
.result-drops h3 { font-size: clamp(11px, 1.8vmin, 14px); color: var(--text-dim2); font-weight: 500; margin-bottom: .6em; }
.drops-row { display: flex; flex-wrap: wrap; gap: clamp(8px, 1.6vmin, 14px); }
.drop-chip {
  display: flex; align-items: center; gap: .6em;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .5em .7em;
}
.drop-name { font-size: clamp(12px, 1.9vmin, 16px); font-weight: 700; }
.drop-val { font-size: clamp(10px, 1.6vmin, 13px); color: var(--amber); }

/* ── 無障礙 ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── 手機直立 ──
   場景係固定 16:9，直立手機必然會有上下黑邊。呢度刻意保留 letterbox
   （黑邊），因為咁樣最似「遊戲機畫面」，亦唔會將題目卡推到畫面之外。
   注意：唔可以喺呢度將 .scene-wrap 改成 aspect-ratio + flex:0 0 auto ——
   咁樣題目卡會食晒剩低嘅高度，倒數條就會爆（見上面 .bar-timer 註解）。
   TODO：想要直立滿屏，要將 canvas 改成 480×360 並下移 GROUND_Y。 */
@media (orientation: portrait) {
  .scene-wrap { max-height: 46vh; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
