/* ============================================
   三千E世界 — 通用样式与组件库
   ============================================ */

/* ---------- CSS 变量 ---------- */
:root {
    /* 基准分辨率 */
    --base-width: 1280px;
    --base-height: 720px;

    /* 遮罩色 */
    --color-overlay: rgba(20, 30, 40, 0.08);
    --color-overlay-dark: rgba(15, 20, 30, 0.55);

    /* 浮雕文字效果 */
    --relief-color: rgba(255, 255, 255, 0.55);
    --relief-shadow-dark: 1px 1px 2px rgba(0, 0, 0, 0.85);
    --relief-shadow-light: -1px -1px 1px rgba(255, 255, 255, 0.25);
    --relief-shadow-soft: 0 0 2px rgba(0, 0, 0, 0.5);
    --relief-hover-glow: 0 0 8px rgba(255, 255, 255, 0.45), 0 0 16px rgba(255, 220, 150, 0.25);

    /* 节点颜色 */
    --node-battle: #e85d3a;
    --node-treasure: #f0c040;
    --node-rest: #3ac8b0;
    --node-boss: #8b2fc0;

    /* 角色卡片 */
    --card-male-border: rgba(100, 160, 220, 0.5);
    --card-male-glow: rgba(100, 160, 220, 0.8);
    --card-male-bg: rgba(60, 100, 160, 0.12);
    --card-female-border: rgba(220, 140, 180, 0.5);
    --card-female-glow: rgba(220, 140, 180, 0.8);
    --card-female-bg: rgba(160, 80, 120, 0.12);

    /* 地图布局 */
    --node-size: 76px;
    --path-width: 3px;
    --map-top: 70px;
    --map-bottom: 60px;

    /* 卡牌等级色 */
    --card-r-border: #8a9aab;
    --card-r-bg: rgba(138, 154, 171, 0.08);
    --card-r-glow: rgba(138, 154, 171, 0.3);
    --card-sr-border: #c8a040;
    --card-sr-bg: rgba(200, 160, 64, 0.08);
    --card-sr-glow: rgba(200, 160, 64, 0.4);
    --card-ssr-border: #e06040;
    --card-ssr-bg: rgba(224, 96, 64, 0.08);
    --card-ssr-glow: rgba(224, 96, 64, 0.5);

    /* 血条 */
    --hp-full: #3ac060;
    --hp-mid: #e8a030;
    --hp-low: #e04040;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: #1a1a2e;
}

/* ---------- 游戏画布容器 ---------- */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    width: var(--base-width);
    height: var(--base-height);
    top: 50%;
    left: 50%;
    transform-origin: center center;
    overflow: hidden;
}

/* ---------- 背景层 ---------- */
#bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#bg-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-overlay);
    z-index: 2;
}

/* ---------- 浮雕文字工具类 ---------- */
.text-relief {
    color: var(--relief-color);
    text-shadow:
        var(--relief-shadow-dark),
        var(--relief-shadow-light),
        var(--relief-shadow-soft);
}

.text-relief-strong {
    color: rgba(255, 255, 255, 0.7);
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.9),
        -1px -1px 2px rgba(255, 255, 255, 0.2),
        0 0 6px rgba(0, 0, 0, 0.4);
}

/* ---------- 按钮组件 ---------- */
.game-btn {
    display: inline-block;
    padding: 12px 32px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    letter-spacing: 2px;
}

.game-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.06);
    text-shadow: var(--relief-hover-glow);
    transform: translateY(-2px);
}

.game-btn:active {
    transform: translateY(0);
    transition: all 0.1s ease;
}

.game-btn--primary {
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.75);
    font-size: 18px;
    padding: 14px 40px;
}

.game-btn--small {
    padding: 8px 20px;
    font-size: 14px;
    letter-spacing: 1px;
}

/* ---------- 弹窗 / 模态框 ---------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: rgba(20, 25, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 32px 40px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}

.modal-title {
    font-size: 22px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.modal-body {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.8;
    margin-bottom: 24px;
}

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

/* ---------- 血条组件 ---------- */
.hp-bar {
    width: 200px;
    height: 14px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hp-bar__fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease, background-color 0.4s ease;
    background: var(--hp-full);
}

.hp-bar__fill.hp-mid { background: var(--hp-mid); }
.hp-bar__fill.hp-low { background: var(--hp-low); }

