/* ========================================================
   PIKACHU CLASSICAL - STYLE.CSS
   Giao diện Retro Hoàn Chỉnh Chuẩn Ảnh Mẫu
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@600;700&family=Nunito:wght@700;800;900&family=VT323&display=swap');

:root {
    --bg-dark-parchment: #2b1104;
    --gold-primary: #f5b938;
    --gold-glow: #ffc400;
    --gold-shadow: #3f1803;
    --gold-dark: #b87814;
    --tile-bg-top: #fef8eb;
    --tile-bg-bottom: #edd5ac;
    --tile-border-light: #ffffff;
    --tile-border-dark: #9e825a;
    --tile-border-side: #cbb48b;
    --highlight-orange: #ff6d00;
    --highlight-green: #00e676;
    --hud-text-shadow: 2px 2px 0px #240a01, 3px 3px 0px #110500, 0 0 10px rgba(255, 179, 0, 0.4);

    /* KÍCH THƯỚC LƯỚI 9x16 MỞ RỘNG CHIẾM 78 - 82% CHIỀU CAO MÀN HÌNH (VH) */
    --tile-h: min(clamp(54px, 8.4vh, 86px), calc((98vw - 320px) / 16 / 0.88));
    --tile-w: calc(var(--tile-h) * 0.88);
    --tile-gap: clamp(2px, 0.4vh, 4px);
}

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

body {
    background-color: #1a0802;
    background-image: 
        radial-gradient(circle at 50% 45%, #461e09 0%, #2b1104 55%, #130501 100%),
        repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 2px, transparent 2px, transparent 4px);
    color: #fff;
    font-family: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Hiệu ứng hạt bụi vàng lơ lửng cổ điển (Retro ambient bokeh) */
.ambient-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(2px 2px at 15% 25%, rgba(255, 215, 0, 0.35), transparent),
        radial-gradient(3px 3px at 85% 15%, rgba(255, 180, 50, 0.3), transparent),
        radial-gradient(2px 2px at 70% 80%, rgba(255, 220, 100, 0.25), transparent),
        radial-gradient(2.5px 2.5px at 30% 75%, rgba(255, 200, 0, 0.25), transparent),
        radial-gradient(1.5px 1.5px at 90% 60%, rgba(255, 240, 150, 0.3), transparent);
    z-index: 1;
}

/* ========================================================
   GAME CONTAINER CHÍNH
   ======================================================== */
.game-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(98vw, 1600px);
    padding: 6px 14px;
    height: 100vh;
    max-height: 100vh;
    justify-content: space-between;
}

/* Hàng trên cùng: Logo bên trái & Icon Bánh Răng bên phải */
.top-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 4px 10px;
}

/* Logo Pikachu Game cổ điển */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 0.9;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.logo-container:hover {
    transform: scale(1.03);
}

.logo-pikachu {
    font-family: 'Fredoka', 'Arial Black', cursive;
    font-size: 42px;
    font-weight: 700;
    color: #ffde00;
    text-shadow: 
        -2px -2px 0 #2a75bb,
         2px -2px 0 #2a75bb,
        -2px  2px 0 #2a75bb,
         2px  2px 0 #2a75bb,
         0 4px 0 #1b4772,
         0 6px 12px rgba(0, 0, 0, 0.6);
    letter-spacing: -1px;
    transform: rotate(-3deg);
    display: inline-block;
}

.logo-game {
    font-family: 'Nunito', cursive, sans-serif;
    font-size: 20px;
    font-weight: 900;
    color: #fff6d6;
    text-shadow: 
        1px 1px 0 #1b4772,
        2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-left: 55px;
    margin-top: -6px;
    letter-spacing: 1px;
}

/* Icon Cài đặt (Gear Button) */
.btn-settings {
    background: linear-gradient(145deg, #57738b, #3b5062);
    border: 2px solid #7594ae;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    color: #dce6ed;
}

.btn-settings:hover {
    transform: rotate(30deg) scale(1.08);
    background: linear-gradient(145deg, #6b89a3, #455d72);
    box-shadow: 0 0 12px rgba(117, 148, 174, 0.8);
}

.btn-settings svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
}

/* ========================================================
   KHU VỰC THI ĐẤU CHÍNH (3 CỘT: TRÁI - BÀN CỜ - PHẢI)
   ======================================================== */
.main-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    width: 100%;
}

