:root {
    --primary-color: #3584e4;
    --primary-light: #62a0ea;
    --primary-lighter: #99c1f1;
    --secondary-color: #33d17a;
    --secondary-light: #57e389;
    --secondary-lighter: #8ff0a4;
    --accent-color: #f66151;
    --accent-light: #ff7800;
    --accent-lighter: #ffbe6f;
    --warning-color: #f5c211;
    --warning-light: #f8e45c;
    --text-color: #3d3846;
    --text-light: #77767b;
    --text-lighter: #9a9996;
    --background-light: #f6f5f4;
    --background-lighter: #ffffff;
    --surface: #deddda;
    --surface-light: #c0bfbc;
    --border-radius: 8px;
    --cell-size: 32px;
    --gap-size: 3px;
    --font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --shadow-light: rgba(61, 56, 70, 0.1);
    --shadow-medium: rgba(61, 56, 70, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding-right: 20px;
    background-color: #fafafb;
    display: flex;
    justify-content: end;
    align-items: center;
    gap: 30px;
    font-family: var(--font-family);
    color: var(--text-color);
}

.game-header {
    text-align: center;
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    flex-direction: column;
    max-width: 300px;
}

.game-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--background-lighter);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow:
        0 2px 8px var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid var(--surface);
    min-width: 100%;
    max-width: 600px;
}

.settings-row {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 80px;
    padding: 10px 12px;
    border: 2px solid var(--surface);
    border-radius: calc(var(--border-radius) - 2px);
    background: var(--background-light);
    color: var(--text-color);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(61, 56, 70, 0.1);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--background-lighter);
    box-shadow:
        inset 0 1px 3px rgba(61, 56, 70, 0.1),
        0 0 0 3px rgba(53, 132, 228, 0.1);
}

.input-group input:hover:not(:focus) {
    border-color: var(--surface-light);
    background: var(--background-lighter);
}

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

.preset-button {
    padding: 10px 16px;
    background: linear-gradient(
        145deg,
        var(--background-light),
        var(--surface)
    );
    color: var(--text-color);
    border: 2px solid transparent;
    border-radius: calc(var(--border-radius) - 2px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.preset-button:hover:not(.active) {
    background: linear-gradient(
        145deg,
        var(--background-lighter),
        var(--background-light)
    );
    transform: translateY(-1px);
    box-shadow: 0 2px 6px var(--shadow-light);
}

.preset-button.active {
    border-color: var(--primary-color);
    background: linear-gradient(
        145deg,
        var(--primary-color),
        var(--primary-light)
    );
    color: var(--background-lighter);
    box-shadow:
        0 2px 8px var(--shadow-medium),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.game-stats {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: 500;
}

.stat-item {
    background: var(--background-lighter);
    padding: 10px 18px;
    border-radius: var(--border-radius);
    box-shadow:
        0 2px 8px var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid var(--surface);
    color: var(--text-color);
}

#timer-display {
    font-weight: 700;
    color: var(--primary-color);
    font-feature-settings: "tnum";
    letter-spacing: 0.5px;
}

#game-field-container {
    display: flex;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
}

#game-field {
    display: grid;
}

.mine-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #babdb6;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
    border: 1px solid #fafafb;
}

.mine-cell:hover:not(.opened):not(.flagged) {
    background-color: #d3d7cf;
}

.mine-cell.opened {
    background-color: #dededc;
    cursor: default;
}

.mine-cell.flagged:not(.opened)::after {
    content: "🚩";
    font-size: 16px;
}

.mine-cell.bomb.opened:not(.flagged) {
    background: linear-gradient(
        145deg,
        var(--accent-color),
        var(--accent-light)
    );
}

.mine-cell.bomb.opened:not(.flagged)::after {
    content: "💣";
    font-size: 16px;
}

.mine-cell.number-1 {
    background-color: #ddfac3;
}
.mine-cell.number-2 {
    background-color: #eaebbe;
}
.mine-cell.number-3 {
    background-color: #eddab4;
}
.mine-cell.number-4 {
    background-color: #edc38a;
}
.mine-cell.number-5 {
    background-color: #f7a1a2;
}
.mine-cell.number-6 {
    background-color: #fea785;
}
.mine-cell.number-7 {
    background-color: #ff7d60;
}
.mine-cell.number-8 {
    background-color: #ff323c;
}

.game-controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-button {
    padding: 14px 28px;
    background: linear-gradient(
        145deg,
        var(--primary-color),
        var(--primary-light)
    );
    color: var(--background-lighter);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow:
        0 4px 12px var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid var(--primary-color);
}

.game-button:hover {
    background: linear-gradient(
        145deg,
        var(--primary-light),
        var(--primary-lighter)
    );
    transform: translateY(-1px);
    box-shadow:
        0 6px 16px var(--shadow-medium),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.game-button:active {
    transform: translateY(0);
    box-shadow:
        0 2px 8px var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.game-button.win {
    background: linear-gradient(
        145deg,
        var(--secondary-color),
        var(--secondary-light)
    );
    border-color: var(--secondary-color);
    color: var(--background-lighter);
}

.game-button.lose {
    background: linear-gradient(
        145deg,
        var(--accent-color),
        var(--accent-light)
    );
    border-color: var(--accent-color);
    color: var(--background-lighter);
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
    100% {
        opacity: 1;
    }
}

.mine-cell.flagged {
    animation: pulse 2s infinite;
}

.mine-cell:focus,
.game-button:focus,
.preset-button:focus,
.input-group input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .settings-row {
        flex-direction: column;
        gap: 15px;
    }

    .input-group {
        flex-direction: row;
        gap: 10px;
        align-items: center;
    }

    .input-group label {
        min-width: 60px;
        text-align: left;
    }

    .difficulty-presets {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .preset-button {
        width: 200px;
        text-align: center;
    }

    .game-settings {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
        gap: 20px;
    }

    .game-stats {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .preset-button {
        font-size: 12px;
        padding: 8px 12px;
    }

    .input-group input {
        width: 70px;
        font-size: 14px;
    }

    .game-settings {
        min-width: auto;
        width: 100%;
    }
}
