* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(-45deg, #f8fafc, #e2e8f0, #cbd5e0, #a0aec0);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #2d3748;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* 主容器布局 */
.main-container {
    display: flex;
    min-height: 100vh;
    gap: 30px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.game-container {
    flex: 1;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    max-width: 800px;
    text-align: center;
}

.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    z-index: -1;
}

h1 {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 25px;
    font-size: 3em;
    font-weight: 800;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.instructions {
    font-size: 1.1em;
    color: #4a5568;
    margin-bottom: 30px;
    line-height: 1.6;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.instructions p {
    margin: 8px 0;
    color: #4a5568;
    font-size: 1.05em;
    line-height: 1.6;
}

kbd {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cards-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: nowrap;
}

.card {
    width: 130px;
    height: 130px;
    background: linear-gradient(145deg, #ffffff, #f0f4f8);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.8),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 18px;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
}

.card.clickable {
    border-color: #ffd700;
    animation: glow 2s ease-in-out infinite alternate;
    background: linear-gradient(145deg, #fffbf0, #fff8e1);
}

.card.clickable::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ffd700, #ffed4e, #ffd700);
    border-radius: 22px;
    z-index: -1;
    animation: borderRotate 3s linear infinite;
}

@keyframes borderRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes glow {
    from {
        box-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700, 0 0 30px #ffd700;
    }
    to {
        box-shadow: 0 0 20px #ffd700, 0 0 30px #ffd700, 0 0 40px #ffd700;
    }
}

.card-content {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 三角形 */
.triangle {
    width: 0;
    height: 0;
    border-left: 32px solid transparent;
    border-right: 32px solid transparent;
    border-bottom: 55px solid #e53e3e;
    filter: drop-shadow(0 4px 8px rgba(229, 62, 62, 0.3));
    position: relative;
}

.triangle::after {
    content: '';
    position: absolute;
    top: 8px;
    left: -24px;
    width: 0;
    height: 0;
    border-left: 24px solid transparent;
    border-right: 24px solid transparent;
    border-bottom: 40px solid rgba(255, 255, 255, 0.2);
}

/* 正方形 */
.square {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #38a169, #2f855a);
    border-radius: 8px;
    box-shadow: 
        0 4px 12px rgba(56, 161, 105, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
    position: relative;
}

.square::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    height: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 4px;
}

/* 五角形 */
.pentagon {
    position: relative;
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #3182ce, #2c5282);
    transform: rotate(35deg);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    filter: drop-shadow(0 4px 8px rgba(49, 130, 206, 0.3));
}

.pentagon::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* 六角形 */
.hexagon {
    width: 55px;
    height: 48px;
    background: linear-gradient(135deg, #805ad5, #6b46c1);
    position: relative;
    margin: 8px 0;
    filter: drop-shadow(0 4px 8px rgba(128, 90, 213, 0.3));
}

.hexagon:before,
.hexagon:after {
    content: "";
    position: absolute;
    width: 0;
    border-left: 27.5px solid transparent;
    border-right: 27.5px solid transparent;
}

.hexagon:before {
    bottom: 100%;
    border-bottom: 14px solid #805ad5;
}

.hexagon:after {
    top: 100%;
    border-top: 14px solid #805ad5;
}

.hexagon::before {
    border-bottom-color: #805ad5;
}

.hexagon::after {
    border-top-color: #805ad5;
}

/* 三颗星星 */
.three-stars {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 65px;
    height: 22px;
}

.star {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    position: relative;
    display: inline-block;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: twinkle 1.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.4));
}

.star::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

@keyframes twinkle {
    from {
        transform: scale(1);
        opacity: 1;
        filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.4));
    }
    to {
        transform: scale(1.15);
        opacity: 0.85;
        filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.6));
    }
}

.status {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 1.1em;
    color: #4a5568;
    border: 1px solid rgba(102, 126, 234, 0.25);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.status::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s infinite;
}

.game-status {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px 25px;
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 1.1em;
    color: #4a5568;
    border: 1px solid rgba(102, 126, 234, 0.25);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.game-status::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9));
    backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.5s ease-out;
}

.result-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9));
    backdrop-filter: blur(20px);
    padding: 50px 60px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.6s ease-out;
    position: relative;
    overflow: hidden;
}

.result-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    animation: rotate 4s linear infinite;
    z-index: -1;
}

