:root {
  --bg: #0d1020;
  --bg2: #161a33;
  --panel: rgba(28, 33, 64, 0.82);
  --panel-solid: #1c2140;
  --line: rgba(217, 180, 90, 0.25);
  --gold: #d9b45a;
  --gold-hi: #f4d88a;
  --text: #ece8dc;
  --muted: #9a97a8;
  --ally: #5b9cf0;
  --enemy: #e0566a;
  --hp: #4fd18b;
  --hp-low: #e8b23c;
  --hp-crit: #e0566a;
  --cr: #6fc3ff;
  --fire: #e8573c;
  --ice: #4fb3e8;
  --wood: #5cbf5a;
  --light: #f2d36b;
  --dark: #9b6ce0;
  --radius: 12px;
  --speed: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, #2a2552 0%, transparent 60%),
    radial-gradient(ellipse at 50% 120%, #1b2a4a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
h1, h2 { font-family: "Noto Serif TC", serif; margin: 0; }

/* ── 共用 ─────────────────────────── */
.screen { display: none; height: 100dvh; flex-direction: column; max-width: 1000px; margin: 0 auto; padding: 16px; }
.screen.active { display: flex; }
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 18px; cursor: pointer; transition: transform .1s, background .2s, border-color .2s;
}
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #e6c26a, #b8913a); color: #1a1405; border-color: transparent; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.big { padding: 12px 32px; font-size: 1.1rem; }
.btn.small { padding: 4px 12px; font-size: .85rem; }
.btn.on { background: var(--gold); color: #1a1405; }
.hidden { display: none !important; }

.screen-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.screen-head h2 { font-size: 1.4rem; color: var(--gold-hi); }
.screen-head .hint { margin-left: auto; color: var(--muted); font-size: .9rem; }
.screen-foot { padding-top: 12px; display: flex; justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--enemy); padding: 8px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ── 元素與頭像 ─────────────────── */
.el-Fire { --el: var(--fire); }
.el-Ice { --el: var(--ice); }
.el-Wood { --el: var(--wood); }
.el-Light { --el: var(--light); }
.el-Dark { --el: var(--dark); }
.el-bg {
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--el) 55%, #2a2f55) 0%, color-mix(in srgb, var(--el) 22%, #12152b) 70%);
}
.portrait {
  --size: 56px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: grid; place-items: center; position: relative;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--el) 70%, black), 0 4px 12px rgba(0,0,0,.5);
  font-family: "Noto Serif TC", serif; font-weight: 900; font-size: calc(var(--size) * .48);
  color: rgba(255,255,255,.95); text-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.portrait .pic { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
/* 圓形頭像只取立繪的頭部 */
.portrait .pic img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.45) translateY(10%); }
.el-badge {
  position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--el); color: var(--el);
  font-size: 11px; display: grid; place-items: center; font-family: "Noto Sans TC", sans-serif; font-weight: 700;
}

