* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
    touch-action: manipulation;
}

.game-container {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

/* 状态栏 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(to right, #3498db, #2c3e50);
    color: white;
    position: relative;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

.status-item {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
}

.status-item i {
    margin-right: 8px;
    font-size: 20px;
}

/* 雷区 */
.minefield-container {
    padding: 15px;
    background: #ecf0f1;
    position: relative;
}

.minefield {
    display: grid;
    gap: 3px;
    margin: 0 auto;
    max-width: 100%;
    overflow: hidden;
    background: #bdc3c7;
    padding: 5px;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.cell {
    aspect-ratio: 1/1;
    background: linear-gradient(145deg, #3498db, #2980b9);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    font-size: 18px;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cell:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #2980b9, #2573a7);
}

.cell.revealed {
    background: #ecf0f1;
    color: #2c3e50;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.cell.flag::after {
    content: "🚩";
    font-size: 20px;
}

.cell.mine::after {
    content: "💣";
    font-size: 22px;
}

.cell.mine.exploded {
    background: #e74c3c;
}

.cell.number-1 {
    color: #3498db;
}

.cell.number-2 {
    color: #2ecc71;
}

.cell.number-3 {
    color: #e74c3c;
}

.cell.number-4 {
    color: #9b59b6;
}

.cell.number-5 {
    color: #e67e22;
}

.cell.number-6 {
    color: #1abc9c;
}

.cell.number-7 {
    color: #34495e;
}

.cell.number-8 {
    color: #f1c40f;
}

/* 控制按钮 */
.controls {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.control-btn {
    flex: 1;
    margin: 0 5px;
    padding: 12px 5px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(to right, #3498db, #2c3e50);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.control-btn i {
    font-size: 20px;
    margin-bottom: 5px;
}

.control-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-btn.active {
    background: linear-gradient(to right, #e74c3c, #c0392b);
}

/* 难度选择界面 */
.difficulty-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    transform: translateY(-150%);
    transition: transform 0.5s ease;
    z-index: 10;
    border-radius: 20px;
}

.difficulty-container.active {
    transform: translateY(0);
}

.home-icon {
    display: inline-block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    margin-bottom: 30px;
    font-size: 24px;
    color: white;
    cursor: pointer;
}

.game-logo {
    text-align: center;
    margin-bottom: 30px;
}

.spiky-ball {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.ball {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #a0a0a0, #707070);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.spike {
    position: absolute;
    width: 15px;
    height: 40px;
    background: linear-gradient(to bottom, #a0a0a0, #707070);
    border-radius: 50%;
    transform-origin: center bottom;
}

.light {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff6b6b;
    box-shadow: 0 0 10px 2px #ff6b6b;
}

.light:nth-child(2) {
    background: #4cd137;
    box-shadow: 0 0 10px 2px #4cd137;
    top: 20%;
    left: 70%;
}

.light:nth-child(3) {
    background: #3498db;
    box-shadow: 0 0 10px 2px #3498db;
    top: 60%;
    left: 15%;
}

.light:nth-child(4) {
    background: #fbc531;
    box-shadow: 0 0 10px 2px #fbc531;
    top: 80%;
    left: 60%;
}

.difficulty-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.difficulty-btn {
    padding: 15px 10px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #00b09b, #96c93d);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.difficulty-btn span {
    font-size: 12px;
    font-weight: normal;
    margin-top: 5px;
    opacity: 0.9;
}

.difficulty-btn:active {
    transform: scale(0.98);
}

.difficulty-btn.medium {
    border: 3px solid #ff6b6b;
    position: relative;
}

.difficulty-btn.medium::after {
    content: "推荐";
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff6b6b;
    color: white;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 10px;
}

/* 当前选中难度样式 */
.difficulty-btn.selected {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    border: 2px solid rgba(255,255,255,0.9);
    background: linear-gradient(135deg, #ffd166, #ff6b6b);
    color: #2c3e50;
}

.difficulty-btn.selected span {
    opacity: 1;
}

.game-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.game-btn {
    padding: 15px 25px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #ff9a9e, #fad0c4);
    color: #2c3e50;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    flex: 1;
    max-width: 150px;
}

.game-btn.continue {
    background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
}

.game-btn:active {
    transform: scale(0.98);
}

/* 响应式调整 */
@media (max-width: 480px) {
    .status-item {
        font-size: 16px;
        padding: 6px 12px;
    }

    .control-btn {
        font-size: 14px;
        padding: 10px 5px;
    }

    .difficulty-options {
        grid-template-columns: 1fr;
    }

    .game-buttons {
        flex-direction: column;
        align-items: center;
    }

    .game-btn {
        max-width: 100%;
        width: 100%;
    }

    /* 小屏修复：允许设置面板滚动并避免被容器或 body 裁切 */
    /* 允许页面滚动（原 body 在大屏隐藏溢出以居中显示） */
    body {
        overflow: auto;
        padding: 8px;
    }

    /* 让 game-container 可显示其绝对定位的设置面板 */
    .game-container {
        max-height: 100vh;
        min-height: 80vh;
    }

    /* 设置面板可滚动，限制最大高度，减小内边距 */
    .difficulty-container {
        padding: 15px 10px;
        border-radius: 14px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 缩小 logo 尺寸，减少间距 */
    .spiky-ball {
        width: 90px;
        height: 90px;
        margin-bottom: 12px;
    }

    .game-logo {
        margin-bottom: 18px;
    }

    .home-icon {
        width: 44px;
        height: 44px;
        line-height: 44px;
        margin-bottom: 20px;
    }

    .difficulty-options {
        gap: 10px;
    }

    .difficulty-btn {
        padding: 12px 8px;
    }

    .difficulty-btn.medium::after {
        top: -6px;
        right: -6px;
        font-size: 9px;
        padding: 2px 5px;
    }
}

/* 缓存提示 */
.cache-notice {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0.8;
}

/* 游戏结束弹窗 */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

.game-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.result-message {
    font-size: 32px;
    font-weight: bold;
    color: white;
    margin-bottom: 30px;
    text-align: center;
}

.result-message.win {
    color: #2ecc71;
}

.result-message.lose {
    color: #e74c3c;
}

.restart-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.restart-btn:active {
    transform: scale(0.98);
}

/* 提示动画 */
.hint-pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}