/**
 * Memory Matching Game - Core Stylesheet
 * ABC Website (abcwebsite.com.vn)
 * Vibrant, modern, responsive gaming interface
 */

:root {
    --primary: #0f75bd;
    --primary-hover: #0284c7;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.5);
    --success: #10b981;
    --danger: #ef4444;
    --font-family: 'Be Vietnam Pro', 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
    font-family: inherit;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: var(--font-family);
    background: radial-gradient(circle at center, #2e1065 0%, #0f172a 100%);
    color: #ffffff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ==========================================================================
   CONTAINER & THEMES (Rich, immersive gradients matching Vòng Quay May Mắn)
   ========================================================================== */
.memory-game-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 24px 14px;
    position: relative;
    transition: background 0.4s ease;
    overflow: hidden;
}

/* Background Ambient Glow Elements */
.memory-game-container::before {
    content: "";
    position: absolute;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.15) 0%, transparent 70%);
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 1;
}

/* 1. Theme Carnival (Mặc định - Sôi động, huyền bí) */
.memory-game-container.theme-carnival {
    background: radial-gradient(circle at center, #2e1065 0%, #170d38 60%, #0a0618 100%);
    --card-back-bg: linear-gradient(135deg, #7c3aed 0%, #c026d3 50%, #f43f5e 100%);
    --card-back-rim: #f43f5e;
}

/* 2. Theme Tết & Lễ Hội (Đỏ Hoàng Kim rực rỡ) */
.memory-game-container.theme-tet {
    background: radial-gradient(circle at center, #881337 0%, #4c0519 60%, #1f0209 100%);
    --card-back-bg: linear-gradient(135deg, #dc2626 0%, #b91c1c 50%, #f59e0b 100%);
    --card-back-rim: #fbbf24;
}
.theme-tet .header-title {
    background: linear-gradient(180deg, #fef08a 0%, #fde047 50%, #eab308 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 3. Theme Neon Cyberpunk (Tối hiện đại, phát quang) */
.memory-game-container.theme-neon {
    background: radial-gradient(circle at center, #0f172a 0%, #030712 100%);
    --card-back-bg: linear-gradient(135deg, #0284c7 0%, #06b6d4 50%, #d946ef 100%);
    --card-back-rim: #06b6d4;
}
.theme-neon .header-title {
    background: linear-gradient(180deg, #e0f2fe 0%, #38bdf8 50%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.6));
}

/* 4. Theme Luxury (Đen Vàng Kim Hoàng Gia) */
.memory-game-container.theme-luxury {
    background: radial-gradient(circle at center, #27272a 0%, #18181b 60%, #09090b 100%);
    --card-back-bg: linear-gradient(135deg, #b45309 0%, #d97706 50%, #f59e0b 100%);
    --card-back-rim: #f59e0b;
}
.theme-luxury .header-title {
    background: linear-gradient(180deg, #fef3c7 0%, #fde68a 50%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 5. Theme Pastel (Dễ thương, năng động) */
.memory-game-container.theme-pastel {
    background: radial-gradient(circle at center, #312e81 0%, #1e1b4b 60%, #0f172a 100%);
    --card-back-bg: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #f472b6 100%);
    --card-back-rim: #f472b6;
}

/* ==========================================================================
   HEADER GAME (Tiêu đề chữ Gradient vàng bóng bẩy)
   ========================================================================== */
.memory-header {
    text-align: center;
    width: 100%;
    max-width: 680px;
    margin-bottom: 10px;
    z-index: 2;
}

.header-title {
    font-size: clamp(22px, 5.2vw, 34px);
    font-weight: 900;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    color: #fed7aa; /* Fallback màu sắc chuẩn cho Tiếng Việt */
    background: linear-gradient(180deg, #fff7ed 0%, #fed7aa 50%, #fb923c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
    line-height: 1.35;
    padding: 4px 0;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: clamp(12.5px, 2.8vw, 15px);
    color: #cbd5e1;
    font-weight: 500;
    opacity: 0.95;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   STATS BAR (Glassmorphism Glow Badges)
   ========================================================================== */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 580px;
    margin-bottom: 16px;
    z-index: 2;
}

.stat-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 72px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    line-height: 1;
}

.stat-value {
    font-size: 21px;
    font-weight: 900;
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
    line-height: 1.2;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* Đồng hồ cảnh báo đếm ngược (<10s) */
.stat-card.timer-warning {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.25) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.55), inset 0 0 10px rgba(239, 68, 68, 0.3) !important;
    animation: pulseWarning 1s infinite alternate;
}
.stat-card.timer-warning .stat-value {
    color: #f87171 !important;
    text-shadow: 0 0 14px rgba(239, 68, 68, 0.8) !important;
}

@keyframes pulseWarning {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Huy hiệu Combo Streak cháy rực */
.stat-card.combo-active {
    border-color: #f97316 !important;
    background: rgba(249, 115, 22, 0.25) !important;
    box-shadow: 0 0 22px rgba(249, 115, 22, 0.6), inset 0 0 10px rgba(249, 115, 22, 0.35) !important;
    animation: bounceCombo 0.4s ease;
}
.stat-card.combo-active .stat-value {
    color: #fdba74 !important;
    text-shadow: 0 0 14px rgba(249, 115, 22, 0.9) !important;
}

@keyframes bounceCombo {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   GAME BOARD & HOLOGRAPHIC 3D CARDS
   ========================================================================== */
.game-board-wrapper {
    width: 100%;
    max-width: 660px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0 16px 0;
    z-index: 2;
}

.cards-grid {
    display: grid;
    gap: 12px;
    width: 100%;
    perspective: 1400px;
    justify-content: center;
    transition: all 0.3s ease;
}

/* Dynamic Grid Classes */
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); max-width: 440px; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); max-width: 560px; }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); max-width: 640px; }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); max-width: 680px; }

/* 3D Card Structure */
.card-item {
    aspect-ratio: 1 / 1;
    perspective: 1200px;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 16px;
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.card-item.flipped .card-inner,
.card-item.matched .card-inner {
    transform: rotateY(180deg);
}

/* Mặt thẻ chung */
.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    transition: all 0.25s ease;
}

/* ----------------------------------------------------
   MẶT SAU (LƯNG BÀI KHI ÚP) - Đẳng cấp, Sang trọng, Bóng bẩy
   ---------------------------------------------------- */
.card-back {
    background: var(--card-back-bg);
    border: 2px solid rgba(255, 255, 255, 0.45);
    outline: 1.5px solid rgba(255, 255, 255, 0.25);
    outline-offset: -5px;
    color: #ffffff;
    box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.4), inset 0 -3px 8px rgba(0, 0, 0, 0.3);
}

/* Ánh gương xiên chéo (Sheen reflection) */
.card-back::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.05) 45%, transparent 60%);
    pointer-events: none;
    border-radius: inherit;
}

/* Vòng tròn hoa văn trung tâm lưng thẻ */
.card-back-pattern {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 2px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255, 255, 255, 0.45);
    z-index: 1;
}

.card-back-pattern svg {
    width: 30px;
    height: 30px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

/* 4 góc trang trí kim cương nhỏ */
.card-back-corner {
    position: absolute;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    transform: rotate(45deg);
}
.corner-tl { top: 8px; left: 8px; }
.corner-tr { top: 8px; right: 8px; }
.corner-bl { bottom: 8px; left: 8px; }
.corner-br { bottom: 8px; right: 8px; }

/* ----------------------------------------------------
   MẶT TRƯỚC (HÌNH PHẦN THƯỞNG KHI LẬT)
   ---------------------------------------------------- */
.card-front {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #cbd5e1;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.9), inset 0 -2px 6px rgba(0, 0, 0, 0.05);
}

.card-front img,
.card-front svg {
    width: 66%;
    height: 66%;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-front .card-label {
    font-size: 11px;
    font-weight: 800;
    margin-top: 5px;
    text-align: center;
    line-height: 1.1;
    color: #0f75bd;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 999px;
    letter-spacing: 0.4px;
}

/* Hiệu ứng rê chuột (Hover) */
@media (hover: hover) {
    .card-item:not(.flipped):not(.matched):hover .card-inner {
        transform: translateY(-6px) scale(1.03);
        box-shadow: 0 18px 36px -8px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.3);
    }
}

/* ----------------------------------------------------
   HIỆU ỨNG GHÉP ĐÔI THÀNH CÔNG (MATCHED GLOW)
   ---------------------------------------------------- */
.card-item.matched {
    cursor: default;
}
.card-item.matched .card-front {
    border-color: #f59e0b !important;
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%) !important;
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.75), inset 0 0 10px rgba(245, 158, 11, 0.4) !important;
    animation: matchSuccess 0.5s ease forwards;
}
.card-item.matched .card-front img,
.card-item.matched .card-front svg {
    transform: scale(1.12);
}
.card-item.matched .card-front .card-label {
    background: #fef08a;
    color: #b45309;
}

@keyframes matchSuccess {
    0% { transform: rotateY(180deg) scale(0.92); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* ----------------------------------------------------
   HIỆU ỨNG GHÉP SAI (MISMATCH SHAKE)
   ---------------------------------------------------- */
.card-item.mismatch .card-inner {
    animation: cardShake 0.45s ease;
}
.card-item.mismatch .card-front {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.6) !important;
}

@keyframes cardShake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    20%, 60% { transform: rotateY(180deg) translateX(-6px); }
    40%, 80% { transform: rotateY(180deg) translateX(6px); }
}

/* ==========================================================================
   CONTROLS BAR (Thanh nút bấm kiểu dáng Vòng Quay May Mắn)
   ========================================================================== */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 440px;
    z-index: 2;
    margin-top: 6px;
}

/* Nút BẮT ĐẦU CHƠI (Pill to nổi bật rực rỡ) */
.btn-action-primary {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 28px;
    font-size: 16.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #ffffff;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 50%, #c2410c 100%);
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    box-shadow: 0 10px 25px -4px rgba(234, 88, 12, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}
.btn-action-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -4px rgba(234, 88, 12, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
}
.btn-action-primary:active {
    transform: translateY(0);
}

/* Nút Icon tròn trong suốt mờ (BGM & Bánh răng Cài đặt) */
.btn-icon-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
    outline: none;
}
.btn-icon-circle:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px) scale(1.05);
    border-color: rgba(255, 255, 255, 0.45);
}
.btn-icon-circle:active {
    transform: translateY(0) scale(0.98);
}
.btn-icon-circle svg {
    width: 24px;
    height: 24px;
    display: block;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#btn-open-settings {
    color: #ffffff;
}
#btn-open-settings svg {
    fill: #ffffff;
}
#btn-open-settings:hover svg {
    transform: rotate(45deg);
}
#btn-toggle-bgm svg {
    width: 22px;
    height: 22px;
    fill: none !important;
    stroke: currentColor;
}
#btn-toggle-bgm svg path {
    fill: none !important;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#btn-toggle-bgm svg circle {
    fill: currentColor !important;
    stroke: currentColor;
}
#btn-toggle-bgm svg line {
    stroke: #ef4444 !important;
    stroke-width: 2.5;
    stroke-linecap: round;
}
.btn-icon-circle .bgm-icon-on,
.btn-icon-circle .bgm-icon-off {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    pointer-events: none;
}
.btn-icon-circle.is-playing {
    border-color: rgba(52, 211, 153, 0.7);
    color: #34d399;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.22);
    animation: bgmPulse 2s infinite ease-in-out;
}
.btn-icon-circle.is-playing .bgm-icon-on {
    display: inline-flex !important;
}
.btn-icon-circle.is-playing .bgm-icon-off {
    display: none !important;
}
.btn-icon-circle.is-muted {
    opacity: 0.85;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}
