/* ==========================================================================
   Tower Rush - 双塔对决 (towerrush 同屏双人对战版)
   移动端全屏样式表 · 180° 顶部倒置触控手牌区 · 纯原生 CSS (零外部依赖)
   ========================================================================== */

/* 1. 设计系统变量与全局重置 (Supercell 3D Vibrant & Clash Royale 经典皇家调色) */
:root {
    --color-bg-dark: #1b2619;
    --color-bg-canvas: #48a637;
    --color-panel-bg: rgba(22, 36, 56, 0.90);
    --color-panel-border: rgba(251, 191, 36, 0.28);
    --color-text-main: #f8fafc;
    --color-text-muted: #cbd5e1;
    --color-p1: #2563eb;
    --color-p1-dark: #1d4ed8;
    --color-p1-glow: rgba(37, 99, 235, 0.5);
    --color-p2: #0284c7;
    --color-p2-dark: #0369a1;
    --color-p2-glow: rgba(2, 132, 199, 0.5);
    --color-elixir: #d946ef;
    --color-elixir-glow: rgba(217, 70, 239, 0.45);
    --color-gold: #f59e0b;
    --color-gold-bright: #fbbf24;
    --color-gold-glow: rgba(245, 158, 11, 0.45);
    --color-card-bg: rgba(28, 42, 64, 0.96);
    --color-card-border: rgba(251, 191, 36, 0.35);
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-bg-dark);
    color: var(--color-text-main);
    font-family: var(--font-stack);
    /* 彻底禁止移动端默认的手势、双击缩放、下拉刷新与文本选中 */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
}

/* 2. 主容器：垂直 Flex 布局，适配 Safe Area（刘海与底部手势条） */
#game-container {
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: #1b2619;
    border: none;
    box-shadow: 0 12px 40px rgba(18, 32, 18, 0.6);
    /* 安全区域内边距 (兼容 iOS 11.0 constant 与 11.2+ env) */
    padding-top: constant(safe-area-inset-top);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: constant(safe-area-inset-left);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: constant(safe-area-inset-right);
    padding-right: env(safe-area-inset-right, 0px);
    transition: box-shadow 0.3s ease;
}

#game-container.surging {
    box-shadow: inset 0 0 36px rgba(245, 158, 11, 0.35), 0 12px 40px rgba(15, 23, 42, 0.7);
}

/* 3. 玩家面板通用样式 (iOS 18 液态毛玻璃质感) */
.player-panel {
    position: relative;
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    padding: 1px 5px 2px;
    z-index: 10;
    touch-action: none;
    background: rgba(22, 34, 52, 0.88);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

/* ==========================================================================
   4. P2 顶部玩家面板：CSS 180° 倒置核心规则
   平放手机时，P2 视角完全正向，手牌朝向竞技场，状态栏朝向顶部边缘
   ========================================================================== */
.player-p2 {
    transform: rotate(180deg);
    transform-origin: center center;
    border-bottom: 2px solid rgba(220, 38, 38, 0.55);
    box-shadow: 0 -3px 14px rgba(45, 18, 22, 0.45);
    background: linear-gradient(180deg, rgba(65, 22, 28, 0.95) 0%, rgba(45, 18, 24, 0.88) 100%);
}

/* AI 对战模式下：P2 作为电脑对手，正向紧凑显示，隐藏倒立手牌，释放中央战场纵向空间 */
#game-container.mode-ai .player-p2 {
    transform: none;
    border-bottom: 2px solid rgba(220, 38, 38, 0.65);
    box-shadow: 0 3px 14px rgba(45, 18, 22, 0.5);
    background: linear-gradient(180deg, rgba(72, 24, 30, 0.96) 0%, rgba(52, 18, 25, 0.90) 100%);
    padding: 1px 5px;
}

#game-container.mode-ai #p2-hand {
    display: none !important;
}

#game-container.mode-ai #p2-timer-badge {
    display: none !important;
}

#game-container.mode-ai #p2-status .next-card-wrapper {
    display: none !important;
}

/* 5. P1 底部玩家面板：正向朝向 */
.player-p1 {
    border-top: 2px solid rgba(37, 99, 235, 0.55);
    box-shadow: 0 -3px 14px rgba(15, 25, 48, 0.45);
    background: linear-gradient(0deg, rgba(18, 34, 62, 0.95) 0%, rgba(26, 46, 78, 0.88) 100%);
}