.result-content h2 {
    font-size: 3em;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.result-content h2.success {
    color: #38a169;
}

.result-content h2.failure {
    color: #e53e3e;
}

.result-content p {
    font-size: 1.3em;
    color: #2d3748;
    margin-bottom: 30px;
    line-height: 1.6;
}

.result-content button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 35px;
    font-size: 1.1em;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-content button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.result-content button:hover::before {
    left: 100%;
}

.result-content button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* 统计面板样式 */
.stats-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    min-width: 250px;
    z-index: 1;
}

.stats-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    z-index: -1;
}

.stats-panel h2 {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 700;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.stat-item {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.stat-label {
    font-size: 0.9em;
    color: #4a5568;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.4em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.reset-stats-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1em;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.reset-stats-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.reset-stats-btn:hover::before {
    left: 100%;
}

.reset-stats-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

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

/* 桌面端默认：显示桌面按钮，隐藏底部工具栏 */
.mobile-only { display: none; }
.desktop-only { display: inline-block; }

/* 桌面端刷新按钮样式（卡牌区下方居中） */
.desktop-refresh-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 16px 0 24px;
}
.refresh-btn-desktop {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;

    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 12px 28px;
    font-size: 1.1em;
    line-height: 1;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
    transition: transform .2s ease, box-shadow .2s ease;
}
.refresh-btn-desktop:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.45);
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 布局改为纵向，卡片自动换行，尺寸缩小 */
    .main-container {
        flex-direction: column;
        gap: 16px;
        padding: 16px 12px 100px 12px; /* 增加底部空间，减少左右边距 */
        align-items: center; /* 整体居中 */
    }

    .game-container {
        padding: 24px 16px; /* 减少内边距 */
        border-radius: 16px; /* 减小圆角 */
    }

    .cards-container {
        flex-wrap: wrap; /* 允许换行 */
        justify-content: center; /* 居中对齐 */
        gap: 16px; /* 增大卡牌间距 */
        margin: 24px 0;
        padding: 0 16px; /* 增加左右边距 */
        overflow-x: visible; /* 不需要横向滚动 */
        max-width: 100%;
    }
    
    .card {
        width: calc((100vw - 80px) / 2); /* 每行2个卡牌，更大的尺寸 */
        height: calc((100vw - 80px) / 2);
        max-width: 140px; /* 增大最大宽度 */
        max-height: 140px;
        min-width: 100px; /* 增大最小宽度 */
        min-height: 100px;
        flex-shrink: 0; /* 防止压缩 */
    }
    
    .card-content {
        width: 50%; /* 稍大的内容区域 */
        height: 50%;
    }
    
    h1 {
        font-size: 1.8em; /* 稍微增大标题字体 */
        margin-bottom: 16px;
    }

    .instructions {
        font-size: 0.95em; /* 稍微增大说明文字 */
        padding: 16px 12px;
        margin-bottom: 20px;
    }

    .instructions p {
        margin: 6px 0;
        font-size: 0.9em;
    }

    .game-status {
        padding: 12px 16px;
        font-size: 1em;
        margin-bottom: 16px;
    }

    /* 统计面板：移动端优化 */
    .stats-panel {
        display: none;
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        bottom: calc(80px + env(safe-area-inset-bottom)); /* 优化安全区适配 */
        border-radius: 16px;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
        max-height: 60vh; /* 限制最大高度 */
        overflow-y: auto;
        margin: 0;
        width: auto;
        max-width: none;
        z-index: 9999;
        padding: 20px 16px; /* 优化内边距 */
    }
    .stats-panel.open {
        display: block;
        animation: slideUpFromBottom 0.3s ease-out;
    }

    .stats-panel h2 {
        font-size: 1.4em;
        margin-bottom: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr); /* 两列布局 */
        gap: 12px;
    }

    .stat-item {
        padding: 12px;
        border-radius: 10px;
    }

    .stat-label {
        font-size: 0.8em;
    }

    .stat-value {
        font-size: 1.1em;
    }

    /* 桌面按钮隐藏，手机底部工具栏显示 */
    .desktop-only { display: none; }
    .mobile-only { display: block; }

    /* 手机端广告位：优化位置 */
    .ad-fixed { 
        bottom: 88px; /* 避开工具栏 */
        z-index: 9998; /* 低于统计面板 */
    }
    .ad-box { 
        transform: scale(0.75); 
        transform-origin: bottom;
    }

    /* 底部工具栏样式优化 */
    .mobile-toolbar {
        position: fixed;
        left: 0; 
        right: 0; 
        bottom: 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) 16px; /* 安全区适配 */
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(15px);
        border-top: 1px solid rgba(0,0,0,0.08);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 12px; /* 减少按钮间距 */
        z-index: 9998;
    }
    
    .refresh-btn-mobile {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: none;
        padding: 12px 20px; /* 调整按钮大小 */
        font-size: 0.9em;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 600;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
        transition: all 0.2s ease;
        min-width: 70px; /* 减少最小宽度 */
        flex: 1; /* 让按钮平分空间 */
        max-width: 120px; /* 限制最大宽度 */
    }
    
    .refresh-btn-mobile:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    }
    
    .refresh-btn-mobile.secondary {
        background: linear-gradient(135deg, #7f9cf5, #9f7aea);
    }
}

