body {
    background: #222;
    color: #f8f8f8;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
}

.container {
    width: 100%;
    margin: 20px auto;
    background: #333;
    border-radius: 12px;
    padding: 24px 0 32px 0;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
    text-align: center;
    box-sizing: border-box;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

h1 {
    margin: 0;
    padding: 4px 0;
    font-size: 1.8em;
    letter-spacing: 1px;
    color: #ffb347;
    white-space: nowrap;
}

#game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 16px;
    padding: 0 12px;
    min-height: 48px;
    flex-wrap: wrap;
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.controls-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 200px; /* Ensure title has room */
    gap: 12px;
}

/* Tablet breakpoint */
@media (max-width: 768px) {
    #game-controls {
        padding: 8px;
        gap: 12px;
        justify-content: center;
    }

    .controls-left, .controls-right, .controls-center {
        flex: 0 1 100%;
        justify-content: center;
    }

    .controls-center {
        order: -1; /* Move title to top */
    }

    h1 {
        font-size: 1.6em;
    }

    #game-message {
        font-size: 1.3rem;
    }
}

/* Phone breakpoint */
@media (max-width: 480px) {
    .container {
        padding: 12px 0;
    }

    #game-controls {
        padding: 4px;
        gap: 8px;
    }

    #difficulty-select {
        gap: 6px; /* Slightly reduced gap between label and dropdown */
    }

    h1 {
        font-size: 1.4em;
    }

    #game-message {
        font-size: 1.2rem;
    }

    .controls-right {
        gap: 8px;
    }
}

#restart-btn {
    background: #ffb347;
    color: #222;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 1em;
    cursor: pointer;
    transition: background 0.2s;
}

#difficulty-select {
    display: flex;
    align-items: center;
    gap: 6px;
}
#difficulty-select label {
    color: #f8f8f8;
    font-size: 1em;
    font-weight: 500;
}
#difficulty-select select {
    background: #444;
    color: #ffb347;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 1em;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}
#difficulty-select select:focus {
    background: #555;
}
#restart-btn:hover {
    background: #ff8800;
}

#board-svg {
    display: block;
    margin: 0 auto;
    background: #222;
    border-radius: 8px;
    padding: 8px;
    touch-action: pan-x pan-y;
    min-width: min-content;
}

/* Responsive wrapper for the board */
#board-wrapper {
    width: 100%;
    overflow: auto;
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    min-width: 0;
}

.cell {
    width: 32px;
    height: 32px;
    background: #444;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15em;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}
.cell.revealed {
    background: #e0e0e0;
    color: #333;
    cursor: default;
}
.cell.mine {
    background: #e74c3c;
    color: #fff;
}
.cell.mine-win {
    background: linear-gradient(135deg, #6ee07a 60%, #27ae60 100%);
    color: #fff;
    box-shadow: 0 0 6px 2px #27ae6080;
    font-weight: bold;
}
.cell.flagged {
    background: #ffd700;
    color: #222;
}
#game-message {
    display: inline-block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffe082;
    letter-spacing: 1px;
    text-shadow: 1px 1px 6px #000;
    text-align: left;
    white-space: nowrap;
    margin: 0;
}
