/* ═══════════════════════════════════════════════════════
   LAYOUT — Game Screen
   Portrait:  sidebar = horizontal top bar (2 hàng)
   Landscape: sidebar = slim right column
   ═══════════════════════════════════════════════════════ */

/* showScreen() sets display:block — override with !important */
#game-screen.active {
    display: flex !important;
    flex-direction: column;
    padding: 0 !important;
    height: 100vh;
    overflow: hidden;
}

#game-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ── SIDEBAR (portrait = top bar, 2 hàng) ── */

#game-sidebar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 4px 10px;
    background: linear-gradient(180deg, #0f0f18 0%, #17172a 100%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 100;
    overflow: visible;
}

.gsb-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 100%;
    min-width: 0;
    padding: 3px 0 2px;
}

.gsb-room {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-sub);
    font-size: 0.78rem;
    flex-shrink: 0;
}

.gsb-code {
    font-weight: bold;
    font-size: 0.86rem;
    letter-spacing: 1px;
}

.gsb-badges {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

#btn-room-settings {
    color: var(--text-sub);
    font-size: 0.9rem;
    padding: 3px 5px;
    cursor: pointer;
    transition: color 0.15s;
    border-radius: 6px;
    flex-shrink: 0;
}
#btn-room-settings:hover { color: var(--gold); }

/* Dòng kẻ giữa 2 hàng */
.gsb-divider {
    display: block;
    width: 100%;
    height: 1px;
    background: var(--border);
    flex-shrink: 0;
}

.gsb-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 100%;
    padding: 2px 0 3px;
    justify-content: space-between;
}

.gsb-user { display: flex; align-items: center; gap: 4px; }

.gsb-balance {
    color: var(--gold) !important;
    font-weight: bold;
    font-size: 0.78rem;
    display: flex !important;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    background: var(--gold-dim);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 8px;
    padding: 3px 8px;
}

.gsb-btns {
    display: flex;
    gap: 5px;
    align-items: center;
}

.gsb-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
}
.gsb-btn:active { opacity: 0.7; transform: scale(0.95); }
.gsb-btn span { display: inline; }

.gsb-transfer { background: rgba(27,94,54,0.9); color: #4caf50; border: 1px solid rgba(76,175,80,0.35); }
.gsb-expand   { background: rgba(61,46,0,0.9);  color: #ffc107; border: 1px solid rgba(255,193,7,0.35); }
.gsb-leave    { background: rgba(61,0,0,0.9);   color: #ff5252; border: 1px solid rgba(255,82,82,0.35); }

/* ── GAME MAIN AREA ── */

#game-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

#dynamic-game-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 0;
    display: flex;
    flex-direction: column;
}

#game-sys-msg {
    padding: 5px 12px;
    font-size: 0.86rem;
    color: var(--text-sub);
    font-weight: bold;
    flex-shrink: 0;
    min-height: 26px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════
   LANDSCAPE AUTO (orientation media query)
   ═══════════════════════════════════════════════════════ */

@media (orientation: landscape) {
    #game-screen.active { flex-direction: row-reverse !important; }
    #game-layout        { flex-direction: row-reverse !important; }

    #game-sidebar {
        flex-direction: column !important;
        width: var(--sidebar-w) !important;
        min-width: var(--sidebar-w) !important;
        max-width: var(--sidebar-w) !important;
        height: 100vh !important;
        padding: 8px 4px !important;
        gap: 5px !important;
        align-items: center !important;
        border-bottom: none !important;
        border-left: 1px solid var(--border) !important;
        overflow: hidden !important;
        flex-wrap: nowrap !important;
    }

    .gsb-info {
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        flex: 0 0 auto !important;
        width: 100% !important;
    }

    .gsb-room {
        flex-direction: column !important;
        gap: 1px !important;
        font-size: 0.68rem !important;
    }
    .gsb-code { font-size: 0.75rem !important; letter-spacing: 0.5px !important; }

    .gsb-badges {
        flex-direction: column !important;
        gap: 3px !important;
        width: 100% !important;
        align-items: center !important;
    }

    .bet-badge {
        width: 62px !important;
        justify-content: center !important;
        font-size: 0.62rem !important;
        padding: 3px 4px !important;
        max-width: 62px !important;
        overflow: hidden !important;
    }

    .gsb-divider {
        display: block !important;
        width: 48px;
        height: 1px;
        background: var(--border);
        flex-shrink: 0;
    }

    .gsb-controls {
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        width: 100% !important;
        flex: 1 !important;
        justify-content: flex-end !important;
        padding-bottom: 4px !important;
    }

    .gsb-user {
        flex-direction: column !important;
        align-items: center !important;
        gap: 3px !important;
        width: 100% !important;
    }

    .gsb-balance {
        font-size: 0.68rem !important;
        justify-content: center !important;
        width: 62px !important;
        padding: 3px 4px !important;
    }

    .gsb-btns {
        flex-direction: column !important;
        gap: 4px !important;
        width: 100% !important;
        align-items: center !important;
    }

    .gsb-btn {
        flex-direction: column !important;
        padding: 7px 4px !important;
        width: 62px !important;
        font-size: 0.58rem !important;
        justify-content: center !important;
        gap: 3px !important;
        border-radius: 8px !important;
    }
    .gsb-btn i    { font-size: 1rem !important; }
    .gsb-btn span { font-size: 0.58rem !important; line-height: 1.1 !important; }

    #game-sys-msg {
        position: absolute !important;
        bottom: 4px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: rgba(0,0,0,0.75) !important;
        padding: 4px 14px !important;
        border-radius: 20px !important;
        pointer-events: none !important;
        white-space: nowrap !important;
        z-index: 500 !important;
    }
}

