* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    text-align: center;
    max-width: 800px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.title-area {
    display: flex;
    align-items: baseline;
}

h1 {
    color: #333;
    margin: 0;
    margin-right: 8px;
}

.version {
    color: #666;
    font-size: 14px;
}

.controls-top {
    display: flex;
    align-items: center;
}

#tutorial-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    font-size: 18px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    margin-right: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#tutorial-button:hover {
    background-color: #0b7dda;
}

.language-selector {
    display: flex;
}

.language-selector button {
    padding: 5px 10px;
    margin-left: 5px;
    background-color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.language-selector button.active {
    background-color: #2196F3;
    color: white;
}

/* Tutorial Overlay */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#tutorial-overlay.hidden {
    display: none;
}

.tutorial-content {
    background: linear-gradient(135deg, #2b2b2b 0%, #1a1a1a 100%);
    border-radius: 15px;
    padding: 25px;
    max-width: 700px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(33, 150, 243, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.tutorial-content h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #fff;
    font-size: 24px;
    text-shadow: 0 0 10px rgba(33, 150, 243, 0.7);
    letter-spacing: 1px;
    position: relative;
    padding-bottom: 10px;
}

.tutorial-content h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #2196F3, #03a9f4);
    border-radius: 3px;
}

.tutorial-steps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-left: 4px solid #2196F3;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideIn 0.5s ease-out forwards;
    opacity: 0;
    height: 100%;
}

.tutorial-step:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tutorial-step:nth-child(1) { animation-delay: 0.1s; }
.tutorial-step:nth-child(2) { animation-delay: 0.2s; }
.tutorial-step:nth-child(3) { animation-delay: 0.3s; }
.tutorial-step:nth-child(4) { animation-delay: 0.4s; }

.step-number {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #2196F3 0%, #03a9f4 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 10px rgba(33, 150, 243, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.step-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.step-content p {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

.tutorial-image {
    display: flex;
    align-items: center;
    margin-top: 5px;
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cell-example {
    width: 40px;
    height: 40px;
    background-color: #c0c0c0;
    border: 2px outset #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 20px;
    margin-right: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.cell-example:hover {
    transform: scale(1.1);
}

.cell-example.revealed {
    background-color: #e0e0e0;
    border: 1px solid #bdbdbd;
    color: blue;
}

.cell-example.flagged::after {
    content: "🚩";
    font-size: 24px;
}

.click-icon {
    font-size: 22px;
    margin-left: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.hint-button-example {
    padding: 8px 15px;
    background: linear-gradient(135deg, #ff9800 0%, #ff5722 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 10px rgba(255, 152, 0, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hint-button-example:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 152, 0, 0.6);
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Media query for smaller screens */
@media (max-width: 600px) {
    .tutorial-steps {
        grid-template-columns: 1fr;
    }
    
    .tutorial-content {
        padding: 20px;
    }
}

/* Game info section */
.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 16px;
}

/* Button sections */
.difficulty, .controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 5px;
}

/* Game buttons */
.difficulty button, .controls button {
    margin: 2px 5px;
    padding: 6px 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    min-width: 80px;
    font-size: 14px;
}

.difficulty button:hover, .controls button:hover {
    background-color: #45a049;
}

#hint-button {
    background-color: #ff9800;
}

#hint-button:hover {
    background-color: #e68a00;
}

#hint-button.active {
    background-color: #ff5722;
    box-shadow: 0 0 5px #ff5722;
}

#hint-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Game board container */
.game-board-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    justify-content: center;
}

#game-board {
    display: grid;
    gap: 0;
    background-color: #bdbdbd;
    border: 2px solid #7b7b7b; /* Reduced border width */
    margin: 0 auto;
    grid-template-columns: repeat(var(--columns), var(--cell-size, 30px));
    grid-template-rows: repeat(var(--rows), var(--cell-size, 30px));
    width: auto;
    max-width: calc(100% - 4px); /* Account for border width */
    transform: scale(1);
    transform-origin: center top;
    box-sizing: border-box; /* Include border in width calculation */
}

/* Cell styling */
.cell {
    width: var(--cell-size, 30px);
    height: var(--cell-size, 30px);
    background-color: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    border: 1px outset #f5f5f5;
    font-size: calc(var(--cell-size, 30px) * 0.5);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.cell:hover {
    background-color: #d5d5d5;
}

.cell.revealed {
    background-color: #e0e0e0;
    border: 1px solid #bdbdbd;
}

.cell.mine {
    background-color: #ff5252;
}

.cell.flagged {
    background-color: #c0c0c0;
    position: relative;
}

:root {
    --flag-size: 14px;
}

.cell.flagged::after {
    content: "🚩";
    font-size: var(--flag-size, 14px);
}

.cell.question-mark::after {
    content: "?";
    font-size: calc(var(--flag-size, 14px) * 1.1);
    font-weight: bold;
    color: #ff9800;
}

.cell.highlight {
    background-color: #ffeb3b;
    animation: pulse 0.5s;
}

.cell.hint-used {
    box-shadow: inset 0 0 0 2px #2196F3;
}

.hint-mode .cell:not(.revealed):not(.flagged):not(.question-mark):hover {
    background-color: #2196F3;
    opacity: 0.7;
    cursor: help;
}

/* Number colors */
.cell[data-value="1"] {
    color: blue;
}

.cell[data-value="2"] {
    color: green;
}

.cell[data-value="3"] {
    color: red;
}

.cell[data-value="4"] {
    color: darkblue;
}

.cell[data-value="5"] {
    color: darkred;
}

.cell[data-value="6"] {
    color: teal;
}

.cell[data-value="7"] {
    color: black;
}

.cell[data-value="8"] {
    color: gray;
}

/* Reset button and message */
#reset {
    padding: 6px 12px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    margin: 5px auto;
    display: block;
    width: fit-content;
}

#reset:hover {
    background-color: #0b7dda;
}

#message {
    font-size: 16px;
    font-weight: bold;
    height: 20px;
    margin: 0;
    padding: 0;
}

.win {
    color: green;
}

.lose {
    color: red;
}

/* Game Over Popup */
#game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease-out;
}

#game-over-overlay.hidden {
    display: none;
}

.game-over-content {
    background: linear-gradient(135deg, #2b2b2b 0%, #1a1a1a 100%);
    border-radius: 15px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

#game-over-title {
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    position: relative;
    padding-bottom: 10px;
}

#game-over-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #ff5252, #ff9800);
    border-radius: 3px;
}

#game-over-title.win {
    color: #4CAF50;
}

#game-over-title.lose {
    color: #ff5252;
}

.game-stats {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.stat-item {
    margin: 10px 0;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
}

.game-over-buttons {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#new-game-same-difficulty {
    padding: 10px 20px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#new-game-same-difficulty:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}
