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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    line-height: 1.6;
    min-height: 100vh;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
}

.back-link {
    display: inline-block;
    color: #4ecca3;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.back-link:hover {
    text-decoration: underline;
}

h1 {
    text-align: center;
    color: #f5b942;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.difficulty-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 2px solid #2a2a3e;
    border-radius: 4px;
    cursor: pointer;
}

.difficulty-btn:hover {
    border-color: #f5b942;
}

.difficulty-btn.active {
    background: #f5b942;
    color: #0f0f1a;
    border-color: #f5b942;
    font-weight: 600;
}

.status-bar {
    display: flex;
    gap: 2rem;
    font-size: 1.1rem;
}

.status-bar strong {
    color: #f5b942;
    font-variant-numeric: tabular-nums;
}

.grid-wrapper {
    position: relative;
}

.grid {
    display: grid;
    gap: 2px;
    background: #1a1a2e;
    padding: 8px;
    border-radius: 8px;
    border: 2px solid #f5b942;
    min-width: min-content;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border-radius: 3px;
    background: #3a3a4e;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.grid[data-difficulty="easy"] .cell {
    width: 30px;
    font-size: 0.9rem;
}

.grid[data-difficulty="medium"] .cell {
    width: 26px;
    font-size: 0.8rem;
}

.grid[data-difficulty="hard"] .cell {
    width: 22px;
    font-size: 0.7rem;
}

.cell:hover:not(.revealed) {
    background: #4a4a5e;
}

.cell.revealed {
    background: #2a2a3e;
    cursor: default;
}

.cell.mine {
    background: #c0392b;
}

.cell.flagged {
    background: #3a3a4e;
}

.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; }

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 26, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    border-radius: 8px;
    z-index: 10;
}

.overlay.hidden {
    display: none;
}

.overlay p {
    font-size: 1.5rem;
    color: #f5b942;
}

.overlay p:first-child {
    font-size: 2rem;
}

.overlay button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    background: #f5b942;
    color: #0f0f1a;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.overlay button:hover {
    background: #e5a932;
}

.overlay .share-btn {
    background: #4ecca3;
    margin-top: 0.5rem;
}

.overlay .share-btn:hover {
    background: #3db892;
}

.instructions {
    font-size: 0.9rem;
    color: #888;
    text-align: center;
    max-width: 400px;
}

.content {
    padding-top: 1rem;
    border-top: 1px solid #2a2a3e;
}

.content h2 {
    color: #f5b942;
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
}

.content h2:first-child {
    margin-top: 1rem;
}

.content p {
    margin-bottom: 0.75rem;
}

.content ul {
    margin: 0.5rem 0 1rem 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content a {
    color: #f5b942;
}

.content a:hover {
    text-decoration: none;
}

@media (min-width: 600px) {
    main {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .instructions {
        font-size: 1rem;
    }
}
