body {
    background: linear-gradient(135deg, #e0e7ef 0%, #b3c6e0 100%);
    color: #263238;
    font-family: 'Segoe UI', 'Courier New', Courier, monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

h1 {
    font-size: 2.3rem;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 18px;
    color: #1976d2;
    text-shadow: 0 2px 12px #90caf9aa;
    filter: drop-shadow(0 2px 8px #fff8);
}

#flag-counter {
    background: rgba(255,255,255,0.7);
    border-radius: 8px;
    padding: 6px 18px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px #90caf966;
    color: #1976d2;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

label[for="mode-select"] {
    color: #1976d2;
    font-weight: bold;
    margin-bottom: 6px;
}

#mode-select {
    background: rgba(255,255,255,0.8);
    border: 1.5px solid #90caf9;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 1rem;
    color: #1976d2;
    font-weight: bold;
    margin-bottom: 18px;
    outline: none;
    box-shadow: 0 1px 4px #90caf955;
    transition: border 0.2s;
}
#mode-select:focus {
    border: 2px solid #1976d2;
}

#grid {
    margin: 0 auto 18px auto;
    border-collapse: separate;
    border-spacing: 4px;
    background: rgba(255,255,255,0.35);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 8px 32px 0 #90caf9aa, 0 1.5px 8px #fff6;
    backdrop-filter: blur(6px);
}

#grid tr td {
    border: none;
    background: linear-gradient(145deg, #e3f2fd 0%, #b3c6e0 100%);
    width: 36px;
    height: 36px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 500;
    color: #263238;
    border-radius: 7px;
    box-shadow: 0 2px 8px #90caf933, 0 1px 2px #fff8;
    cursor: pointer;
    transition: 
        background 0.15s, 
        color 0.15s, 
        box-shadow 0.15s, 
        transform 0.08s;
    user-select: none;
    vertical-align: middle;
    line-height: 36px;
    padding: 0;
    outline: none;
}

#grid tr td:hover:not(.active):not(.mine) {
    background: #fffde7;
    border: 1.5px solid #ffd54f;
    box-shadow: 0 2px 12px #ffd54faa;
    transform: scale(1.07);
}

#grid tr td:active:not(.active):not(.mine) {
    background: #b3c6e0;
    color: #1976d2;
    box-shadow: 0 1px 2px #90caf955;
    transform: scale(0.97);
}

#grid tr td.active {
    background: #fff;
    color: #263238;
    border: 1.5px solid #bdbdbd;
    box-shadow: none;
    cursor: default;
    font-weight: 600;
}

#grid tr td.mine {
    background: linear-gradient(135deg, #ff5252 60%, #ffbaba 100%);
    color: #fff;
    font-size: 1.3rem;
    border: 1.5px solid #bdbdbd;
    animation: mineReveal 0.4s;
}

@keyframes mineReveal {
    0% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

#grid tr td.flag {
    background: #fffde7;
    color: #d32f2f;
    font-size: 1.2rem;
    border: 1.5px solid #ffd54f;
}

body.theme-light {
    background: linear-gradient(135deg, #e0e7ef 0%, #b3c6e0 100%);
    color: #263238;
}
body.theme-light h1 {
    color: #1976d2;
    text-shadow: 0 2px 12px #90caf9aa;
}
body.theme-light #flag-counter {
    background: rgba(255,255,255,0.7);
    color: #1976d2;
}
body.theme-light #mode-select {
    background: rgba(255,255,255,0.8);
    border: 1.5px solid #90caf9;
    color: #1976d2;
}
body.theme-light #grid {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 8px 32px 0 #90caf9aa, 0 1.5px 8px #fff6;
}
body.theme-light #grid tr td {
    background: linear-gradient(145deg, #e3f2fd 0%, #b3c6e0 100%);
    color: #263238;
    box-shadow: 0 2px 8px #90caf933, 0 1px 2px #fff8;
}
body.theme-light #grid tr td.active {
    background: #fff;
    color: #263238;
}
body.theme-light #grid tr td.mine {
    background: linear-gradient(135deg, #ff5252 60%, #ffbaba 100%);
    color: #fff;
}
body.theme-light #grid tr td.flag {
    background: #fffde7;
    color: #d32f2f;
}
body.theme-light button, body.theme-light #theme-toggle {
    background: linear-gradient(90deg, #1976d2 0%, #64b5f6 100%);
    color: #fff;
}
body.theme-light button:hover, body.theme-light #theme-toggle:hover {
    background: linear-gradient(90deg, #64b5f6 0%, #1976d2 100%);
    color: #fffde7;
}