/* 6. 手牌区域 (Hand Bar)：4 张可用卡牌横向排布 */
.hand-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(2px, 0.8vw, 4px);
    padding: 1px 0;
    width: 100%;
}

/* 卡牌槽位 (Supercell 3D 浮雕立体卡牌，带手机端大拇指防漏点热区扩展) */
.card-slot {
    position: relative;
    flex: 1 1 0;
    max-width: clamp(33px, 9.6vw, 44px);
    height: clamp(37px, 10.8vw, 45px);
    background: linear-gradient(175deg, #2b3e58 0%, #1c2b3e 60%, #121e2e 100%);
    border: 1.2px solid rgba(251, 191, 36, 0.35);
    border-radius: 7px;
    box-shadow: 0 2px 8px rgba(10, 18, 28, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -2px 0 rgba(10, 18, 28, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    transition: transform 0.14s cubic-bezier(0.2, 0.8, 0.25, 1),
                box-shadow 0.14s ease,
                border-color 0.14s ease,
                filter 0.14s ease;
    overflow: visible;
}

/* 手机端虚拟触控扩展层：视觉微小，但大拇指点击极其灵敏不会漏点 */
.card-slot::before {
    content: '';
    position: absolute;
    top: -5px;
    bottom: -5px;
    left: -4px;
    right: -4px;
    border-radius: 8px;
    pointer-events: auto;
}

/* 可用卡牌边缘呼吸光泽与按压下沉立体拟物感 */
.card-slot:not(.disabled):not(.selected) {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(7, 11, 20, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.card-slot:not(.disabled):not(.selected):hover {
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.card-slot:not(.disabled):active {
    transform: translateY(1px) scale(0.95);
    box-shadow: 0 1px 3px rgba(7, 11, 20, 0.5), inset 0 2px 4px rgba(15, 23, 42, 0.5);
}

/* 费用能量角标 (皇室战争经典高饱和粉紫能量水滴) */
.cost-badge {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 15px;
    height: 15px;
    background: radial-gradient(circle at 35% 30%, #f472b6 0%, #d946ef 55%, #a21caf 100%);
    border: 1.2px solid #ffffff;
    border-radius: 50% 50% 50% 18%;
    transform: rotate(-15deg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9.5px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.6);
    box-shadow: 0 2px 6px rgba(217, 70, 239, 0.6);
    z-index: 4;
}

/* 卡牌主要图标/美术占位 */
.card-icon {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(15px, 4.5vw, 19px);
    line-height: 1;
    user-select: none;
    filter: drop-shadow(0 1px 3px rgba(7, 11, 20, 0.5));
    margin-top: 0;
    transition: transform 0.12s ease;
}

.card-icon svg {
    width: clamp(18px, 5.2vw, 23px);
    height: clamp(18px, 5.2vw, 23px);
    display: block;
    filter: drop-shadow(0 1px 3px rgba(7, 11, 20, 0.45));
    transition: transform 0.12s ease;
}

.card-slot.selected .card-icon svg {
    transform: scale(1.08);
    filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.7));
}

/* 卡牌名称横条 */
.card-name {
    width: 100%;
    padding: 0 0 1px;
    font-size: 8px;
    font-weight: 800;
    line-height: 1.1;
    color: #f1f5f9;
    text-align: center;
    background: rgba(15, 23, 42, 0.88);
    border-radius: 0 0 5px 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.8);
}

/* 卡牌状态：选中高亮 (金黄色脉冲光圈与悬浮) */
.card-slot.selected {
    border-color: var(--color-gold-bright);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.85), inset 0 0 6px rgba(251, 191, 36, 0.5);
    transform: translateY(-4px) scale(1.04);
    z-index: 5;
    animation: card-pulse 1.3s ease-in-out infinite alternate;
}

.card-slot.selected .card-icon {
    transform: scale(1.1);
}

@keyframes card-pulse {
    0% {
        box-shadow: 0 0 10px rgba(245, 158, 11, 0.65), inset 0 0 6px rgba(251, 191, 36, 0.3);
    }
    100% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.95), inset 0 0 10px rgba(251, 191, 36, 0.6);
    }
}

/* 卡牌状态：不可用（能量不足时半灰度与暗淡） */
.card-slot.disabled {
    filter: grayscale(60%) brightness(0.65);
    opacity: 0.6;
    cursor: not-allowed;
}

.card-slot.disabled .cost-badge {
    background: radial-gradient(circle at 35% 30%, #64748b, #334155);
    border-color: rgba(255, 255, 255, 0.5);
    color: #94a3b8;
    text-shadow: none;
    box-shadow: 0 1px 3px rgba(7, 11, 20, 0.4);
}

/* 卡牌交互：费用不足颤抖反馈 */
.card-slot.shake {
    animation: card-shake 0.35s ease;
}

@keyframes card-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* 选牌时：未选中卡牌轻微弱化聚焦 */
.hand-bar.has-selection .card-slot:not(.selected) {
    opacity: 0.65;
    filter: brightness(0.75);
}

/* ============================================================
   7. 状态栏 (Status Bar)：能量槽、核心节点数、下一张手牌预览与计时控制
   ============================================================ */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    height: 22px;
    padding: 0 5px;
    background: rgba(22, 34, 52, 0.90);
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(10, 18, 28, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    box-sizing: border-box;
    width: 100%;
}

/* 玩家身份标识徽章 (P1 / P2) */
.player-identity {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.player-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border-radius: 2px;
    font-size: 8.5px;
    font-weight: 900;
    letter-spacing: 0.5px;
    line-height: 1;
}

.p1-badge {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(14, 165, 233, 0.45);
    border: 1px solid #7dd3fc;
}

.p2-badge {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(239, 68, 68, 0.45);
    border: 1px solid #fca5a5;
}

.player-role {
    font-size: 8px;
    font-weight: 800;
    color: #e2e8f0;
    white-space: nowrap;
}

/* 核心节点计数器 - 金属胶囊质感风格 */
.crown-counter {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 3px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(7, 11, 20, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.crown-icon {
    font-size: 9px;
    line-height: 1;
    filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.8));
}

.crown-num {
    font-size: 9.5px;
    font-weight: 900;
    color: #fbbf24;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.8);
    font-variant-numeric: tabular-nums;
}

/* 能量容器 (Flux Energy Bar) */
.elixir-container {
    flex: 1 1 70px;
    max-width: 105px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.elixir-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 8px;
    font-weight: 900;
    color: #f472b6;
}

.elixir-icon {
    font-size: 8px;
    filter: drop-shadow(0 0 3px rgba(217, 70, 239, 0.7));
}

.elixir-text {
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 6px rgba(217, 70, 239, 0.5);
    font-size: 8px;
    letter-spacing: 0.5px;
    font-weight: 900;
    color: #f472b6;
}

.elixir-bar-track {
    position: relative;
    height: 6px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(7, 11, 20, 0.7);
}

.elixir-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #ec4899 0%, #d946ef 60%, #c026d3 100%);
    box-shadow: 0 0 8px rgba(217, 70, 239, 0.75);
    transition: width 0.1s linear;
    overflow: hidden;
}

/* 能量液体流光脉冲 */
.elixir-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
    animation: elixir-sheen 2.2s infinite linear;
    pointer-events: none;
}

