/* Ensure html covers the full height and background in dark mode */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Base styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background 0.3s, color 0.3s;
    background: var(--background);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
}

/* Header styling */
header {
    padding: 1rem;
    background: var(--header-bg);
    color: var(--header-text);
    text-align: center;
}

/* Accent colors for headings and buttons */
h1 {
    margin: 0;
    color: var(--accent-color);
}

/* Controls container */
.controls {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

/* Main area */
main {
    flex: 1;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Board styling */
#board {
    display: grid;
    gap: 1px;
    background: var(--board-border);
}

/* Cell styling */
.cell {
    width: 30px;
    height: 30px;
    background: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s;
}

.cell.revealed {
    background: var(--cell-revealed-bg);
    cursor: default;
}

.cell.flagged {
    background: var(--cell-flagged-bg);
    color: var(--flag-color);
}

/* Button styling */
button {
    padding: 0.5rem 1rem;
    cursor: pointer;
    background: var(--button-bg);
    border: none;
    border-radius: 4px;
    color: var(--button-text);
    transition: background 0.3s;
}

button:hover {
    background: var(--button-hover);
}

/* Modal styling */
.modal {
    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: 10;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--modal-bg);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

/* Light Theme Variables */
:root {
    --header-bg: #f0f0f0;
    --header-text: #333;
    --cell-bg: #e0e0e0;
    --cell-revealed-bg: #fff;
    --cell-flagged-bg: #ffcccc;
    --board-border: #444;
    --background: #fff;
    --text-color: #000;
    --modal-bg: #fff;
    --button-bg: #008cba;
    --button-hover: #007ba7;
    --button-text: #fff;
    --accent-color: #008cba;
    --flag-color: red;
}

/* Dark Theme Variables */
body.dark {
    --header-bg: #333;
    --header-text: #f0f0f0;
    --cell-bg: #555;
    --cell-revealed-bg: #777;
    --cell-flagged-bg: #cc6666;
    --board-border: #888;
    --background: #222;
    --text-color: #eee;
    --modal-bg: #444;
    --button-bg: #005f8a;
    --button-hover: #004f70;
    --button-text: #fff;
    --accent-color: #00aced;
    --flag-color: #ff6666;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .cell {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }

    #board {
        /* Allow board to shrink and scroll if needed */
        max-width: 100%;
        overflow: auto;
    }

    header,
    main {
        padding: 0.5rem;
    }
}