* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --accent-blue: #3498db;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    --accent-orange: #f39c12;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Загрузочный экран */
.loader-screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: var(--bg-primary) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    margin: 0 !important;
    padding: 0 !important;
}

.loader-screen.hidden {
    display: none !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(205, 74, 127, 0.2);
    border-top-color: #CD4A7F;
    border-right-color: #EC5866;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: block;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loader-text {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    display: block !important;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.screen {
    display: none !important;
    width: 100%;
    height: 100%;
    max-width: 400px;
    max-height: 600px;
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Меню */
.menu-container {
    text-align: center;
    width: 100%;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 16px;
    padding: 28px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(205, 74, 127, 0.1);
    position: relative;
    z-index: 2;
    border: 1px solid rgba(205, 74, 127, 0.2);
    overflow: hidden;
}

.menu-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #CD4A7F 0%, #EC5866 100%);
    z-index: 1;
}

.menu-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(205, 74, 127, 0.3);
    position: relative;
    z-index: 2;
}

.menu-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(205, 74, 127, 0.5));
    transition: transform 0.3s ease;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-5px);
    }
}

.title {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #CD4A7F 0%, #EC5866 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    margin: 0;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(205, 74, 127, 0.3);
    position: relative;
}

.menu-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(205, 74, 127, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.menu-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-link {
    color: var(--text-secondary);
    font-size: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.menu-link:hover {
    color: var(--accent-blue);
    opacity: 1;
    text-decoration: underline;
}

.menu-link-separator {
    color: var(--text-secondary);
    font-size: 10px;
    opacity: 0.5;
}

.version-text {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    opacity: 0.6;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.difficulty-btn {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(45, 45, 45, 0.8) 100%);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(205, 74, 127, 0.1), transparent);
    transition: left 0.5s ease;
}

.difficulty-btn:hover::before {
    left: 100%;
}

.difficulty-btn:hover {
    background: linear-gradient(135deg, #353535 0%, #3a3a3a 100%);
    border-color: var(--accent-blue);
    transform: translateX(4px) scale(1.02);
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.3), 0 0 0 1px rgba(52, 152, 219, 0.2);
}

.difficulty-btn:active {
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
}

.btn-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.btn-content {
    flex: 1;
    text-align: left;
}

.btn-title {
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-primary);
    font-size: 14px;
}

.btn-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Игровое поле */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 2;
}

.game-info {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.info-item {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.info-label {
    margin-right: 6px;
    color: var(--text-secondary);
}

.new-game-btn {
    background: var(--accent-blue);
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.new-game-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.new-game-btn:active {
    transform: translateY(0);
}

.board-container {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    max-width: 100%;
    position: relative;
    z-index: 2;
}

#board {
    display: grid;
    gap: 2px;
    background: var(--bg-tertiary);
    padding: 2px;
    border-radius: 6px;
}

.cell {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    position: relative;
    z-index: 5;
    pointer-events: auto;
}

.cell:hover:not(.revealed):not(.flagged) {
    background: #353535;
    border-color: var(--accent-blue);
}

.cell:active:not(.revealed):not(.flagged) {
    transform: scale(0.95);
}

.cell.revealed {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    cursor: default;
}

.cell.flagged {
    background: #3d2e1f;
    border-color: var(--accent-orange);
}

.cell.mine {
    background: #3d1f1f;
    border-color: var(--accent-red);
}

.cell-number-1 { color: #3498db; }
.cell-number-2 { color: #2ecc71; }
.cell-number-3 { color: #e74c3c; }
.cell-number-4 { color: #9b59b6; }
.cell-number-5 { color: #f39c12; }
.cell-number-6 { color: #1abc9c; }
.cell-number-7 { color: #95a5a6; }
.cell-number-8 { color: #7f8c8d; }

.game-status {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    min-height: 20px;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
}

.game-status.won {
    color: var(--accent-green);
}

.game-status.lost {
    color: var(--accent-red);
}

/* Результат */
.result-container {
    text-align: center;
    max-width: 350px;
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px 16px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 2;
}

.result-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.result-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.result-title.won {
    color: var(--accent-green);
}

.result-title.lost {
    color: var(--accent-red);
}

.result-stats {
    font-size: 12px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.play-again-btn {
    background: var(--accent-blue);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.play-again-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.play-again-btn:active {
    transform: translateY(0);
}

/* Адаптивность для мобильных */
@media (max-width: 600px) {
    .cell {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        font-size: 14px;
    }
    
    .title {
        font-size: 32px;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .game-info {
        justify-content: space-between;
        width: 100%;
    }
    
    .new-game-btn {
        width: 100%;
    }
    
    .menu-container {
        padding: 32px 20px;
    }
    
    .result-container {
        padding: 32px 20px;
    }
    
    .loader-spinner {
        width: 40px;
        height: 40px;
    }
    
    .menu-icon {
        width: 40px;
        height: 40px;
    }
    
    .title {
        font-size: 32px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 400px) {
    .cell {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        font-size: 12px;
    }
    
    .title {
        font-size: 28px;
    }
    
    .menu-icon {
        width: 36px;
        height: 36px;
    }
    
    .loader-spinner {
        width: 35px;
        height: 35px;
    }
}