/* CỘT THÔNG TIN BÊN TRÁI (BÀN - LƯỢT ĐỔI - ĐIỂM) */
.left-hud {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 130px;
    gap: 28px;
}

.hud-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

.hud-title {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 25px;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: var(--hud-text-shadow);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.hud-value {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 38px;
    font-weight: 700;
    color: #ffea79;
    text-shadow: var(--hud-text-shadow);
    line-height: 1;
}

#displayScore {
    font-size: 34px;
}

/* ========================================================
   KHU VỰC BÀN CỜ TRUNG TÂM (9 HÀNG x 16 CỘT)
   ======================================================== */
.board-container {
    position: relative;
    background: rgba(18, 6, 2, 0.65);
    padding: 6px;
    border-radius: 8px;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.8),
        inset 0 0 15px rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(138, 92, 51, 0.35);
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(16, var(--tile-w));
    grid-template-rows: repeat(9, var(--tile-h));
    gap: var(--tile-gap);
    position: relative;
    z-index: 2;
}

/* Canvas vẽ đường nối tia sét laser */
#laserCanvas {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    pointer-events: none;
    z-index: 10;
}

/* ========================================================
   Ô GẠCH PIKACHU (TILE STYLING)
   ======================================================== */
.tile {
    width: var(--tile-w);
    height: var(--tile-h);
    padding: 0;
    margin: 0;
    background: linear-gradient(to bottom, var(--tile-bg-top) 0%, var(--tile-bg-bottom) 100%);
    border-top: 2px solid var(--tile-border-light);
    border-left: 2px solid var(--tile-border-light);
    border-right: 2px solid var(--tile-border-dark);
    border-bottom: 2px solid var(--tile-border-dark);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 2px 4px rgba(0, 0, 0, 0.45);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 0 0 2px #ffc107,
        0 4px 8px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

/* Ô được chọn */
.tile.selected {
    transform: translateY(-2px) scale(1.05);
    background: linear-gradient(to bottom, #fff5e0 0%, #ffdf9e 100%);
    box-shadow: 
        0 0 0 3px var(--highlight-orange),
        0 0 14px rgba(255, 109, 0, 0.9);
    border-color: #ffb74d;
    z-index: 8;
    animation: pulseSelected 1s infinite alternate;
}

@keyframes pulseSelected {
    0% { box-shadow: 0 0 0 2.5px var(--highlight-orange), 0 0 8px rgba(255, 109, 0, 0.7); }
    100% { box-shadow: 0 0 0 3.5px #ffab00, 0 0 16px rgba(255, 171, 0, 1); }
}

/* Ô gợi ý */
.tile.hinted {
    animation: pulseHint 0.6s infinite alternate;
    z-index: 7;
}

@keyframes pulseHint {
    0% { 
        box-shadow: 0 0 0 3px #00e676, 0 0 10px rgba(0, 230, 118, 0.8);
        transform: scale(1.03);
    }
    100% { 
        box-shadow: 0 0 0 3px #ffd600, 0 0 16px rgba(255, 214, 0, 1);
        transform: scale(1.08);
    }
}

/* Ô trống (đã ăn) */
.tile.empty {
    visibility: hidden;
    pointer-events: none;
    box-shadow: none;
    border: none;
    background: transparent;
}

/* Ô đá chướng ngại vật (Obstacle Rock) */
.tile.obstacle {
    background: linear-gradient(135deg, #545b62 0%, #2f353a 100%);
    border-top: 2px solid #868e96;
    border-left: 2px solid #868e96;
    border-right: 2px solid #1c2125;
    border-bottom: 2px solid #1c2125;
    cursor: not-allowed;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.6);
}

.tile.obstacle:hover {
    transform: none;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.6);
}

.obstacle-icon {
    font-size: 22px;
    filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.8));
    opacity: 0.85;
}

/* Ô đóng băng (Frozen Tile) */
.tile.frozen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(165, 242, 255, 0.6) 0%, rgba(64, 196, 255, 0.5) 100%);
    border: 1.5px solid rgba(224, 247, 250, 0.85);
    border-radius: 3px;
    box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.7);
    pointer-events: none;
}

