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

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
    --panel-bg: rgba(255, 255, 255, 0.08);
    --panel-border: rgba(255, 255, 255, 0.12);
    --cell-unrevealed: linear-gradient(145deg, #334155, #1e293b);
    --cell-revealed: #f8fafc;
    --text-light: #f8fafc;
    --accent-green: #10b981;
    --accent-red: #ef4444;
}

body {
    min-height: 100vh;
    background: var(--bg-gradient);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    overflow-x: hidden;
    user-select: none;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.seo-content {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.title {
    color: var(--text-light);
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 20px;
    letter-spacing: 2px;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.panel-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 450px;
    margin-bottom: 20px;
}

.level, .mode-switch {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.level button, .mode-btn {
    padding: 10px 10px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    color: #94a3b8;
    background: transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
}

.level button:hover, .mode-btn:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
}

.level button.active, .mode-btn.active {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.level .restart {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    min-width: 80px;
    white-space: nowrap;
}
.level .restart:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.game-wrapper {
    max-width: 100%;
    overflow: auto;
    padding: 10px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

.gameBox {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
}

.row {
    display: flex;
    gap: 2px;
    list-style: none;
}

.col {
    width: 32px;
    height: 32px;
    background: var(--cell-unrevealed);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    position: relative;
    position: relative;
    transition: background 0.2s, transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}

.col:hover:not(.revealed) {
    transform: translateY(-1px);
    background: linear-gradient(145deg, #475569, #334155);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.col:active:not(.revealed) {
    transform: translateY(0) scale(0.95);
}

.col span:not(.img-flag) {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.col.revealed {
    background: var(--cell-revealed);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    transform: none !important;
}

.col.revealed span {
    opacity: 1;
    transform: scale(1);
}

/* 旗子样式 */
.img-flag {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    opacity: 1;
    transition: all 0.2s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.img-flag.hide {
    opacity: 0;
    pointer-events: none;
}

/* 揭开的格子不显示旗子 */
.col.revealed .img-flag {
    opacity: 0;
    pointer-events: none;
}

/* 经典数字色彩美化 */
.num-1 { color: #2563eb; }
.num-2 { color: #16a34a; }
.num-3 { color: #dc2626; }
.num-4 { color: #7c3aed; }
.num-5 { color: #9a3412; }
.num-6 { color: #0891b2; }
.num-7 { color: #0f172a; }
.num-8 { color: #64748b; }

.custom-flag {
    font-size: 15px;
    animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.boom {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    animation: mineExplode 0.4s ease-out forwards;
}

.boom::after {
    content: '💣';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    animation: bounce 0.3s ease-out;
}

@keyframes popIn {
    from { transform: scale(0) rotate(-30deg); opacity: 0; }
    to { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes mineExplode {
    0% { transform: scale(1); filter: brightness(1.5); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); filter: brightness(1); }
}

.info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 450px;
    margin-top: 20px;
    gap: 15px;
}

.info-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    color: var(--text-light);
}

.info-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.residue, .tick {
    font-family: monospace;
    font-size: 22px;
    font-weight: 700;
    color: #38bdf8;
}

.unit {
    font-size: 12px;
    color: #64748b;
    margin-left: 2px;
}

/* 适配移动端小屏幕的弹性缩放 */
@media (max-width: 500px) {
    .col {
        width: 7vw;
        height: 7vw;
        max-width: 30px;
        max-height: 30px;
        font-size: 4.5vw;
    }
    .custom-flag { font-size: 4vw; }
}
