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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Khung chứa game gốc cố định độ phân giải thiết kế 1920x1080 */
.game-container {
    position: absolute;
    width: 1920px;
    height: 1080px;
    background-image: url('assets/bg_table.jpg');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    transform-origin: center center;
    overflow: hidden; /* Tránh bi bay ra ngoài tạo scrollbar */
}

/* Các lớp layer full màn hình xếp chồng khít lên nhau */
.layer-full {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}
.pointer-none { pointer-events: none; }

/* =====================================================
   NÚT BẮN
   ===================================================== */
.btn-shoot {
    position: absolute;
    top: 709px;
    left: 855px;
    width: 200px;
    height: 173px;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.08s ease, filter 0.08s ease;
    border-radius: 50%;
}
.btn-shoot:hover {
    transform: scale(1.06);
    filter: brightness(1.15) drop-shadow(0 0 14px rgba(255,80,80,0.7));
}
.btn-shoot:active {
    transform: scale(0.93);
    filter: brightness(0.9);
}
.btn-shoot.disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

/* =====================================================
   KHAY BI
   ===================================================== */
.marble-box {
    position: absolute;
    top: 900px;
    left: 540px;
    width: 120px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    z-index: 10;
}
.marble {
    width: 70px;
    height: 70px;
    background-image: url('assets/marble.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity .4s ease, transform .4s ease;
}
.marble.used {
    opacity: 0.15;
    transform: scale(0.7);
}

/* =====================================================
   CARD CLICK ZONES
   ===================================================== */
.card-zone {
    position: absolute;

    width: 92px;      /* từ 80 -> 92 */
    height: 112px;

    margin-left: 12px; /* từ 18 -> 12 */
    margin-top: -18px;

    border-radius: 10px;
    z-index: 25;
    cursor: pointer;
}
.card-zone:hover:not(.zone-disabled) {
    border-color: rgba(255,215,0,0.6);
    background: rgba(255,215,0,0.08);
}
.card-zone.selected {
    border-color: #ffd700;
    background: rgba(255,215,0,0.18);
    box-shadow: 0 0 18px rgba(255,215,0,0.5);
}
.card-zone.has-bet {
    border-color: #00e676;
    box-shadow: 0 0 14px rgba(0,230,118,0.45);
}
.card-zone.zone-disabled {
    pointer-events: none;
    cursor: default;
}
.card-zone.zone-disabled:not(.has-bet) {
    opacity: 0.45;
}

/* Bet overlay */
.bet-overlay {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 27;
    animation: bet-overlay-pop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes bet-overlay-pop {
    from { transform: translateX(-50%) scale(0.4) translateY(10px); opacity: 0; }
    to   { transform: translateX(-50%) scale(1)   translateY(0);    opacity: 1; }
}
.bet-chip-icon {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}
.bet-amount-label {
    font-size: 12px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 1px 3px #000;
    background: rgba(0,0,0,0.6);
    padding: 1px 4px;
    border-radius: 4px;
    margin-top: -5px;
}

/* =====================================================
   CHIPS
   ===================================================== */
.chips-box {
    position: absolute;
    top: 877px;
    left: 745px;
    display: flex;
    gap: 8px;
    z-index: 40;
}
.chip {
    width: 99px;
    height: 99px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    border-radius: 50%;
}
.chip:hover { transform: translateY(-5px) scale(1.05); }
.chip.active {
    transform: translateY(-8px) scale(1.08);
    filter: drop-shadow(0 0 10px rgba(255,215,0,0.95)) brightness(1.1);
}
.chips-box.disabled .chip {
    pointer-events: none;
    opacity: 0.5;
}

/* =====================================================
   TEXT OVERLAY
   ===================================================== */
.text-overlay {
    position: absolute;
    color: #ffd043;
    font-weight: bold;
    font-size: 26px;
    font-family: 'Arial Black', sans-serif;
    text-shadow: 0 2px 4px #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    user-select: none;
}
.pos-con-lai   { top: 750px; left: 620px;  width: 133px; height: 87px; }
.pos-tong-cuoc { top: 750px; left: 1113px; width: 213px; height: 87px; }
.pos-thoi-gian {
    top: 900px; left: 1260px; width: 120px; height: 85px;
    color: #fff; font-size: 36px;
}

/* =====================================================
   TRẠNG THÁI GAME (Badge)
   ===================================================== */
.game-state-badge {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 28px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Arial Black', sans-serif;
    z-index: 30;
    text-shadow: 0 1px 3px #000;
    transition: all 0.4s;
}
.badge-offline  { background: rgba(60,60,60,0.9);   color: #aaa;    border: 1.5px solid #666; }
.badge-bet      { background: rgba(0,140,60,0.9);   color: #c8ffd4; border: 1.5px solid #00e676; }
.badge-result   { background: rgba(180,60,0,0.9);   color: #ffe8b0; border: 1.5px solid #ff9900; }

/* =====================================================
   TOAST
   ===================================================== */
#toast-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}
.toast {
    padding: 12px 30px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Arial Black', sans-serif;
    text-shadow: 0 1px 3px #000;
    animation: toast-in 0.3s ease, toast-out 0.4s ease 2.1s forwards;
    white-space: nowrap;
}
.toast-success { background: rgba(0,160,60,0.92); color: #fff; border: 1.5px solid #00ff88; }
.toast-error   { background: rgba(200,30,30,0.92); color: #fff; border: 1.5px solid #ff5555; }
.toast-info    { background: rgba(30,80,200,0.92); color: #fff; border: 1.5px solid #55aaff; }
.toast-win     { background: rgba(180,120,0,0.95); color: #ffe; border: 2px solid gold; font-size: 24px; }
@keyframes toast-in  { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform:translateY(-10px); } }

/* =====================================================
   ANIMATION ELEMENTS
   ===================================================== */
.flying-marble {
    position: absolute;
    background-image: url('assets/marble.png');
    background-size: 100% 100%;
    border-radius: 50%;
    z-index: 55;
    pointer-events: none;
    filter: drop-shadow(0 15px 10px rgba(0,0,0,0.5)) drop-shadow(0 0 6px rgba(255,220,100,0.7));
    will-change: transform, left, top;
}

@keyframes flash-pop {
  0%   { opacity: 0.9; transform: scale(0.5); }
  100% { opacity: 0;   transform: scale(2.2); }
}

@keyframes marble-rest-pulse {
  0%   { filter: drop-shadow(0 0 8px rgba(255,220,80,1)); transform: scale(1); }
  50%  { filter: drop-shadow(0 0 16px rgba(255,220,80,1)); transform: scale(1.1); }
  100% { filter: drop-shadow(0 0 8px rgba(255,220,80,1)); transform: scale(1); }
}

/* =====================================================
   WINNER HIGHLIGHT
   ===================================================== */
.card-zone.winner {
    animation: winner-glow 0.8s ease-out forwards;
    z-index: 28;
    border-color: #ffd700;
    box-shadow: 0 0 20px #ffd700;
}
@keyframes winner-glow {
    0%   { box-shadow: 0 0 0px #ffd700; filter: brightness(1); transform: scale(1); }
    50%  { box-shadow: 0 0 40px #ffd700, inset 0 0 20px #ffd700; filter: brightness(1.5); transform: scale(1.05); }
    100% { box-shadow: 0 0 20px #ffd700; filter: brightness(1); transform: scale(1); }
}



/* =====================================================
   LOADING OVERLAY
   ===================================================== */
#loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    color: #fff;
    font-size: 24px;
    gap: 20px;
    transition: opacity 0.5s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 50px; height: 50px;
    border: 5px solid rgba(255,255,255,0.2);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.round-info {
    position: absolute;
    top: 18px;
    right: 30px;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    z-index: 20;
}

/* ============================================================
   FIXED UI ELEMENTS
   ============================================================ */
.btn-lobby-fixed {
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 8px));
    left: max(8px, env(safe-area-inset-left, 8px));
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    color: #fff;
    text-decoration: none;
    padding: clamp(6px, 1.5vw, 7px) clamp(10px, 2.5vw, 14px);
    font-size: clamp(10px, 2.3vw, 12px);
    font-weight: 700;
    border-radius: clamp(6px, 1.2vw, 8px);
    border: clamp(1px, 0.2vw, 1.5px) solid var(--gold);
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(211,47,47,.5);
    transition: all .2s;
    z-index: 9999;
    letter-spacing: clamp(0.5px, 0.5vw, 1px);
    white-space: normal;
    max-width: clamp(110px, 38vw, 160px);
    min-height: clamp(32px, 7vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
