/* ==========================================================================
   playbox Minesweeper - Design System & Stylesheet (minesweeper.css)
   100% Unified with playboxlab.net Design System (Sudoku & Solitaire)
   ========================================================================== */

:root {
    /* Color Tokens (Midnight Dark Mode - Default) */
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b, #0f172a 60%, #020617);
    --card-bg: rgba(30, 41, 59, 0.75);
    --card-border: rgba(255, 255, 255, 0.1);
    --card-hover-border: rgba(99, 102, 241, 0.45);
    --card-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent-color: #8b5cf6;
    --brand-gold: #facc15;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    /* Cell Variables - Modern Flat-Neumorphic Tokens */
    --cell-size: 34px;
    --cell-gap: 4px;
    --cell-font-size: 1.15rem;

    /* Unopened Tile: Elevated modern card tile */
    --cell-unopened-bg: linear-gradient(145deg, rgba(51, 65, 85, 0.8), rgba(30, 41, 59, 0.95));
    --cell-unopened-border: rgba(255, 255, 255, 0.15);
    --cell-unopened-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --cell-unopened-radius: 6px;

    /* Opened Tile: Sunken, recessed, flat dark surface */
    --cell-opened-bg: rgba(11, 17, 32, 0.75);
    --cell-opened-border: rgba(255, 255, 255, 0.04);
    --cell-opened-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
    --cell-opened-radius: 4px;

    /* Grid Board Background */
    --grid-bg: rgba(15, 23, 42, 0.65);
    --grid-border: rgba(255, 255, 255, 0.08);

    /* Fonts & Radii */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f0f4ff 0%, #e2e8f0 100%);
    --card-bg: rgba(255, 255, 255, 0.88);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.5);
    --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);

    /* Unopened Tile in Light Mode */
    --cell-unopened-bg: linear-gradient(145deg, #ffffff, #f1f5f9);
    --cell-unopened-border: rgba(0, 0, 0, 0.12);
    --cell-unopened-shadow: 0 3px 6px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);

    /* Opened Tile in Light Mode */
    --cell-opened-bg: rgba(203, 213, 225, 0.7);
    --cell-opened-border: rgba(0, 0, 0, 0.06);
    --cell-opened-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.12);

    --grid-bg: rgba(226, 232, 240, 0.65);
    --grid-border: rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Fullscreen Win Confetti Canvas */
#win-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99998;
}

/* Main Container Layout - Unified max-width: 1080px matching Solitaire */
.mine-layout {
    width: 100%;
    max-width: 1080px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ==========================================================================
   Header (Logo, Title, Cross-Game Switchers, Controls)
   ========================================================================== */
.mine-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 4px 14px rgba(250, 204, 21, 0.25));
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
}

.brand-link:hover .brand-logo-img {
    transform: scale(1.08) rotate(3deg);
    filter: drop-shadow(0 6px 18px rgba(250, 204, 21, 0.5));
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
}

.brand-title-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.brand-title-link:hover {
    color: var(--primary-color);
    opacity: 0.9;
}

.brand-text h1 span {
    color: var(--brand-gold);
    margin-left: 0;
}

.brand-text .sub-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Game Switcher Badges */
.game-switch-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
}

.game-switch-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

[data-theme="light"] .game-switch-badge {
    background: rgba(0, 0, 0, 0.05);
}

.game-switch-badge:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Header Controls */
.mine-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.icon-btn.active {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.15);
}

.lang-btn {
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0 10px;
    width: auto;
}

.guide-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.guide-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* ==========================================================================
   Control Ribbon (Matches Solitaire & Sudoku Status Ribbon)
   ========================================================================== */
.mine-ribbon {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--card-shadow);
}

.ribbon-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.ribbon-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.ribbon-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

/* Toggle Group for Difficulty */
.btn-toggle-group {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

[data-theme="light"] .btn-toggle-group {
    background: rgba(0, 0, 0, 0.05);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 6px var(--primary-glow);
}

/* Ribbon Stats Badge (Mine Count & Timer) */
.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    white-space: nowrap;
}

[data-theme="light"] .stat-item {
    background: rgba(0, 0, 0, 0.04);
}

.stat-item i {
    font-size: 0.95rem;
}

.stat-item strong {
    font-family: var(--font-heading);
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Action Buttons (Hint, New Game) */
.action-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.action-btn.primary {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.action-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Shortcut Key Badges */
.shortcut-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    font-family: var(--font-heading), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    line-height: 1.3;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    pointer-events: none;
    user-select: none;
}

.action-btn:hover:not(:disabled) .shortcut-key {
    background: rgba(255, 255, 255, 0.22);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.38);
}

.action-btn.primary .shortcut-key {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.action-btn.primary:hover .shortcut-key {
    background: rgba(255, 255, 255, 0.32);
    border-color: #ffffff;
}

.action-btn:disabled .shortcut-key {
    opacity: 0.45;
}

[data-theme="light"] .shortcut-key {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #475569;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .action-btn:hover:not(:disabled) .shortcut-key {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.22);
    color: #0f172a;
}

[data-theme="light"] .action-btn.primary .shortcut-key {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.45);
    color: #ffffff;
}

