/* 主色系、明暗雙場景 tokens、稀有度與裝備品質色皆由 theme-tokens.css 統一提供 */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--viewport-bg);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

.app-shell {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--light-bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--light-border);
  border-right: 1px solid var(--light-border);
  box-shadow: 0 8px 28px rgba(24, 43, 64, 0.14);
}

/* === 頂部資源列：墨藍鎏金 === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(29, 51, 76, 0.94) 0%, rgba(24, 43, 64, 0.96) 100%);
  color: var(--ink-on-dark);
  padding: calc(8px + env(safe-area-inset-top)) 10px 7px;
  border-bottom: 1.5px solid var(--palette-gilded-gold);
  box-shadow: 0 4px 12px rgba(16, 32, 51, 0.25);
}
.has-ui-surfaces .topbar {
  background-image: linear-gradient(180deg, rgba(29, 51, 76, 0.9) 0%, rgba(24, 43, 64, 0.94) 100%), var(--ui-ink-surface);
  background-size: auto, 240px auto;
}
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 6px; }
.brand-title { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--gold-light); letter-spacing: 0.08em; }
.brand-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(184, 154, 93, 0.18);
  border: 1px solid rgba(184, 154, 93, 0.45);
  color: var(--palette-xuanzhi);
}
.user-controls { display: flex; align-items: center; gap: 6px; }
.student-pill { font-size: 12px; color: var(--palette-xuanzhi); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.resource-bar-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}
.res-chip {
  background: rgba(69, 97, 126, 0.34);
  border: 1px solid rgba(230, 217, 191, 0.18);
  border-radius: 8px;
  padding: 3px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.res-k { display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-size: 10px; color: var(--muted-on-dark); white-space: nowrap; }
.resource-art { width: 15px; height: 15px; object-fit: contain; vertical-align: middle; flex-shrink: 0; }
.res-chip strong { font-size: 12px; color: var(--gold-light); }

body.modal-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: fit-content;
  max-width: min(380px, calc(100vw - 24px));
  z-index: 90;
  pointer-events: none;
  background: rgba(24, 43, 64, 0.94);
  border: 1px solid var(--palette-gilded-gold);
  color: var(--ink-on-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 18px rgba(24, 43, 64, 0.28);
  backdrop-filter: blur(4px);
}
.toast.ok { background: rgba(35, 108, 70, 0.94); border-color: #84C09E; color: #fff; }
.toast.err { background: rgba(166, 58, 50, 0.95); border-color: #D69792; color: #fff; }

.view-pad {
  padding: 16px 14px 28px;
  flex: 1;
  background: var(--bg);
  color: var(--ink);
  position: relative;
}
.has-login-bg .view-pad {
  background-color: #14253B;
  background-image: linear-gradient(180deg, rgba(16, 32, 51, 0.36) 0%, rgba(16, 32, 51, 0.84) 55%, rgba(16, 32, 51, 0.94) 100%), var(--login-study-bg);
  background-size: cover;
  background-position: center;
}
.login-card {
  position: relative;
  margin-top: 26px;
  padding: 20px 16px 18px;
  border-radius: 18px;
  border: 1px solid #C8AC69;
  background: rgba(248, 242, 229, 0.96);
  color: var(--light-ink);
  box-shadow: inset 0 0 0 3px rgba(255, 250, 238, 0.72), 0 14px 32px rgba(8, 17, 29, 0.36);
}
.login-seal {
  width: 50px;
  height: 50px;
  margin: -44px auto 10px;
  border: 1.5px solid #C8AC69;
  border-radius: 50%;
  background: radial-gradient(circle, #E0C583 0%, #9E7E46 100%);
  display: grid;
  place-items: center;
  color: #182B40;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(16, 32, 51, 0.32);
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 22px;
  text-align: center;
  margin: 0 0 6px;
  color: #182B40;
  letter-spacing: 0.06em;
}
.main-scroll { flex: 1; padding: 10px 10px calc(84px + env(safe-area-inset-bottom)); background: var(--bg); color: var(--ink); transition: background-color 0.18s ease; }
.has-ui-surfaces .main-scroll:not(.is-dark-scene) {
  background-color: var(--light-bg);
  background-image: linear-gradient(180deg, rgba(250, 246, 236, 0.72), rgba(240, 235, 223, 0.8)), var(--ui-paper-surface);
  background-size: auto, 240px auto;
}
.has-ui-surfaces .main-scroll.is-dark-scene {
  background-color: var(--dark-bg);
  background-image: linear-gradient(180deg, rgba(24, 43, 64, 0.82), rgba(16, 32, 51, 0.9)), var(--ui-ink-surface);
  background-size: auto, 240px auto;
}
body.modal-open .main-scroll { pointer-events: none; }
.tab-panel { display: flex; flex-direction: column; gap: 10px; }

/* === 通用卡片（隨所在明暗場景自動切換淺宣紙／深墨藍・對齊 Codex UI_STYLE_SPEC） === */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 250, 238, 0.45), 0 3px 10px rgba(24, 43, 64, 0.06);
}
.is-dark-scene .card {
  box-shadow: inset 0 1px 0 rgba(255, 246, 220, 0.06), 0 4px 14px rgba(8, 17, 29, 0.28);
}
.card h2, .card h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 16px; color: var(--ink); letter-spacing: 0.03em; }
.card p { margin: 4px 0; font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }

/* === 黛藍章節／篩選強調面板（用於主線探索、副本分類等） === */
.slate-panel {
  background: linear-gradient(135deg, #4B6886 0%, var(--palette-slate-blue) 100%);
  border: 1px solid #395169;
  color: #FAF6EC;
  box-shadow: 0 2px 8px rgba(24, 43, 64, 0.14);
}
.slate-panel h2, .slate-panel h3, .slate-panel strong { color: #FAF6EC; }
.slate-panel .muted { color: #D7E2ED; }
.slate-panel .tag { background: rgba(24, 43, 64, 0.34); border-color: rgba(230, 217, 191, 0.28); color: #FAF6EC; }
.slate-panel .tag.ok { background: rgba(59, 142, 98, 0.32); border-color: rgba(150, 224, 182, 0.55); color: #E4F9EC; }
.slate-panel .tag.warn { background: rgba(184, 154, 93, 0.32); border-color: rgba(251, 230, 166, 0.55); color: #FBE6A6; }
.slate-panel .progress-track { background: rgba(24, 43, 64, 0.36); border-color: rgba(230, 217, 191, 0.2); }
.slate-panel .progress-fill { background: #D7BA7A; }
.slate-panel .filter-pill {
  background: rgba(24, 43, 64, 0.28);
  border-color: rgba(230, 217, 191, 0.26);
  color: #EAE0CC;
}
.slate-panel .filter-pill.active {
  background: var(--active-tab-bg);
  color: var(--palette-ink-blue);
  border-color: #E2C688;
}

.notice-box {
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
}
.warn-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger-ink);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
}
.ok-box {
  background: var(--ok-soft);
  border: 1px solid var(--ok-border);
  color: var(--ok-ink);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
}

.stack-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
.field input, textarea, select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-light);
  font-size: 14px;
  color: var(--paper-ink);
}
.scene-dark .field input,
.scene-dark textarea,
.scene-dark select,
.is-dark-scene .field input,
.is-dark-scene textarea,
.is-dark-scene select {
  background: var(--dark-surface-deep);
  color: var(--dark-ink);
}
.field input::placeholder, textarea::placeholder { color: var(--muted); }
.field input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus-ring); border-color: var(--palette-gilded-gold); }
.quick-accounts { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line-subtle); }

/* === 按鈕規範（古金主要、黛藍一般、朱砂點綴、墨藍外框；符合 44px 觸控與四態規範） === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(24, 43, 64, 0.16);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--secondary-bg);
  color: var(--secondary-ink);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.16), 0 2px 4px rgba(16, 32, 51, 0.12);
  transition: filter 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:focus-visible { outline: 2px solid var(--palette-gilded-gold); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; filter: saturate(0.6); cursor: not-allowed; box-shadow: none; }
.btn-primary {
  background: linear-gradient(180deg, #D5C18B 0%, #B89A5D 100%);
  color: var(--primary-ink);
  border-color: #AB9057;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), 0 2px 5px rgba(54, 40, 15, 0.16);
}
.btn-accent {
  background: linear-gradient(180deg, #A9483E 0%, var(--accent) 100%);
  color: var(--accent-ink);
  border-color: #7D3028;
}
.btn-gem {
  background: linear-gradient(180deg, #3A72A5 0%, var(--gem-btn-bg) 100%);
  color: #F4F9FE;
  border-color: var(--gem-btn-border);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger-border);
}
.btn-outline {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.scene-dark .btn-outline,
.is-dark-scene .btn-outline {
  background: rgba(24, 43, 64, 0.56);
  border-color: var(--dark-border);
  color: var(--dark-ink);
}
.btn-ghost {
  background: rgba(69, 97, 126, 0.42);
  border-color: rgba(230, 217, 191, 0.28);
  color: var(--ink-on-dark);
  min-height: 30px;
}
.btn-xs { padding: 4px 8px; font-size: 12px; min-height: 30px; white-space: nowrap; }
.btn-block { width: 100%; padding: 10px 14px; font-size: 14px; min-height: 44px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.sub-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sub-tabs-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sub-tabs-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.sub-tabs-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.sub-tabs-5 .sub-tab { font-size: 11px; padding: 8px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-tab {
  padding: 8px 4px;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.sub-tab.active {
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  border-color: #AE8E4D;
  font-weight: 800;
}

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--line-subtle);
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}
.tag.ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-ink); }
.tag.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-ink); }
.tag.danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-ink); }

/* 稀有度標籤：R 水藍 / SR 紫晶 / SSR 赤金（ART_STYLE_GUIDE §3） */
.tag.rarity-R {
  background: var(--rarity-r-dark);
  border-color: var(--rarity-r-main);
  color: var(--rarity-r-light);
}
.tag.rarity-SR {
  background: var(--rarity-sr-dark);
  border-color: var(--rarity-sr-main);
  color: var(--rarity-sr-light);
}
.tag.rarity-SSR {
  background: var(--rarity-ssr-dark);
  border-color: var(--rarity-ssr-main);
  color: var(--rarity-ssr-light);
}