.tile.frozen .ice-badge {
    position: absolute;
    top: 1px;
    right: 2px;
    font-size: 11px;
    z-index: 3;
    filter: drop-shadow(0 0 3px #00b0ff);
}

/* Hình ảnh Sprite Pokémon (Chiếm 85% diện tích ô, không có padding thừa) */
.pokemon-sprite {
    width: 85%;
    height: 85%;
    max-width: 85%;
    max-height: 85%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: drop-shadow(1px 2px 1px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    transition: transform 0.12s ease;
}

/* Fallback icon nếu ảnh chưa load */
.fallback-sprite {
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* ========================================================
   CỘT BÊN PHẢI (THANH THỜI GIAN DỌC & ĐỒNG HỒ)
   ======================================================== */
.right-hud {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 110px;
    height: 100%;
    justify-content: space-between;
}

/* Vỏ bọc thanh thời gian: Chiều cao khớp với lưới 9 hàng */
.timer-bar-wrapper {
    position: relative;
    width: 24px;
    height: calc(9 * var(--tile-h) + 8 * var(--tile-gap) - 44px);
    max-height: 76vh;
    background: #190902;
    border-radius: 12px;
    border: 2px solid #5a2f14;
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.9),
        0 4px 8px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Tụt dần từ đỉnh xuống đáy */
    overflow: hidden;
    padding: 2px;
}

/* Thanh gradient tụt theo thời gian */
.timer-progress {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(
        to bottom,
        #76ff03 0%,   /* Xanh lá tươi ở đỉnh */
        #aeea00 25%,
        #ffd600 55%,  /* Vàng ở giữa */
        #ff6d00 80%,
        #ff3d00 100%  /* Đỏ cam rực rỡ ở đáy */
    );
    box-shadow: 
        0 0 12px rgba(118, 255, 3, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.8);
    transition: height 0.35s linear;
}

/* Chớp cảnh báo khi gần hết giờ */
.timer-progress.warning {
    animation: flashTimerWarning 0.5s infinite alternate;
}

@keyframes flashTimerWarning {
    0% { filter: brightness(1) drop-shadow(0 0 6px #ff1744); }
    100% { filter: brightness(1.6) drop-shadow(0 0 16px #ff1744); }
}

/* Phần chữ và số hiển thị thời gian bên dưới thanh */
.timer-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}

.timer-label {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: var(--hud-text-shadow);
}

.timer-clock {
    font-family: 'Fredoka', 'Nunito', monospace;
    font-size: 26px;
    font-weight: 700;
    color: #ffea79;
    text-shadow: var(--hud-text-shadow);
    letter-spacing: 1px;
}

/* ========================================================
   THANH CÔNG CỤ DƯỚI CÙNG (BOTTOM TOOLBAR)
   ======================================================== */
.bottom-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-top: 14px;
    width: 100%;
}

.tool-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--gold-primary);
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    text-shadow: var(--hud-text-shadow);
    padding: 6px 14px;
    border-radius: 8px;
    position: relative;
    transition: all 0.15s ease;
}

.tool-btn:hover {
    color: #fff089;
    transform: translateY(-2px);
    text-shadow: 
        0 0 10px rgba(255, 214, 0, 0.8),
        var(--hud-text-shadow);
}

.tool-btn:active {
    transform: translateY(1px) scale(0.97);
}

.tool-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.8));
    transition: transform 0.25s ease;
}

.tool-btn:hover svg {
    transform: rotate(15deg);
}

/* Badge số lượng gợi ý */
.badge-count {
    background: #ffde00;
    color: #3b1904;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 900;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: -4px;
    right: -8px;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.6),
        inset 0 1px 1px #fff;
    border: 1.5px solid #fff;
}

/* ========================================================
   FLOATING SCORE & COMBO TEXT
   ======================================================== */
.floating-text {
    position: absolute;
    pointer-events: none;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    z-index: 30;
    animation: floatUpAndFade 0.9s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes floatUpAndFade {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.6);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -15px) scale(1.2);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -35px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50px) scale(0.9);
    }
}

.floating-score {
    color: #ffeb3b;
    font-size: 22px;
    text-shadow: 0 0 8px #ff6f00, 2px 2px 0 #000;
}

.floating-combo {
    color: #ff3d00;
    font-size: 26px;
    text-shadow: 0 0 12px #ffeb3b, 2px 2px 0 #000;
}

/* ========================================================
   TOAST NOTIFICATION (Báo tự động đổi bàn, v.v.)
   ======================================================== */
