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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #636e72 0%, #2d3436 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* ==================== Page Layout with Sidebars ==================== */
.page-wrapper {
    display: grid;
    grid-template-columns: 160px 1fr 160px;
    gap: 20px;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.sidebar {
    min-height: 100vh;
}

.sidebar-left,
.sidebar-right {
    display: flex;
    align-items: flex-start;
    padding-top: 80px;
}

.sticky-ad {
    position: sticky;
    top: 20px;
    width: 160px;
    min-height: 600px;
}

.main-content {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

/* Responsive: Hide sidebars on tablets and mobile */
@media (max-width: 1024px) {
    .page-wrapper {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .sidebar {
        display: none;
    }
}

.container {
    max-width: 800px;
    width: 100%;
}

.header {
    text-align: center;
    position: relative;
    margin-bottom: 30px;
}

.back-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.title {
    color: white;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.difficulty-select {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.difficulty-select:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.info-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.info-box.highlight {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
    opacity: 0.8;
}

.info-box.highlight .label {
    opacity: 1;
}

.value {
    font-size: 24px;
    font-weight: bold;
}

.instructions {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 14px;
    opacity: 0.9;
}

.game-board {
    display: inline-grid;
    gap: 2px;
    background: #2d3436;
    padding: 4px;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.board-grid {
    display: inline-grid;
    gap: 2px;
}

/* Grid sizes for different difficulties */
.board-grid.easy {
    grid-template-columns: repeat(8, 35px);
    grid-template-rows: repeat(8, 35px);
}

.board-grid.medium {
    grid-template-columns: repeat(12, 32px);
    grid-template-rows: repeat(12, 32px);
}

.board-grid.hard {
    grid-template-columns: repeat(16, 28px);
    grid-template-rows: repeat(16, 28px);
}

.cell {
    background: #95a5a6;
    border: 2px solid #7f8c8d;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    user-select: none;
    transition: all 0.1s ease;
    position: relative;
}

.cell:hover:not(.revealed):not(.flagged) {
    background: #a8b9ba;
    transform: scale(0.95);
}

.cell.revealed {
    background: #ecf0f1;
    border-color: #bdc3c7;
    cursor: default;
    transform: scale(1);
}

.cell.revealed:hover {
    transform: scale(1);
}

.cell.flagged {
    background: #e74c3c;
    border-color: #c0392b;
}

.cell.mine {
    background: #2c3e50;
}

.cell.mine-hit {
    background: #e74c3c;
    animation: explode 0.3s ease;
}

@keyframes explode {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Number colors */
.cell[data-number="1"] {
    color: #0984e3;
}

.cell[data-number="2"] {
    color: #00b894;
}

.cell[data-number="3"] {
    color: #e74c3c;
}

.cell[data-number="4"] {
    color: #6c5ce7;
}

.cell[data-number="5"] {
    color: #d63031;
}

.cell[data-number="6"] {
    color: #00cec9;
}

.cell[data-number="7"] {
    color: #2d3436;
}

.cell[data-number="8"] {
    color: #636e72;
}

.controls {
    text-align: center;
    margin-top: 20px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.start-btn {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
}

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.game-over-overlay.show {
    display: flex;
}

.game-over-content {
    background: linear-gradient(135deg, #636e72 0%, #2d3436 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    animation: popIn 0.3s ease forwards;
}

@keyframes popIn {
    to {
        transform: scale(1);
    }
}

.game-over-title {
    color: white;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-over-title.win {
    color: #00b894;
}

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

.final-score {
    color: white;
    font-size: 1.5em;
    margin-bottom: 10px;
}

.best-time {
    color: #ffd700;
    font-size: 1.2em;
    margin-bottom: 20px;
    font-weight: bold;
}

.play-again-btn {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Responsive design */
@media (max-width: 768px) {
    .title {
        font-size: 2em;
    }

    .board-grid.easy {
        grid-template-columns: repeat(8, 30px);
        grid-template-rows: repeat(8, 30px);
    }

    .board-grid.medium {
        grid-template-columns: repeat(12, 26px);
        grid-template-rows: repeat(12, 26px);
    }

    .board-grid.hard {
        grid-template-columns: repeat(16, 22px);
        grid-template-rows: repeat(16, 22px);
    }

    .cell {
        font-size: 14px;
    }
}