/* ==========================================================================
   Main Game Workspace & Board Card (Matching Solitaire .sol-board)
   ========================================================================== */
.mine-workspace {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

/* Board Card Container - Solitaire & Sudoku Glassmorphism Card pattern */
.mine-board-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 540px;
    position: relative;
    transition: all 0.3s ease;
}

.mine-board-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.2);
}

.mine-board-wrapper::-webkit-scrollbar {
    height: 6px;
}

.mine-board-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

/* Minesweeper Grid */
.mine-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 9), var(--cell-size, 34px));
    grid-template-rows: repeat(var(--rows, 9), var(--cell-size, 34px));
    gap: var(--cell-gap, 4px);
    background: var(--grid-bg);
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--grid-border);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: padding 0.2s ease;
}

/* Default difficulty sizing presets for desktop (1080px layout) */
.mine-grid[data-diff="beginner"] {
    --cell-size: 46px;
    --cell-gap: 5px;
    --cell-font-size: 1.4rem;
}

.mine-grid[data-diff="intermediate"] {
    --cell-size: 34px;
    --cell-gap: 4px;
    --cell-font-size: 1.15rem;
}

.mine-grid[data-diff="expert"] {
    /* 30 cols * 28px + 29 * 3.5px = 941.5px -> comfortably fits in 1040px without horiz scroll! */
    --cell-size: 28px;
    --cell-gap: 3.5px;
    --cell-font-size: 0.95rem;
}

/* ==========================================================================
   Minesweeper Cell: High Modern Aesthetic & Instant Contrast
   ========================================================================== */
.mine-cell {
    width: var(--cell-size, 34px);
    height: var(--cell-size, 34px);
    font-size: var(--cell-font-size, 1.15rem);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    transition: filter 0.12s ease, transform 0.1s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;

    /* UNOPENED STATE: Sleek floating glass card tile */
    background: var(--cell-unopened-bg);
    border: 1px solid var(--cell-unopened-border);
    border-radius: var(--cell-unopened-radius);
    box-shadow: var(--cell-unopened-shadow);
}

/* Unopened Hover & Active States */
.mine-cell:hover:not(.opened):not(.exploded) {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.35);
    filter: brightness(1.15);
}

.mine-cell:active:not(.opened):not(.exploded) {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Dual-Click Chord Preview & Pressed States (Authentic Left+Right simultaneous sensation) */
.mine-cell.chord-preview:not(.opened),
.mine-cell.pressed:not(.opened) {
    transform: translateY(1px) !important;
    background: var(--cell-opened-bg) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55) !important;
    filter: brightness(1.2) !important;
}

[data-theme="light"] .mine-cell.chord-preview:not(.opened),
[data-theme="light"] .mine-cell.pressed:not(.opened) {
    background: var(--cell-opened-bg) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15) !important;
    filter: brightness(0.95) !important;
}

/* OPENED STATE: Recessed, sunken dark slate surface with zero elevation */
.mine-cell.opened {
    background: var(--cell-opened-bg) !important;
    border: 1px solid var(--cell-opened-border) !important;
    border-radius: var(--cell-opened-radius) !important;
    box-shadow: var(--cell-opened-shadow) !important;
    cursor: default;
    transform: none !important;
    filter: none !important;
}

/* Chord Flash Effect */
.mine-cell.chord-highlight {
    filter: brightness(1.4) drop-shadow(0 0 6px var(--primary-color)) !important;
}

/* Flag & Mine Icons */
.mine-cell .cell-flag {
    color: #ef4444;
    font-size: 0.95em;
    filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.45));
    animation: flagPop 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mine-cell .cell-mine {
    font-size: 0.95em;
    color: #f87171;
}

.mine-cell.exploded {
    background: #dc2626 !important;
    border: 1px solid #ef4444 !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.8) !important;
    animation: explodeShake 0.3s ease;
}

.mine-cell.exploded .cell-mine {
    color: #ffffff;
    transform: scale(1.15);
}

.mine-cell.safe-hint-pulse {
    animation: radarPulse 1.2s infinite ease-in-out;
}

@keyframes flagPop {
    0% { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes explodeShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px) rotate(-2deg); }
    40%, 80% { transform: translateX(3px) rotate(2deg); }
}

@keyframes radarPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.85); }
    50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