@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .stats-panel {
        width: 100%;
        max-width: 800px;
        margin: 0 auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
    }
}

/* iPad端优化 (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        gap: 24px;
        padding: 24px 20px 100px 20px;
        align-items: center; /* 整体居中 */
    }

    .game-container {
        margin: 0 auto;
        max-width: 720px;
        width: calc(100% - 40px);
        padding: 32px 24px;
    }

    h1 {
        font-size: 2.2em;
        margin-bottom: 20px;
    }

    .instructions {
        font-size: 1.0em;
        padding: 18px 16px;
        margin-bottom: 24px;
    }

    .cards-container {
        flex-wrap: wrap; /* 允许换行 */
        justify-content: center; /* 居中对齐 */
        gap: 16px; /* 卡牌间距 */
        margin: 28px 0;
        padding: 0 20px;
        overflow-x: visible; /* 不需要横向滚动 */
        max-width: 100%;
    }

    .card {
        width: 120px; /* 稍大于手机端 */
        height: 120px;
        min-width: 120px; /* 防止压缩 */
        flex-shrink: 0;
    }

    .card-content {
        width: 55px;
        height: 55px;
    }

    .game-status {
        padding: 14px 20px;
        font-size: 1.1em;
        margin-bottom: 20px;
    }

    /* iPad统计面板：底部抽屉式，更大的显示区域 */
    .stats-panel {
        display: none;
        position: fixed;
        top: auto;
        left: 24px;
        right: 24px;
        bottom: calc(88px + env(safe-area-inset-bottom));
        border-radius: 20px;
        box-shadow: 0 -12px 40px rgba(0,0,0,0.15);
        max-height: 70vh; /* iPad可以显示更多内容 */
        overflow-y: auto;
        margin: 0;
        width: auto;
        max-width: none;
        z-index: 9999;
        padding: 28px 24px;
    }
    .stats-panel.open {
        display: block;
        animation: slideUpFromBottom 0.3s ease-out;
    }

    .stats-panel h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr); /* iPad三列布局 */
        gap: 16px;
    }

    .stat-item {
        padding: 16px;
        border-radius: 12px;
    }

    .stat-label {
        font-size: 0.9em;
    }

    .stat-value {
        font-size: 1.3em;
    }

    .reset-stats-btn {
        padding: 14px 24px;
        font-size: 1.1em;
        margin-top: 8px;
    }

    /* iPad底部工具栏优化 */
    .mobile-toolbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 16px 24px calc(16px + env(safe-area-inset-bottom)) 24px;
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(15px);
        border-top: 1px solid rgba(0,0,0,0.08);
        box-shadow: 0 -6px 24px rgba(0,0,0,0.1);
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 24px; /* 增加按钮间距 */
        z-index: 9998;
    }

    .refresh-btn-mobile {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: none;
        padding: 16px 32px; /* 增大按钮尺寸 */
        font-size: 1.1em;
        border-radius: 14px;
        cursor: pointer;
        font-weight: 600;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
        transition: all 0.2s ease;
        min-width: 120px; /* 增加最小宽度 */
        flex: none; /* 不自动拉伸 */
    }

    .refresh-btn-mobile:active {
        transform: scale(0.95);
        box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
    }

    .refresh-btn-mobile.secondary {
        background: linear-gradient(135deg, #7f9cf5, #9f7aea);
    }

    /* 显示移动工具栏，隐藏桌面控件 */
    .mobile-only { display: block; }
    .desktop-only { display: none; }

    /* iPad端广告位优化 */
    .ad-fixed {
        bottom: 96px;
        z-index: 9997;
    }
    .ad-box {
        transform: scale(0.85);
        transform-origin: bottom;
    }
}