body.theme-dark {
    background: linear-gradient(135deg, #23272f 0%, #2c3e50 100%);
    color: #eceff1;
}
body.theme-dark h1 {
    color: #ffd54f;
    text-shadow: 0 2px 12px #ffecb3aa;
}
body.theme-dark #flag-counter {
    background: rgba(40,44,52,0.7);
    color: #ffd54f;
}
body.theme-dark #mode-select {
    background: rgba(40,44,52,0.8);
    border: 1.5px solid #ffd54f;
    color: #ffd54f;
}
body.theme-dark #grid {
    background: rgba(40,44,52,0.35);
    box-shadow: 0 8px 32px 0 #ffd54faa, 0 1.5px 8px #23272faa;
}
body.theme-dark #grid tr td {
    background: linear-gradient(145deg, #37474f 0%, #23272f 100%);
    color: #eceff1;
    box-shadow: 0 2px 8px #23272f33, 0 1px 2px #ffd54f22;
}
body.theme-dark #grid tr td.active {
    background: #23272f;
    color: #ffd54f;
}
body.theme-dark #grid tr td.mine {
    background: linear-gradient(135deg, #ff5252 60%, #b71c1c 100%);
    color: #fff;
}
body.theme-dark #grid tr td.flag {
    background: #37474f;
    color: #ffd54f;
}
body.theme-dark button, body.theme-dark #theme-toggle {
    background: linear-gradient(90deg, #ffd54f 0%, #ff7043 100%);
    color: #23272f;
}
body.theme-dark button:hover, body.theme-dark #theme-toggle:hover {
    background: linear-gradient(90deg, #ff7043 0%, #ffd54f 100%);
    color: #fffde7;
}

/* Angka tetap sama di kedua tema */
#grid tr td.num1 { color: #1976d2; }
#grid tr td.num2 { color: #388e3c; }
#grid tr td.num3 { color: #d32f2f; }
#grid tr td.num4 { color: #7b1fa2; }
#grid tr td.num5 { color: #ff8f00; }
#grid tr td.num6 { color: #00838f; }
#grid tr td.num7 { color: #455a64; }
#grid tr td.num8 { color: #c62828; }

#grid tr td {
    width: 36px;
    height: 36px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 500;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.08s;
    user-select: none;
    vertical-align: middle;
    line-height: 36px;
    padding: 0;
    outline: none;
}

#grid tr td:hover:not(.active):not(.mine) {
    border: 1.5px solid #ffd54f;
    box-shadow: 0 2px 12px #ffd54faa;
    transform: scale(1.07);
}

#grid tr td:active:not(.active):not(.mine) {
    filter: brightness(0.95);
    transform: scale(0.97);
}

#grid tr td.mine {
    font-size: 1.3rem;
    animation: mineReveal 0.4s;
}

@keyframes mineReveal {
    0% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

button, #theme-toggle {
    margin: 8px 0 0 0;
    padding: 10px 32px;
    border: none;
    outline: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 2px 8px #90caf955;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}

@media (max-width: 600px) {
    #grid tr td {
        width: 22px;
        height: 22px;
        font-size: 1rem;
        line-height: 22px;
    }
    h1 {
        font-size: 1.2rem;
    }
    button, #theme-toggle {
        font-size: 1rem;
        padding: 8px 16px;
    }
}