/* Number Colors - Vibrant Modern Palette */
.num-1 { color: #38bdf8; text-shadow: 0 0 8px rgba(56, 189, 248, 0.35); } /* Cyan */
.num-2 { color: #34d399; text-shadow: 0 0 8px rgba(52, 211, 153, 0.35); } /* Emerald */
.num-3 { color: #f87171; text-shadow: 0 0 8px rgba(248, 113, 113, 0.35); } /* Coral Red */
.num-4 { color: #a78bfa; text-shadow: 0 0 8px rgba(167, 139, 250, 0.35); } /* Violet */
.num-5 { color: #fbbf24; text-shadow: 0 0 8px rgba(251, 191, 36, 0.35); }  /* Amber */
.num-6 { color: #2dd4bf; text-shadow: 0 0 8px rgba(45, 212, 191, 0.35); }  /* Teal */
.num-7 { color: #f472b6; text-shadow: 0 0 8px rgba(244, 114, 182, 0.35); } /* Rose */
.num-8 { color: #e2e8f0; }                                                /* Silver */

[data-theme="light"] .num-1 { color: #0284c7; text-shadow: none; }
[data-theme="light"] .num-2 { color: #059669; text-shadow: none; }
[data-theme="light"] .num-3 { color: #dc2626; text-shadow: none; }
[data-theme="light"] .num-4 { color: #6366f1; text-shadow: none; }
[data-theme="light"] .num-5 { color: #d97706; text-shadow: none; }
[data-theme="light"] .num-6 { color: #0d9488; text-shadow: none; }
[data-theme="light"] .num-7 { color: #db2777; text-shadow: none; }
[data-theme="light"] .num-8 { color: #475569; text-shadow: none; }

/* ==========================================================================
   Mobile Touch Toolbar (Floating Bar)
   ========================================================================== */
.mobile-touch-toolbar {
    display: none;
    position: sticky;
    bottom: 16px;
    z-index: 100;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    padding: 6px;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

[data-theme="light"] .mobile-touch-toolbar {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.touch-mode-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.touch-mode-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #ffffff;
    box-shadow: 0 2px 10px var(--primary-glow);
}

.touch-mode-btn .shortcut-key {
    font-size: 0.62rem;
    padding: 1px 5px;
    margin-left: 2px;
}

.touch-mode-btn.active .shortcut-key {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.45);
    color: #ffffff;
}

/* ==========================================================================
   Modals (Rules Guide, Stats, Victory, Revive, Hint)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 520px;
    padding: 26px;
    color: var(--text-primary);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body-scroll {
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 0.92rem;
    line-height: 1.6;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 6px;
}

/* Stats Modal Grid */
.stats-mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    margin-bottom: 16px;
}

[data-theme="light"] .stats-mode-selector {
    background: rgba(0, 0, 0, 0.05);
}

.stats-mode-selector .toggle-btn {
    flex: 1;
    text-align: center;
}

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

.stat-box {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    text-align: center;
}

[data-theme="light"] .stat-box {
    background: rgba(0, 0, 0, 0.03);
}

.stat-box .val {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.stat-box .lbl {
    font-size: 0.76rem;
    color: var(--text-secondary);
}

/* Sponsored Ad Slot */
.ad-slot-horizontal {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    text-align: center;
    position: relative;
    box-shadow: var(--card-shadow);
}

.ad-slot-label {
    position: absolute;
    top: 6px;
    right: 12px;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Footer */
.mine-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 10px 0;
}

/* ==========================================================================
   Responsive Rules
   ========================================================================== */

/* Standard Desktop / Laptop (1024px ~ 1199px) */
@media (max-width: 1199px) and (min-width: 1024px) {
    .mine-layout {
        max-width: 1040px;
    }
    .mine-grid[data-diff="expert"] {
        --cell-size: 27px;
        --cell-gap: 3px;
        --cell-font-size: 0.92rem;
    }
}

/* Tablet & Smaller Laptops (769px ~ 1023px) */
@media (max-width: 1023px) and (min-width: 769px) {
    .mine-layout {
        max-width: 950px;
    }
    .mine-grid[data-diff="expert"] {
        --cell-size: 24px;
        --cell-gap: 3px;
        --cell-font-size: 0.84rem;
    }
    .mine-grid[data-diff="intermediate"] {
        --cell-size: 30px;
        --cell-font-size: 1.05rem;
    }
}

/* Mobile & Small Tablets (<= 768px) */
@media (max-width: 768px) {
    .mine-layout {
        padding: 12px 10px 30px;
        gap: 12px;
    }

    .mine-board-card {
        padding: 16px 8px;
        min-height: 420px;
    }

    .mine-ribbon {
        padding: 10px 12px;
        gap: 10px;
        justify-content: center;
    }

    .ribbon-left,
    .ribbon-center,
    .ribbon-right {
        width: 100%;
        justify-content: center;
    }

    .mine-grid[data-diff="beginner"] {
        --cell-size: 36px;
        --cell-gap: 4px;
        --cell-font-size: 1.15rem;
    }

    .mine-grid[data-diff="intermediate"] {
        --cell-size: 26px;
        --cell-gap: 3px;
        --cell-font-size: 0.9rem;
    }

    .mine-grid[data-diff="expert"] {
        --cell-size: 22px;
        --cell-gap: 2.5px;
        --cell-font-size: 0.78rem;
    }

    .mobile-touch-toolbar {
        display: flex;
    }

    .game-switch-group {
        display: none;
    }
}

@media (max-width: 480px) {
    .mine-grid[data-diff="beginner"] {
        --cell-size: 33px;
        --cell-font-size: 1.05rem;
    }

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

    .action-btn .shortcut-key {
        display: none;
    }
}
