:root {
    --primary: #ef4444;
    --primary-light: #f87171;
    --accent: #f97316;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --cell-size: 32px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    color: var(--text-light);
    background-color: var(--bg-dark);
}

.ms-game-container {
    max-width: 95%;
    width: fit-content;
    margin: 80px auto 20px auto;
    padding: 24px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    position: relative;
    min-width: 320px;
}

.ms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.ms-header h1 {
    margin: 0;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ms-game-icon-small {
    width: 32px;
    height: 32px;
}

.ms-back-btn {
    padding: 10px 20px;
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    color: var(--text-light);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-back-btn:hover {
    background: rgba(51, 65, 85, 0.8);
    transform: translateX(-5px);
}

.ms-game-info {
    display: flex;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.6);
    padding: 15px 25px;
    border-radius: 18px;
    margin-bottom: 24px;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    font-size: 1.2rem;
}

.ms-stats {
    display: flex;
    gap: 30px;
    width: 100%;
    justify-content: space-around;
}

.ms-grid {
    display: grid;
    background: #334155;
    gap: 2px;
    padding: 2px;
    border-radius: 12px;
    margin: 0 auto;
    user-select: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    overflow-x: auto;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: #475569;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.1s;
    border-radius: 4px;
}

.cell.revealed {
    background: #e2e8f0;
    color: #1e293b;
    cursor: default;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.1);
}

.cell.revealed.mine {
    background: var(--primary);
}

.cell.flagged {
    color: white;
}

.cell:hover:not(.revealed) {
    background: #64748b;
    transform: scale(0.95);
}

/* Number colors */
.cell[data-num="1"] {
    color: #2563eb;
}

.cell[data-num="2"] {
    color: #16a34a;
}

.cell[data-num="3"] {
    color: #dc2626;
}

.cell[data-num="4"] {
    color: #1e3a8a;
}

.cell[data-num="5"] {
    color: #7c2d12;
}

.cell[data-num="6"] {
    color: #0891b2;
}

.cell[data-num="7"] {
    color: #111;
}

.cell[data-num="8"] {
    color: #4b5563;
}

.ms-controls {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 24px;
}

.ms-control-btn {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    background: #334155;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.ms-control-btn:hover {
    transform: translateY(-3px);
    background: #475569;
}

.ms-control-btn.active {
    background: var(--primary);
    box-shadow: 0 10px 20px -5px rgba(239, 68, 68, 0.4);
    border-color: var(--primary-light);
}

.ms-modal,
.ms-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 24px;
    animation: fadeIn 0.3s ease-out;
}

.ms-modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 32px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    border: 1px solid var(--glass-border);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
}

.ms-input-group {
    margin-bottom: 24px;
    text-align: left;
}

.ms-input-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.ms-input-group input,
.ms-input-group select {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.ms-input-group input:focus,
.ms-input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.ms-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
    border-radius: 18px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.4);
    transition: all 0.3s ease;
}

.ms-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(239, 68, 68, 0.5);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    :root {
        --cell-size: 28px;
    }

    .ms-game-container {
        padding: 16px;
        margin: 80px 10px;
    }

    .ms-game-info {
        padding: 10px 15px;
        font-size: 1rem;
    }

    .cell {
        font-size: 1rem;
    }
}