/* === 宣紙閱讀區與考題卡片（暖白／宣紙色配墨藍字，舒適易讀） === */
.reading-box {
  background: var(--paper-light);
  color: var(--paper-ink);
  border: 1px solid var(--paper-border);
  border-left: 4px solid var(--palette-slate-blue);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  margin: 6px 0;
}
.q-card {
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  padding: 11px;
  background: var(--paper-light);
  color: var(--paper-ink);
  box-shadow: 0 1px 4px rgba(24, 43, 64, 0.05);
}
.q-card .muted { color: var(--paper-muted); }
.q-card .tag { background: var(--paper-alt); color: var(--paper-ink); border-color: var(--paper-border); }
.q-card .tag.ok { background: #E5F3EB; border-color: #84C09E; color: #174D30; }
.q-card .tag.warn { background: #F9EFDA; border-color: #D2B06F; color: #63430B; }
.q-card .tag.danger { background: #FAE8E6; border-color: #D69792; color: #6D1F1A; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
.q-stem { font-size: 13.5px; font-weight: 700; margin-bottom: 8px; line-height: 1.55; }
.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt-btn {
  text-align: left;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--light-divider);
  background: #FAF6EC;
  color: var(--paper-ink);
  font-size: 13.5px;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt-btn:hover:not(:disabled) { border-color: var(--palette-slate-blue); background: #EBE2CE; }
.opt-btn:disabled { opacity: 0.78; cursor: default; }
.opt-btn.picked-wrong { border-color: #B34840; background: #FAE8E6; color: #6D1F1A; }
.opt-btn.picked-ok { border-color: #2D7C52; background: #E3F3E9; color: #174D30; font-weight: 700; }

.progress-track { width: 100%; height: 8px; border-radius: 999px; background: var(--line-subtle); overflow: hidden; margin: 4px 0; }
.progress-fill { height: 100%; background: var(--palette-slate-blue); transition: width 0.2s ease; }
.progress-fill.hp { background: var(--hp); }
.progress-fill.hp.low { background: var(--hp-enemy); }
.progress-fill.weekly-gold { background: var(--gold-bright); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 6px 0; }
.stat-cell {
  background: var(--surface-alt);
  border: 1px solid var(--line-subtle);
  border-radius: 7px;
  padding: 5px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.stat-cell strong { display: block; font-size: 13px; color: var(--ink); }

.slots-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.slot-btn {
  padding: 5px 3px;
  min-height: 58px;
  border-radius: 7px;
  border: 1px dashed var(--line);
  background: var(--surface-card-soft);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  position: relative;
}
.slot-btn.filled {
  border-style: solid;
  border-color: var(--selected-border);
  background: var(--selected-bg);
  font-weight: 600;
}

.skill-branch-box { border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: var(--surface-card-soft); }
.skill-nodes-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.skill-node-btn {
  padding: 6px 4px;
  min-height: 44px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
}
.skill-node-btn.active {
  border-color: #AE8E4D;
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  font-weight: 800;
}
.skill-node-btn:disabled { opacity: 0.42; cursor: not-allowed; }

.point-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-subtle); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper strong { min-width: 24px; text-align: center; color: var(--ink); }

.shop-balance-card {
  background: linear-gradient(135deg, #563F2E 0%, var(--palette-aged-wood) 100%);
  border: 1px solid var(--line);
  color: var(--ink-on-dark);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.shop-balance-card.gem-theme {
  background: linear-gradient(135deg, #1E344D 0%, var(--palette-slate-blue) 100%);
  border-color: rgba(112, 179, 202, 0.55);
}
.shop-balance-val { font-size: 16px; font-weight: 800; color: var(--gold-light); white-space: nowrap; flex-shrink: 0; }
.shop-sub-caption { font-size: 12px; color: var(--palette-xuanzhi); }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-subtle); font-size: 12px; }
.item-row:last-child { border-bottom: 0; }

.floor-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.floor-pill {
  padding: 5px 4px;
  border-radius: 7px;
  border: 1px solid var(--line);
  text-align: center;
  font-size: 10px;
  background: var(--surface-card-soft);
  color: var(--ink);
}
.floor-pill.cleared { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-ink); }
.floor-pill.current {
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  border-color: #AE8E4D;
  font-weight: 800;
}

.row-label { font-size: 11px; font-weight: 700; color: var(--palette-slate-blue); margin: 6px 0 3px; }
.scene-dark .row-label,
.is-dark-scene .row-label { color: var(--gold-bright); }
.lineup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 4px 0; }
.unit-tile {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px;
  background: var(--surface-card-soft);
  font-size: 11px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.unit-tile.selected {
  border-color: var(--selected-border);
  background: var(--selected-bg);
  box-shadow: inset 0 0 0 1px var(--selected-border);
}
.unit-tile:disabled { opacity: 0.45; cursor: not-allowed; }
.unit-tile-top { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }
.unit-tile-top svg { width: 22px; height: 22px; flex-shrink: 0; }

/* M4 歷練・預設編隊條與拖曳換位 */
.lineup-summary-card { padding: 9px 10px; }
.mini-lineup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.inline-drag-slot {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-alt);
  border: 1.5px solid var(--line);
  border-radius: 7px;
  padding: 6px 5px;
  font-size: 11px;
  color: var(--ink);
  min-width: 0;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.inline-drag-slot.empty { border-style: dashed; background: var(--surface-card-soft); cursor: default; justify-content: center; }
.inline-drag-slot.tap-swap-active { border-color: var(--palette-gilded-gold); background: var(--selected-bg-strong); box-shadow: 0 0 0 2px rgba(184, 154, 93, 0.35); }
.inline-drag-slot.drag-source { opacity: 0.38; transform: scale(0.95); }
.inline-drag-slot.drop-target { border-style: dashed; border-color: var(--drop-target-border); box-shadow: 0 0 0 2px rgba(69, 97, 126, 0.22); }
.inline-drag-slot.drop-hover { border-style: solid; border-color: var(--palette-gilded-gold); background: var(--drop-hover-bg); transform: scale(1.04); z-index: 2; }
.lineup-slot-empty {
  border: 2px dashed var(--line);
  border-radius: 9px;
  padding: 12px 6px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-card-soft);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.lineup-slot-empty.drop-target { border-color: var(--drop-target-border); box-shadow: 0 0 0 2px rgba(69, 97, 126, 0.22); }
.lineup-slot-empty.drop-hover { border-style: solid; border-color: var(--palette-gilded-gold); background: var(--drop-hover-bg); transform: scale(1.04); }
.unit-tile.drag-source { opacity: 0.45; transform: scale(0.96); }
.mini-pos-tag { font-weight: 800; color: var(--palette-slate-blue); flex-shrink: 0; font-size: 10px; }
.scene-dark .mini-pos-tag,
.is-dark-scene .mini-pos-tag { color: var(--gold-bright); }
.mini-chip-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* M4 模式橫幅（淺色頁面采古典宣紙書卷橫幅；深色沉浸場景采對應暗調橫幅；放圖後自動覆蓋） */
.mode-banner-slot {
  border-radius: var(--radius);
  padding: 11px 12px;
  border: 1px solid var(--line);
}
.mode-banner-slot.banner-light {
  background: var(--light-surface);
  border-color: var(--light-border);
  border-left: 4px solid var(--palette-slate-blue);
  color: var(--light-ink);
}
.mode-banner-slot.banner-light .mode-banner-content strong { color: var(--light-ink); }
.mode-banner-slot.banner-light .mode-banner-sub { color: var(--light-muted); opacity: 1; }

.mode-banner-slot.theme-academy:not(.banner-light) { background: linear-gradient(135deg, #182B40 0%, #2D4663 100%); color: var(--ink-on-dark); }
.mode-banner-slot.theme-bamboo:not(.banner-light) { background: linear-gradient(135deg, #1E3339 0%, #2F4F4D 100%); border-color: rgba(112, 179, 202, 0.42); color: var(--ink-on-dark); }
.mode-banner-slot.theme-tower { background: linear-gradient(135deg, #3A2920 0%, var(--palette-aged-wood) 100%); border-color: rgba(231, 184, 93, 0.44); color: var(--ink-on-dark); }
.mode-banner-slot.theme-secret { background: linear-gradient(135deg, #212445 0%, #3E3361 100%); border-color: rgba(168, 139, 214, 0.45); color: var(--ink-on-dark); }
.mode-banner-slot:not(.banner-light) .mode-banner-content strong { color: var(--gold-light); }
.mode-banner-slot:not(.banner-light) .mode-banner-sub { color: var(--palette-xuanzhi); opacity: 0.92; }
.mode-banner-content strong { font-size: 15px; display: block; }
.mode-banner-sub { font-size: 11px; margin-top: 2px; }

.stage-card { padding: 10px; }
.stage-card.stage-cleared { border-color: var(--ok-border); }
.stage-card.stage-locked { opacity: 0.72; background: var(--surface-alt); }
.enemy-intel-card { padding: 8px 10px; background: var(--danger-soft); border-color: var(--danger-border); }
.enemy-preview-tile { cursor: default; background: var(--danger-soft); border-color: var(--danger-border); }
.enemy-mini-strip { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.enemy-mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}
.stage-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line-subtle);
}

.secret-steps-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.secret-step-pill {
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.secret-step-pill.active {
  background: linear-gradient(180deg, #523E78 0%, var(--rarity-sr-dark) 100%);
  color: var(--rarity-sr-light);
  border-color: var(--rarity-sr-main);
}

/* 古人問答補給：在深色爬塔／秘境中維持宣紙展開閱讀手感 */
.tower-quiz-card {
  border: 1.5px solid var(--palette-gilded-gold);
  background: var(--paper-light);
  color: var(--paper-ink);
}
.tower-quiz-card h3 { color: var(--paper-ink); }
.tower-quiz-card .muted { color: var(--paper-muted); }
.tower-quiz-card .tag.ok { background: #E5F3EB; border-color: #84C09E; color: #174D30; }
.tower-quiz-card .tag.warn { background: #F9EFDA; border-color: #D2B06F; color: #63430B; }
.tower-swap-btn {
  color: var(--danger-ink);
  border-color: var(--danger-border);
  font-size: 11px;
}

/* Codex 美術素材掛載圖層（立繪與外框嚴格分離） */
.asset-slot-hero { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; position: relative; z-index: 1; }
.hero-mini-portrait .asset-slot-hero,
.hero-modal-avatar .asset-slot-hero,
.bu-avatar .asset-slot-hero { width: 100%; height: 100%; }
.asset-slot-hero img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-slot-gear { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.asset-slot-gear img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-frame-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit; width: 100%; height: 100%; object-fit: contain; }
.asset-gear-frame { position: absolute; inset: 0; pointer-events: none; z-index: 2; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* === 戰鬥舞台（深色沉浸） === */
.battle-topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.round-chip {
  background: var(--dark-surface-deep);
  border: 1px solid var(--dark-border);
  color: var(--gold-light);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.arena-stage {
  background: linear-gradient(180deg, #16263A 0%, #233B57 52%, #182C42 100%);
  border: 1px solid var(--dark-border);
  border-radius: 14px;
  padding: 8px 7px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}
.arena-stage.theme-bamboo { background: linear-gradient(180deg, #182C33 0%, #274347 52%, #1B3338 100%); }
.arena-stage.theme-tower { background: linear-gradient(180deg, #2D211B 0%, #4A362B 52%, #31231C 100%); }
.arena-stage.theme-secret { background: linear-gradient(180deg, #1B1E3B 0%, #302B54 52%, #202042 100%); }
.arena-row-tag { font-size: 10px; font-weight: 700; color: var(--palette-xuanzhi); margin: 2px 0 3px; opacity: 0.9; }
.arena-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-bottom: 4px; }
.arena-clash-line { display: flex; justify-content: center; align-items: center; margin: 5px 0; position: relative; }
.arena-clash-line::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--dark-border); }
.next-turn-chip {
  position: relative;
  z-index: 1;
  background: var(--dark-surface-deep);
  border: 1px solid var(--dark-border);
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}

.battle-unit {
  position: relative;
  background: rgba(24, 43, 64, 0.92);
  border: 2px solid rgba(112, 179, 202, 0.45);
  border-radius: 9px;
  padding: 4px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--dark-ink);
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.battle-unit.enemy-side { background: rgba(54, 30, 35, 0.92); border-color: rgba(196, 88, 78, 0.48); }
.battle-unit.energy-full { border-color: #E7B85D; box-shadow: 0 0 10px rgba(231, 184, 93, 0.45); }
.battle-unit.acting-ally { transform: translateY(-7px) scale(1.03); border-color: var(--gold-light); z-index: 3; }
.battle-unit.acting-enemy { transform: translateY(7px) scale(1.03); border-color: var(--gold-light); z-index: 3; }
.battle-unit.target-hit { border-color: var(--crimson); animation: hitShake 0.22s ease; }
.battle-unit.target-heal { border-color: var(--hp); }
.battle-unit.dead { opacity: 0.36; filter: grayscale(0.85); }
@keyframes hitShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.bu-top { display: flex; align-items: center; gap: 4px; }
.bu-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--dark-surface-deep);
  border: 1px solid var(--dark-divider);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bu-avatar svg { width: 24px; height: 24px; }
.bu-name-wrap { min-width: 0; flex: 1; }
.bu-name { font-size: 11px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--dark-ink); }
.bu-badges { display: flex; gap: 2px; flex-wrap: wrap; min-height: 13px; }
.mini-state { font-size: 9px; font-weight: 800; padding: 0 3px; border-radius: 3px; }
.ms-stun { background: #632320; color: #FFDAD6; }
.ms-buff { background: #21495F; color: #BDE3EF; }
.ms-next { background: #5A4519; color: #FBE6A6; }

.bars-stack { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.bar-track { height: 5px; background: #0E1824; border-radius: 4px; overflow: hidden; }
.bar-track.thin { height: 3px; }
.bar-hp-fill { height: 100%; background: var(--hp); transition: width 0.18s ease; }
.bar-hp-fill.enemy { background: var(--hp-enemy); }
.bar-shield-fill { height: 100%; background: var(--shield); transition: width 0.18s ease; }
.bar-energy-fill { height: 100%; background: var(--energy); transition: width 0.18s ease; }
.bu-hp-text { font-size: 9px; color: var(--dark-muted); text-align: right; margin-top: 1px; }

.fx-burst { position: absolute; inset: -4px; border-radius: 10px; pointer-events: none; z-index: 4; animation: fxFade 0.36s ease-out forwards; }
.fx-slash { background: radial-gradient(circle, rgba(206, 75, 66, 0.38), transparent 70%); border: 2px solid rgba(224, 92, 82, 0.78); }
.fx-heal { background: radial-gradient(circle, rgba(63, 160, 106, 0.34), transparent 70%); border: 2px solid rgba(85, 185, 128, 0.75); }
.fx-shield { background: radial-gradient(circle, rgba(90, 174, 212, 0.34), transparent 70%); border: 2px solid rgba(112, 179, 202, 0.78); }
.fx-control { background: radial-gradient(circle, rgba(168, 139, 214, 0.36), transparent 70%); border: 2px solid rgba(168, 139, 214, 0.78); }
@keyframes fxFade { 0% { opacity: 0.95; transform: scale(0.88); } 100% { opacity: 0; transform: scale(1.06); } }

.pop-float {
  position: absolute;
  top: -6px;
  right: 3px;
  z-index: 5;
  font-size: 12px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(18, 33, 50, 0.95);
  border: 1px solid var(--dark-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: popUp 0.45s ease-out forwards;
}
.pop-dmg { color: #FF948A; }
.pop-crit { color: #FBE6A6; font-size: 13px; border-color: #E7B85D; }
.pop-heal { color: #8AE6B2; }
.pop-shield { color: #BDE3EF; }
.pop-miss { color: var(--dark-muted); font-size: 11px; }
@keyframes popUp { 0% { opacity: 0; transform: translateY(6px); } 25% { opacity: 1; transform: translateY(0); } 100% { opacity: 0.95; transform: translateY(-7px); } }

.narrative-ticker {
  background: var(--dark-surface-deep);
  border: 1px solid var(--dark-border);
  color: var(--palette-xuanzhi);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  min-height: 36px;
}
.battle-controls { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.speed-pills, .action-pills { display: flex; gap: 4px; }
.btn-ctrl {
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-card-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ctrl.active { background: var(--active-tab-bg); color: var(--active-tab-ink); border-color: #AE8E4D; }

.result-banner { border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; border: 1px solid transparent; }
.result-banner.win { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-ink); }
.result-banner.loss { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-ink); }
.result-banner.draw { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-ink); }
.contrib-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.contrib-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-card-soft);
  border-radius: 8px;
  border: 1px solid var(--line-subtle);
}
.contrib-item .bu-avatar svg { width: 24px; height: 24px; }
.sbar-track { height: 5px; background: var(--line-subtle); border-radius: 999px; overflow: hidden; margin-top: 3px; }
.sbar-fill-dmg { height: 100%; background: var(--crimson); }

/* === 底部導覽列：墨藍鎏金 === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: linear-gradient(180deg, rgba(24, 43, 64, 0.96) 0%, rgba(16, 30, 46, 0.98) 100%);
  border-top: 1.5px solid var(--palette-gilded-gold);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.has-ui-surfaces .bottom-nav {
  background-image: linear-gradient(180deg, rgba(24, 43, 64, 0.92) 0%, rgba(16, 30, 46, 0.96) 100%), var(--ui-ink-surface);
  background-size: auto, 240px auto;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: transparent;
  border: 0;
  color: var(--muted-on-dark);
  font-size: 11px;
  padding: 4px 2px;
  min-height: 44px;
  justify-content: center;
  cursor: pointer;
}
.nav-btn.active { color: var(--gold-light); font-weight: 800; }
.nav-ico {
  width: 26px;
  height: 20px;
  line-height: 20px;
  border-radius: 6px;
  background: rgba(69, 97, 126, 0.32);
  font-size: 12px;
}
.nav-btn.active .nav-ico {
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  box-shadow: 0 0 8px rgba(231, 184, 93, 0.35);
}

/* === 彈窗與手機全螢幕子頁面（固定頂欄＋獨立中段捲動＋固定底欄） === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 19, 33, 0.66);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop:has(.modal-box.is-mobile-sheet) {
  padding: 6px 0 0;
  align-items: flex-end;
}
.modal-box {
  width: min(460px, 100%);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  border-radius: 16px;
  border: 1.5px solid #C4A861;
  box-shadow: 0 22px 56px rgba(3, 8, 17, 0.56);
  padding: 0;
}
.has-ui-surfaces .modal-box {
  background-color: var(--surface);
  background-image: linear-gradient(180deg, rgba(250, 246, 236, 0.78), rgba(240, 235, 223, 0.86)), var(--ui-paper-surface);
  background-size: auto, 240px auto;
}
.modal-box.is-mobile-sheet {
  width: 100%;
  max-width: 480px;
  height: calc(100dvh - 6px);
  max-height: calc(100dvh - 6px);
  border-radius: 18px 18px 0 0;
  border-bottom: 0;
}
.modal-head {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-subtle);
  background: rgba(250, 246, 236, 0.92);
}
.modal-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-top-fixed {
  flex-shrink: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.modal-body-inner { display: flex; flex-direction: column; gap: 8px; }
.modal-footer {
  flex-shrink: 0;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-subtle);
  background: var(--surface);
  box-shadow: 0 -4px 12px rgba(24, 43, 64, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-footer .btn-row { margin-top: 0; }

/* 手機觸控裝置隱藏傳統粗大捲軸，保留自然觸控滑動與慣性捲動；桌面滑鼠保留捲軸 */
@media (max-width: 767px) and (pointer: coarse) {
  html,
  body,
  .modal-body,
  .forge-bag-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  .modal-body::-webkit-scrollbar,
  .forge-bag-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}

/* 四大職業（含內部細分代碼對應）定位色 */
.role-tank { background: #2D628B; }
.role-dps,
.role-fighter { background: #A14F28; }
.role-aoe { background: #A14F28; }
.role-assassin { background: #A14F28; }
.role-healer { background: #2A7863; }
.role-support { background: #74602A; }
.role-pill { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 800; color: #fff; padding: 1px 7px; border-radius: 999px; line-height: 1.35; border: 1px solid rgba(255, 255, 255, 0.22); }
.bu-role-mini { display: inline-flex; align-items: center; gap: 2px; font-size: 9px; font-weight: 800; color: #fff; padding: 1px 4px; border-radius: 4px; line-height: 1.25; white-space: nowrap; }

.tower-slot {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 9px;
  padding: 6px;
  background: var(--surface-card-soft);
  font-size: 11px;
  color: var(--ink);
  text-align: left;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
[data-drag-slot] *,
[data-drag-roster] * {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
[data-drag-slot] [data-tower-hero-info],
[data-drag-slot] [data-remove-slot] {
  pointer-events: auto;
}
.tower-slot.dead { opacity: 0.56; background: var(--danger-soft); border-color: var(--danger-border); }
.tower-slot.tap-swap-active { border-color: var(--palette-gilded-gold); background: var(--selected-bg-strong); box-shadow: 0 0 0 2px rgba(184, 154, 93, 0.35); }
.tower-slot.drag-source { opacity: 0.38; transform: scale(0.95); }
.tower-slot.drop-target { border-style: dashed; border-color: var(--drop-target-border); box-shadow: 0 0 0 2px rgba(69, 97, 126, 0.2); }
.tower-slot.drop-hover { border-style: solid; border-color: var(--palette-gilded-gold); background: var(--drop-hover-bg); transform: scale(1.04); box-shadow: 0 4px 12px rgba(184, 154, 93, 0.28); z-index: 2; }
.tower-slot.invalid-shake { animation: hitShake 0.28s ease; }
.tower-info-mini {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  cursor: pointer;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  width: 96px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--palette-gilded-gold);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  z-index: 120;
  box-shadow: 0 10px 24px rgba(24, 43, 64, 0.32);
  transform: translate(-50%, -70%) scale(1.06);
}
.drag-ghost svg { width: 30px; height: 30px; }

.player-bonus-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ink);
  text-align: left;
}
.player-bonus-bar:hover { border-color: var(--palette-gilded-gold); background: var(--surface-alt); }

.filter-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-pill {
  padding: 4px 9px;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.filter-pill.active { background: var(--active-tab-bg); color: var(--active-tab-ink); border-color: #AE8E4D; }

/* === 人物圖鑑小卡（在深色場景凸顯 R 水藍 / SR 紫晶 / SSR 赤金） === */
.hero-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.hero-mini-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--dark-surface-soft);
  border: 2px solid var(--dark-border);
  border-radius: 10px;
  padding: 6px 4px 7px;
  cursor: pointer;
  color: var(--dark-ink);
  text-align: center;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.hero-mini-card:hover { transform: translateY(-2px); }
.hero-mini-card.rarity-border-R {
  border-color: var(--rarity-r-main);
  background: linear-gradient(180deg, rgba(112, 179, 202, 0.14), var(--rarity-r-dark) 125%);
}
.hero-mini-card.rarity-border-SR {
  border-color: var(--rarity-sr-main);
  background: linear-gradient(180deg, rgba(168, 139, 214, 0.18), var(--rarity-sr-dark) 125%);
  box-shadow: 0 0 8px rgba(168, 139, 214, 0.22);
}
.hero-mini-card.rarity-border-SSR {
  border-color: var(--rarity-ssr-main);
  background: linear-gradient(180deg, rgba(231, 184, 93, 0.2), var(--rarity-ssr-dark) 125%);
  box-shadow: 0 0 10px rgba(231, 184, 93, 0.28);
}
.hero-mini-card.has-rarity-frame {
  aspect-ratio: 8 / 11;
  justify-content: space-between;
  padding: 10px 9px 8px;
  border: 0;
  border-radius: 8px;
}
.hero-mini-card.has-rarity-frame .asset-frame-overlay {
  border-radius: 0;
  object-fit: contain;
  z-index: 3;
}
.hero-mini-card.has-rarity-frame .hero-mini-portrait {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  margin: 2px 0;
  padding: 2px 4px 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, rgba(235, 222, 194, 0.16) 0%, rgba(16, 29, 46, 0.08) 72%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.hero-mini-portrait .asset-slot-hero,
.hero-mini-portrait img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.hero-mini-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 4;
  width: 100%;
  padding: 3px 3px 1px;
  background: linear-gradient(180deg, rgba(12, 22, 36, 0.35) 0%, rgba(10, 18, 30, 0.88) 100%);
  border-radius: 4px;
}
.hero-mini-card.has-rarity-frame .hero-mini-name,
.hero-mini-card.has-rarity-frame .hero-mini-meta {
  text-shadow: 0 1px 3px rgba(6, 12, 20, 0.96);
}
.hero-mini-top { flex-shrink: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 2px; margin-bottom: 0; position: relative; z-index: 4; }
.hero-mini-portrait {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  min-height: 68px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 35%, rgba(230, 217, 191, 0.16), rgba(18, 33, 50, 0.65));
  border: 1px solid var(--dark-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0;
  padding: 2px 4px 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.hero-mini-portrait svg { width: 40px; height: 40px; }
.hero-mini-name { font-size: 11.5px; font-weight: 800; line-height: 1.18; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--dark-ink); position: relative; z-index: 4; }
.hero-mini-meta { font-size: 9.5px; line-height: 1.15; color: var(--dark-muted); position: relative; z-index: 4; }
.hero-mini-stars { font-size: 9.5px; color: #E7B85D; letter-spacing: -0.5px; line-height: 1.15; position: relative; z-index: 4; }
.hero-star-text { color: #C28922; }

.hero-modal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--dark-surface-deep) 0%, var(--dark-surface-alt) 100%);
  color: var(--dark-ink);
  border: 1.5px solid var(--dark-border);
  border-radius: 10px;
  padding: 10px;
}
.hero-modal-banner .muted { color: var(--dark-muted); }
.hero-modal-banner .hero-star-text { color: #E7B85D; }
.hero-modal-banner.rarity-R { border-color: var(--rarity-r-main); background: linear-gradient(135deg, var(--rarity-r-dark), var(--dark-surface)); }
.hero-modal-banner.rarity-SR { border-color: var(--rarity-sr-main); background: linear-gradient(135deg, var(--rarity-sr-dark), var(--dark-surface)); }
.hero-modal-banner.rarity-SSR { border-color: var(--rarity-ssr-main); background: linear-gradient(135deg, var(--rarity-ssr-dark), var(--dark-surface)); }
.hero-modal-avatar {
  width: 78px;
  height: 108px;
  border-radius: 8px;
  background: var(--dark-surface-deep);
  border: 2px solid var(--palette-gilded-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 7px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.hero-modal-avatar:has(.gx-portrait-card),
.hero-modal-avatar:has(.asset-frame-overlay.has-img) {
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.hero-modal-avatar .gx-portrait-card {
  width: 100%;
  border-radius: 7px;
  box-shadow: 0 4px 12px rgba(6, 12, 20, 0.45);
}
.hero-modal-avatar .gx-rarity-chip {
  font-size: 8px;
  padding: 0 3px;
}
.hero-modal-avatar .gx-title-slip span {
  font-size: 8px;
}
.hero-modal-avatar .gx-card-stats {
  display: none;
}
.hero-modal-avatar .asset-frame-overlay {
  z-index: 3;
}
.hero-modal-avatar .asset-slot-hero {
  width: 100%;
  height: 100%;
}
.hero-modal-avatar .asset-slot-hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.hero-modal-avatar svg { width: 44px; height: 44px; }
.modal-hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }

/* === 裝備六品質圖卡（宣紙／沉木暖底清楚呈現白／綠／藍／紫／橘／紅邊框與角標） === */
.item-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.item-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card-soft);
  border: 2px solid var(--gear-white);
  border-radius: 9px;
  padding: 6px 4px 5px;
  cursor: pointer;
  color: var(--ink);
  text-align: center;
  min-height: 92px;
}
.item-tile:disabled { opacity: 0.46; cursor: not-allowed; }
.item-tile.q-white { border-color: var(--gear-white); background: linear-gradient(180deg, var(--gear-white-bg), var(--surface-card-soft)); }
.item-tile.q-green { border-color: var(--gear-green); background: linear-gradient(180deg, var(--gear-green-bg), var(--surface-card-soft)); }
.item-tile.q-blue { border-color: var(--gear-blue); background: linear-gradient(180deg, var(--gear-blue-bg), var(--surface-card-soft)); }
.item-tile.q-purple { border-color: var(--gear-purple); background: linear-gradient(180deg, var(--gear-purple-bg), var(--surface-card-soft)); }
.item-tile.q-orange { border-color: var(--gear-orange); background: linear-gradient(180deg, var(--gear-orange-bg), var(--surface-card-soft)); }
.item-tile.q-red { border-color: var(--gear-red); background: linear-gradient(180deg, var(--gear-red-bg), var(--surface-card-soft)); }
.item-tile.picked-main { box-shadow: 0 0 0 2px var(--palette-gilded-gold), inset 0 0 0 1px var(--palette-gilded-gold); background: var(--selected-bg-strong); }
.item-tile.picked-mat { box-shadow: 0 0 0 2px var(--palette-slate-blue), inset 0 0 0 1px var(--palette-slate-blue); background: rgba(69, 97, 126, 0.16); }
.item-tile.picked-sell { box-shadow: 0 0 0 2px var(--danger), inset 0 0 0 1px var(--danger); background: var(--danger-soft); }

.item-badge-tl {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  font-weight: 800;
  color: var(--palette-ink-blue);
  background: rgba(250, 246, 236, 0.94);
  border: 1px solid var(--light-border);
  padding: 0 4px;
  border-radius: 4px;
}
.item-badge-tr { position: absolute; top: 2px; right: 3px; font-size: 9px; color: var(--palette-aged-wood); font-weight: 800; }

.item-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--paper-alt);
  border: 1px solid var(--light-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  position: relative;
}
.item-icon-box svg { width: 24px; height: 24px; }
.item-tile-name { font-size: 10px; font-weight: 800; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.item-price-tag { margin-top: 3px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-border); }
.item-price-tag.gem { background: #E3EEFA; border-color: #8CB6DF; color: #1B4A78; }
.item-worn-tag { margin-top: 3px; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 999px; background: var(--selected-bg); border: 1px solid var(--light-border); color: var(--palette-ink-blue); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.affix-chip-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.affix-chip { font-size: 11px; font-weight: 600; background: var(--surface-alt); border: 1px solid var(--line); color: var(--ink); padding: 2px 7px; border-radius: 6px; }

.weekly-hero-card {
  background: linear-gradient(135deg, #4B6886 0%, var(--palette-slate-blue) 100%);
  border: 1px solid #395169;
  color: #FAF6EC;
  border-radius: var(--radius);
  padding: 12px;
}
.weekly-sub-caption { font-size: 12px; color: #E2EAF2; }
.task-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-card-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.task-card.done { border-color: var(--ok-border); background: var(--ok-soft); }

/* 教師驗收橫幅（溫潤宣紙金邊，不壓迫整體明度） */
.qa-banner {
  background: #EAE0C8;
  border-bottom: 1px solid var(--light-border);
  color: var(--palette-aged-wood);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.qa-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.qa-art-btn {
  background: var(--light-surface);
  border-color: var(--palette-gilded-gold);
  color: var(--palette-ink-blue);
  min-height: 26px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}
.qa-art-btn.active {
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  border-color: #AE8E4D;
  font-weight: 800;
}
.qa-link-btn {
  background: var(--palette-slate-blue);
  border-color: #395169;
  color: #FAF6EC;
  min-height: 26px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.qa-reset-btn { background: var(--palette-ink-blue); border-color: var(--palette-gilded-gold); color: var(--gold-light); min-height: 26px; padding: 2px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; flex-shrink: 0; }
.qa-login-box {
  margin-top: 14px;
  padding: 10px;
  border-radius: 10px;
  background: var(--warn-soft);
  border: 1px dashed var(--palette-gilded-gold);
}
.qa-login-title { font-size: 13px; font-weight: 800; color: var(--palette-aged-wood); }

/* 工坊五合一：宣紙暖色及沉木色 */
.forge-workbench {
  background: linear-gradient(180deg, #F5EFE1 0%, #E7DCC4 100%);
  border: 1px solid #B59C72;
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.forge-top-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.forge-arrow { font-size: 18px; font-weight: 900; color: var(--palette-aged-wood); text-align: center; }
.forge-slot {
  position: relative;
  min-height: 86px;
  border-radius: 10px;
  border: 2px dashed #B59C72;
  background: #FAF6EC;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.forge-slot.filled { border-style: solid; background: #FFFDF8; border-color: var(--palette-aged-wood); }
.forge-slot.preview-slot { border-style: solid; border-color: var(--palette-gilded-gold); background: #FDF7E8; cursor: default; }
.forge-slot.drop-over { border-color: var(--palette-gilded-gold); background: #FBF0D6; transform: scale(1.03); }
.forge-slot-tag { font-size: 9px; font-weight: 800; color: var(--palette-aged-wood); margin-bottom: 2px; }
.forge-remove-btn {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  border-radius: 999px;
  background: rgba(166, 58, 50, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}
.forge-mat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.forge-mat-grid .forge-slot { min-height: 78px; }
.forge-summary-bar {
  background: rgba(250, 246, 236, 0.92);
  border: 1px solid var(--light-border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.forge-bag-scroll { max-height: 270px; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: 2px; }
.item-tile.dimmed { opacity: 0.35; }
.sell-bulk-card { background: var(--danger-soft); border-color: var(--danger-border); }

/* 許願池：墨藍夜色＋金色儀式光（深色沉浸凸顯稀有度） */
.wish-stage-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #2D4A6B 0%, var(--palette-ink-blue) 58%, #0E1B2B 100%);
  color: var(--dark-ink);
  padding: 16px 12px 14px;
  border: 1.5px solid var(--palette-gilded-gold);
  text-align: center;
}
.wish-stage-bg {
  position: relative;
  z-index: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(231, 184, 93, 0.45);
  background: radial-gradient(circle, rgba(231, 184, 93, 0.16), transparent 72%);
}
.wish-stage-title { font-size: 18px; font-weight: 800; letter-spacing: 1px; color: var(--gold-light); text-shadow: 0 1px 4px rgba(10, 20, 32, 0.85); }
.wish-stage-card.has-wish-banner {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: 96px;
}
.wish-stage-card.has-wish-banner .wish-stage-bg {
  min-height: 0;
  border-style: solid;
  border-color: rgba(231, 184, 93, 0.42);
  background: linear-gradient(180deg, rgba(16, 30, 46, 0.48) 0%, rgba(16, 30, 46, 0.82) 100%);
  backdrop-filter: blur(2px);
}
.wish-sub-caption { font-size: 12px; color: var(--gold-light); }
.wish-vfx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.wish-ticket-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(18, 33, 50, 0.72);
  border: 1px solid var(--dark-border);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-light);
}

/* 正式素材圖示尺寸與問道書齋淺底保底 */
.inline-ico-xs { width: 12px; height: 12px; object-fit: contain; vertical-align: -2px; margin-right: 2px; }
.inline-ico-sm { width: 15px; height: 15px; object-fit: contain; vertical-align: -3px; margin-right: 3px; }
.inline-ico-md { width: 20px; height: 20px; object-fit: contain; vertical-align: -4px; margin-right: 5px; }
.offer-currency-img, .wish-currency-img { width: 28px; height: 28px; object-fit: contain; }
.nav-ico { display: inline-flex; align-items: center; justify-content: center; }
.nav-ico:has(.nav-ico-img) { background: transparent !important; width: 26px; height: 22px; box-shadow: none !important; }
.nav-ico-img { width: 22px; height: 22px; object-fit: contain; }
.role-art { width: 13px; height: 13px; object-fit: contain; vertical-align: middle; flex-shrink: 0; background: #efe3dce8; border-radius: 50%; padding: 1px; }
.bu-role-mini.has-role-art {
  border: 1px solid rgba(230, 217, 191, 0.42);
  padding: 1px 4px 1px 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.bu-role-mini.has-role-art .role-art {
  width: 11px;
  height: 11px;
}
.bu-role-txt {
  font-size: 9px;
  font-weight: 800;
  color: #FAF6EC;
  line-height: 1;
}
.role-pill.has-role-art { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 3px; }
.has-study-bg { border-color: var(--light-border); }
.wish-action-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.wish-result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wish-card-tile {
  position: relative;
  border: 2px solid var(--dark-border);
  border-radius: 10px;
  padding: 8px 6px;
  background: var(--dark-surface-soft);
  color: var(--dark-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
.wish-card-tile .muted { color: var(--dark-muted); }
.wish-card-tile > div:first-child > .muted {
  background: rgba(12, 22, 36, 0.72);
  color: #F4ECD9;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.wish-card-tile.q-R { border-color: var(--rarity-r-main); background: linear-gradient(180deg, rgba(28, 56, 82, 0.92), var(--rarity-r-dark)); }
.wish-card-tile.q-SR, .wish-card-tile.q-purple { border-color: var(--rarity-sr-main); background: linear-gradient(180deg, rgba(50, 38, 78, 0.92), var(--rarity-sr-dark)); box-shadow: 0 0 10px rgba(168, 139, 214, 0.25); }
.wish-card-tile.q-SSR, .wish-card-tile.q-orange { border-color: var(--rarity-ssr-main); background: linear-gradient(180deg, rgba(64, 48, 22, 0.92), var(--rarity-ssr-dark)); box-shadow: 0 0 12px rgba(231, 184, 93, 0.34); }
.wish-card-tile.q-blue { border-color: var(--gear-blue); background: linear-gradient(180deg, rgba(30, 54, 88, 0.92), #1A2C44); }
.wish-card-icon { width: 44px; height: 44px; border-radius: 10px; background: var(--dark-surface-deep); border: 1px solid var(--dark-divider); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.wish-card-icon.is-hero-card { width: 88px; height: 121px; padding: 9px 8px; border-radius: 6px; }
.wish-card-icon.is-hero-card:has(.asset-frame-overlay.has-img) { border: 0; background: radial-gradient(circle at 50% 35%, rgba(235, 222, 194, 0.16), rgba(14, 24, 38, 0.94)); }
.wish-card-icon.is-hero-card .asset-frame-overlay { z-index: 3; }
.wish-card-icon.is-hero-card .asset-slot-hero { width: 100%; height: 100%; }
.wish-card-icon.is-hero-card .asset-slot-hero img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.wish-card-icon svg { width: 32px; height: 32px; }

.equip-empty-preview {
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-card-soft);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.equip-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--paper-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  flex-shrink: 0;
}
.equip-empty-icon svg { width: 28px; height: 28px; }
.equip-current-card {
  border: 2px solid var(--selected-border);
  border-radius: 12px;
  background: var(--selected-bg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.equip-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.hero-res-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line-subtle);
  font-size: 11.5px;
}
.hero-equip-slot-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.hero-equip-slot-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px dashed var(--line);
  background: var(--surface-card-soft);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.hero-equip-slot-card.filled {
  border-style: solid;
  border-color: var(--selected-border);
  background: var(--surface);
}
.hero-equip-slot-card:hover { border-color: var(--palette-gilded-gold); }
.hero-equip-slot-ico {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--paper-alt);
  border: 1px solid var(--light-divider);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hero-equip-slot-ico svg { width: 24px; height: 24px; }
.equip-choice-card {
  position: relative;
  border: 2px solid var(--gear-white);
  border-radius: 10px;
  background: var(--surface-card-soft);
  padding: 8px 7px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.equip-choice-card:hover { transform: translateY(-1px); border-color: var(--palette-gilded-gold); }
.equip-choice-card.q-green { border-color: var(--gear-green); background: linear-gradient(180deg, var(--gear-green-bg), var(--surface-card-soft)); }
.equip-choice-card.q-blue { border-color: var(--gear-blue); background: linear-gradient(180deg, var(--gear-blue-bg), var(--surface-card-soft)); }
.equip-choice-card.q-purple { border-color: var(--gear-purple); background: linear-gradient(180deg, var(--gear-purple-bg), var(--surface-card-soft)); }
.equip-choice-card.q-orange { border-color: var(--gear-orange); background: linear-gradient(180deg, var(--gear-orange-bg), var(--surface-card-soft)); }
.equip-choice-card.q-red { border-color: var(--gear-red); background: linear-gradient(180deg, var(--gear-red-bg), var(--surface-card-soft)); }
.equip-action-hint { margin-top: auto; font-size: 11px; font-weight: 700; }
.equip-action-hint.free { color: var(--palette-slate-blue); }
.equip-action-hint.swap { color: var(--accent); }
.other-worn-details { margin-top: 6px; border-top: 1px dashed var(--line-subtle); padding-top: 8px; }
.other-worn-details summary { font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 4px 0; }

/* === 桌面版閱讀舒適度微調（保留手機直式構圖與單手操作邏輯） === */
@media (min-width: 768px) {
  .app-shell,
  .bottom-nav {
    max-width: 540px;
  }
  .modal-backdrop:has(.modal-box.is-mobile-sheet) {
    padding: 16px;
    align-items: center;
  }
  .modal-box,
  .modal-box.is-mobile-sheet {
    width: min(500px, 94vw);
    height: auto;
    max-height: 88dvh;
    border-radius: 14px;
    border: 1.5px solid var(--line);
  }
  .main-scroll {
    padding: 14px 16px 88px;
  }
  .reading-box {
    padding: 12px 14px;
    font-size: 14.5px;
    line-height: 1.7;
  }
  .q-stem {
    font-size: 14.5px;
  }
  .opt-btn {
    font-size: 14px;
    padding: 10px 12px;
  }
}

/* === 頂部快捷列（G05 週任務置頂入口 ＋ 門派狀態捷徑） === */
.topbar-quick-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.top-quick-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(230, 217, 191, 0.28);
  background: rgba(69, 97, 126, 0.36);
  color: var(--palette-xuanzhi);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  min-width: 0;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.top-quick-pill:hover { background: rgba(69, 97, 126, 0.56); }
.top-quick-pill.active {
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  border-color: #E2C688;
}
.top-pill-ico {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: rgba(18, 33, 50, 0.55);
  color: var(--gold-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}
.top-quick-pill.active .top-pill-ico {
  background: var(--palette-ink-blue);
  color: var(--gold-light);
}
.top-pill-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-weekly-pill {
  flex-shrink: 0;
  border-color: rgba(231, 184, 93, 0.45);
}
.top-weekly-dot {
  background: var(--accent);
  color: #FDF4E6;
  border: 1px solid rgba(251, 230, 166, 0.7);
  border-radius: 999px;
  padding: 0 5px;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.45;
  flex-shrink: 0;
}

/* === M5 經史子集四大門派介面（宣紙沉木 × 墨藍鎏金） === */
.guild-sect-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.guild-sect-card,
.guild-hero-card {
  border-left: 4px solid var(--sect-accent, var(--palette-slate-blue));
  background: linear-gradient(135deg, color-mix(in srgb, var(--sect-accent, #45617E) 7%, var(--surface)) 0%, var(--surface) 58%);
  position: relative;
}
.guild-hero-card {
  border-top: 2px solid color-mix(in srgb, var(--sect-accent, #45617E) 38%, var(--palette-gilded-gold));
}
.guild-sect-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  color: #FAF6EC;
  background: var(--sect-accent, var(--palette-slate-blue));
  flex-shrink: 0;
}
.guild-sect-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.guild-emblem-box {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border: 1px solid var(--line);
}
.asset-slot-guild,
.asset-slot-guild-bldg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.asset-slot-guild svg,
.guild-emblem-img,
.asset-slot-guild-bldg svg,
.guild-bldg-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.guild-sect-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-card-soft);
  border: 1px solid var(--line-subtle);
}
.guild-stats-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}
.guild-qa-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-subtle);
}
.guild-confirm-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-card-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sect-accent, var(--palette-slate-blue));
}
.guild-rule-list {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-soft);
}

.guild-bldg-card {
  padding: 10px;
}
.guild-bldg-card.ready {
  border-color: var(--palette-gilded-gold);
  box-shadow: 0 2px 8px rgba(184, 154, 93, 0.16);
}
.guild-bldg-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.guild-bldg-icon {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  background: var(--paper-alt);
  border: 1px solid var(--light-border);
  padding: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guild-bldg-icon.sm {
  width: 34px;
  height: 34px;
  padding: 3px;
}
.guild-bldg-foot {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--line-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.guild-reserved-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.guild-reserved-tile {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px;
  border-radius: 9px;
  background: var(--surface-alt);
  border: 1px dashed var(--line);
  opacity: 0.85;
}

.guild-ms-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-card-soft);
}
.guild-ms-row.ready {
  border-color: var(--palette-gilded-gold);
  background: var(--warn-soft);
}
.guild-ms-row.claimed {
  border-color: var(--ok-border);
  background: var(--ok-soft);
}
.guild-goal-row {
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--surface-card-soft);
  border: 1px solid var(--line-subtle);
}
.guild-goal-row.done {
  border-color: var(--ok-border);
  background: var(--ok-soft);
}

.guild-member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--surface-card-soft);
  border: 1px solid var(--line-subtle);
}
.guild-member-row.self {
  border-color: var(--palette-gilded-gold);
  background: var(--selected-bg);
}
.guild-rank-badge {
  min-width: 28px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.guild-rank-badge.top-1 { background: var(--active-tab-bg); color: var(--active-tab-ink); border-color: #AE8E4D; }
.guild-rank-badge.top-2 { background: #D7E2ED; color: #182B40; border-color: #7092B3; }
.guild-rank-badge.top-3 { background: #E9D7C2; color: #563F2E; border-color: #B89A5D; }

.guild-shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.guild-offer-locked {
  opacity: 0.72;
}

/* === M6 PVP 離線天梯與自由切磋（宣紙雅色 × 墨藍鎏金） === */
.pvp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pvp-target-card {
  padding: 10px;
}
.pvp-target-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.pvp-rank-badge {
  min-width: 34px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--active-tab-bg);
  color: var(--active-tab-ink);
  border: 1px solid #AE8E4D;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pvp-rank-badge.sm {
  min-width: 28px;
  height: 22px;
  font-size: 11px;
}
.pvp-sect-mini {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pvp-sect-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.pvp-squad-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}
.pvp-mini-unit {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 2px;
  text-align: center;
  min-width: 0;
}
.pvp-mini-unit .asset-slot-hero {
  width: 26px;
  height: 26px;
  margin: 0 auto 2px;
}
.pvp-mini-unit .asset-slot-hero img,
.pvp-mini-unit .asset-slot-hero svg {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.pvp-mini-name {
  display: block;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pvp-milestone-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pvp-milestone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}
.pvp-milestone-item.is-claimable {
  border-color: var(--palette-gilded-gold);
  background: var(--selected-bg);
}
.pvp-milestone-item.is-claimed {
  opacity: 0.72;
}
.pvp-top-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pvp-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}
.pvp-top-row.is-me {
  border-color: var(--palette-gilded-gold);
  background: var(--selected-bg);
}
.pvp-log-row {
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.pvp-log-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.txt-ok { color: #2D7C52; }
.txt-danger { color: #963E35; }
.pvp-join-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.pvp-join-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface);
  color: var(--ink);
}
.pvp-spar-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.pvp-spar-slot {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink);
}
.pvp-spar-slot.is-empty {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-style: dashed;
  cursor: pointer;
  min-height: 44px;
}
.pvp-spar-slot.is-me {
  border-color: var(--palette-gilded-gold);
  background: var(--selected-bg);
}
.pvp-spar-slot.is-locked {
  border-left: 4px solid #2D7C52;
}
.pvp-spar-slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.pvp-spar-match-row {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}

/* === 排陣舞台放大 vs 緊湊方形人物名冊（與墨藍鎏金主介面一致） === */
.formation-stage-box {
  background: linear-gradient(180deg, #16263A 0%, #203652 55%, #16263A 100%);
  color: var(--dark-ink);
  border: 2px solid var(--palette-gilded-gold);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 0 4px 14px rgba(18, 33, 50, 0.22);
}
.formation-stage-box .row-label {
  color: #EAD8B1;
}
.formation-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gold-light);
}
.formation-slot-lg {
  min-height: 118px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(35, 56, 84, 0.94) 0%, rgba(16, 28, 45, 0.97) 100%);
  color: var(--dark-ink);
  border: 1.5px solid rgba(200, 173, 114, 0.48);
  box-shadow: 0 2px 8px rgba(10, 18, 30, 0.35);
}
.formation-slot-lg.rarity-border-R { border-color: var(--rarity-r-main); }
.formation-slot-lg.rarity-border-SR { border-color: var(--rarity-sr-main); box-shadow: 0 0 8px rgba(168, 139, 214, 0.28); }
.formation-slot-lg.rarity-border-SSR { border-color: var(--rarity-ssr-main); box-shadow: 0 0 10px rgba(231, 184, 93, 0.36); }
.formation-slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.formation-pos-tag {
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-light);
  background: rgba(14, 24, 38, 0.85);
  border: 1px solid rgba(212, 180, 114, 0.52);
  padding: 1px 5px;
  border-radius: 4px;
}
.formation-slot-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 2px;
}
.formation-avatar-lg {
  width: 100%;
  height: 66px;
  padding: 3px 4px 2px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 35%, rgba(230, 217, 191, 0.14), rgba(11, 20, 32, 0.55));
}
.formation-avatar-lg .asset-slot-hero,
.formation-avatar-lg svg,
.formation-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.formation-slot-name {
  font-weight: 800;
  font-size: 12px;
  line-height: 1.2;
  margin-top: 3px;
  color: var(--dark-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.formation-slot-meta {
  font-size: 10px;
  color: var(--dark-muted);
  white-space: nowrap;
}
.formation-slot-empty {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(13, 24, 38, 0.42);
  border: 1.5px dashed rgba(212, 180, 114, 0.45);
  color: rgba(242, 232, 210, 0.72);
  border-radius: 8px;
}
.formation-slot-empty small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
}

.roster-drawer-box {
  background: linear-gradient(180deg, #EFE6D4 0%, #E7DCC6 100%);
  border: 1.5px solid #C8B48B;
  border-radius: 10px;
  padding: 8px;
}
.roster-compact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 4px;
}
@media (min-width: 600px) {
  .roster-compact-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
.roster-square-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px;
  min-height: 104px;
  border-radius: 8px;
  border: 1.5px solid #4E6784;
  background: linear-gradient(180deg, #21354F 0%, #16263A 100%);
  color: var(--dark-ink);
  text-align: center;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  transition: transform 0.1s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.roster-square-card.rarity-border-R { border-color: var(--rarity-r-main); }
.roster-square-card.rarity-border-SR { border-color: var(--rarity-sr-main); }
.roster-square-card.rarity-border-SSR { border-color: var(--rarity-ssr-main); }
.roster-square-card.selected {
  border: 2px solid #E7B85D;
  box-shadow: 0 0 0 1px rgba(231, 184, 93, 0.45), 0 3px 8px rgba(18, 33, 50, 0.35);
}
.roster-square-card:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.roster-square-card.drag-source {
  opacity: 0.42;
  transform: scale(0.95);
}
.roster-sq-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2px;
}
.roster-sq-badge {
  font-size: 9px;
  font-weight: 800;
  color: var(--dark-ink);
  background: rgba(14, 24, 38, 0.72);
  padding: 1px 4px;
  border-radius: 3px;
}
.roster-sq-badge.is-on {
  background: #D8A446;
  color: #182B40;
}
.roster-sq-avatar {
  width: 100%;
  height: 54px;
  padding: 2px 4px 1px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 2px 0;
  overflow: hidden;
  border-radius: 5px;
  background: radial-gradient(circle at 50% 35%, rgba(230, 217, 191, 0.12), rgba(10, 18, 30, 0.45));
}
.roster-sq-avatar .asset-slot-hero,
.roster-sq-avatar svg,
.roster-sq-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.roster-sq-name {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--dark-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.roster-sq-sub {
  font-size: 9px;
  color: var(--dark-muted);
  line-height: 1.1;
}

/* === 學生端登入／註冊碼開通／生命週期禮包橫幅 === */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0;
}
.auth-tab-btn {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--line-subtle);
  background: var(--surface-soft, #f6f1e4);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.auth-tab-btn.active {
  background: var(--palette-ink-blue);
  color: var(--gold-light);
  border-color: var(--palette-gilded-gold);
}
.reg-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.reg-info-box {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(35, 108, 70, 0.08);
  border: 1px solid rgba(35, 108, 70, 0.35);
  color: var(--ink);
}
.reg-info-box.warn {
  background: var(--warn-soft);
  border-color: var(--palette-gilded-gold);
}
.auth-subswitch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-subtle);
  background: var(--surface-soft, #faf6ec);
  cursor: pointer;
}
.lifecycle-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.lifecycle-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fffdf6 0%, #f6ebd4 100%);
  border: 1px solid var(--palette-gilded-gold);
  color: var(--light-ink);
  font-size: 12px;
}
.lifecycle-card .muted {
  color: var(--light-muted);
}
.lifecycle-card strong {
  display: block;
  color: var(--palette-ink-blue);
}
.guild-switch-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--line-subtle);
  border-radius: 8px;
  cursor: pointer;
}

/* === Alpha 試玩標示條、人物姓名替代牌與人物圖鑑 === */
.alpha-notice-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(184, 154, 93, 0.16);
  border: 1px solid rgba(184, 154, 93, 0.45);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}
.main-scroll.is-dark-scene .alpha-notice-strip {
  background: rgba(184, 154, 93, 0.2);
  color: #FAF6EC;
}
.alpha-link-btn {
  border: 1px solid var(--palette-gilded-gold);
  background: var(--palette-ink-blue);
  color: var(--gold-light);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.hero-name-plate {
  width: 100%;
  height: 100%;
  min-height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 4px;
  text-align: center;
  color: #FAF6EC;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  letter-spacing: 0.5px;
  border: 1.5px solid rgba(231, 184, 93, 0.6);
  background: linear-gradient(155deg, #2B4563 0%, #192B40 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.hero-name-plate.role-plate-tank { background: linear-gradient(155deg, #2D628B 0%, #193852 100%); }
.hero-name-plate.role-plate-fighter { background: linear-gradient(155deg, #A14F28 0%, #5F2A12 100%); }
.hero-name-plate.role-plate-aoe { background: linear-gradient(155deg, #7D4494 0%, #482358 100%); }
.hero-name-plate.role-plate-assassin { background: linear-gradient(155deg, #9C2E39 0%, #59161D 100%); }
.hero-name-plate.role-plate-healer { background: linear-gradient(155deg, #2A7863 0%, #164438 100%); }
.hero-name-plate.role-plate-support { background: linear-gradient(155deg, #74602A 0%, #443817 100%); }
.alpha-codex-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 360px) {
  .alpha-codex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.codex-card {
  border: 1px solid rgba(184, 154, 93, 0.36);
  border-radius: 10px;
  padding: 5px;
  background: linear-gradient(180deg, #1E324B 0%, #142235 100%);
  color: var(--dark-ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.codex-card:hover { transform: translateY(-2px); border-color: var(--palette-gilded-gold); }
.codex-card .muted {
  color: var(--dark-muted);
}
.codex-card.is-unowned {
  opacity: 0.84;
}
.codex-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 1px 2px 2px;
}
.codex-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.codex-visual {
  width: 100%;
  height: 92px;
  padding: 4px 6px 2px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 2px 0;
  overflow: hidden;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 35%, rgba(230, 217, 191, 0.16), rgba(10, 18, 30, 0.5));
}
.codex-visual .asset-slot-hero,
.codex-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

/* === Codex 雙規格側題式卡牌系統（嚴格依 cards-40.css & UI_STYLE_SPEC.md 實作） === */
.hero-card-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: transform 0.12s ease;
}
.hero-card-btn:hover { transform: translateY(-2px); }
.hero-card-btn:active { transform: translateY(1px); }
.hero-card-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 0 3px;
  font-size: 10.5px;
  color: var(--dark-ink);
  font-weight: 700;
}
.hero-equip-pill {
  padding: 0 5px;
  border-radius: 999px;
  font-size: 9.5px;
  background: rgba(184, 154, 93, 0.22);
  border: 1px solid rgba(184, 154, 93, 0.5);
  color: var(--gold-light);
}

.hero-large-showcase {
  width: min(268px, 76vw);
  margin: 2px auto 6px;
}

.gx-portrait-card {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 512 / 704;
  overflow: hidden;
  border-radius: 8px;
  background-color: #16293d;
  background-image: var(--rarity-bg, linear-gradient(180deg, #213751 0%, #132132 100%));
  background-size: 100% 100%;
  box-shadow: 0 8px 20px rgba(5, 11, 19, 0.56);
}
.gx-portrait-card.rarity-r:not(.has-card-bg) {
  background-image: linear-gradient(180deg, rgba(112, 179, 202, 0.24), var(--rarity-r-dark) 120%);
  border: 1.5px solid var(--rarity-r-main);
}
.gx-portrait-card.rarity-sr:not(.has-card-bg) {
  background-image: linear-gradient(180deg, rgba(168, 139, 214, 0.26), var(--rarity-sr-dark) 120%);
  border: 1.5px solid var(--rarity-sr-main);
}
.gx-portrait-card.rarity-ssr:not(.has-card-bg) {
  background-image: linear-gradient(180deg, rgba(231, 184, 93, 0.28), var(--rarity-ssr-dark) 120%);
  border: 1.5px solid var(--rarity-ssr-main);
}
.gx-portrait-card.size-large {
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(5, 11, 19, 0.62);
}
.gx-portrait-card.is-dimmed .gx-art-layer img {
  filter: grayscale(0.55) brightness(0.84) drop-shadow(0 2px 3px rgba(20, 35, 53, 0.35));
}

.gx-art-layer {
  position: absolute;
  z-index: 1;
  inset: 5% 4% 8%;
  overflow: hidden;
}
.gx-portrait-card.size-large .gx-art-layer {
  inset: 9% 7% 10%;
}
.gx-art-layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transform: translate(var(--art-x, 0%), var(--art-y, 0%)) scale(var(--art-scale, 1));
  transform-origin: center center;
  user-select: none;
}
.gx-portrait-card.size-mini .gx-art-layer img {
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 77%, #000d 89%, #0008 95%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 77%, #000d 89%, #0008 95%, transparent 100%);
  filter: drop-shadow(0 2px 3px rgba(20, 35, 53, 0.35));
}
.gx-art-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18% 12%;
}

.gx-rarity-frame {
  position: absolute;
  z-index: 8;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.gx-rarity-chip {
  position: absolute;
  z-index: 9;
  left: 9%;
  top: 9%;
  padding: 1px 4px;
  border: 1px solid #e3d2aa;
  border-radius: 2px;
  background: #233950ee;
  color: #fff2d0;
  font-size: clamp(9px, 2.6vw, 11px);
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  text-shadow: 0 1px 2px #152235;
}
.gx-portrait-card.rarity-sr .gx-rarity-chip { background: #554273ee; }
.gx-portrait-card.rarity-ssr .gx-rarity-chip { background: #775d2dee; color: #fff1c7; }
.gx-portrait-card.size-large .gx-rarity-chip {
  padding: 2px 6px;
  font-size: clamp(10px, 2.8vw, 12px);
}

.gx-role-badge {
  position: absolute;
  z-index: 10;
  left: 8.5%;
  top: 19%;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px 1px 2px;
  border: 1px solid #d8c18a;
  border-radius: 999px;
  background: rgba(24, 38, 56, 0.9);
  color: #FAF6EC;
  box-shadow: 0 1px 3px rgba(16, 30, 43, 0.55);
  line-height: 1;
}
.gx-role-badge.role-bg-tank { background: rgba(45, 98, 139, 0.94); }
.gx-role-badge.role-bg-dps { background: rgba(161, 79, 40, 0.94); }
.gx-role-badge.role-bg-healer { background: rgba(42, 120, 99, 0.94); }
.gx-role-badge.role-bg-support { background: rgba(116, 96, 42, 0.94); }
.gx-role-art {
  width: 12px;
  height: 12px;
  object-fit: contain;
  background: #efe3dce8;
  border-radius: 50%;
  padding: 1px;
  flex-shrink: 0;
}
.gx-role-txt {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #FAF6EC;
}
.gx-portrait-card.size-large .gx-role-badge {
  top: 18.5%;
  gap: 4px;
  padding: 2px 7px 2px 3px;
}
.gx-portrait-card.size-large .gx-role-art {
  width: 17px;
  height: 17px;
  padding: 1.5px;
}
.gx-portrait-card.size-large .gx-role-txt {
  font-size: clamp(10px, 2.7vw, 12px);
}

.gx-title-slip {
  position: absolute;
  z-index: 9;
  top: 8.5%;
  right: 10%;
  display: block;
  width: max-content;
  height: auto;
  min-height: 0;
  max-height: 40%;
  padding: 2px 2px 3px;
  border: 0;
  border-right: 1px solid #9c7d49;
  background: linear-gradient(180deg, rgba(241, 229, 203, 0.78), rgba(241, 229, 203, 0.28) 80%, transparent);
  color: #192d43;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 1px rgba(255, 255, 255, 0.6);
  writing-mode: vertical-rl;
  text-orientation: upright;
}
.gx-title-slip span {
  display: block;
  font-size: clamp(10px, 3vw, 14px);
  letter-spacing: 0.1em;
}
.gx-portrait-card.size-large .gx-title-slip {
  top: 9.5%;
  right: 10%;
  padding: 4px 3px;
}
.gx-portrait-card.size-large .gx-title-slip span {
  font-size: clamp(15px, 3.8vw, 19px);
}

.gx-card-stats {
  position: absolute;
  z-index: 9;
  left: 7%;
  bottom: 8.5%;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 3px 5px;
  border-left: 1px solid #d9bf7a;
  background: linear-gradient(90deg, rgba(22, 43, 64, 0.82), rgba(22, 43, 64, 0.45) 80%, transparent);
  color: #fff0d1;
  font-size: clamp(9px, 2.5vw, 11px);
  line-height: 1.2;
  text-shadow: 0 1px 2px #101e2b;
  white-space: nowrap;
}
.gx-stars {
  color: #ffe08a;
  font-size: 1.04em;
  letter-spacing: -0.08em;
}
.gx-card-stats b {
  font-size: 0.95em;
}
.gx-portrait-card.size-large .gx-card-stats {
  left: 50%;
  bottom: 4.6%;
  transform: translateX(-50%);
  justify-content: center;
  padding: 2px 7px;
  border: 0;
  background: rgba(23, 40, 61, 0.68);
  border-radius: 4px;
  font-size: clamp(10px, 2.8vw, 12px);
}

.wish-card-hero-tile {
  padding: 6px;
}
.wish-hero-card-wrap {
  width: 100%;
  max-width: 112px;
  margin: 2px auto;
}

@media (min-width: 700px) {
  .gx-portrait-card.size-mini {
    border-radius: 10px;
  }
}
@media (max-width: 350px) {
  .gx-role-badge { padding: 1px 3px 1px 1.5px; }
  .gx-role-art { width: 10px; height: 10px; }
  .gx-role-txt { font-size: 8.5px; }
  .gx-card-stats { left: 5%; gap: 2px; }
}

/* === 正式帳號註冊、自助救援與跨裝置設定 === */
.auth-tabs-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 480px) {
  .auth-tabs-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.auth-helper-links {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.recovery-code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  background: #fffdf6;
  color: #182b40;
  border: 1.5px dashed #b89143;
  user-select: all;
}
.claim-guest-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-subtle);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  cursor: pointer;
}
.claim-guest-option input {
  margin-top: 2px;
}
.ext-bind-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px dashed var(--line-subtle);
}