@keyframes elixir-sheen {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(50%); }
}

/* 10 能量满溢辉光 (Elixir Overflow Burst) */
.elixir-container.elixir-full .elixir-bar-fill {
    box-shadow: 0 0 12px rgba(244, 114, 182, 0.95), 0 0 20px rgba(217, 70, 239, 0.7);
    filter: brightness(1.15);
    animation: elixirFullPulse 1s ease-in-out infinite alternate;
}

@keyframes elixirFullPulse {
    0% { box-shadow: 0 0 8px rgba(244, 114, 182, 0.7); filter: brightness(1.05); }
    100% { box-shadow: 0 0 16px rgba(244, 114, 182, 1), 0 0 24px rgba(217, 70, 239, 0.8); filter: brightness(1.2); }
}

.elixir-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    pointer-events: none;
}

.elixir-seg {
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.elixir-seg:last-child {
    border-right: none;
}

/* 矢量超频状态 (Vector Surge Overdrive) */
.elixir-container.surging .elixir-bar-fill {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 50%, #fef08a 100%);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.95);
    animation: surgePulse 0.8s ease-in-out infinite alternate;
}

.elixir-container.surging .elixir-info {
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.hand-bar.surging .card-slot {
    border-color: rgba(245, 158, 11, 0.85);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.35), inset 0 0 6px rgba(251, 191, 36, 0.25);
    animation: surgeCardGlow 1s ease-in-out infinite alternate;
}

@keyframes surgePulse {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.2) drop-shadow(0 0 4px #f59e0b); }
}

@keyframes surgeCardGlow {
    0% { box-shadow: 0 0 6px rgba(245, 158, 11, 0.25); }
    100% { box-shadow: 0 0 14px rgba(245, 158, 11, 0.75), inset 0 0 8px rgba(251, 191, 36, 0.3); }
}

/* 下一张卡牌预览 (Next Card) */
.next-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
}

