/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 字体变量体系（组合②：C 符文脉冲 × B 七曜星轨）：
   --font-display  雅黑重体（标题/副标题/按钮等展示性文字，符文脉冲冷蓝辉光）
   --font-latin    无衬线拉丁（Elemental Chain 副标题英文）
   --font-hud      无衬线（战斗信息/数值/日志，小字可读性优先，克制层） */
:root {
    --font-display: 'Microsoft YaHei', 'PingFang SC', 'Segoe UI', sans-serif;
    --font-latin: 'Segoe UI', 'Trebuchet MS', 'Verdana', sans-serif;
    --font-hud: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    font-family: var(--font-hud);
    /* 深靛紫舞台：冷蓝体系基底（呼应 C 符文脉冲标题的冷蓝辉光），星轨由 js/background.js 画布绘制 */
    background:
        radial-gradient(ellipse 62% 52% at 50% 42%, rgba(24, 42, 110, 0.20), transparent 70%),
        linear-gradient(155deg, #05020d 0%, #0b0620 35%, #140a2e 65%, #1a0f38 100%);
    color: #fff;
    overflow: hidden;
    user-select: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    /* 置于星轨画布层与暗角之上，保证 UI 内容不被遮挡 */
    z-index: 1;
}

/* 七曜星轨画布层（由 js/background.js 创建：固定铺满、不拦截点击、置于内容层之下） */
.bg-fx-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* 中央暗角（vignette）：压暗四周星轨，保证标题/按钮/血量数字可读 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(ellipse 78% 70% at 50% 46%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.52) 100%);
}

/* 背景主角 = js/background.js 的七曜星轨画布（组合①的 CSS 图层已移除，星轨 canvas 为唯一背景主角） */

/* 屏幕切换 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* 主菜单 */
.menu-content {
    text-align: center;
}

.game-title {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-display);
    font-weight: 900;
    /* 符文脉冲：雅黑重体 + 宽字距；主形态冷蓝辉光（细描边 + 双层辉光） */
    letter-spacing: 0.2em;
    text-indent: 0.2em; /* 视觉居中补偿：letter-spacing 在末字符右侧留出的空隙 */
    color: #cfe8ff;
    -webkit-text-stroke: 1px rgba(140, 200, 255, 0.35);
    text-shadow:
        0 0 6px rgba(120, 200, 255, 0.9),
        0 0 24px rgba(80, 140, 255, 0.5);
}

