/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
    color: #fff;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* Settings Screen */
.settings-container {
    max-width: 600px;
    margin: auto;
    padding: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    text-align: center;
}

.settings-container h1 {
    font-size: 3.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.settings-container h2 {
    font-size: 2rem;
    margin-bottom: 40px;
    font-weight: normal;
    opacity: 0.9;
}

.setting-group {
    margin-bottom: 30px;
}

.setting-group > label {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.setting-btn {
    padding: 15px 25px;
    font-size: 1.2rem;
    border: 3px solid #fff;
    background: transparent;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
    min-height: 60px;
}

.setting-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.setting-btn.active {
    background: #fff;
    color: #2c3e50;
    font-weight: bold;
}

.custom-settings {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.custom-settings.hidden {
    display: none;
}

.custom-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.custom-row label {
    font-size: 1.3rem;
    min-width: 100px;
    text-align: right;
}

.custom-row input {
    width: 100px;
    padding: 12px;
    font-size: 1.3rem;
    border: 2px solid #fff;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    text-align: center;
}

.difficulty-info {
    margin: 20px 0;
    font-size: 1.3rem;
    opacity: 0.9;
}

.primary-btn {
    margin-top: 20px;
    padding: 20px 50px;
    font-size: 1.8rem;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    min-height: 70px;
    display: block;
    width: 100%;
    text-decoration: none;
    text-align: center;
}

.primary-btn:hover {
    background: #c0392b;
    transform: scale(1.03);
    box-shadow: 0 5px 20px rgba(231, 76, 60, 0.5);
}

.primary-btn:focus {
    outline: 4px solid #f39c12;
    outline-offset: 3px;
}

.secondary-btn {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid #fff;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.03);
    box-shadow: none;
}

.rules-summary {
    background: rgba(255,255,255,0.1); border-radius: 12px;
    padding: 18px 22px; margin: 20px 0; text-align: left;
}
.rules-summary h3 { font-size: 1.3rem; margin-bottom: 10px; }
.rules-summary ul { list-style: none; }
.rules-summary li { font-size: 1.05rem; padding: 5px 0; opacity: 0.9; }
.rules-summary li::before { content: '• '; color: #f39c12; font-weight: bold; }

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.header-left h1 {
    font-size: 2rem;
}

.counters {
    display: flex;
    gap: 20px;
}

.counter {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 100px;
    text-align: center;
}

.header-right {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 15px 25px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    min-height: 55px;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}

.action-btn:hover {
    background: #fff;
    transform: scale(1.05);
}

a.action-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Header Center - Tool Selector */
.header-center {
    display: flex;
    gap: 15px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 55px;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.tool-btn.active {
    background: #fff;
    color: #2c3e50;
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.5);
}

.tool-icon {
    font-size: 1.5rem;
}

.tool-label {
    font-weight: bold;
}

/* Game Area */
.game-area {
    flex: 1;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
}

/* Grid */
.grid {
    display: grid;
    gap: 4px;
    background: #7f8c8d;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Cells */
.cell {
    width: 55px;
    height: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
}

.cell.hidden {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    border: 3px solid;
    border-color: #bdc3c7 #6c7a7d #6c7a7d #bdc3c7;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}

.cell.hidden:hover {
    background: linear-gradient(145deg, #a3b1b3, #8d9a9c);
    transform: scale(1.05);
}

.cell.revealed {
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    cursor: default;
}

.cell.revealed:hover {
    transform: none;
}

.cell.flagged {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    border: 3px solid;
    border-color: #f5b041 #d35400 #d35400 #f5b041;
}

.cell.mine {
    background: #e74c3c;
    border: 2px solid #c0392b;
}

.cell.mine-clicked {
    background: #c0392b;
    border: 2px solid #922b21;
}

/* Number colors */
.cell[data-number="1"] { color: #3498db; }
.cell[data-number="2"] { color: #27ae60; }
.cell[data-number="3"] { color: #e74c3c; }
.cell[data-number="4"] { color: #8e44ad; }
.cell[data-number="5"] { color: #c0392b; }
.cell[data-number="6"] { color: #16a085; }
.cell[data-number="7"] { color: #2c3e50; }
.cell[data-number="8"] { color: #7f8c8d; }

/* Result Screens */
.result-container {
    max-width: 500px;
    margin: auto;
    padding: 60px;
    border-radius: 20px;
    text-align: center;
}

.result-container.win {
    background: rgba(39, 174, 96, 0.9);
}

.result-container.lose {
    background: rgba(192, 57, 43, 0.9);
}

.result-container h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.result-container p {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 1100px) {
    .game-header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .header-left,
    .header-center,
    .header-right {
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .game-header {
        justify-content: center;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .header-center {
        width: 100%;
        justify-content: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .cell {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }

    .tool-btn {
        padding: 10px 20px;
    }
}

@media (max-width: 600px) {
    .cell {
        width: 38px;
        height: 38px;
        font-size: 1.3rem;
    }

    .settings-container {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
        align-items: center;
    }
}