.next-card-label {
    font-size: 6px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.card-slot.next-card-slot {
    width: 16px;
    height: 16px;
    min-width: 16px;
    max-width: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: linear-gradient(165deg, #253347 0%, #0f172a 100%);
    box-shadow: 0 1px 3px rgba(7, 11, 20, 0.4);
    cursor: default;
    pointer-events: none;
    padding: 0;
}

.card-slot.next-card-slot .cost-badge {
    width: 9px;
    height: 9px;
    font-size: 6px;
    top: -2px;
    left: -2px;
    border-width: 1px;
    background: radial-gradient(circle at 35% 30%, #f472b6 0%, #d946ef 55%, #a21caf 100%);
    box-shadow: 0 1px 3px rgba(217, 70, 239, 0.5);
}

.card-slot.next-card-slot .card-icon {
    font-size: 9px;
    margin-top: 0;
}

.card-slot.next-card-slot .card-icon svg {
    width: 11px;
    height: 11px;
}

.card-slot.next-card-slot .card-name {
    display: none;
}

/* 比赛计时与控制按钮区 */
.match-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.timer-badge {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    padding: 0 3px;
    font-size: 8.5px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.7);
    box-shadow: 0 1px 2px rgba(7, 11, 20, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.timer-badge.overtime {
    border-color: #ef4444;
    color: #f87171;
    animation: timer-flash 0.8s ease-in-out infinite alternate;
}

@keyframes timer-flash {
    0% { background: rgba(30, 18, 24, 0.85); box-shadow: 0 0 4px #ef4444; }
    100% { background: rgba(127, 29, 29, 0.85); box-shadow: 0 0 10px #ef4444; }
}

.ctrl-buttons {
    display: flex;
    gap: 2px;
}

.ctrl-btn {
    position: relative;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 3.5px;
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8.5px;
    color: #f1f5f9;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 1px 3px rgba(7, 11, 20, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: background 0.1s ease, transform 0.1s ease;
}

.ctrl-btn::before {
    content: '';
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -6px;
    right: -6px;
    border-radius: 6px;
    pointer-events: auto;
}

.ctrl-btn:active {
    background: rgba(51, 65, 85, 0.9);
    transform: scale(0.92);
}

.ctrl-btn.btn-lang-toggle {
    font-size: 7.5px;
    font-weight: 800;
    color: #38bdf8;
}

/* P2 辅助计时标签（供 P2 正视） */
.p2-aux-badge {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    padding: 0 3px;
    font-size: 8px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.7);
    box-shadow: inset 0 1px 2px rgba(7, 11, 20, 0.4);
    flex-shrink: 0;
}

/* ==========================================================================
   8. 中央竞技场 (Center Arena)：自适应填充剩余高度
   ========================================================================== */
.arena-container {
    position: relative;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    background: #48a637; /* 皇室战争绿茵沙盘底色 */
    touch-action: none;
    transition: box-shadow 0.3s ease;
}

.arena-container.surging {
    box-shadow: inset 0 0 36px rgba(245, 158, 11, 0.28), 0 0 16px rgba(245, 158, 11, 0.2);
    animation: surge-ambient-pulse 2.2s ease-in-out infinite alternate;
}

@keyframes surge-ambient-pulse {
    0% {
        box-shadow: inset 0 0 20px rgba(245, 158, 11, 0.18), 0 0 10px rgba(245, 158, 11, 0.15);
    }
    100% {
        box-shadow: inset 0 0 42px rgba(245, 158, 11, 0.38), 0 0 20px rgba(245, 158, 11, 0.3);
    }
}

#arena-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* 下兵区域高亮反馈与触控边界指引层 */
.deploy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.deploy-overlay.active {
    opacity: 1;
    background: radial-gradient(ellipse at center, rgba(16, 185, 129, 0.05) 0%, rgba(5, 150, 105, 0.12) 100%);
    border: 2px dashed rgba(16, 185, 129, 0.5);
    box-shadow: inset 0 0 24px rgba(16, 185, 129, 0.18);
    animation: deploy-pulse 2s ease-in-out infinite alternate;
}

@keyframes deploy-pulse {
    0% {
        box-shadow: inset 0 0 14px rgba(16, 185, 129, 0.15);
        border-color: rgba(16, 185, 129, 0.35);
    }
    100% {
        box-shadow: inset 0 0 28px rgba(16, 185, 129, 0.35);
        border-color: rgba(16, 185, 129, 0.75);
    }
}

/* 战场中心大字横幅（双倍能量 / 加时绝杀等） */
.arena-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.96) 0%, rgba(217, 119, 6, 0.96) 100%);
    color: #ffffff;
    padding: 8px 24px;
    border-radius: 22px;
    border: 2px solid #fef08a;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    font-size: clamp(15px, 4.5vw, 19px);
    font-weight: 900;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(120, 53, 15, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: none;
    z-index: 8;
    white-space: nowrap;
    animation: banner-float 1.2s ease-in-out infinite alternate;
}

.arena-banner.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.hidden {
    display: none !important;
}

/* 底部操作轻量提示 Toast（不遮挡中心战场） */
.game-toast {
    position: absolute;
    bottom: 78px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    border: 1.2px solid rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 24px rgba(7, 11, 20, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.game-toast.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

@keyframes banner-float {
    0% {
        transform: translate(-50%, -50%) scale(0.98);
        box-shadow: 0 0 16px rgba(245, 158, 11, 0.5);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.04);
        box-shadow: 0 0 28px rgba(245, 158, 11, 0.9);
    }
}

/* ==========================================================================
   9. 模态框与弹层系统 (Modals & Overlays - iOS 18 深邃曜石毛玻璃风格)
   ========================================================================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 11, 20, 0.76);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 16px;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 370px;
    background: rgba(15, 23, 42, 0.95);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(7, 11, 20, 0.7),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    padding: 24px 20px 20px;
    text-align: center;
    animation: modal-enter 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #f8fafc;
}

@keyframes modal-enter {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-crest {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    background: radial-gradient(circle at 35% 30%, #fef08a, #f59e0b 60%, #b45309 100%);
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.crest-crown {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(7, 11, 20, 0.4));
}

.modal-card-start {
    max-width: 320px;
    padding: 24px 22px 24px;
}

.modal-top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}

.btn-lang-start {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #38bdf8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.btn-lang-start:active {
    background: rgba(56, 189, 248, 0.2);
    transform: scale(0.95);
}

.modal-card-start .modal-title {
    margin-top: 0;
}

.modal-title {
    font-size: clamp(22px, 6.5vw, 26px);
    font-weight: 900;
    color: #fbbf24;
    letter-spacing: 2px;
    margin-top: 10px;
    text-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

.modal-subtitle {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 1.5px;
    margin-top: 2px;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.modal-guide {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.guide-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1.2;
}

.guide-text {
    display: flex;
    flex-direction: column;
}

.guide-text strong {
    font-size: 12px;
    color: #38bdf8;
    font-weight: 800;
}

.guide-text span {
    font-size: 10px;
    color: #cbd5e1;
    line-height: 1.3;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 4px;
}

.btn-mode {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    touch-action: manipulation;
}

.btn-pvp {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: 1.5px solid #7dd3fc;
    box-shadow: 0 3px 0 #075985, 0 6px 14px rgba(2, 132, 199, 0.35);
    color: #ffffff;
}

.btn-ai {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: 1.5px solid #a5b4fc;
    box-shadow: 0 3px 0 #3730a3, 0 6px 14px rgba(99, 102, 241, 0.35);
    color: #ffffff;
}

.btn-mode:active {
    transform: translateY(2px);
}

.btn-pvp:active {
    box-shadow: 0 1px 0 #075985, 0 2px 4px rgba(2, 132, 199, 0.35);
}

.btn-ai:active {
    box-shadow: 0 1px 0 #3730a3, 0 2px 4px rgba(99, 102, 241, 0.35);
}

.btn-mode-icon {
    font-size: 18px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(7, 11, 20, 0.3));
}

.btn-mode-desc {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.btn-title {
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-shadow: 0 1px 2px rgba(7, 11, 20, 0.5);
}

.btn-subtitle {
    font-size: 11px;
    opacity: 0.92;
    font-weight: 500;
}

.btn-arrow {
    font-size: 14px;
    opacity: 0.85;
}

.modal-footer-tip {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
}

/* ==========================================================================
   10. 结算层 (Game Over Modal)
   ========================================================================== */
.game-over-card {
    max-width: 350px;
    padding: 24px 18px;
}

.game-over-crowns {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.crown-star {
    font-size: 32px;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.7));
    animation: crown-pop 0.5s ease backwards;
}

.crown-star:nth-child(2) { animation-delay: 0.15s; font-size: 38px; }
.crown-star:nth-child(3) { animation-delay: 0.3s; }

@keyframes crown-pop {
    0% { transform: scale(0.2) rotate(-20deg); opacity: 0; }
    80% { transform: scale(1.15) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.game-over-title {
    font-size: clamp(22px, 6vw, 26px);
    font-weight: 900;
    color: #fbbf24;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
    margin-bottom: 12px;
}

.game-over-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(30, 41, 59, 0.75);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 10px 16px;
    margin-bottom: 12px;
}

.score-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.side-tag {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    color: #ffffff;
}

.tag-p1 {
    background: #0ea5e9;
}

.tag-p2 {
    background: #ef4444;
}

.side-crowns {
    font-size: 28px;
    font-weight: 900;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 8px rgba(245, 158, 11, 0.5);
}

.score-vs {
    font-size: 16px;
    font-weight: 900;
    color: #64748b;
    letter-spacing: 1px;
}

.game-over-desc {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 18px;
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-rematch {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1.5px solid #6ee7b7;
    box-shadow: 0 4px 0 #047857, 0 6px 14px rgba(16, 185, 129, 0.4);
    color: #ffffff;
}

.btn-rematch:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #047857;
}

.btn-menu {
    background: rgba(30, 41, 59, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 4px 0 #0f172a, 0 4px 12px rgba(7, 11, 20, 0.4);
    color: #f1f5f9;
}

.btn-menu:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #0f172a;
}

/* ==========================================================================
   14. 紧凑型小屏设备响应式适配 (Compact Screen Scaling <= 360px)
   ========================================================================== */
@media (max-width: 360px) {
    .status-bar {
        gap: 2px;
        padding: 0 2px;
        height: 19px;
    }

    .player-identity {
        gap: 2px;
    }

    .player-badge {
        font-size: 7.5px;
        padding: 0 2px;
    }

    .player-role {
        font-size: 7.5px;
    }

    .crown-counter {
        gap: 2px;
        padding: 0 2px;
    }

    .crown-icon,
    .crown-num {
        font-size: 8px;
    }

    .elixir-container {
        flex: 1 1 60px;
        max-width: 95px;
        gap: 1px;
    }

    .elixir-info {
        font-size: 7.5px;
    }

    .elixir-bar-track {
        height: 5px;
    }

    .next-card-wrapper {
        gap: 0;
    }

    .next-card-label {
        font-size: 6px;
    }

    .card-slot.next-card-slot {
        width: 14px;
        height: 14px;
        min-width: 14px;
        max-width: 14px;
    }

    .card-slot.next-card-slot .card-icon {
        font-size: 8px;
    }

    .card-slot.next-card-slot .cost-badge {
        width: 8px;
        height: 8px;
        font-size: 5.5px;
    }

    .match-controls {
        gap: 1px;
    }

    .timer-badge,
    .p2-aux-badge {
        padding: 0 2px;
        font-size: 8px;
    }

    .ctrl-btn {
        width: 14px;
        height: 14px;
        font-size: 7.5px;
    }
}