/* 升级形态：支持文字渐变裁剪时，蓝紫脉冲渐变 + drop-shadow 发光（此时取消 text-shadow） */
@supports (-webkit-background-clip: text) {
    .game-title {
        background: linear-gradient(120deg, #9fd8ff, #5f8bff 55%, #b78aff);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        text-shadow: none;
        filter: drop-shadow(0 0 14px rgba(120, 190, 255, 0.55)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
    }
}

.game-subtitle {
    font-size: 1.5rem;
    margin-bottom: 3rem;
    font-family: var(--font-latin);
    text-transform: uppercase;
    font-weight: 600;
    color: #9fc4e8;
    letter-spacing: 0.45em;
    text-indent: 0.45em; /* 视觉居中补偿：letter-spacing 在末字符右侧留出的空隙 */
    opacity: 0.85;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

/* ===== 主菜单战绩（fix6，符文脉冲字体体系，风格与主菜单一致） ===== */
.menu-stats {
    margin-top: 1.8rem;
    padding: 0.9rem 1.2rem;
    display: inline-block;
    min-width: 300px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(120, 200, 255, 0.25);
    border-radius: 12px;
    box-shadow: 0 0 18px rgba(80, 140, 255, 0.12);
}

.menu-stats-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    text-indent: 0.25em; /* letter-spacing 视觉居中补偿 */
    color: #9fd8ff;
    text-shadow: 0 0 10px rgba(120, 190, 255, 0.5);
    margin-bottom: 0.6rem;
    opacity: 0.92;
}

.menu-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}

.menu-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.3rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.menu-stat-label {
    font-family: var(--font-hud);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    opacity: 0.75;
    white-space: nowrap;
}

.menu-stat-value {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 900;
    color: #eaf4ff;
    text-shadow: 0 0 8px rgba(140, 200, 255, 0.55);
    font-variant-numeric: tabular-nums;
}

/* 屏幕内容 */
.screen-content {
    background: rgba(0, 0, 0, 0.5);
    padding: 2rem;
    border-radius: 20px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

.screen-content h2 {
    margin-bottom: 2rem;
    text-align: center;
    font-family: var(--font-display);
    color: #c9dcf5;
    letter-spacing: 0.1em;
    text-shadow: 0 0 14px rgba(120, 170, 255, 0.35);
}

.back-btn {
    margin-top: 2rem;
    padding: 0.8rem 2rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 难度选择 */
.difficulty-options {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.difficulty-btn {
    padding: 2rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    min-width: 150px;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
}

.difficulty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.difficulty-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.difficulty-desc {
    font-size: 0.9rem;
    font-family: var(--font-hud);
    letter-spacing: normal;
    opacity: 0.7;
}

/* ===== 战斗界面 ===== */
#battle-screen {
    padding: 0.5rem;
    justify-content: space-between;
}

/* 玩家信息条 */
.player-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.player-name {
    font-size: 1.1rem;
    font-weight: bold;
    min-width: 80px;
}

.health-bar {
    flex: 1;
    min-width: 100px;
    height: 26px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 13px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff8888);
    transition: width 0.5s;
    width: 100%;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 0.85rem;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

.player-stats {
    display: flex;
    gap: 0.6rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.stat-icon {
    font-size: 1rem;
}

.stat-value {
    font-weight: bold;
    font-size: 1rem;
}

/* ===== 战斗信息可读性：HUD 无衬线 + 等宽数字 + 纯白高对比 ===== */
.health-text,
.stat-value,
#chain-display,
.chain-multiplier,
.turn-indicator,
#battle-log {
    font-family: var(--font-hud);
    font-variant-numeric: tabular-nums;
    color: #fff;
}

/* ===== 战场区域 ===== */
#battlefield {
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0.3rem 0;
    min-height: 120px;
}

#battle-log {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    max-width: 220px;
    max-height: 120px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.75rem;
    z-index: 10;
    line-height: 1.4;
}

#chain-display {
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 仅弱辉光：中央连锁信息保持克制 */
    text-shadow: 0 0 10px rgba(255, 224, 160, 0.28);
}

