/* ============================================
   TCG Pack Opener - 全局样式
   版本: 0.2.0
   ============================================ */

/* --- CSS 变量（方便统一调整颜色和风格） --- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-panel: #1a1a3e;
    --text-primary: #e0e0ff;
    --text-secondary: #a0a0cc;
    --accent-gold: #ffd700;
    --accent-blue: #4a9eff;
    --accent-red: #ff4757;
    --rarity-N: #a0a0a0;
    --rarity-R: #4a9eff;
    --rarity-SR: #c850c0;
    --rarity-UR: #ffd700;
    --border-color: #2a2a5e;
    --shadow-glow: 0 0 20px rgba(74, 158, 255, 0.3);
}

/* --- 全局重置 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   全局加载遮罩层
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    color: var(--accent-gold);
    font-size: 1.1rem;
    animation: textPulse 0.8s ease-in-out infinite alternate;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   顶部导航栏
   ============================================ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-title {
    font-size: 1.5rem;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
}

.top-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--accent-blue);
    color: #fff;
}

/* ============================================
   主游戏区域
   ============================================ */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.section-panel {
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.section-title {
    text-align: center;
    font-size: 1.4rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

/* ============================================
   卡包选择区域
   ============================================ */
.pack-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    width: 100%;
}

.pack-card {
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.pack-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
}

.pack-card .pack-icon {
    font-size: 4rem;
    margin-bottom: 12px;
    display: block;
}

.pack-card .pack-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.pack-card .pack-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    opacity: 0.7;
}

.pack-card .pack-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   开包按钮
   ============================================ */
.pack-info {
    text-align: center;
    margin-bottom: 32px;
}

.pack-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 8px;
}

.open-btn-container {
    text-align: center;
    margin-bottom: 20px;
}

.btn-open-pack {
    padding: 16px 48px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #000;
    background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.btn-open-pack:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(255, 215, 0, 0.6);
}

.btn-open-pack:active {
    transform: scale(0.98);
}

.btn-secondary {
    display: block;
    margin: 16px auto 0;
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-danger {
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: var(--accent-red);
    color: #fff;
}

/* ============================================
   开包动画
   ============================================ */
.opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.opening-animation {
    text-align: center;
}

.pack-tear {
    animation: packShake 0.6s ease-in-out;
}

.pack-visual {
    font-size: 8rem;
    animation: packGlow 1.2s ease-in-out;
}

.opening-text {
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin-top: 20px;
    animation: textPulse 0.8s ease-in-out infinite alternate;
}

/* ============================================
   卡牌结果展示（支持卡图）
   ============================================ */
.cards-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 32px;
}

.card-item {
    width: 140px;
    height: 220px;
    background: var(--bg-panel);
    border: 3px solid var(--rarity-N);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 6px;
    position: relative;
    opacity: 0;
    transform: translateY(30px) rotateY(90deg);
    animation: cardReveal 0.6s ease forwards;
    transition: transform 0.3s ease;
    cursor: default;
    overflow: hidden;
}

.card-item:hover {
    transform: translateY(-8px) scale(1.05);
}

/* 按稀有度设置不同的边框颜色和特效 */
.card-item.rarity-N {
    border-color: var(--rarity-N);
}

.card-item.rarity-R {
    border-color: var(--rarity-R);
    box-shadow: 0 0 12px rgba(74, 158, 255, 0.4);
}

.card-item.rarity-SR {
    border-color: var(--rarity-SR);
    box-shadow: 0 0 18px rgba(200, 80, 192, 0.5);
}

.card-item.rarity-UR {
    border-color: var(--rarity-UR);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    animation: cardReveal 0.6s ease forwards, urShine 2s ease-in-out infinite;
}

.card-rarity-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    color: #000;
    z-index: 2;
}