/* 新增动画 */
@keyframes slideUpFromBottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 平板断点：将 iPad 等设备也使用移动端布局与底部抽屉统计面板 */
@media (max-width: 1024px) {
    /* 主容器与游戏容器保持水平居中 */
    .main-container { margin: 0 auto; }
    .game-container { 
        margin: 0 auto; 
        max-width: 720px; 
        width: calc(100% - 40px); 
    }

    /* 显示移动工具栏，隐藏桌面控件 */
    .mobile-only { display: block; }
    .desktop-only { display: none; }

    /* 卡牌区：单行横滑，左右更大留白，避免贴边（平板略大于手机） */
    .cards-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        margin: 20px 0;
        padding: 0 20px;               /* 平板左右留白 */
        overflow-x: visible;



    }

    /* 统计面板：统一使用底部抽屉，默认隐藏，点击“统计”展开 */
    .stats-panel {
        display: none;
        position: fixed;
        top: auto;
        left: 20px;
        right: 20px;
        bottom: calc(108px + env(safe-area-inset-bottom)); /* 避开底部工具栏与安全区 */
        max-height: 65vh;
        overflow-y: auto;
        margin: 0;
        width: auto;
        max-width: none;
        border-radius: 16px;
        box-shadow: 0 16px 40px rgba(0,0,0,0.18);
        z-index: 9999;
    }
    .stats-panel.open { display: block; }
}

/* 优化不同屏幕尺寸下的卡牌间距和大小 */
@media (min-width: 480px) and (max-width: 768px) {
    /* 大屏手机优化 */
    .card {
        width: calc((100vw - 100px) / 2); /* 每行2个卡牌，更大的尺寸 */
        height: calc((100vw - 100px) / 2);
        max-width: 95px; /* 稍大的最大宽度 */
        max-height: 95px;
        min-width: 75px; /* 稍大的最小宽度 */
        min-height: 75px;
    }
    
    .cards-container {
        gap: 14px; /* 稍大的间距 */
        padding: 0 12px;
    }
}

@media (max-width: 479px) {
    /* 小屏手机优化 */
    .card {
        width: calc((100vw - 70px) / 2); /* 每行2个卡牌，紧凑布局 */
        height: calc((100vw - 70px) / 2);
        max-width: 80px;
        max-height: 80px;
        min-width: 60px;
        min-height: 60px;
    }
    
    .cards-container {
        gap: 10px; /* 更紧凑的间距 */
        padding: 0 6px;
    }
    
    .card-content {
        width: 40%; /* 稍小的内容区域 */
        height: 40%;
    }
}
/* ====== 模式切换与限时模式收集面板样式 ====== */
/* 模式切换开关 - 标题左侧 */
.mode-toggle-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-toggle {
    position: relative;
    display: inline-block;
}

.mode-switch-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-switch-label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    background-color: #ccc;
    border-radius: 30px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.mode-switch-label:hover {
    background-color: #bbb;
}

.mode-switch-input:checked + .mode-switch-label {
    background-color: #6c5ce7;
}

.mode-switch-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mode-switch-input:checked + .mode-switch-label .mode-switch-slider {
    transform: translateX(30px);
}

.mode-description {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 倒计时显示样式 */
.timer-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.timer-display {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    display: flex;
    align-items: center;
    gap: 4px;
    animation: pulse 2s infinite;
}

.timer-value {
    font-size: 18px;
    font-weight: 900;
    min-width: 24px;
    text-align: center;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(255, 107, 107, 0.5);
    }
}

.mode-switch {
  display: none;
}
.mode-btn {
  display: none;
}
.mode-tip {
  display: none;
}

.collect-panel {
  display: none; /* 默认仅在限时模式显示 */
  width: 100%;
  margin: 8px 0 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
}
.collect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.collect-title {
  font-size: 14px;
  color: #444;
}
.collect-progress {
  font-size: 13px;
  color: #555;
}
.collect-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.slot {
  height: 44px;
  background: rgba(255,255,255,0.9);
  border: 1px dashed rgba(75,115,255,0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini-card {
  height: 32px;
  width: 52px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stars-set {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.stars-set .star {
  width: 20px;
  height: 20px;
}
.mini .star,
.mini-card .star {
  width: 14px;
  height: 14px;
}

@media (max-width: 768px) {
  .mode-toggle-container {
      top: 10px;
      left: 10px;
  }
  
  .mode-switch-label {
      width: 50px;
      height: 25px;
  }
  
  .mode-switch-slider {
      width: 19px;
      height: 19px;
      top: 3px;
      left: 3px;
  }
  
  .mode-switch-input:checked + .mode-switch-label .mode-switch-slider {
      transform: translateX(25px);
  }
  
  .mode-description {
      font-size: 11px;
      padding: 3px 6px;
  }
  
  .collect-panel { padding: 8px 10px; }
  .slot { height: 40px; }
  .mini-card { height: 28px; width: 48px; }
}