/* ---------- 属性条组件 ---------- */
.stat-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 200px;
}

.stat-bar__label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    width: 40px;
    text-align: right;
    letter-spacing: 1px;
}

.stat-bar__track {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
}

.stat-bar__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.stat-bar__fill--atk { background: #e85d3a; }
.stat-bar__fill--def { background: #3a8ce8; }
.stat-bar__fill--luck { background: #e8c03a; }

/* ---------- 卡牌组件 ---------- */
.card-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-r-border);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.card-item.card-sr {
    border-color: var(--card-sr-border);
    background: var(--card-sr-bg);
    box-shadow: 0 0 6px var(--card-sr-glow);
}
.card-item.card-ssr {
    border-color: var(--card-ssr-border);
    background: var(--card-ssr-bg);
    box-shadow: 0 0 8px var(--card-ssr-glow);
    animation: cardSSRGlow 2s ease-in-out infinite;
}
.card-item.card-unknown {
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.3);
}

/* SSR卡牌呼吸光晕 */
@keyframes cardSSRGlow {
    0%, 100% { box-shadow: 0 0 6px var(--card-ssr-glow); }
    50% { box-shadow: 0 0 16px var(--card-ssr-glow), 0 0 30px rgba(224, 96, 64, 0.25); }
}

/* ======== 卡牌背面设计 ======== */
.card-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 140px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1a1a3e 0%, #2a1a4e 40%, #1a2a4e 100%);
    border: 2px solid rgba(200, 160, 64, 0.4);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}
/* 背面花纹 */
.card-back::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 6px;
    border: 1px solid rgba(200, 160, 64, 0.25);
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(200, 160, 64, 0.04) 4px,
        rgba(200, 160, 64, 0.04) 8px
    );
}
/* 背面中心图标 */
.card-back::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: rgba(200, 160, 64, 0.5);
    text-shadow: 0 0 12px rgba(200, 160, 64, 0.3);
}
/* 背面等级边框色 */
.card-back.card-back-r {
    border-color: rgba(138, 154, 171, 0.4);
    background: linear-gradient(135deg, #1a1a2e 0%, #1e222e 40%, #1a1e2e 100%);
}
.card-back.card-back-r::before { border-color: rgba(138, 154, 171, 0.2); }
.card-back.card-back-r::after { color: rgba(138, 154, 171, 0.4); }

.card-back.card-back-sr {
    border-color: rgba(200, 160, 64, 0.5);
    box-shadow: 0 0 10px rgba(200, 160, 64, 0.15);
}
.card-back.card-back-sr::after { color: rgba(200, 160, 64, 0.6); }

.card-back.card-back-ssr {
    border-color: rgba(224, 96, 64, 0.6);
    box-shadow: 0 0 14px rgba(224, 96, 64, 0.2);
    animation: cardBackSSR 2.5s ease-in-out infinite;
}
.card-back.card-back-ssr::after { color: rgba(224, 96, 64, 0.7); }

@keyframes cardBackSSR {
    0%, 100% { box-shadow: 0 0 10px rgba(224, 96, 64, 0.15); }
    50% { box-shadow: 0 0 22px rgba(224, 96, 64, 0.35); }
}

/* ======== 卡牌翻转动画 ======== */
.card-flip-container {
    perspective: 600px;
    display: inline-block;
}
.card-flip-inner {
    position: relative;
    width: 100px;
    height: 140px;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}
.card-flip-container.flipped .card-flip-inner {
    transform: rotateY(180deg);
}
.card-flip-front,
.card-flip-back-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
}
.card-flip-front {
    /* 正面：卡牌内容 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}
.card-flip-back-face {
    /* 背面 */
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a3e 0%, #2a1a4e 40%, #1a2a4e 100%);
    border: 2px solid rgba(200, 160, 64, 0.4);
}

/* 卡牌正面等级颜色 */
.card-flip-front.flip-r { border-color: rgba(138, 154, 171, 0.4); }
.card-flip-front.flip-sr { border-color: rgba(200, 160, 64, 0.5); box-shadow: 0 0 6px var(--card-sr-glow); }
.card-flip-front.flip-ssr { border-color: rgba(224, 96, 64, 0.5); box-shadow: 0 0 8px var(--card-ssr-glow); }

/* ---------- 通用动画 ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px currentColor; }
    50% { box-shadow: 0 0 20px currentColor, 0 0 40px currentColor; }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
