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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-light: #0f3460;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.3);
    --text: #eee;
    --text-dim: #888;
    --cell-hidden: #2a3a5c;
    --cell-hidden-hover: #3a4a6c;
    --cell-revealed: #0d1b36;
    --cell-border-light: #3d5080;
    --cell-border-dark: #1a2540;
    --gold: #ffd700;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    max-width: 800px;
    width: 100%;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--accent-glow);
}

.controls {
    margin-bottom: 15px;
}

.difficulty {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 8px 18px;
    border: 2px solid var(--surface-light);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.diff-btn:hover {
    border-color: var(--accent);
}

.diff-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 700;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-radius: 12px;
    padding: 10px 20px;
    margin-bottom: 15px;
    border: 1px solid var(--surface-light);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.info-icon {
    font-size: 1.2rem;
}

.reset-btn {
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s;
    padding: 4px;
}

.reset-btn:hover {
    transform: scale(1.2);
}

.reset-btn:active {
    transform: scale(0.95);
}

.board-wrapper {
    overflow-x: auto;
    padding-bottom: 10px;
    display: flex;
    justify-content: center;
}

.board {
    display: inline-grid;
    gap: 2px;
    background: var(--cell-border-dark);
    border: 3px solid var(--surface-light);
    border-radius: 8px;
    padding: 4px;
    user-select: none;
    -webkit-user-select: none;
}

.cell {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.1s;
    position: relative;
}

.cell.hidden {
    background: var(--cell-hidden);
    border-top: 2px solid var(--cell-border-light);
    border-left: 2px solid var(--cell-border-light);
    border-right: 2px solid var(--cell-border-dark);
    border-bottom: 2px solid var(--cell-border-dark);
}

.cell.hidden:hover {
    background: var(--cell-hidden-hover);
}

.cell.revealed {
    background: var(--cell-revealed);
    border: 1px solid rgba(255,255,255,0.05);
    cursor: default;
}

.cell.flagged {
    background: var(--cell-hidden);
    border-top: 2px solid var(--cell-border-light);
    border-left: 2px solid var(--cell-border-light);
    border-right: 2px solid var(--cell-border-dark);
    border-bottom: 2px solid var(--cell-border-dark);
}

.cell.mine-hit {
    background: var(--accent) !important;
    border: none;
}

.cell.mine-revealed {
    background: #1a0a10;
    border: 1px solid rgba(233, 69, 96, 0.2);
}

.cell.wrong-flag {
    background: #3a1a1a;
    border: 1px solid rgba(233, 69, 96, 0.3);
}

/* 数字颜色 */
.cell.n1 { color: #4fc3f7; }
.cell.n2 { color: #66bb6a; }
.cell.n3 { color: #ef5350; }
.cell.n4 { color: #7e57c2; }
.cell.n5 { color: #ff7043; }
.cell.n6 { color: #26c6da; }
.cell.n7 { color: #ec407a; }
.cell.n8 { color: #bdbdbd; }

.instructions {
    margin-top: 15px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* 胜利/失败弹窗 */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: var(--surface);
    border: 2px solid var(--surface-light);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.overlay-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.overlay-time {
    color: var(--text-dim);
    margin-bottom: 20px;
}

.play-again-btn {
    padding: 12px 30px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

@media (max-width: 600px) {
    body { padding: 10px; }
    .header h1 { font-size: 1.5rem; }
    .cell { width: 28px; height: 28px; font-size: 0.75rem; }
    .game-info { padding: 8px 15px; }
    .overlay-content { padding: 30px 20px; }
}

@media (max-width: 400px) {
    .cell { width: 24px; height: 24px; font-size: 0.7rem; }
}
