:root {
    --bg-color: #2d3436;
    --board-bg: #b2bec3;
    --cell-closed: #dfe6e9;
    --cell-open: #fab1a0; /* Slightly reddish/warm for open cells */
    --accent: #0984e3;
    --text-color: #ffffff;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
}

* {
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
}

header {
    margin-bottom: 20px;
}

h1 {
    margin-bottom: 15px;
    color: #fdcb6e;
    text-shadow: 2px 2px 0 #d63031;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.stat-box {
    background: #000;
    color: #e17055;
    font-family: monospace;
    font-size: 1.5rem;
    padding: 5px 10px;
    border-radius: 5px;
    border: 2px solid #636e72;
    min-width: 80px;
}

.stat-box span:first-child {
    font-size: 0.8rem;
    display: block;
    color: #aaa;
    margin-bottom: -5px;
}

.emoji-btn {
    background: #ffeaa7;
    border: 4px outset #fdcb6e;
    font-size: 1.8rem;
    width: 50px;
    height: 50px;
    cursor: pointer;
    border-radius: 5px;
    transition: transform 0.1s;
}

.emoji-btn:active {
    border-style: inset;
    transform: scale(0.95);
}

.difficulty-select {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.diff-btn {
    background: #636e72;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.diff-btn.active {
    background: #0984e3;
    box-shadow: 0 0 10px #0984e3;
}

.game-board-wrapper {
    display: inline-block;
    background: #b2bec3;
    padding: 10px;
    border-radius: 5px;
    border: 4px solid #636e72;
}

.game-board {
    display: grid;
    gap: 2px;
}

.cell {
    width: 35px;
    height: 35px;
    background: var(--cell-closed);
    border: 3px outset white;
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #2d3436;
}

.cell:active:not(.open):not(.flagged) {
    border-style: inset;
}

.cell.open {
    background: #dfe6e9;
    border: 1px solid #b2bec3;
}

.cell.flagged {
    color: red;
}

.cell.mine {
    background: #d63031;
    border: 1px solid #b2bec3;
}

/* Number colors */
.cell[data-num="1"] { color: blue; }
.cell[data-num="2"] { color: green; }
.cell[data-num="3"] { color: red; }
.cell[data-num="4"] { color: purple; }
.cell[data-num="5"] { color: maroon; }
.cell[data-num="6"] { color: turquoise; }
.cell[data-num="7"] { color: black; }
.cell[data-num="8"] { color: gray; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    color: #2d3436;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.btn {
    background: #0984e3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 15px;
}

.back-link {
    display: block;
    margin-top: 20px;
    color: #bdc3c7;
    text-decoration: none;
}

.back-link:hover {
    color: white;
}

@media (max-width: 500px) {
    .cell {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}