/* ===== 动态生成类最小可读性（ui.js 生成，原无样式，仅补样式不加 DOM） ===== */
.chain-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.chain-cards {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.chain-multiplier {
    font-size: 0.85rem;
    opacity: 0.92;
}

/* 卡牌详情弹窗（detail-* 系列） */
.detail-card {
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(18, 4, 42, 0.92);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    min-width: 260px;
    max-width: 420px;
    color: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.7rem;
}

.detail-element {
    font-size: 1.8rem;
    line-height: 1;
}

.detail-name {
    font-size: 1.15rem;
    font-weight: bold;
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.7rem;
    font-size: 0.85rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    line-height: 1.5;
}

.detail-row span:first-child {
    opacity: 0.75;
}

.detail-effect {
    border-top: 1px solid rgba(255, 255, 255, 0.22);
    padding-top: 0.55rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.detail-effect p {
    margin-top: 0.3rem;
    opacity: 0.92;
}

#effects-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* ===== 中央出牌区 ===== */
#played-cards-area {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.5rem;
    min-height: 100px;
}

.played-card {
    width: 70px;
    height: 100px;
    border-radius: 8px;
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    text-align: center;
    position: relative;
    /* fix6：保留 index*0.1s 延时（ui.js 内联 animationDelay）基础上，增强为"从手牌方向滑入+淡入"飞入动画 */
    animation: playedCardFlyInPlayer 0.45s ease-out both;
    will-change: transform, opacity;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* AI 出牌从上方（对手手牌区方向）飞入 */
.played-card[data-owner="ai"] {
    animation-name: playedCardFlyInAI;
}

.played-card[data-owner="player"] {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.3);
}

.played-card[data-owner="ai"] {
    background: rgba(255, 100, 100, 0.15);
    box-shadow: 0 0 10px rgba(255, 100, 100, 0.3);
}

.played-card .played-element {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
}

.played-card .played-name {
    font-weight: bold;
    font-size: 0.6rem;
    line-height: 1.2;
}

.played-card .played-owner {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.7rem;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* fix6：玩家出牌飞入 —— 自手牌区方向（下方）滑入 + 淡入 + 轻微回弹 */
@keyframes playedCardFlyInPlayer {
    0% {
        transform: translateY(60px) scale(0.6) rotate(8deg);
        opacity: 0;
    }
    60% {
        transform: translateY(-6px) scale(1.08) rotate(-2deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* fix6：AI 出牌飞入 —— 自对手手牌区方向（上方）滑入 + 淡入 */
@keyframes playedCardFlyInAI {
    0% {
        transform: translateY(-60px) scale(0.6) rotate(-8deg);
        opacity: 0;
    }
    60% {
        transform: translateY(6px) scale(1.08) rotate(2deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* fix6：受击震动（幅度小、0.3s 内，避免晃晕玩家） */
@keyframes hitShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: hitShake 0.3s ease-out;
}

/* ===== 对手手牌区（背面堆叠） ===== */
#opponent-hand-area {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.3rem;
    min-height: 70px;
    position: relative;
}

.opponent-card-back {
    width: 50px;
    height: 70px;
    background: linear-gradient(135deg, #2a1040, #4a2060);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.opponent-card-back::after {
    content: '?';
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: bold;
}

/* ===== 玩家手牌区 ===== */
#player-hand {
    width: 100%;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

#hand-cards {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    flex: 1;
}

#btn-end-turn {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    background: rgba(255, 100, 100, 0.2);
    border: 2px solid rgba(255, 100, 100, 0.5);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

#btn-end-turn:hover {
    background: rgba(255, 100, 100, 0.4);
    transform: scale(1.05);
}

#btn-end-turn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ===== 卡牌样式（缩小版） ===== */
.card {
    width: 85px;
    height: 120px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 0.3rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.3);
    z-index: 10;
}

/* 触屏优化：禁止长按选中/系统菜单，双击不缩放 */
.card,
.played-card,
.opponent-card-back {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* 移动端提示条（默认隐藏，窄屏显示） */
.touch-hint {
    display: none;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(159, 216, 255, 0.5);
    letter-spacing: 1px;
    padding: 0.15rem 0 0.3rem;
}

.card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.card.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* 堆叠数量角标 */
.card-stack-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ff4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    z-index: 20;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* 元素颜色 - 仅对非普通卡牌生效 */
.card[data-element="fire"]:not([data-rarity="common"]) {
    border-color: #ff4444;
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.2), rgba(255, 68, 68, 0.1));
}

.card[data-element="water"]:not([data-rarity="common"]) {
    border-color: #4488ff;
    background: linear-gradient(135deg, rgba(68, 136, 255, 0.2), rgba(68, 136, 255, 0.1));
}

.card[data-element="earth"]:not([data-rarity="common"]) {
    border-color: #886644;
    background: linear-gradient(135deg, rgba(136, 102, 68, 0.2), rgba(136, 102, 68, 0.1));
}

.card[data-element="wind"]:not([data-rarity="common"]) {
    border-color: #88ff88;
    background: linear-gradient(135deg, rgba(136, 255, 136, 0.2), rgba(136, 255, 136, 0.1));
}

.card[data-element="light"]:not([data-rarity="common"]) {
    border-color: #ffff88;
    background: linear-gradient(135deg, rgba(255, 255, 136, 0.2), rgba(255, 255, 136, 0.1));
}

.card[data-element="dark"]:not([data-rarity="common"]) {
    border-color: #8844ff;
    background: linear-gradient(135deg, rgba(136, 68, 255, 0.2), rgba(136, 68, 255, 0.1));
}

.card[data-element="wild"]:not([data-rarity="common"]) {
    border-color: #ffffff;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
}

/* 普通卡牌样式 - 使用最高优先级确保覆盖所有其他样式 */
.card[data-rarity="common"] {
    border: 2px solid #999 !important;
    background: linear-gradient(135deg, #fafafa, #e8e8e8, #d8d8d8) !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.8) !important;
    color: #222 !important;
}

/* 普通卡牌所有文字元素 - 强制深色，最高优先级 */
.card[data-rarity="common"] .card-name,
.card[data-rarity="common"] .card-effect,
.card[data-rarity="common"] .card-stats,
.card[data-rarity="common"] .card-element,
.card[data-rarity="common"] .card-cost {
    color: #1a1a1a !important;
    text-shadow: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #1a1a1a !important;
}

/* 普通卡牌特殊样式：名称加粗，效果文字清晰 */
.card[data-rarity="common"] .card-name {
    font-weight: 800 !important;
    letter-spacing: 0.02em;
}

.card[data-rarity="common"] .card-effect {
    font-weight: 600 !important;
    font-size: 0.6rem !important;
    line-height: 1.3;
}

.card[data-rarity="common"] .card-element {
    font-size: 1.6rem !important;
    margin: 0.05rem 0 !important;
    display: block !important;
}

/* 普通卡牌元素图标 - 保持原样，不应用 filter */
.card[data-rarity="common"][data-element="fire"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="water"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="earth"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="wind"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="light"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="dark"] .card-element { /* 保持 emoji 原色 */ }
.card[data-rarity="common"][data-element="wild"] .card-element { /* 保持 emoji 原色 */ }

/* 稀有度样式 */
.card[data-rarity="rare"] {
    border: 3px solid rgba(68, 136, 255, 0.8);
    background: linear-gradient(135deg, rgba(68, 136, 255, 0.5), rgba(68, 136, 255, 0.3));
    box-shadow: 0 0 10px rgba(68, 136, 255, 0.5);
}
.card[data-rarity="epic"] {
    border: 3px solid rgba(136, 68, 255, 0.8);
    background: linear-gradient(135deg, rgba(136, 68, 255, 0.5), rgba(136, 68, 255, 0.3));
    box-shadow: 0 0 15px rgba(136, 68, 255, 0.5);
}
.card[data-rarity="legendary"] {
    border: 3px solid rgba(255, 215, 0, 0.9);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.6), rgba(255, 180, 0, 0.4));
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

.card-name {
    font-size: 0.7rem;
    font-weight: bold;
    flex: 1;
    line-height: 1.2;
}

.card-cost {
    background: rgba(0, 0, 0, 0.5);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.65rem;
}

.card-element {
    font-size: 1.5rem;
    text-align: center;
    margin: 0.1rem 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-effect {
    font-size: 0.55rem;
    line-height: 1.2;
    overflow: hidden;
    text-align: center;
}

.card-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 0.2rem;
    font-size: 0.65rem;
}

/* 游戏按钮 */
.game-btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: auto;
}

.game-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.game-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 回合提示 */
.turn-indicator {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 10;
}

/* 卡组编辑 */
.deck-editor {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.deck-list,
.card-collection {
    flex: 1;
    max-height: 500px;
    overflow-y: auto;
}

.deck-list h3,
.card-collection h3 {
    margin-bottom: 1rem;
}

#deck-cards,
#collection-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

/* 卡牌收藏 */
#all-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

/* 设置 */
.settings-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.setting-item label {
    font-size: 1.1rem;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.setting-item select {
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(50, 0, 100, 0.95);
    padding: 2rem;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

.game-over-content {
    text-align: center;
}

.game-over-content h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
}

.game-over-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.game-over-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* 动画 */
@keyframes cardPlay {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-100px) scale(1.2); }
    100% { transform: translateY(-200px) scale(0.8); opacity: 0; }
}

@keyframes damageFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

.damage-float {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: #ff4444;
    animation: damageFloat 1s forwards;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    z-index: 100;
}

.heal-float {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: #88ff88;
    animation: damageFloat 1s forwards;
    pointer-events: none;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
    z-index: 100;
}

/* 滚动条样式 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

/* ===== 移动端适配（fix6） ===== */
/* 触控友好：按钮/卡牌避免双击缩放延迟（配合 viewport user-scalable=no） */
html {
    -webkit-tap-highlight-color: transparent;
}

.menu-btn,
.back-btn,
.difficulty-btn,
.game-btn,
#btn-end-turn,
.card,
.modal-close,
.setting-item input,
.setting-item select {
    touch-action: manipulation;
}

@media (max-width: 768px) {
    /* 核心字号/间距相对单位收缩 */
    .game-title {
        font-size: 2.2rem;
        letter-spacing: 0.12em;
        text-indent: 0.12em;
        margin-bottom: 0.4rem;
    }

    .game-subtitle {
        font-size: 1rem;
        margin-bottom: 1.6rem;
        letter-spacing: 0.3em;
        text-indent: 0.3em;
    }

    .screen-content {
        padding: 1.2rem;
    }

    /* 按钮触控目标 ≥ 44px */
    .menu-btn {
        padding: 0.9rem 2rem;
        font-size: 1.1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .back-btn {
        min-height: 44px;
    }

    .difficulty-options {
        flex-direction: column;
        gap: 0.8rem;
        margin-bottom: 1rem;
    }

    .difficulty-btn {
        width: 100%;
        min-width: 0;
        min-height: 72px;
        padding: 1.1rem;
    }

    .difficulty-icon {
        font-size: 2rem;
        margin-bottom: 0.4rem;
    }

    .difficulty-name {
        font-size: 1.2rem;
    }

    /* 战斗界面：信息条/血条/手牌区压缩 */
    #battle-screen {
        padding: 0.3rem;
    }

    .player-info {
        padding: 0.4rem 0.6rem;
        gap: 0.5rem;
    }

    .player-name {
        font-size: 0.9rem;
        min-width: 56px;
    }

    .health-bar {
        height: 18px;
        min-width: 70px;
    }

    .health-text {
        font-size: 0.7rem;
    }

    .stat {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }

    .stat-icon {
        font-size: 0.8rem;
    }

    #player-hand {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.4rem;
    }

    #hand-cards {
        gap: 0.4rem;
        /* 移动端手牌改为横向滚动，避免换行占满屏幕高度 */
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    #hand-cards::-webkit-scrollbar {
        display: none;
    }

    /* 移动端显示"长按查看详情"提示 */
    .touch-hint {
        display: block;
    }

    .card {
        width: 68px;
        height: 96px;
    }

    .card-name {
        font-size: 0.6rem;
    }

    .card-element {
        font-size: 1.2rem;
    }

    #btn-end-turn {
        width: 100%;
        min-height: 44px;
        font-size: 1rem;
    }

    .played-card {
        width: 56px;
        height: 80px;
    }

    .played-card .played-element {
        font-size: 1.2rem;
    }

    #played-cards-area {
        gap: 0.5rem;
        min-height: 84px;
    }

    /* 战绩区在窄屏改为 2 列，避免挤爆 */
    .menu-stats {
        min-width: 0;
        width: 90%;
        max-width: 340px;
    }

    .menu-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-over-content h2 {
        font-size: 2.2rem;
    }

    .game-over-buttons {
        flex-direction: column;
    }

    /* 移动端视口高度兼容（浏览器地址栏伸缩），不支持 dvh 时回退 100vh */
    #game-container {
        height: 100vh;
        height: 100dvh;
    }
}

