/* ============================================
   GLOBAL STYLES
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a0f2e 100%);
    position: relative;
}

.container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    position: relative;
    z-index: 1;
    animation: slideUp 0.8s ease-out;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.header-content {
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.title {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    line-height: 1.2;
}

.title-icon {
    display: inline-block;
    animation: bounce 1s ease-in-out infinite;
    flex-shrink: 0;
    font-size: 1.2em;
    line-height: 1;
}

.title-text {
    white-space: nowrap;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    font-weight: var(--font-weight-light);
    letter-spacing: 0.5px;
    margin: 0;
    padding: 0;
    text-align: center;
}

/* ============================================
   GAME CONTAINER
   ============================================ */

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* ============================================
   DIFFICULTY SECTION - NOW AT TOP
   ============================================ */

.difficulty-section {
    animation: slideUp 0.8s ease-out 0s both;
    width: 100%;
    display: flex;
    justify-content: center;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    max-width: 450px;
    width: 100%;
}

.difficulty-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: center;
    text-align: center;
}

.difficulty-btn:hover {
    border-color: var(--primary-light);
    background: rgba(30, 41, 59, 0.8);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

.difficulty-btn.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.difficulty-label {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
}

.difficulty-info {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

/* ============================================
   GAME STATS - MOVED BELOW DIFFICULTY
   ============================================ */

.game-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.8s ease-out 0.1s both;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.stat-item {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md) var(--spacing-sm);
    text-align: center;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-item:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.1));
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
    height: 20px;
    display: flex;
    align-items: center;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: var(--font-mono);
    letter-spacing: 1px;
}

/* ============================================
   BOARD SECTION
   ============================================ */

.board-section {
    animation: slideUp 0.8s ease-out 0.2s both;
    width: 100%;
    display: flex;
    justify-content: center;
}

.board-wrapper {
    padding: var(--spacing-lg);
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(99, 102, 241, 0.4);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), 0 0 40px rgba(99, 102, 241, 0.1);
    transition: all var(--transition-base);
}

.board-wrapper:hover {
    border-color: var(--primary-color);
    box-shadow: 0 20px 70px rgba(99, 102, 241, 0.3), 0 0 50px rgba(99, 102, 241, 0.15);
}

.board {
    display: grid;
    gap: 4px;
    width: fit-content;
    margin: 0 auto;
}

/* ============================================
   CELLS
   ============================================ */

.cell {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.cell:hover:not(.revealed):not(.flagged) {
    transform: translateY(-2px);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), 0 8px 16px rgba(99, 102, 241, 0.3);
}

.cell:active:not(.revealed) {
    animation: buttonClick 0.2s ease-out;
}

.cell.revealed {
    background: linear-gradient(135deg, #1a1f3a 0%, #0f1629 100%);
    cursor: default;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.cell.flagged {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(236, 72, 153, 0.4);
    animation: flagWave 0.5s ease-in-out;
}

.cell.mine {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.1));
    animation: mineExplode 0.6s ease-out;
}

.cell.mine-initial-crack {
    animation: mineInitialCrack 0.6s cubic-bezier(0.36, 0, 0.66, -0.56) forwards !important;
}

.cell.mine-chain-reaction {
    animation: mineChainReaction 0.5s ease-out forwards !important;
}

.cell.mine-exploding {
    background: radial-gradient(circle, #fbbf24, #ff6b00, #ef4444) !important;
    animation: mineFlash 0.6s ease-out forwards !important;
}

.cell.empty {
    color: transparent;
}

/* Number Colors */
.cell[data-neighbors="1"] {
    color: #3b82f6;
}

.cell[data-neighbors="2"] {
    color: #10b981;
}

.cell[data-neighbors="3"] {
    color: #f59e0b;
}

.cell[data-neighbors="4"] {
    color: #8b5cf6;
}

.cell[data-neighbors="5"] {
    color: #ef4444;
}

.cell[data-neighbors="6"] {
    color: #06b6d4;
}

.cell[data-neighbors="7"] {
    color: #ec4899;
}

.cell[data-neighbors="8"] {
    color: #6366f1;
}

/* ============================================
   CONTROLS SECTION
   ============================================ */

.controls-section {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    animation: slideUp 0.8s ease-out 0.3s both;
    margin-top: var(--spacing-md);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: var(--primary-color);
    color: var(--primary-light);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* ============================================
   GAME STATUS
   ============================================ */

.game-status {
    animation: slideUp 0.8s ease-out 0.4s both;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: var(--spacing-md);
}

.status-content {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg) var(--spacing-xl);
    text-align: center;
    max-width: 420px;
    width: 100%;
    transition: all var(--transition-base);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.status-content.victory {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    animation: celebrate 0.6s ease-in-out;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.3);
}

.status-content.defeat {
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.3);
}

.status-icon {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-sm);
    animation: bounce 0.8s ease-in-out infinite;
}

.status-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md);
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    position: relative;
    z-index: 1;
    margin-top: auto;
}

.heart {
    display: inline-block;
    animation: celebrate 0.8s ease-in-out infinite;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .title {
        font-size: var(--font-size-3xl);
    }

    .cell {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-sm);
    }

    .board-wrapper {
        padding: var(--spacing-md);
    }

    .game-container {
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }

    .controls-section {
        gap: var(--spacing-sm);
    }

    .btn {
        padding: var(--spacing-md) var(--spacing-md);
        font-size: var(--font-size-sm);
    }

    .difficulty-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-sm);
    }

    .game-stats {
        gap: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .title {
        font-size: var(--font-size-2xl);
    }

    .cell {
        width: 28px;
        height: 28px;
        font-size: var(--font-size-xs);
    }

    .difficulty-buttons {
        grid-template-columns: 1fr;
    }

    .controls-section {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .header {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .game-container {
        padding: var(--spacing-md);
    }
}

/* ============================================
   CELEBRATION & CONFETTI STYLES
   ============================================ */

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    top: -10px;
}

.confetti.rect {
    background: linear-gradient(45deg, #6366f1, #ec4899);
}

.confetti.circle {
    border-radius: 50%;
    background: #10b981;
}

.confetti.star {
    background: #f59e0b;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.confetti.heart {
    background: #ef4444;
}

.firework {
    position: fixed;
    width: 4px;
    height: 4px;
    pointer-events: none;
    background: radial-gradient(circle, #fbbf24, #f59e0b);
    border-radius: 50%;
}

.celebration-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 1001;
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.8),
                 0 0 40px rgba(236, 72, 153, 0.6);
    animation: celebrationRise 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.celebration-text-1 {
    animation: victoryTextFloat 2s ease-out forwards;
    position: fixed;
    font-size: 3rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

.celebration-text-2 {
    animation: victoryTextFloat 2.2s ease-out 0.2s forwards;
    position: fixed;
    font-size: 2.5rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

.celebration-text-3 {
    animation: victoryTextFloat 2.4s ease-out 0.4s forwards;
    position: fixed;
    font-size: 2rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

.celebration-active {
    animation: victoryShake 0.8s ease-out;
}

.board.celebration-active {
    animation: boardRotate 0.8s ease-out;
}

/* Victory status enhancement */
.status-content.victory {
    animation: celebrate 0.6s ease-in-out, victoryGlow 2s ease-out;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
}

.status-content.victory .status-text {
    animation: textSparkle 1.5s ease-in-out infinite;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    body {
        background: white;
    }

    .container {
        background: white;
    }

    .btn, .controls-section {
        display: none;
    }
}
