/* ==================================================
   DUNGEON REBORN — 暗黑奇幻 × 金色 UI
================================================== */

* { box-sizing: border-box; }

:root {
    color-scheme: dark;
    --gold: #d9b66f;
    --gold-light: #f5dda1;
    --gold-dark: #96733c;
    --ember: #ff8a3a;
    --text: #eee9df;
    --muted: #9c9eab;
    --panel: linear-gradient(165deg, rgba(38, 36, 50, 0.96), rgba(16, 16, 24, 0.97) 80%);
    --border: #ffffff14;
    --border-gold: #d9b66f66;
    --radius: 12px;
    --transition: 200ms ease;
    --title-font: "Cinzel", Georgia, "Times New Roman", serif;
}

@property --spin {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Microsoft JhengHei", "Noto Sans TC", "PingFang TC", sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, #3a2c1e 0%, transparent 60%),
        radial-gradient(ellipse at 50% 120%, #1c1430 0%, transparent 55%),
        linear-gradient(180deg, #13131c 0%, #0b0b11 100%);
    background-attachment: fixed;
}

button { font: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

.hidden { display: none !important; }

#iconDefs { position: absolute; width: 0; height: 0; overflow: hidden; }

.game-container { width: min(1180px, 94%); margin: 0 auto; }

/* ---------- 標題 ---------- */
.game-header {
    min-height: 72px;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.game-header::after {
    content: ""; position: absolute; left: 0; bottom: -1px; width: 180px; height: 1px;
    background: linear-gradient(90deg, var(--gold), transparent);
}
.logo {
    font-family: var(--title-font);
    font-size: clamp(18px, 2.4vw, 24px);
    font-weight: 800; letter-spacing: 4px;
}
.logo span { color: var(--gold); }
.header-tag { color: #7d7f8d; font-size: 10px; letter-spacing: 3px; text-align: right; }

/* ---------- 通用按鈕 ---------- */
.btn {
    padding: 12px 24px;
    font-weight: bold; letter-spacing: 1px;
    border-radius: 8px; cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition);
}
.btn-gold {
    color: #1d150a;
    background: linear-gradient(180deg, #fbe7b4 0%, var(--gold) 55%, #b88d48 100%);
    border: 1px solid #fff0c4;
    box-shadow: 0 4px 0 #6d5129, 0 8px 20px #00000055, inset 0 1px 0 #ffffffaa;
}
.btn-gold:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 #6d5129, 0 12px 28px #d9b66f40, inset 0 1px 0 #ffffffaa; }
.btn-gold:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #6d5129, 0 4px 12px #00000055; }
.btn-gold:disabled { color: #79736a; background: #2e2c33; border-color: #45414a; box-shadow: none; cursor: not-allowed; }
.btn-dark {
    color: var(--text);
    background: linear-gradient(180deg, #2c2d3a, #1d1e28);
    border: 1px solid #ffffff1f;
    box-shadow: inset 0 1px 0 #ffffff10, 0 4px 14px #00000040;
}
.btn-dark:hover { color: var(--gold-light); border-color: var(--gold-dark); transform: translateY(-1px); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon span { font-size: 16px; }

/* ---------- 主頁 ---------- */
.home-screen {
    position: relative; overflow: hidden;
    min-height: min(78vh, 760px);
    display: flex; justify-content: center; align-items: center;
    margin-top: 20px; padding: 56px 20px;
    border: 1px solid #4a3e2c; border-radius: 16px; text-align: center;
    background: #0d0d14;
    box-shadow: 0 30px 80px #000a, inset 0 0 0 1px #ffffff06;
    animation: screenFadeIn 450ms ease both;
}
/* 封面圖：images/cover/cover.png（找不到時顯示 SVG 預設封面） */
.home-cover {
    position: absolute; inset: 0; z-index: 0;
    background:
        linear-gradient(180deg, rgba(8, 8, 14, 0.35) 0%, rgba(8, 8, 14, 0.55) 45%, rgba(8, 8, 14, 0.95) 100%),
        url("images/cover/cover.png") center / cover no-repeat,
        url("images/cover/cover-placeholder.svg") center / cover no-repeat;
    transform: scale(1.04);
    animation: coverDrift 24s ease-in-out infinite alternate;
}
@keyframes coverDrift { to { transform: scale(1.1) translateY(-1%); } }
.home-embers { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.home-embers i {
    position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
    background: #ffb35a; box-shadow: 0 0 8px 2px #ff7a2a;
    animation: ember 9s linear infinite; opacity: 0;
}
.home-embers i:nth-child(1)  { left: 6%;  animation-delay: 0s; }
.home-embers i:nth-child(2)  { left: 14%; animation-delay: 2.2s; animation-duration: 11s; }
.home-embers i:nth-child(3)  { left: 23%; animation-delay: 4.1s; }
.home-embers i:nth-child(4)  { left: 31%; animation-delay: 1.3s; animation-duration: 12s; }
.home-embers i:nth-child(5)  { left: 42%; animation-delay: 6.5s; }
.home-embers i:nth-child(6)  { left: 51%; animation-delay: 3.3s; animation-duration: 10s; }
.home-embers i:nth-child(7)  { left: 60%; animation-delay: 7.7s; }
.home-embers i:nth-child(8)  { left: 68%; animation-delay: 0.8s; animation-duration: 13s; }
.home-embers i:nth-child(9)  { left: 77%; animation-delay: 5.2s; }
.home-embers i:nth-child(10) { left: 85%; animation-delay: 2.9s; animation-duration: 11s; }
.home-embers i:nth-child(11) { left: 92%; animation-delay: 8.4s; }
.home-embers i:nth-child(12) { left: 47%; animation-delay: 9.6s; animation-duration: 14s; }
@keyframes ember {
    0%   { transform: translate(0, 0) scale(1); opacity: 0; }
    10%  { opacity: 1; }
    100% { transform: translate(40px, -760px) scale(0.3); opacity: 0; }
}

.home-content { position: relative; z-index: 2; width: 100%; max-width: 720px; }
.home-eyebrow { margin: 0; color: #cdb98d; letter-spacing: 6px; font-size: 12px; text-shadow: 0 2px 8px #000; }
.home-title {
    margin: 20px 0 10px; font-family: var(--title-font); font-weight: 800;
    font-size: clamp(42px, 8vw, 92px); letter-spacing: 6px; line-height: 1.02;
    background: linear-gradient(180deg, #fff6dc 0%, #f0d69a 45%, #b5843f 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 4px 0 #3b2a14) drop-shadow(0 0 28px rgba(255, 170, 70, 0.35));
}
.home-title span {
    display: block; font-size: 0.72em; letter-spacing: 0.32em;
    background: linear-gradient(180deg, #ffcf8a 0%, #e0823a 60%, #8a3a14 100%);
    -webkit-background-clip: text; background-clip: text;
}
.home-description { color: #d6d2c6; margin: 18px 0 34px; letter-spacing: 2px; text-shadow: 0 2px 10px #000; }

.home-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.home-sub-actions { display: flex; gap: 12px; }
.home-sub-actions .btn { min-width: 128px; background: rgba(28, 28, 38, 0.82); backdrop-filter: blur(4px); }
.home-start-button {
    position: relative; overflow: hidden;
    min-width: 280px; padding: 17px 40px;
    border: 1px solid #ffe0a0; border-radius: 10px;
    background: linear-gradient(180deg, #e6b765 0%, #b07a34 55%, #7d5121 100%);
    color: #fff8e6; font-size: 20px; font-weight: bold; letter-spacing: 6px; cursor: pointer;
    text-shadow: 0 2px 2px #4a2e0e;
    box-shadow: 0 5px 0 #4f3214, 0 12px 34px rgba(230, 160, 70, 0.35), inset 0 1px 0 #fff4c8;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.home-start-button::after {
    content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }
.home-start-button:hover { transform: translateY(-3px); box-shadow: 0 8px 0 #4f3214, 0 18px 40px rgba(230, 160, 70, 0.5), inset 0 1px 0 #fff4c8; }
.home-start-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #4f3214, 0 6px 16px rgba(0, 0, 0, 0.5); }

.home-records {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
    margin-top: 40px;
}
.home-records .rec {
    padding: 10px 6px; border-radius: 10px;
    background: rgba(10, 10, 16, 0.7); border: 1px solid #d9b66f2a; backdrop-filter: blur(4px);
}
.home-records .rec span { display: block; color: #a99f88; font-size: 11px; letter-spacing: 1px; }
.home-records .rec b { display: block; margin-top: 4px; color: var(--gold-light); font-family: var(--title-font); font-size: 17px; }
.home-records .rec:first-child { border-color: #ffb23e88; background: linear-gradient(160deg, rgba(90, 58, 18, 0.7), rgba(10, 10, 16, 0.7)); }
.home-records .rec:first-child b { color: #ffd27a; }
.home-help { margin: 26px 0 0; color: #8c8d99; font-size: 12px; letter-spacing: 1px; text-shadow: 0 1px 4px #000; }
.home-version { margin-top: 22px; color: #5f606d; font-size: 11px; letter-spacing: 4px; }

/* ---------- 角色選擇 ---------- */
.selection-panel { padding: 44px 0 36px; animation: screenFadeIn 450ms ease both; }
.section-heading { margin-bottom: 36px; text-align: center; }
.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: 11px; letter-spacing: 6px; }
.section-heading h1 {
    margin: 0; font-family: var(--title-font), "Microsoft JhengHei", serif;
    font-size: clamp(28px, 4vw, 42px); letter-spacing: 5px; text-shadow: 0 4px 24px #00000055;
}
.subtitle { margin-top: 15px; color: var(--muted); font-size: 14px; line-height: 1.8; }

.character-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }

.character-card {
    position: relative; min-width: 0; overflow: hidden;
    padding: 22px 16px 20px; color: var(--text); text-align: center;
    background: radial-gradient(ellipse at 50% 0%, #3a2f2244, transparent 60%), linear-gradient(165deg, #282a38 0%, #1a1b26 50%, #111219 100%);
    border: 1px solid var(--border); border-radius: 14px; cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.character-card::before {
    content: ""; position: absolute; top: 0; left: 12%; right: 12%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: 0.25;
    transition: opacity var(--transition), left var(--transition), right var(--transition);
}
.character-card:hover { transform: translateY(-6px); border-color: var(--border-gold); box-shadow: 0 16px 40px #00000050, 0 0 28px #d9b66f14; }
.character-card:hover::before, .character-card.selected::before { left: 0; right: 0; opacity: 1; }
.character-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px #d9b66f40, 0 0 40px #d9b66f22, 0 16px 36px #00000040; }

.character-art {
    position: relative; display: flex; align-items: center; justify-content: center;
    height: 200px; margin-bottom: 8px;
    background: radial-gradient(ellipse at center 70%, #5a4a3a 0%, #352e3c 30%, #20212b 62%, transparent 76%);
    border-radius: 10px;
}
.character-art::after {
    content: ""; position: absolute; bottom: 14px; left: 50%; width: 120px; height: 16px; transform: translateX(-50%);
    background: radial-gradient(ellipse, #00000088, transparent 70%);
}
.character-art canvas { position: relative; z-index: 1; display: block; width: 192px; height: 192px; max-width: 100%; image-rendering: pixelated; }

.character-card h2 { margin: 12px 0 6px; color: var(--gold-light); font-family: var(--title-font); font-size: 28px; letter-spacing: 4px; }
.character-name { margin: 0 0 12px; font-size: 22px; font-weight: 700; }
.character-description { min-height: 56px; margin: 0 0 10px; color: #b9b9c6; font-size: 16px; line-height: 1.7; }
.character-stats { margin: 0 0 6px; color: #e3c585; font-size: 16px; font-weight: 700; letter-spacing: 1px; }


.selection-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border);
}
#selectionStatus { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- 遊戲畫面 HUD ---------- */
#dungeonScreen { width: 100%; margin-top: 16px; animation: screenFadeIn 350ms ease; }

#gameStatusBar {
    width: 100%; max-width: 1280px; margin: 0 auto 8px; padding: 10px 16px;
    display: flex; align-items: center; justify-content: center; gap: 22px;
    background: linear-gradient(180deg, rgba(26, 26, 36, 0.96), rgba(12, 13, 19, 0.96));
    border: 1px solid #8c754680; border-radius: 12px; color: #f1d18a;
    box-shadow: 0 8px 24px #0006, inset 0 1px 0 #ffffff0d;
}
.status-level {
    display: grid; place-items: center; min-width: 64px; height: 40px; padding: 0 12px;
    font-family: var(--title-font); font-size: 17px; font-weight: 800; white-space: nowrap; color: #1d150a;
    background: linear-gradient(180deg, #fbe7b4, #c39552); border-radius: 8px;
    box-shadow: 0 0 16px #d9b66f40, inset 0 1px 0 #fff;
}
.status-item { width: 32%; max-width: 360px; }
.status-label { display: flex; justify-content: space-between; margin-bottom: 5px; color: #e8e5dc; font-size: 12px; letter-spacing: 1px; }
.status-label span:first-child { color: #a9a6b3; font-weight: bold; }
.status-track {
    position: relative; width: 100%; height: 12px; overflow: hidden;
    background: #14161f; border: 1px solid #3a3d4b; border-radius: 6px; box-shadow: inset 0 2px 4px #0008;
}
.status-fill { position: relative; height: 100%; width: 0%; border-radius: 6px; transition: width 0.12s ease; }
.status-fill::after {
    content: ""; position: absolute; inset: 0 0 50% 0; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, #ffffff55, transparent);
}
.hp-fill { background: linear-gradient(90deg, #8d1f2e, #e23f4f 60%, #ff7b86); box-shadow: 0 0 10px #ff4b5a66; }
.exp-fill { background: linear-gradient(90deg, #1d5fb8, #3e9bff 60%, #8fd0ff); box-shadow: 0 0 10px #3e9bff66; }
.status-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 38px; height: 38px; color: var(--gold-light); font-size: 15px; cursor: pointer;
    background: linear-gradient(180deg, #2a2c3a, #1a1b25); border: 1px solid #8c754666; border-radius: 9px;
    transition: background var(--transition), transform var(--transition), border-color var(--transition);
}
.icon-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.icon-btn.off { color: #70717e; text-decoration: line-through; }

.hud-sub {
    max-width: 1280px; margin: 0 auto 6px;
    display: flex; justify-content: center; gap: 30px; flex-wrap: wrap;
    color: #b9b4a6; font-size: 13px; letter-spacing: 1px;
}
.hud-sub b { color: var(--gold-light); font-family: var(--title-font); font-size: 15px; }

/* 已持有技能晶片（可點擊 / 滑鼠移入查看介紹） */
.passive-list {
    max-width: 1280px; min-height: 32px; margin: 0 auto 8px;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 3px; font-size: 12px; color: #e8dcc0; cursor: pointer;
    background: linear-gradient(180deg, #23243200, #1b1c27), #1b1c27; border: 1px solid #d9b66f50; border-radius: 999px;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.chip:hover { transform: translateY(-2px); box-shadow: 0 4px 14px #0007; }
.chip.weapon { border-color: #ff9d4a; color: #ffd98a; }
.chip.evo { background: linear-gradient(135deg, #5a3a12, #2a1c08); border-color: #ffb23e; color: #ffe2a3; }
.chip.skill { border-color: #5fb4ff; color: #cfe8ff; }
.chip.max { border-color: #ffb23e; color: #ffd98a; background: #2a1f0e; }
.chip.item { border-color: #6fe0b088; color: #d4fbe9; }
.chip.stats { border-color: #ffffff30; color: #c9c6d0; }
.chip.fusion-ready { border-color: #ffb23e; color: #fff0c4; animation: chipPulse 1.2s ease-in-out infinite; }
@keyframes chipPulse { 50% { box-shadow: 0 0 14px #ffb23e99; } }

.stage { position: relative; max-width: 1280px; margin: 0 auto; }

#game {
    display: block; width: 100%; max-width: 1280px; height: auto; margin: 0 auto;
    background: #171923; border: 1px solid #d9b66f55; border-radius: 10px;
    box-shadow: 0 0 0 4px #ffffff05, 0 18px 60px #00000066, 0 0 40px #d9b66f0c;
}

/* ---------- 圖示徽章（技能 SVG / 符號） ---------- */
.ico {
    --ic: #5fb4ff;
    position: relative; flex: none; display: inline-grid; place-items: center;
    width: 80px; height: 80px; padding: 3px; border-radius: 50%;
    background: conic-gradient(from var(--spin), var(--ic), transparent 25%, var(--ic) 50%, transparent 75%, var(--ic));
    box-shadow: 0 0 18px color-mix(in srgb, var(--ic) 45%, transparent);
}
.ico-in {
    display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
    background:
        radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--ic) 40%, #1a1a28) 0%, #0d0e16 72%);
    box-shadow: inset 0 0 14px color-mix(in srgb, var(--ic) 50%, transparent), inset 0 -6px 12px #0009;
}
.ico svg { width: 66%; height: 66%; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--ic) 80%, transparent)) drop-shadow(0 2px 2px #000a); }
.ico-glyph {
    font-size: 34px; line-height: 1; color: var(--ic);
    text-shadow: 0 0 10px var(--ic), 0 2px 2px #000;
}
.ico.big { animation: icoSpin 5s linear infinite; }
.ico.mid { width: 52px; height: 52px; padding: 2px; }
.ico.mid .ico-glyph { font-size: 22px; }
.ico.mini { width: 24px; height: 24px; padding: 1.5px; box-shadow: none; }
.ico.mini .ico-glyph { font-size: 12px; text-shadow: 0 0 4px var(--ic); }
.ico.mini svg { width: 78%; height: 78%; filter: none; }
@keyframes icoSpin { to { --spin: 360deg; } }

/* ---------- 覆蓋層 ---------- */
.overlay {
    position: absolute; inset: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: radial-gradient(ellipse at center, rgba(20, 16, 30, 0.82), rgba(4, 4, 8, 0.92));
    backdrop-filter: blur(6px);
    border-radius: 10px; animation: fadeIn 220ms ease-out;
}

.menu-panel {
    position: relative;
    width: min(400px, 100%); padding: 30px 28px; text-align: center;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--panel);
    border: 1px solid #8b774b90; border-radius: 16px;
    box-shadow: 0 24px 70px #000c, inset 0 1px 0 #ffffff12;
    animation: popIn 260ms cubic-bezier(.2, 1.4, .4, 1);
}
.menu-panel::before, .modal-panel::before {
    content: ""; position: absolute; top: -1px; left: 20%; right: 20%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-title { margin: 0; color: #f0d69a; font-family: var(--title-font); font-size: 38px; letter-spacing: 6px; text-shadow: 0 0 25px #d9b66f50; }
.menu-sub { margin: 0 0 6px; color: #a9a6b3; font-size: 13px; }
.pause-panel { width: min(460px, 100%); }
.pause-skills {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
    padding: 12px; margin-bottom: 6px; border-radius: 10px; background: #00000040; border: 1px solid #ffffff10;
}
.death-panel { width: min(480px, 100%); }
.death-title { color: #f06464; text-shadow: 0 0 30px #f0646470; }
.death-stats {
    display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 6px 0 12px; padding: 14px 18px;
    text-align: left; font-size: 14px; color: #c9c6d0; background: #00000045; border: 1px solid #ffffff12; border-radius: 10px;
}
.death-stats b { color: var(--gold-light); text-align: right; font-family: var(--title-font); }
.death-stats .new { color: #1d150a; background: #ffb23e; font-size: 10px; margin-left: 6px; padding: 1px 5px; border-radius: 4px; letter-spacing: 1px; }
.death-stats .up { color: #7dffb0; font-style: normal; font-size: 12px; }

/* ---------- 升級選單 ---------- */
.upgrade-panel { width: 100%; max-width: 960px; text-align: center; }
.upgrade-eyebrow { color: #d9b66f; font-size: 11px; letter-spacing: 6px; margin-bottom: 8px; }
.upgrade-title {
    margin: 0; font-family: var(--title-font); font-weight: 800;
    font-size: clamp(32px, 5vw, 52px); letter-spacing: 6px;
    background: linear-gradient(180deg, #fff6dc, #f0d69a 50%, #b5843f);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 0 18px #d9b66f55);
    animation: titlePop 500ms cubic-bezier(.2, 1.5, .4, 1);
}
.upgrade-subtitle { margin: 10px 0 24px; color: #c0bdc8; font-size: 14px; }
.upgrade-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

.upgrade-card {
    --rc: #c9c6d0;
    position: relative; display: flex; flex-direction: column; align-items: center;
    min-width: 0; min-height: 300px; padding: 20px 16px 16px; overflow: hidden;
    color: #eee9df; font: inherit; cursor: pointer; text-align: center;
    background:
        radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--rc) 22%, transparent), transparent 62%),
        linear-gradient(165deg, #262634, #12131c 85%);
    border: 1px solid color-mix(in srgb, var(--rc) 65%, transparent); border-radius: 14px;
    box-shadow: 0 10px 30px #0008, inset 0 1px 0 #ffffff10;
    animation: cardIn 420ms cubic-bezier(.2, 1.3, .4, 1) both; animation-delay: calc(var(--card-index, 0) * 90ms);
    transition: transform 200ms ease, box-shadow 200ms ease;
}
.upgrade-card::before {
    content: ""; position: absolute; top: 0; left: 12%; width: 76%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--rc), transparent);
}
.upgrade-card:hover, .upgrade-card:focus-visible {
    transform: translateY(-8px) scale(1.02); outline: none;
    box-shadow: 0 16px 40px #000a, 0 0 28px color-mix(in srgb, var(--rc) 50%, transparent);
}
.upgrade-card.k-fusion, .upgrade-card.k-evolve {
    background: radial-gradient(ellipse at 50% 0%, #8a5a1c88, transparent 70%), linear-gradient(165deg, #30251a, #14110d 85%);
    box-shadow: 0 0 30px #ffb23e40;
}
.upgrade-kind {
    padding: 3px 10px; font-size: 11px; font-weight: bold; letter-spacing: 3px; color: var(--rc);
    border: 1px solid color-mix(in srgb, var(--rc) 50%, transparent); border-radius: 999px; background: #0005;
}
.upgrade-number {
    position: absolute; top: 12px; left: 12px; display: grid; place-items: center;
    width: 22px; height: 22px; color: #9c98a8; font-family: var(--title-font); font-size: 12px;
    border: 1px solid #ffffff22; border-radius: 6px;
}
.upgrade-card .ico { margin: 14px 0 12px; transition: transform 250ms ease; }
.upgrade-card:hover .ico { transform: scale(1.1) rotate(-4deg); }
.upgrade-card-title { color: #f6e2b0; font-size: 19px; font-weight: bold; letter-spacing: 1px; }
.upgrade-card-description { margin-top: 10px; color: #b9b6c2; font-size: 13px; line-height: 1.75; }
.upgrade-card-description .lv-step { color: var(--rc); font-weight: bold; }
.upgrade-card-description small { font-size: 11px; line-height: 1.5; opacity: 0.7; }
.upgrade-card-action {
    margin-top: auto; padding: 7px 18px; color: var(--rc); font-size: 12px; letter-spacing: 2px;
    border-top: 1px solid #ffffff10; width: 100%;
}
.upgrade-hint { margin: 20px 0 0; color: #858392; font-size: 12px; letter-spacing: 1px; }

/* 幸運卡：流光金綠邊框 + 標籤 */
.upgrade-card.lucky {
    border-color: transparent;
    background:
        radial-gradient(ellipse at 50% 0%, #4bffa033, transparent 62%) padding-box,
        linear-gradient(165deg, #1f2a26, #10161a 85%) padding-box,
        conic-gradient(from var(--spin), #7dffb0, #ffe27a, #ffffff, #7dffb0, #ffe27a, #7dffb0) border-box;
    border: 2px solid transparent;
    animation: cardIn 420ms cubic-bezier(.2, 1.3, .4, 1) both, luckySpin 3s linear infinite;
    animation-delay: calc(var(--card-index, 0) * 90ms), 0s;
    box-shadow: 0 0 34px #7dffb055, 0 10px 30px #0008;
}
.upgrade-card.lucky::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.14) 45%, transparent 60%);
    background-size: 250% 100%; animation: sheen 2.4s ease-in-out infinite;
}
@keyframes luckySpin { to { --spin: 360deg; } }
@keyframes sheen { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.lucky-badge {
    position: relative; z-index: 2; margin-top: 8px;
    padding: 3px 9px; font-size: 11px; font-weight: bold; color: #0d2a1a; letter-spacing: 1px;
    background: linear-gradient(90deg, #7dffb0, #ffe27a); border-radius: 999px;
    box-shadow: 0 0 14px #7dffb0aa; animation: badgeBounce 1.2s ease-in-out infinite;
}
@keyframes badgeBounce { 50% { transform: translateY(-2px) scale(1.05); } }

/* ---------- 技能介紹浮窗 ---------- */
.skill-tip {
    position: fixed; z-index: 120; width: min(300px, calc(100vw - 16px)); padding: 14px 16px;
    color: #e8e5dc; font-size: 13px; line-height: 1.7; text-align: left;
    background: linear-gradient(165deg, rgba(36, 34, 48, 0.98), rgba(14, 14, 22, 0.98));
    border: 1px solid #d9b66f88; border-radius: 12px;
    box-shadow: 0 18px 50px #000d, 0 0 20px #d9b66f22;
    animation: tipIn 150ms ease-out;
}
.tip-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tip-title { color: #f6e2b0; font-size: 16px; font-weight: bold; }
.tip-tag { color: #9c98a8; font-size: 11px; letter-spacing: 1px; }
.tip-body { color: #d6d2c6; }
.tip-next, .tip-fusion { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #ffffff22; color: #b9b6c2; font-size: 12px; }
.tip-next b, .tip-fusion > b { display: block; color: #7dd0ff; font-size: 11px; letter-spacing: 2px; }
.tip-fusion ul { margin: 4px 0 0; padding-left: 16px; }
.tip-fusion li span { color: #777; }
.tip-fusion li b { color: #ffd27a; }
.tip-stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; }
.tip-stats b { color: var(--gold-light); text-align: right; }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } }

/* ---------- 視窗（設定 / 排行榜） ---------- */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(4, 4, 8, 0.78); backdrop-filter: blur(8px);
    animation: fadeIn 200ms ease-out; overflow-y: auto;
}
.modal-panel {
    position: relative; width: min(460px, 100%); margin: auto; padding: 26px 24px 22px;
    background: var(--panel); border: 1px solid #8b774b90; border-radius: 18px;
    box-shadow: 0 30px 80px #000d, inset 0 1px 0 #ffffff12;
    animation: popIn 260ms cubic-bezier(.2, 1.4, .4, 1);
}
.modal-close {
    position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
    color: #c9c6d0; background: #ffffff0a; border: 1px solid #ffffff1a; border-radius: 50%; cursor: pointer;
}
.modal-close:hover { color: var(--gold-light); border-color: var(--gold-dark); }
.modal-eyebrow { margin: 0; color: var(--gold); font-size: 10px; letter-spacing: 6px; text-align: center; }
.modal-title { margin: 4px 0 18px; text-align: center; color: #f0d69a; font-family: var(--title-font), "Microsoft JhengHei", serif; font-size: 28px; letter-spacing: 6px; }
.modal-done { width: 100%; margin-top: 8px; }

.set-group { margin-bottom: 14px; padding: 6px 14px; border-radius: 12px; background: #00000038; border: 1px solid #ffffff0f; }
.set-group-title { padding: 6px 0 2px; color: var(--gold); font-size: 11px; letter-spacing: 3px; }
.set-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: 48px; border-bottom: 1px solid #ffffff0a; cursor: pointer;
}
.set-row:last-child { border-bottom: none; }
.set-label { font-size: 14px; }
.set-label small { display: block; color: #7d7f8d; font-size: 11px; }

.switch { position: relative; flex: none; width: 48px; height: 26px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i {
    position: absolute; inset: 0; border-radius: 999px; background: #2c2d38; border: 1px solid #ffffff22;
    transition: background 200ms ease; pointer-events: none;
}
.switch i::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
    background: #c9c6d0; box-shadow: 0 2px 4px #0008; transition: transform 200ms ease, background 200ms ease;
}
.switch input:checked + i { background: linear-gradient(90deg, #b88d48, #e6c27a); border-color: #ffe0a0; }
.switch input:checked + i::after { transform: translateX(22px); background: #fff8e6; }
.switch input:disabled + i { opacity: 0.4; }
.switch input:focus-visible + i { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.set-slider { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 230px; }
.set-slider b { min-width: 42px; text-align: right; color: var(--gold-light); font-family: var(--title-font); font-size: 13px; }
.set-slider input[type="range"] {
    --fill: 80%;
    flex: 1; height: 6px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 6px; cursor: pointer;
    background: linear-gradient(90deg, #d9b66f var(--fill), #2c2d38 var(--fill));
}
.set-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff8e6, #d9b66f); border: 2px solid #6d5129; box-shadow: 0 0 10px #d9b66f88;
}
.set-slider input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff8e6, #d9b66f); border: 2px solid #6d5129;
}
.set-input {
    width: 160px; padding: 8px 10px; color: var(--text); font: inherit; font-size: 14px;
    background: #12131b; border: 1px solid #ffffff22; border-radius: 8px;
}
.set-input:focus { border-color: var(--gold); outline: none; }

/* 排行榜 */
.board-panel { width: min(640px, 100%); }
.board-me {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px;
}
.board-me div {
    padding: 10px; text-align: center; border-radius: 12px;
    background: linear-gradient(160deg, rgba(90, 58, 18, 0.5), rgba(10, 10, 16, 0.6)); border: 1px solid #ffb23e55;
}
.board-me small { display: block; color: #a99f88; font-size: 11px; letter-spacing: 1px; }
.board-me b { display: block; margin-top: 2px; color: #ffd27a; font-family: var(--title-font); font-size: 20px; }
.board-head, .board-row {
    display: grid; grid-template-columns: 48px minmax(0, 1fr) 56px 60px 48px 82px; align-items: center; gap: 6px;
    padding: 0 12px;
}
.board-head { padding-bottom: 6px; color: #7d7f8d; font-size: 11px; letter-spacing: 1px; }
.board-head span:last-child, .board-row .b-score { text-align: right; }
.board-list {
    list-style: none; margin: 0; padding: 4px; max-height: min(52vh, 460px); overflow-y: auto;
    border-radius: 12px; background: #00000040; border: 1px solid #ffffff0d;
    scrollbar-width: thin; scrollbar-color: #d9b66f55 transparent;
}
.board-row { min-height: 38px; border-radius: 8px; font-size: 13px; color: #c9c6d0; }
.board-row:nth-child(even) { background: #ffffff05; }
.b-rank { color: #8d8a98; font-family: var(--title-font); font-weight: 800; text-align: center; }
.b-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #e8e5dc; }
.b-char, .b-time, .b-wave { color: #9c98a8; font-size: 12px; }
.b-score { color: var(--gold-light); font-family: var(--title-font); }
.board-row.top .b-rank { font-size: 18px; }
.board-row.top1 { background: linear-gradient(90deg, #ffd27a26, transparent) !important; }
.board-row.top2 { background: linear-gradient(90deg, #d8e2ff1c, transparent) !important; }
.board-row.top3 { background: linear-gradient(90deg, #d9955a1c, transparent) !important; }
.board-row.me {
    position: sticky; top: 0; bottom: 0; z-index: 1;
    background: linear-gradient(90deg, #2c6b4a, #1a3a2c) !important; border: 1px solid #7dffb0aa;
    box-shadow: 0 0 18px #7dffb044;
}
.board-row.me .b-name { color: #d7ffe8; font-weight: bold; }
.board-row.me em { font-style: normal; font-size: 10px; color: #0d2a1a; background: #7dffb0; padding: 1px 5px; border-radius: 4px; margin-left: 4px; }
.board-note { margin: 10px 0 0; color: #6c6d79; font-size: 11px; text-align: center; }

/* ---------- 頁尾與動畫 ---------- */
.game-footer {
    margin-top: 26px; padding: 20px 0 28px; color: #70717e;
    font-family: var(--title-font); font-size: 10px; letter-spacing: 3px; text-align: center;
    border-top: 1px solid #ffffff12;
}
.game-footer span { margin: 0 7px; color: var(--gold); }

@keyframes screenFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) rotateX(20deg); } to { opacity: 1; transform: translateY(0); } }
@keyframes titlePop { from { opacity: 0; transform: scale(1.4); letter-spacing: 16px; } }

/* ---------- RWD ---------- */
@media (max-width: 850px) {
    .character-list { gap: 14px; }
    .character-card { padding: 16px 10px; }
    .character-art { height: 160px; }
    .character-art canvas { width: 160px; height: 160px; }
    .character-card h2 { font-size: 22px; letter-spacing: 2px; }
    .character-name { font-size: 18px; }
    .character-description { font-size: 14px; }
    .character-stats { font-size: 14px; }
    .home-records { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .game-header { min-height: 64px; flex-direction: column; justify-content: center; gap: 6px; padding: 14px 0; }
    .header-tag { text-align: center; font-size: 9px; }
    .home-screen { padding: 40px 16px; }
    .home-start-button { min-width: 0; width: 100%; }
    .home-actions { width: 100%; }
    .home-sub-actions { width: 100%; }
    .home-sub-actions .btn { flex: 1; min-width: 0; }
    .selection-panel { padding-top: 32px; }
    .section-heading h1 { letter-spacing: 2px; }
    .subtitle { font-size: 12px; }
    .character-list { grid-template-columns: 1fr; gap: 14px; }
    .character-card {
        display: grid; grid-template-columns: 112px minmax(0, 1fr); column-gap: 14px; align-items: center;
        padding: 14px; text-align: left;
    }
    .character-art { grid-column: 1; grid-row: 1 / span 5; height: 120px; margin: 0; }
    .character-art canvas { width: 112px; height: 112px; }
    .character-card h2, .character-name, .character-description, .character-stats { grid-column: 2; }
    .character-card h2 { margin: 0 0 3px; font-size: 21px; }
    .character-name { margin-bottom: 6px; font-size: 17px; }
    .character-description { min-height: 0; margin-bottom: 6px; font-size: 14px; line-height: 1.5; }
    .character-stats { margin-bottom: 0; font-size: 14px; }
    .selection-footer { flex-direction: column; align-items: stretch; gap: 10px; }
    #gameStatusBar { padding: 10px; gap: 10px; flex-wrap: wrap; }
    .status-level { font-size: 14px; min-width: 52px; height: 34px; }
    .status-item { width: 38%; }
    .status-label { font-size: 11px; }
    .hud-sub { gap: 14px; font-size: 12px; }
    .game-footer { font-size: 9px; }
    .board-head, .board-row { grid-template-columns: 36px minmax(0, 1fr) 56px 70px; padding: 0 8px; }
    .board-head .b-char, .board-row .b-char, .board-head .b-wave, .board-row .b-wave { display: none; }
    .board-me b { font-size: 16px; }
    .set-input { width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ==================================================
   觸控 / 手機版
================================================== */
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch .kb-only { display: none; }

#game, .stage {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
body.playing { overscroll-behavior: none; }

.joystick { position: fixed; z-index: 70; width: 0; height: 0; pointer-events: none; }
.joy-base {
    position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%;
    border: 2px solid #d9b66f99; background: radial-gradient(circle, #d9b66f18, #00000055);
}
.joy-knob {
    position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f5dda1, #96733c);
    border: 1px solid #f5dda1; box-shadow: 0 0 14px #d9b66f77;
}

@media (pointer: coarse), (max-width: 900px) {
    .overlay { position: fixed; z-index: 60; border-radius: 0; overflow-y: auto; padding: 12px; }
    .overlay > * { margin: auto; }
    .icon-btn { width: 44px; height: 44px; font-size: 16px; }
    .btn { padding: 13px 20px; }
}

@media (max-height: 500px) {
    .game-header { display: none; }
    .home-screen { margin-top: 8px; min-height: calc(100vh - 16px); padding: 20px 16px; }
    .home-title { margin: 8px 0 4px; font-size: 44px; }
    .home-description { margin: 6px 0 14px; }
    .home-records { margin-top: 16px; }
    .home-help, .home-version { display: none; }
    #dungeonScreen { margin-top: 6px; }
    #gameStatusBar { padding: 6px 12px; margin-bottom: 4px; }
    .hud-sub { display: none; }
    .passive-list { min-height: 0; margin-bottom: 4px; }
    #game { width: auto; max-width: 100%; max-height: calc(100vh - 80px); }
    .upgrade-card { min-height: 170px; padding: 10px; }
    .upgrade-card .ico { width: 46px; height: 46px; margin: 6px 0; }
    .upgrade-card .ico-glyph { font-size: 20px; }
    .upgrade-title { font-size: 26px; }
    .upgrade-subtitle { margin: 4px 0 10px; }
    .upgrade-hint, .upgrade-eyebrow { display: none; }
    .upgrade-card-description { font-size: 11px; line-height: 1.5; margin-top: 4px; }
    .game-footer { display: none; }
    .modal-panel { padding: 16px 18px; }
    .modal-title { margin-bottom: 10px; font-size: 22px; }
    .set-row { min-height: 40px; }
    .board-list { max-height: 46vh; }
}

/* ==================================================
   手機遊玩模式：隱藏頁首頁尾、畫面填滿、緊湊 HUD
================================================== */
@media (pointer: coarse), (max-width: 900px) {
    body.playing { overflow: hidden; }
    body.playing .game-header,
    body.playing .game-footer { display: none; }
    body.playing .game-container { width: 100%; padding: 0 max(6px, env(safe-area-inset-left)) 0 max(6px, env(safe-area-inset-right)); }
    body.playing { min-height: 0; }
    body.playing #dungeonScreen { margin-top: 0; padding-top: 4px; }
    body.playing #gameStatusBar { padding: 6px 10px; gap: 10px; margin-bottom: 4px; flex-wrap: nowrap; }
    body.playing .status-level { font-size: 13px; min-width: 48px; height: 32px; padding: 0 8px; }
    body.playing .status-item { width: auto; flex: 1 1 0; min-width: 0; }
    body.playing .status-label { font-size: 11px; margin-bottom: 3px; }
    body.playing .status-track { height: 9px; }
    body.playing .icon-btn { width: 40px; height: 40px; flex: none; }
    body.playing .hud-sub { gap: 12px; font-size: 11px; margin-bottom: 3px; }
    body.playing .hud-sub b { font-size: 13px; }
    body.playing .passive-list {
        min-height: 30px; margin-bottom: 4px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
        scrollbar-width: none;
    }
    body.playing .passive-list::-webkit-scrollbar { display: none; }
    body.playing .chip { flex: none; padding: 2px 8px 2px 3px; font-size: 11px; }
    body.playing #game { border-radius: 6px; }
    .home-title { letter-spacing: 2px; }
    .selection-footer .btn { width: 100%; }
}

/* 橫向手機：HUD 浮在畫面上，把整個高度留給遊戲畫面 */
@media (orientation: landscape) and (max-height: 500px) {
    body.playing #gameStatusBar {
        position: fixed; top: 4px; left: 50%; transform: translateX(-50%); z-index: 40;
        width: min(600px, calc(100% - 24px)); margin: 0; padding: 4px 10px;
        background: rgba(12, 14, 21, 0.72);
    }
    body.playing .icon-btn { width: 36px; height: 36px; }
    body.playing .hud-sub {
        display: flex; position: fixed; left: 10px; top: 56px; z-index: 40; margin: 0;
        flex-direction: column; align-items: flex-start; gap: 1px; pointer-events: none;
        text-shadow: 0 1px 3px #000, 0 0 6px #000;
    }
    body.playing .hud-sub span:last-child { display: none; }
    body.playing .passive-list {
        display: flex; position: fixed; left: 10px; bottom: 6px; z-index: 40; margin: 0; min-height: 0;
        max-width: 55%; flex-wrap: wrap; overflow: visible; pointer-events: none;
    }
    body.playing .passive-list .chip { pointer-events: auto; background: rgba(20, 20, 30, 0.8); }
    body.playing #dungeonScreen { padding-top: 3px; }
    .menu-panel { padding: 14px 20px; gap: 8px; }
    .menu-title { font-size: 26px; letter-spacing: 4px; }
    .menu-sub { margin: 0 0 2px; font-size: 12px; }
    .pause-skills { padding: 6px; }
    .btn { padding: 9px 18px; }
    .death-stats { grid-template-columns: 1fr auto 1fr auto; gap: 4px 14px; font-size: 12px; padding: 8px 12px; margin: 0 0 6px; }
    .death-panel { width: min(580px, 100%); }
    .home-records { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* 窄螢幕：升級卡片壓縮，三張卡不需捲動即可看完 */
@media (max-width: 700px) {
    .upgrade-cards { grid-template-columns: 1fr; gap: 8px; }
    .upgrade-title { font-size: 30px; letter-spacing: 3px; }
    .upgrade-subtitle { margin: 6px 0 12px; font-size: 12px; }
    .upgrade-card {
        min-height: 0; padding: 10px 12px; display: grid; grid-template-columns: 56px minmax(0, 1fr);
        column-gap: 12px; align-items: center; text-align: left;
    }
    .upgrade-card .ico { grid-column: 1; grid-row: 1 / span 4; width: 52px; height: 52px; margin: 0; }
    .upgrade-card .ico-glyph { font-size: 22px; }
    .upgrade-kind { grid-column: 2; justify-self: start; font-size: 10px; padding: 1px 8px; }
    .upgrade-card-title { grid-column: 2; font-size: 16px; margin-top: 2px; }
    .upgrade-card-description { grid-column: 2; margin-top: 2px; font-size: 12px; line-height: 1.5; }
    .upgrade-number { display: none; }
    .lucky-badge { grid-column: 2; justify-self: start; margin-top: 4px; font-size: 10px; }
    .upgrade-card-action, .upgrade-eyebrow, .upgrade-hint { display: none; }
}

/* ---------- 設定：螢幕方向切換 ---------- */
.seg { display: inline-flex; border: 1px solid var(--border-gold, #d9b66f55); border-radius: 8px; overflow: hidden; }
.seg button {
    padding: 8px 14px; color: #bfc0ca; background: transparent; border: 0; border-right: 1px solid #ffffff18;
    font-size: 14px; cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button.on { color: #17130b; background: var(--gold, #d9b66f); font-weight: 700; }

/* ==================================================
   橫向手機（螢幕高度很矮）：主頁 / 選角 / 設定都縮到一屏內，不用捲動
================================================== */
@media (orientation: landscape) and (max-height: 520px) {
    html, body { min-height: 0; }
    .selection-panel { padding: 6px 0 4px; }
    .section-heading { margin-bottom: 8px; }
    .eyebrow, .subtitle { display: none; }
    .section-heading h1 { font-size: 22px; letter-spacing: 3px; }
    .character-list { gap: 10px; }
    .character-card {
        display: grid; grid-template-columns: 84px minmax(0, 1fr); column-gap: 10px; align-items: center;
        padding: 8px 10px; text-align: left;
    }
    .character-card:hover { transform: none; }
    .character-art { grid-column: 1; grid-row: 1 / span 4; height: 84px; margin: 0; }
    .character-art canvas { width: 84px; height: 84px; }
    .character-art::after { bottom: 6px; width: 60px; height: 8px; }
    .character-card h2, .character-name, .character-description, .character-stats { grid-column: 2; }
    .character-card h2 { margin: 0; font-size: 18px; letter-spacing: 2px; }
    .character-name { margin: 0 0 2px; font-size: 16px; }
    .character-description { min-height: 0; margin: 0 0 2px; font-size: 12px; line-height: 1.4; }
    .character-stats { margin: 0; font-size: 12px; letter-spacing: 0; }
    .selection-footer { margin-top: 8px; padding-top: 8px; gap: 10px; flex-direction: row; }
    .selection-footer .btn { width: auto; padding: 8px 16px; }
    #selectionStatus { font-size: 13px; }
    .home-screen { padding: 8px 14px; min-height: calc(100dvh - 16px); }
    .home-eyebrow { font-size: 10px; margin: 0; }
    .home-title { font-size: 34px; margin: 2px 0; }
    .home-description { margin: 2px 0 8px; font-size: 13px; }
    .home-start-button { padding: 10px 40px; font-size: 18px; }
    .home-records { margin-top: 8px; gap: 6px; }
    .home-records .rec { padding: 5px 4px; }
    .home-records .rec b { font-size: 14px; margin-top: 1px; }
    .modal-panel { max-height: calc(100dvh - 16px); overflow-y: auto; }
}

/* 手機遊玩中：整個頁面鎖在可視範圍內，不會被撐大或捲動 */
@media (pointer: coarse), (max-width: 900px) {
    html:has(body.playing), body.playing { height: 100dvh; max-height: 100dvh; overflow: hidden; }
}