.toast-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(28, 11, 4, 0.95);
    border: 2px solid var(--gold-primary);
    border-radius: 12px;
    padding: 14px 28px;
    color: #ffea79;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 0 25px rgba(255, 193, 7, 0.6), 0 8px 30px rgba(0, 0, 0, 0.9);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-msg.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ========================================================
   MODAL / POPUP DIALOGS (SETTINGS, VICTORY, GAMEOVER)
   ======================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 2, 0, 0.82);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: linear-gradient(145deg, #381a0b, #1f0b03);
    border: 3px solid var(--gold-primary);
    border-radius: 16px;
    width: 90%;
    max-width: 580px;
    padding: 24px 28px;
    box-shadow: 
        0 0 35px rgba(245, 185, 56, 0.4),
        0 15px 40px rgba(0, 0, 0, 0.9);
    position: relative;
    color: #fff;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(245, 185, 56, 0.35);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-title {
    font-family: 'Fredoka', cursive;
    font-size: 28px;
    color: var(--gold-primary);
    text-shadow: var(--hud-text-shadow);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: #e0a340;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.btn-close-modal:hover {
    color: #ff3d00;
    transform: scale(1.1);
}

.modal-body {
    overflow-y: auto;
    padding-right: 6px;
    margin-bottom: 16px;
}

/* Custom scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 4px;
}

/* Settings Item Rows */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
}

.setting-label {
    font-size: 17px;
    font-weight: 700;
    color: #f7e6ce;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #553322;
    transition: .3s;
    border-radius: 28px;
    border: 1.5px solid var(--gold-dark);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

input:checked + .slider {
    background-color: #ffb300;
}

input:checked + .slider:before {
    transform: translateX(23px);
}

/* Volume Slider */
.volume-range {
    -webkit-appearance: none;
    width: 140px;
    height: 8px;
    border-radius: 4px;
    background: #553322;
    outline: none;
}

.volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold-primary);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0,0,0,0.6);
}

/* Nút Chọn Màn (Test) trong Settings */
.btn-test-level {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    border: 1.5px solid #a78bfa;
    color: #f5f3ff;
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-test-level:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.7);
}

.btn-test-level.unlocked {
    background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    border-color: #4ade80;
    color: #f0fdf4;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

/* Lưới chọn 50 màn chơi trong Settings */
.level-select-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 10px;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
}

.level-badge-btn {
    background: #462210;
    border: 1.5px solid #8c5228;
    color: #ffea79;
    font-family: 'Fredoka', sans-serif;
    font-size: 16px;
    padding: 8px 4px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.level-badge-btn:hover:not(.locked) {
    background: #6d3619;
    border-color: var(--gold-primary);
    transform: scale(1.05);
}

.level-badge-btn.current {
    background: #c67c13;
    border-color: #fff;
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.8);
}

.level-badge-btn.locked {
    background: #200f07;
    border-color: #3f2012;
    color: #665045;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.level-badge-btn .star-icon {
    font-size: 11px;
    color: #ffd600;
}

/* Nút hành động Modal */
.modal-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    border-top: 2px solid rgba(245, 185, 56, 0.35);
    padding-top: 14px;
}

.modal-action-btn {
    background: linear-gradient(to bottom, #f5b938 0%, #d88914 100%);
    border: 2px solid #fff;
    border-radius: 8px;
    color: #341203;
    font-family: 'Fredoka', sans-serif;
    font-size: 20px;
    font-weight: 700;
    padding: 10px 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: all 0.15s ease;
}

.modal-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(245, 185, 56, 0.6);
}

.modal-action-btn.secondary {
    background: linear-gradient(to bottom, #546e7a 0%, #37474f 100%);
    color: #eceff1;
    border-color: #78909c;
}

/* Thống kê Victory / Gameover */
.stat-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 18px;
    margin: 14px 0;
    background: rgba(0,0,0,0.3);
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px dashed rgba(245, 185, 56, 0.5);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-val {
    font-weight: 800;
    color: #ffeb3b;
    font-size: 22px;
}

/* ========================================================
   RESPONSIVE DESIGN CHO CÁC MÀN HÌNH NHỎ HƠN
   ======================================================== */
@media (max-width: 1200px) {
    :root {
        --tile-h: min(clamp(48px, 7.8vh, 74px), calc((98vw - 260px) / 16 / 0.88));
    }
    .left-hud {
        width: 105px;
        gap: 18px;
    }
    .hud-title {
        font-size: 21px;
    }
    .hud-value {
        font-size: 30px;
    }
    #displayScore {
        font-size: 26px;
    }
}

@media (max-width: 900px) {
    .game-wrapper {
        transform: scale(0.9);
        transform-origin: top center;
    }
}