.btn-icon-circle.is-muted:hover {
    opacity: 1;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.18);
}
.btn-icon-circle.is-muted .bgm-icon-on {
    display: none !important;
}
.btn-icon-circle.is-muted .bgm-icon-off {
    display: inline-flex !important;
}
@keyframes bgmPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* ==========================================================================
   CONFETTI CANVAS
   ========================================================================== */
#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
    display: none;
}

/* ==========================================================================
   MODAL POPUPS (QUẢ LÝ MƯỢT MÀ BẰNG OPACITY & VISIBILITY CHUẨN VÒNG QUAY)
   ========================================================================== */
.memory-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.memory-modal.is-active {
    opacity: 1;
    visibility: visible;
}

/* Card Kết quả */
.result-card {
    background: #ffffff;
    color: #0f172a;
    width: 100%;
    max-width: 410px;
    border-radius: 24px;
    padding: 32px 24px 24px 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.memory-modal.is-active .result-card {
    transform: scale(1) translateY(0);
}

.result-icon {
    font-size: 54px;
    line-height: 1;
    margin-bottom: 8px;
    animation: iconBounce 0.6s ease;
}

@keyframes iconBounce {
    0% { transform: scale(0.4); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.result-stars {
    font-size: 26px;
    color: #f59e0b;
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.result-title {
    font-size: 22px;
    font-weight: 900;
    color: #0f75bd;
    line-height: 1.35;
    margin-bottom: 6px;
}

.result-desc {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
    line-height: 1.45;
}

.result-prize-box {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 18px;
}

.prize-highlight {
    font-size: 18px;
    font-weight: 900;
    color: #f97316;
}

.result-stats-summary {
    display: flex;
    justify-content: space-around;
    border-top: 1px solid #f1f5f9;
    padding-top: 14px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #64748b;
}
.result-stats-summary strong {
    color: #0f75bd;
    font-size: 15px;
    font-weight: 800;
}

.btn-modal-action {
    width: 100%;
    height: 48px;
    border-radius: 999px;
    border: none;
    font-weight: 800;
    font-size: 15.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #0f75bd 0%, #0284c7 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 117, 189, 0.35);
    transition: all 0.25s ease;
}
.btn-modal-action:hover {
    background: linear-gradient(135deg, #0d65a3 0%, #0369a1 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 117, 189, 0.45);
}

.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================================== */
@media (max-width: 600px) {
    .stats-bar {
        gap: 8px;
    }
    .stat-card {
        padding: 6px 8px;
        min-width: 60px;
        border-radius: 12px;
    }
    .stat-label {
        font-size: 10px;
    }
    .stat-value {
        font-size: 17px;
    }
    .cards-grid {
        gap: 8px;
    }
    .card-item {
        border-radius: 12px;
    }
    .card-inner {
        border-radius: 12px;
    }
    .card-face {
        border-radius: 12px;
        padding: 4px;
    }
    .card-back-pattern {
        width: 38px;
        height: 38px;
    }
    .card-back-pattern svg {
        width: 24px;
        height: 24px;
    }
    .card-front .card-label {
        font-size: 9.5px;
        padding: 2px 6px;
    }
    .controls-bar {
        gap: 12px;
    }
    .btn-action-primary {
        height: 48px;
        font-size: 15px;
    }
    .btn-icon-circle {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 380px) {
    .cards-grid {
        gap: 6px;
    }
    .card-front .card-label {
        display: none; /* Ẩn nhãn trên màn hình siêu hẹp để giữ hình to rõ */
    }
}
