:root {
    --wb-purple: #cb11ab;
    --wb-purple-glow: rgba(203, 17, 171, 0.4);
    --wb-purple-dark: #8c0a76;
    --bg-dark: #0a0a14;
    --card-bg: rgba(22, 22, 38, 0.85);
    --card-border: rgba(203, 17, 171, 0.25);
    --cell-unrevealed: #282840;
    --cell-unrevealed-hover: #373756;
    --cell-revealed: #141424;
    --cell-border: #1e1e32;
    --accent-fire: #ff4500;
    --accent-gold: #ffb703;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-heading);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 20px 10px;
}

/* Background Ambient Glow */
.background-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 20%, rgba(203, 17, 171, 0.18) 0%, transparent 65%),
                radial-gradient(circle at 80% 80%, rgba(255, 69, 0, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Wildberries Warehouse Fire Backdrop */
.fire-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.fire-backdrop.hidden {
    opacity: 0;
}

.fire-bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.7) contrast(1.25) saturate(1.2);
    animation: zoomPulse 10s infinite alternate ease-in-out;
}

@keyframes zoomPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

.fire-overlay-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 69, 0, 0.25) 0%, rgba(10, 10, 20, 0.85) 85%);
}

/* Explosive Canvas Overlay */
#explosionCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999;
}

/* Screen Shake Effect */
body.shake {
    animation: shakeAnim 0.6s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeAnim {
    10%, 90% { transform: translate3d(-3px, 1px, 0); }
    20%, 80% { transform: translate3d(5px, -3px, 0); }
    30%, 50%, 70% { transform: translate3d(-7px, 5px, 0); }
    40%, 60% { transform: translate3d(7px, -5px, 0); }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 960px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 15px var(--wb-purple-glow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    border: 1.5px solid var(--wb-purple);
    box-shadow: 0 0 12px var(--wb-purple-glow);
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-title {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #fff, #f4a2ec);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-select {
    background: transparent;
    color: var(--text-main);
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

.custom-select option {
    background: #181829;
    color: #fff;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--wb-purple);
    box-shadow: 0 0 10px var(--wb-purple);
}

/* Game Card Console */
.game-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.card-toolbar {
    width: 100%;
    display: flex;
    justify-content: center;
}

.difficulty-picker {
    display: flex;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 4px;
}

.diff-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diff-btn.active, .diff-btn:hover {
    background: var(--wb-purple);
    color: #fff;
    box-shadow: 0 0 10px var(--wb-purple-glow);
}

/* Scoreboard LCD Bar */
.scoreboard-bar {
    width: 100%;
    max-width: 520px;
    background: #0d0d18;
    border: 2px solid rgba(203, 17, 171, 0.4);
    border-radius: 14px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
}

.lcd-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #05050a;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.lcd-icon {
    font-size: 1.2rem;
}

.lcd-digital {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    color: #ff0055;
    text-shadow: 0 0 8px rgba(255, 0, 85, 0.6);
    letter-spacing: 2px;
}

.status-face-btn {
    background: radial-gradient(circle, #0057b7 0%, #0a0a1a 100%);
    border: 2px solid #ffd700;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4), inset 0 0 10px rgba(0, 87, 183, 0.5);
}

.status-face-btn:hover {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.7), inset 0 0 12px rgba(0, 87, 183, 0.8);
    transform: scale(1.05);
}

.status-face-btn:active {
    transform: scale(0.92);
}

#faceIcon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#faceIcon svg {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s ease;
}

/* Board Wrapper & Grid */
.board-wrapper {
    width: 100%;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.board-grid {
    display: grid;
    gap: 4px;
    background: #0c0c16;
    padding: 12px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
}

/* Cell Styling */
.cell {
    width: 36px;
    height: 36px;
    background: var(--cell-unrevealed);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-top-color: rgba(255, 255, 255, 0.18);
    border-left-color: rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cell:hover:not(.revealed):not(.flagged) {
    background: var(--cell-unrevealed-hover);
    border-color: var(--wb-purple);
    transform: translateY(-1px);
}

.cell:active:not(.revealed):not(.flagged) {
    transform: translateY(1px);
}

.cell.revealed {
    background: var(--cell-revealed);
    border-color: var(--cell-border);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
    cursor: default;
}

.cell.flagged {
    color: #ff3366;
}

.cell.mine-hit {
    background: radial-gradient(circle, #ff0000 0%, #8b0000 100%) !important;
    animation: pulseHit 0.5s infinite alternate;
}

@keyframes pulseHit {
    0% { box-shadow: 0 0 5px #ff0000; }
    100% { box-shadow: 0 0 20px #ff4500; }
}

.cell.mine-revealed {
    background: #2a0815;
}

/* Cell Number Colors */
.cell-1 { color: #38bdf8; text-shadow: 0 0 6px rgba(56, 189, 248, 0.4); }
.cell-2 { color: #4ade80; text-shadow: 0 0 6px rgba(74, 222, 128, 0.4); }
.cell-3 { color: #f87171; text-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }
.cell-4 { color: #c084fc; text-shadow: 0 0 6px rgba(192, 132, 252, 0.4); }
.cell-5 { color: #fbbf24; text-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
.cell-6 { color: #2dd4bf; text-shadow: 0 0 6px rgba(45, 212, 191, 0.4); }
.cell-7 { color: #f43f5e; text-shadow: 0 0 6px rgba(244, 63, 94, 0.4); }
.cell-8 { color: #ffffff; text-shadow: 0 0 6px rgba(255, 255, 255, 0.8); }

/* Card Footer / Legend */
.card-footer {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* Stats Panel */
.stats-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px 24px;
}

.stats-panel h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
    color: var(--wb-purple);
    font-weight: 800;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Modal Backdrops & Cards */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 12, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: #141424;
    border-radius: 20px;
    padding: 24px 30px;
    width: 92%;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.loss-theme {
    border: 2px solid #ff4500;
    box-shadow: 0 0 35px rgba(255, 69, 0, 0.6);
}

.win-theme {
    border: 2px solid var(--wb-purple);
    box-shadow: 0 0 35px var(--wb-purple-glow);
}

.modal-fire-image-wrapper {
    position: relative;
    width: 100%;
    height: 190px;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 69, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.4);
}

.modal-fire-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.95) contrast(1.15);
}

.modal-fire-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #ff4500;
    border: 1px solid #ff4500;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    white-space: nowrap;
}

.modal-win-icon {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 10px;
}

.loss-theme h2 { color: #ff4500; }
.win-theme h2 { color: var(--wb-purple); }

.modal-card p {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

.victory-stats {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn-primary-fire {
    background: linear-gradient(135deg, #ff4500 0%, #b30000 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.6);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.btn-primary-win {
    background: linear-gradient(135deg, var(--wb-purple) 0%, #ff007f 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 0 15px var(--wb-purple-glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.btn-primary-fire:hover, .btn-primary-win:hover {
    transform: translateY(-2px);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .main-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .header-controls {
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cell {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }
}