/* ═══════════════════════════════════════════════════════
   EXPLICIT FULLSCREEN (body.is-fullscreen via JS toggle)
   ═══════════════════════════════════════════════════════ */

body.is-fullscreen #game-screen.active { flex-direction: row-reverse !important; }
body.is-fullscreen #game-layout        { flex-direction: row-reverse !important; }

body.is-fullscreen #game-sidebar {
    flex-direction: column !important;
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    max-width: var(--sidebar-w) !important;
    height: 100vh !important;
    padding: 8px 4px !important;
    gap: 5px !important;
    align-items: center !important;
    border-bottom: none !important;
    border-left: 1px solid var(--border) !important;
    overflow: hidden !important;
    flex-wrap: nowrap !important;
}

body.is-fullscreen .gsb-info       { flex-direction: column !important; align-items: center !important; gap: 4px !important; flex: 0 0 auto !important; width: 100% !important; }
body.is-fullscreen .gsb-room       { flex-direction: column !important; gap: 1px !important; font-size: 0.68rem !important; }
body.is-fullscreen .gsb-code       { font-size: 0.75rem !important; letter-spacing: 0.5px !important; }
body.is-fullscreen .gsb-badges     { flex-direction: column !important; gap: 3px !important; width: 100% !important; align-items: center !important; }
body.is-fullscreen .bet-badge      { width: 62px !important; justify-content: center !important; font-size: 0.62rem !important; padding: 3px 4px !important; max-width: 62px !important; overflow: hidden !important; }
body.is-fullscreen .gsb-divider    { display: block !important; width: 48px; height: 1px; background: var(--border); flex-shrink: 0; }
body.is-fullscreen .gsb-controls   { flex-direction: column !important; align-items: center !important; gap: 4px !important; width: 100% !important; flex: 1 !important; justify-content: flex-end !important; padding-bottom: 4px !important; }
body.is-fullscreen .gsb-user       { flex-direction: column !important; align-items: center !important; gap: 3px !important; width: 100% !important; }
body.is-fullscreen .gsb-balance    { font-size: 0.68rem !important; justify-content: center !important; width: 62px !important; padding: 3px 4px !important; }
body.is-fullscreen .gsb-btns       { flex-direction: column !important; gap: 4px !important; width: 100% !important; align-items: center !important; }
body.is-fullscreen .gsb-btn        { flex-direction: column !important; padding: 7px 4px !important; width: 62px !important; font-size: 0.58rem !important; justify-content: center !important; gap: 3px !important; border-radius: 8px !important; }
body.is-fullscreen .gsb-btn i      { font-size: 1rem !important; }
body.is-fullscreen .gsb-btn span   { font-size: 0.58rem !important; line-height: 1.1 !important; }

body.is-fullscreen #game-sys-msg {
    position: absolute !important;
    bottom: 4px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(0,0,0,0.75) !important;
    padding: 4px 14px !important;
    border-radius: 20px !important;
    pointer-events: none !important;
    white-space: nowrap !important;
    z-index: 500 !important;
}

body.is-fullscreen .modal-box  { transform: none !important; width: min(80vw, 380px) !important; }
body.is-fullscreen #toast-msg  { transform: translateX(-50%) !important; top: 12px !important; left: 50% !important; }