/* 减动效偏好：禁用 CSS 过渡与关键帧动画（星尘粒子动画由 background.js 内部处理） */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    /* 星轨动画由 background.js 内部处理（reducedMotion 时仅呈现静态帧） */
}

/* ===== 规则介绍弹窗 ===== */
.rules-content {
    width: min(560px, 92vw);
    text-align: center;
    padding: 2rem 2.2rem;
    background: rgba(20, 30, 58, 0.97);
    border: 2px solid rgba(159, 216, 255, 0.35);
    box-shadow: 0 0 40px rgba(95, 139, 255, 0.2);
}

.rules-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: #cfe8ff;
    letter-spacing: 0.1em;
    margin-bottom: 1.4rem;
}

/* 跳过按钮（右上角，× 左侧） */
.rules-skip {
    position: absolute;
    top: 1.1rem;
    right: 3.2rem;
    background: rgba(159, 216, 255, 0.1);
    border: 1px solid rgba(159, 216, 255, 0.35);
    color: #9fd8ff;
    font-family: var(--font-hud);
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.rules-skip:hover {
    background: rgba(159, 216, 255, 0.22);
    color: #fff;
    border-color: rgba(159, 216, 255, 0.6);
}

#rules-list {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    text-align: left;
}

.ec-rule {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.45s, transform 0.45s;
    font-size: 1.05rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.88);
    padding: 8px 14px;
    background: rgba(159, 216, 255, 0.06);
    border-left: 3px solid rgba(159, 216, 255, 0.5);
    border-radius: 6px;
}

.ec-rule.visible {
    opacity: 1;
    transform: translateY(0);
}

.rules-adv {
    font-size: 13px;
    color: rgba(159, 216, 255, 0.4);
    letter-spacing: 1px;
    margin-bottom: 10px;
    min-height: 20px;
    animation: ecBlink 1.2s infinite;
}

.rules-adv.ready {
    color: rgba(159, 216, 255, 0.95);
    cursor: pointer;
    animation: none;
}

.rules-adv.counting {
    font-size: 13px;
    font-weight: normal;
    color: rgba(159, 216, 255, 0.35);
    animation: none;
}

@keyframes ecBlink {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

#rules-start {
    display: none;
    margin: 6px auto 0;
    min-width: 180px;
}