.card-rarity-badge.rarity-N { background-color: var(--rarity-N); }
.card-rarity-badge.rarity-R { background-color: var(--rarity-R); }
.card-rarity-badge.rarity-SR { background-color: var(--rarity-SR); }
.card-rarity-badge.rarity-UR { background-color: var(--rarity-UR); }

/* 卡牌图片样式 */
.card-image {
    width: 100%;
    height: 150px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 4px;
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    line-height: 150px;
}

.card-name {
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
    width: 100%;
}

/* 每张卡牌依次出现的延迟 */
.card-item:nth-child(1) { animation-delay: 0.1s; }
.card-item:nth-child(2) { animation-delay: 0.25s; }
.card-item:nth-child(3) { animation-delay: 0.4s; }
.card-item:nth-child(4) { animation-delay: 0.55s; }
.card-item:nth-child(5) { animation-delay: 0.7s; }
.card-item:nth-child(6) { animation-delay: 0.85s; }
.card-item:nth-child(7) { animation-delay: 1.0s; }
.card-item:nth-child(8) { animation-delay: 1.15s; }
.card-item:nth-child(9) { animation-delay: 1.3s; }

.result-actions {
    text-align: center;
}

.result-actions .btn-open-pack {
    margin-bottom: 8px;
}

/* ============================================
   弹窗通用样式
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--accent-gold);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

/* ============================================
   更新日志样式
   ============================================ */
.changelog-version {
    margin-bottom: 24px;
}

.changelog-version:last-child {
    margin-bottom: 0;
}

.changelog-version-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.changelog-version-tag {
    background: var(--accent-blue);
    color: #fff;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

.changelog-version-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.changelog-version-title {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.changelog-changes {
    list-style: none;
    padding: 0;
}

.changelog-changes li {
    padding: 4px 0 4px 20px;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.changelog-changes li::before {
    content: "✦";
    position: absolute;
    left: 0;
    color: var(--accent-blue);
}

/* ============================================
   缓存管理样式
   ============================================ */
.cache-summary {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cache-summary p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.8;
}

.cache-summary strong {
    color: var(--accent-gold);
}

.cache-list h3 {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.cache-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-panel);
    border-radius: 8px;
    margin-bottom: 8px;
}

.cache-item-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: bold;
}

.cache-item-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ============================================
   页脚
   ============================================ */
.footer {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
}

.footer-credit {
    margin-top: 6px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.footer-credit a {
    color: var(--accent-blue);
    text-decoration: none;
}

.footer-credit a:hover {
    text-decoration: underline;
}

/* ============================================
   动画关键帧
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes packShake {
    0% { transform: rotate(0deg); }
    20% { transform: rotate(-5deg); }
    40% { transform: rotate(5deg); }
    60% { transform: rotate(-3deg); }
    80% { transform: rotate(3deg); }
    100% { transform: rotate(0deg); }
}

@keyframes packGlow {
    0% { filter: brightness(1); transform: scale(1); }
    50% { filter: brightness(1.8); transform: scale(1.2); }
    100% { filter: brightness(2.5); transform: scale(1.5); opacity: 0; }
}

@keyframes textPulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(30px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateY(0deg);
    }
}

@keyframes urShine {
    0%, 100% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.9), 0 0 60px rgba(255, 170, 0, 0.4); }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   响应式适配（手机端）
   ============================================ */
@media (max-width: 600px) {
    .top-bar {
        padding: 12px 16px;
    }

    .game-title {
        font-size: 1.1rem;
    }

    .top-nav {
        gap: 4px;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .game-area {
        padding: 20px 12px;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .pack-list {
        grid-template-columns: 1fr;
    }

    .btn-open-pack {
        padding: 14px 36px;
        font-size: 1.1rem;
    }

    .cards-display {
        gap: 8px;
    }

    .card-item {
        width: 105px;
        height: 185px;
    }

    .card-image {
        height: 120px;
    }

    .card-icon {
        font-size: 2.2rem;
        line-height: 120px;
    }

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

    .modal-content {
        max-height: 90vh;
    }

    .cache-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