/* ── 標題 ─────────────────────── */
#screen-title { justify-content: center; align-items: center; }
.title-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.title-cast { display: flex; justify-content: center; margin-bottom: 8px; }
.title-cast img { width: clamp(64px, 14vw, 120px); margin: 0 -10px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
.title-cast img:nth-child(2) { width: clamp(80px, 18vw, 150px); z-index: 1; }
.crown { width: 120px; filter: drop-shadow(0 0 18px rgba(217,180,90,.5)); }
.crown path:first-child { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linejoin: round; }
.crown .thorn { fill: none; stroke: var(--wood); stroke-width: 2.5; stroke-dasharray: 4 3; }
.crown circle { fill: var(--gold-hi); }
.title-wrap h1 { font-size: clamp(2.6rem, 10vw, 4.5rem); letter-spacing: .2em; padding-left: .2em;
  background: linear-gradient(180deg, #fff3c8, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.subtitle { margin: 0 0 24px; letter-spacing: .5em; color: var(--muted); font-size: .85rem; padding-left: .5em; }
.version { color: var(--muted); font-size: .8rem; }

/* ── 組隊 ─────────────────────── */
.team-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.team-slot {
  border: 1px dashed var(--line); border-radius: var(--radius); height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: .8rem; cursor: pointer; background: rgba(0,0,0,.15);
}
.team-slot.filled { border-style: solid; border-color: var(--gold); color: var(--text); }
.team-slot .portrait { --size: 52px; }
.roster { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; align-content: start; padding-bottom: 8px; }
.hero-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; cursor: pointer; transition: border-color .2s, transform .15s;
}
.hero-card:hover { border-color: var(--gold); }
.hero-card.picked { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(217,180,90,.25); }
.hero-card .bust { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; }
.hero-card .bust img { width: 100%; height: 100%; display: block; }
.hero-card .name { font-weight: 700; font-size: 1.15rem; }
.hero-card .title { font-size: .78rem; color: var(--gold); margin-bottom: 4px; }
.hero-card .stats { display: grid; grid-template-columns: repeat(4, auto); gap: 2px 10px; font-size: .78rem; color: var(--muted); }
.hero-card .stats b { color: var(--text); font-weight: 500; }
.hero-card .skills { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; border-top: 1px solid rgba(255,255,255,.06); padding-top: 6px; }
.hero-card .skills b { color: var(--gold-hi); font-weight: 500; }

/* ── 選關 ─────────────────────── */
.stage-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.stage-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; cursor: pointer; transition: border-color .2s;
}
.stage-card:hover:not(.locked) { border-color: var(--gold); }
.stage-card.locked { opacity: .45; cursor: not-allowed; }
.stage-card.boss { border-color: rgba(224,86,106,.5); background: linear-gradient(90deg, rgba(224,86,106,.12), var(--panel)); }
.stage-no { font-family: "Noto Serif TC", serif; font-size: 1.6rem; color: var(--gold); width: 2ch; text-align: center; }
.stage-card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.stage-card p { margin: 0; color: var(--muted); font-size: .85rem; }
.stage-enemies { display: flex; gap: 6px; }
.stage-enemies .portrait { --size: 40px; }
.stage-tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold); margin-left: 6px; }
.stage-tag.boss { border-color: var(--enemy); color: var(--enemy); }

/* ── 戰鬥：共用 ─────────────────── */
#screen-battle { padding: 0; position: relative; max-width: 1280px; }
.battle { display: flex; flex-direction: column; height: 100%; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
.battle-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.battle-title { display: flex; align-items: center; gap: 8px; font-family: "Noto Serif TC", serif; color: var(--gold-hi); white-space: nowrap; }
.battle-controls { display: flex; gap: 6px; }
.turn-order { display: flex; gap: 4px; justify-content: center; overflow: hidden; min-width: 0; padding: 4px 0 8px; }
.turn-order .portrait { --size: 32px; }
.turn-order .el-badge { display: none; }
.turn-order .slot { position: relative; transition: transform .3s; }
.turn-order .slot.side-0 .portrait { box-shadow: 0 0 0 2px var(--ally); }
.turn-order .slot.side-1 .portrait { box-shadow: 0 0 0 2px var(--enemy); }
.turn-order .slot:first-child { transform: scale(1.18); margin-right: 6px; }
.turn-order .slot:first-child::after { content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  border: 4px solid transparent; border-bottom-color: var(--gold-hi); }

/*
 * 戰場陣形：菱形站位。1 號位在最前（被怪物選中機率 40%），2、3 號位在中排，4 號位在最後。
 * JS 只標記 data-rank（front/middle/back）與 data-lane（1/2/span），
 * 直式時「排」對應到列（我方前排在最上），橫式時對應到欄（我方前排在最右）。
 */
.field { flex: 1; min-height: 0; position: relative; display: grid; gap: 10px;
  grid-template-rows: 1fr 1fr; grid-template-areas: "enemy" "ally"; }
.side { grid-area: ally; min-height: 0; display: grid; gap: 6px; place-items: center; }
.side.enemy { grid-area: enemy; }

/* 直式：三列 × 兩欄 */
@media (orientation: portrait) {
  .side { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); }
  .side.ally .unit[data-rank="front"], .side.enemy .unit[data-rank="back"] { grid-row: 1; }
  .side .unit[data-rank="middle"] { grid-row: 2; }
  .side.ally .unit[data-rank="back"], .side.enemy .unit[data-rank="front"] { grid-row: 3; }
  .side .unit[data-lane="1"] { grid-column: 1; }
  .side .unit[data-lane="2"] { grid-column: 2; }
  .side .unit[data-lane="span"] { grid-column: 1 / span 2; max-width: min(50%, 210px); }
  .side .unit.boss[data-lane="span"] { max-width: min(80%, 320px); }
  .side.ally { --lunge: 0 -16px; }
  .side.enemy { --lunge: 0 16px; }
}

