:root {
    --bg-primary: #2c3e50;
    --bg-secondary: #34495e;
    --bg-cell: #ecf0f1;
    --bg-cell-revealed: #bdc3c7;
    --bg-cell-hover: #d5dbdb;
    --text-primary: #2c3e50;
    --text-secondary: #ecf0f1;
    --border-color: #7f8c8d;
    --mine-color: #e74c3c;
    --flag-color: #e67e22;
    --number-1: #3498db;
    --number-2: #27ae60;
    --number-3: #e74c3c;
    --number-4: #8e44ad;
    --number-5: #f39c12;
    --number-6: #1abc9c;
    --number-7: #2c3e50;
    --number-8: #95a5a6;
    --shadow: rgba(0, 0, 0, 0.2);
    --shadow-hover: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 480px;
    max-height: 600px;
    height: 600px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 4px 20px var(--shadow);
    overflow: hidden;
}

.game-header {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.game-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-secondary);
    text-shadow: 2px 2px 4px var(--shadow);
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.btn {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-secondary);
    box-shadow: 0 2px 8px var(--shadow);
}

.btn-primary {
    background: #27ae60;
    color: white;
}

.btn-primary:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

.btn:focus {
    outline: 2px solid var(--text-secondary);
    outline-offset: 2px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 14px;
}

.mine-counter {
    display: flex;
    gap: 8px;
    align-items: center;
}

.info-label {
    font-weight: 600;
}

.info-value {
    font-weight: 700;
    color: var(--flag-color);
    min-width: 30px;
    text-align: right;
}

.status-message {
    flex: 1;
    text-align: right;
    font-weight: 500;
}

#status-text {
    color: var(--text-secondary);
}

.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 0;
    max-height: 100%;
}

.game-board {
    display: grid;
    gap: 1px;
    background: var(--border-color);
    padding: 1px;
    border-radius: 4px;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 15 / 14;
    max-height: 100%;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(14, 1fr);
}

.game-board:focus {
    outline: 2px solid var(--text-secondary);
    outline-offset: 4px;
}

.cell {
    background: var(--bg-cell);
    border: none;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: clamp(11px, 2.2vw, 14px);
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1;
}

.cell:hover:not(.cell--revealed):not(.cell--flag) {
    background: var(--bg-cell-hover);
    transform: scale(0.95);
}

.cell:active:not(.cell--revealed):not(.cell--flag) {
    transform: scale(0.9);
    background: var(--bg-cell-revealed);
}

.cell--revealed {
    background: var(--bg-cell-revealed);
    cursor: default;
}

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

.cell--mine {
    background: var(--mine-color);
    color: white;
}

.cell--mine::after {
    content: '💣';
    font-size: 80%;
}

.cell--flag {
    background: var(--flag-color);
    cursor: pointer;
}

.cell--flag::after {
    content: '🚩';
    font-size: 80%;
}

.cell--number {
    color: var(--text-primary);
    font-weight: 800;
}

.cell--number-1 {
    color: var(--number-1);
}

.cell--number-2 {
    color: var(--number-2);
}

.cell--number-3 {
    color: var(--number-3);
}

.cell--number-4 {
    color: var(--number-4);
}

.cell--number-5 {
    color: var(--number-5);
}

.cell--number-6 {
    color: var(--number-6);
}

.cell--number-7 {
    color: var(--number-7);
}

.cell--number-8 {
    color: var(--number-8);
}

.cell--focused {
    outline: 2px solid var(--text-secondary);
    outline-offset: -2px;
    z-index: 1;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .game-container {
        max-width: 100%;
        max-height: 100vh;
        padding: 12px;
        border-radius: 8px;
    }

    .game-title {
        font-size: 24px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 16px;
    }

    .game-info {
        font-size: 13px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .status-message {
        width: 100%;
        text-align: center;
    }

    .game-board {
        gap: 1px;
        padding: 1px;
    }

    .cell {
        font-size: clamp(10px, 3vw, 14px);
    }
}

/* Prevent text selection on mobile */
@media (max-width: 768px) {
    .cell {
        -webkit-touch-callout: none;
    }
}

/* Accessibility: screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