/* 橫式：三欄 × 兩列，我左敵右 */
@media (orientation: landscape) {
  .field { grid-template-rows: 1fr; grid-template-columns: 1fr 1fr; grid-template-areas: "ally enemy"; gap: 24px; }
  .side { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: 1fr 1fr; }
  .side.ally .unit[data-rank="back"], .side.enemy .unit[data-rank="front"] { grid-column: 1; }
  .side .unit[data-rank="middle"] { grid-column: 2; }
  .side.ally .unit[data-rank="front"], .side.enemy .unit[data-rank="back"] { grid-column: 3; }
  .side .unit[data-lane="1"] { grid-row: 1; }
  .side .unit[data-lane="2"] { grid-row: 2; }
  .side .unit[data-lane="span"] { grid-row: 1 / span 2; max-height: 56%; }
  .side .unit.boss[data-lane="span"] { max-height: 95%; }
  .side.ally { --lunge: 18px 0; }
  .side.enemy { --lunge: -18px 0; }
}
/* ── 角色卡 ─────────────────────── */
.unit {
  position: relative; width: 100%; height: 100%; max-width: 210px; max-height: 260px; min-height: 0;
  background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius);
  padding: 6px; display: flex; flex-direction: column; gap: 5px;
  transition: translate calc(.25s / var(--speed)), scale .25s, border-color .2s, box-shadow .2s, opacity .4s, filter .4s;
}
.unit[data-rank="back"] { scale: .92; }
.unit.boss { max-width: 320px; max-height: 420px; }
.unit .art { position: relative; flex: 1; min-height: 0; border-radius: 8px; overflow: hidden; display: grid; place-items: center; }
.unit .art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.unit .art .glyph { font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 2.4rem; color: rgba(255,255,255,.9); }
.unit .art .el-badge { left: 4px; top: 4px; right: auto; bottom: auto; z-index: 2; }
.slot-badge { position: absolute; left: 28px; top: 4px; z-index: 2; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: rgba(0,0,0,.55); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.slot-badge.first { background: var(--gold); color: #1a1405; }
.team-slot small { font-size: .7rem; color: var(--muted); }
.team-slot .first { color: var(--gold-hi); font-weight: 700; }
.unit .nameplate { display: flex; align-items: baseline; gap: 6px; min-width: 0; line-height: 1.2; flex: none; padding: 0 2px; }
.unit .uname { font-size: .9rem; font-weight: 700; white-space: nowrap; }
.unit .utitle { font-size: .65rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.unit .statuses { position: absolute; right: 4px; top: 4px; z-index: 2; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.bar { width: 100%; height: 8px; background: rgba(0,0,0,.45); border-radius: 4px; overflow: hidden; position: relative; flex: none; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; transition: width calc(.35s / var(--speed)); }
.bar.hp > i { background: var(--hp); }
.bar.hp.low > i { background: var(--hp-low); }
.bar.hp.crit > i { background: var(--hp-crit); }
.bar.cr { height: 4px; }
.bar.cr > i { background: var(--cr); }
.hp-text { font-size: .66rem; color: var(--muted); margin-top: -3px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.status { font-size: .66rem; padding: 0 5px; border-radius: 4px; background: rgba(40,70,140,.85); border: 1px solid rgba(91,156,240,.7); }
.status.debuff { background: rgba(120,30,45,.85); border-color: rgba(224,86,106,.8); }
.unit.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(217,180,90,.4); }
.unit.dead { opacity: .3; filter: grayscale(1); }
.unit.targetable { cursor: pointer; border-color: var(--enemy); animation: pulse 1.1s infinite; }
.affinity-tag { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); z-index: 3; font-size: .65rem; padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.affinity-tag.adv { background: var(--hp); color: #06200f; }
.affinity-tag.dis { background: #555; color: #ddd; }
.unit.lunge { translate: var(--lunge); }
.unit.hit .art { animation: shake calc(.3s / var(--speed)); }
.unit.hit .art::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.35); animation: flash calc(.25s / var(--speed)) forwards; }

.float {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%); pointer-events: none; z-index: 5;
  font-weight: 900; font-size: 1.4rem; white-space: nowrap; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0,0,0,.8);
  animation: floatUp calc(1s / var(--speed)) ease-out forwards;
}
.float.crit { color: var(--gold-hi); font-size: 1.8rem; }
.float.heal { color: var(--hp); }
.float.info { font-size: .9rem; color: var(--cr); font-weight: 700; }
.float.bad { font-size: .9rem; color: var(--enemy); font-weight: 700; }

.banner {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 10; pointer-events: none; white-space: nowrap;
  padding: 8px 22px; border-radius: 999px; font-family: "Noto Serif TC", serif; font-size: 1.1rem;
  background: var(--panel-solid); border: 1px solid var(--line); opacity: 0; scale: .9; transition: .2s;
}
.banner.show { opacity: 1; scale: 1; }
.banner.side-0 { border-color: var(--ally); }
.banner.side-1 { border-color: var(--enemy); }

.skill-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; flex: none; }
.skill-info { min-height: 2.4em; font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.skill-info b { color: var(--gold-hi); }
.skill-info .btn { margin-left: auto; flex: none; }
.skill-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skill-btn {
  position: relative; border: 1px solid var(--line); background: rgba(0,0,0,.25); border-radius: 10px;
  padding: 8px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; transition: .15s;
}
.skill-btn .kind { font-size: .7rem; color: var(--muted); }
.skill-btn .sname { font-weight: 700; }
.skill-btn.selected { border-color: var(--gold); background: rgba(217,180,90,.15); }
.skill-btn:disabled { opacity: .35; cursor: not-allowed; }
.skill-btn .cd { position: absolute; top: 4px; right: 6px; font-size: .7rem; color: var(--enemy); }

/* 橫式時技能列放右下，讓戰場佔滿高度 */
@media (orientation: landscape) {
  .battle { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .skill-panel { flex-direction: row; align-items: center; }
  .skill-info { flex: 1; min-width: 0; }
  .skill-buttons { flex: none; width: min(420px, 48%); }
}

.result { position: absolute; inset: 0; background: rgba(5,6,15,.7); display: grid; place-items: center; z-index: 20; backdrop-filter: blur(3px); }
.result-card { background: var(--panel-solid); border: 1px solid var(--gold); border-radius: 16px; padding: 28px 32px; text-align: center; min-width: min(360px, 90vw); animation: pop .3s; }
.result-card h2 { font-size: 2.4rem; margin-bottom: 8px; }
.result-card h2.win { color: var(--gold-hi); }
.result-card h2.lose { color: var(--enemy); }
.result-card p { color: var(--muted); margin: 0 0 20px; }
.result-actions { display: flex; flex-direction: column; gap: 8px; }

@keyframes pulse { 50% { box-shadow: 0 0 0 1px var(--enemy), 0 0 16px rgba(224,86,106,.5); } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes flash { to { opacity: 0; } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -46px) scale(1); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ── 小螢幕 ─────────────────────── */
@media (max-width: 640px) {
  .screen { padding: 12px; }
  .battle-top { grid-template-columns: 1fr auto; }
  .turn-order { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .roster { grid-template-columns: 1fr; }
  .stage-card { grid-template-columns: auto 1fr; }
  .stage-enemies { grid-column: 1 / -1; }
  .unit .uname { font-size: .8rem; }
  .float { font-size: 1.1rem; }
  .float.crit { font-size: 1.4rem; }
}
/* 橫拿手機：高度很矮，壓縮上方列與技能列 */
@media (orientation: landscape) and (max-height: 500px) {
  .battle { padding: 4px 10px; gap: 4px; }
  .battle-top { grid-template-columns: auto 1fr auto; }
  .turn-order { grid-row: auto; grid-column: auto; justify-content: center; padding: 2px 0 6px; }
  .turn-order .portrait { --size: 24px; }
  .skill-panel { padding: 4px 8px; }
  .skill-info { font-size: .75rem; min-height: 0; }
  .skill-btn { padding: 4px; }
  .skill-btn .kind { display: none; }
  .unit { padding: 4px; gap: 3px; }
  .unit .utitle, .hp-text { display: none; }
  .field { gap: 16px; }
  .side { gap: 4px; }
}

/* ── 載入畫面 ─────────────────── */
.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 角色一覽與配裝 ─────────────── */
.grade-Normal { --grade: #9a97a8; }
.grade-Good { --grade: #5cbf5a; }
.grade-Rare { --grade: #4fb3e8; }
.grade-Heroic { --grade: #b07cff; }
.grade-Epic { --grade: #f0a43a; }
.grade-star3 { --grade: #4fb3e8; }
.grade-star4 { --grade: #b07cff; }
.grade-star5 { --grade: #f0a43a; }

.heroes-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 1fr; gap: 12px; }
.hero-tabs { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.hero-tab { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; }
.hero-tab .portrait { --size: 44px; }
.hero-tab.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.tab-info { display: flex; flex-direction: column; min-width: 0; }
.tab-info small { color: var(--muted); font-size: .72rem; }
.hero-detail { overflow-y: auto; min-height: 0; padding-right: 4px; display: flex; flex-direction: column; gap: 10px; }
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-bust { width: 110px; height: 110px; border-radius: 12px; overflow: hidden; flex: none; }
.detail-bust img { width: 100%; height: 100%; display: block; }
.detail-info h3 { margin: 0; font-size: 1.4rem; }
.detail-info .title { color: var(--gold); font-size: .85rem; margin: 2px 0 8px; }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.set-chip { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold-hi); }
.set-chip.none { border-color: var(--line); color: var(--muted); }
.section-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.stat-table { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; font-size: .9rem; }
.stat-name { color: var(--muted); }
.stat-base { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.stat-row b { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.stat-row b.up { color: var(--hp); }
.gear-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot-card { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left; padding: 10px; min-height: 78px; border-radius: 10px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--grade, var(--line)); box-shadow: inset 3px 0 0 var(--grade, transparent); }
.slot-card.empty { border-style: dashed; }
.slot-card.artifact { grid-column: 1 / -1; }
.slot-name { font-size: .72rem; color: var(--muted); }
.slot-card b { color: var(--grade, var(--text)); font-size: .9rem; }
.slot-main { font-size: .8rem; }
.slot-empty { font-size: .8rem; color: var(--muted); }

.picker { position: fixed; inset: 0; z-index: 40; background: rgba(5,6,15,.7); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.picker-card { width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel-solid); border: 1px solid var(--gold); border-radius: 16px; overflow: hidden; }
.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.picker-head h3 { margin: 0; font-family: "Noto Serif TC", serif; color: var(--gold-hi); }
.picker-body { overflow-y: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.item-card { border: 1px solid var(--grade, var(--line)); box-shadow: inset 3px 0 0 var(--grade); border-radius: 10px; padding: 10px 12px; background: rgba(0,0,0,.2); display: flex; flex-direction: column; gap: 4px; }
.item-top { display: flex; justify-content: space-between; gap: 8px; }
.item-top b { color: var(--grade); }
.item-enh { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.item-main { font-weight: 700; }
.item-lines { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: .82rem; color: var(--text); }
.item-desc { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.item-owner { font-size: .75rem; color: var(--gold); }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: .75rem; }

.result-rewards { display: flex; flex-direction: column; gap: 4px; margin: -8px 0 16px; text-align: left; }
.rewards-title { font-size: .8rem; color: var(--muted); }
.reward { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.25); border-left: 3px solid var(--gold); }
.reward.artifact { border-left-color: #f0a43a; }
.reward b { font-size: .9rem; }
.reward span { font-size: .75rem; color: var(--muted); }
.result-card { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* 直式：角色清單改成上方橫向捲動 */
@media (orientation: portrait), (max-width: 640px) {
  .heroes-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .hero-tabs { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .hero-tab { flex-direction: column; gap: 4px; min-width: 76px; padding: 6px; text-align: center; }
  .tab-info { align-items: center; }
  .tab-info small { display: none; }
  .stat-table { grid-template-columns: 1fr; }
  .gear-slots { grid-template-columns: repeat(2, 1fr); }
  .detail-bust { width: 84px; height: 84px; }
}
