/* ═══════════════════════════════════════════════════════════
   Dojo eSports — Game Room Layout
   Overrides the legacy console-style gamebody with a
   modern full-screen PvP split layout.
══════════════════════════════════════════════════════════════ */

/* ─── Full-screen override for #gamebody ─────────────────── */
#gamebody {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
    background-image: none !important;
    background-color: #080604 !important;
    display: flex !important;
    flex-direction: row !important;
    overflow: hidden !important;
    align-items: stretch !important;
}

/* Chat panel inside gamebody — keeps natural flex-row position */
#gamebody .game-chat-panel {
    position: relative !important;
    z-index: 10 !important;
}

/* Chat collapsed tab — always fixed to right edge */
#gamebody + .chat-collapsed-tab,
.chat-collapsed-tab {
    position: fixed !important;
    right: 0;
    top: 50%;
}

/* ─── Left sidebar (same token system as dashboard) ──────── */
.game-sidebar {
    width: 260px;
    min-width: 260px;
    height: 100%;
    background: var(--bg-panel, rgba(14,10,6,0.97));
    border-right: 1px solid var(--border-subtle, rgba(255,107,0,0.12));
    display: flex;
    flex-direction: column;
    padding: 24px 18px 18px;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 10;
    gap: 0;
    flex-shrink: 0;
}

.game-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: -1px;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--orange-primary, #ff6b00), transparent);
    opacity: 0.22;
    pointer-events: none;
}

/* Scrollbar for sidebar */
.game-sidebar::-webkit-scrollbar { width: 3px; }
.game-sidebar::-webkit-scrollbar-track { background: transparent; }
.game-sidebar::-webkit-scrollbar-thumb {
    background: var(--orange-border, rgba(255,107,0,0.20));
    border-radius: 3px;
}

/* ── Active game info card ─────────────────────────────────── */
.active-game-card {
    background: var(--orange-gradient-soft, linear-gradient(135deg, rgba(255,107,0,0.12),rgba(255,154,60,0.05)));
    border: 1px solid var(--orange-border, rgba(255,107,0,0.20));
    border-radius: 12px;
    padding: 14px 14px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.active-game-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary, #f5f0eb);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Right game content panel ───────────────────────────── */
.game-content {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

/* ── Top controls bar ─────────────────────────────────────── */
.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 44px;
    flex-shrink: 0;
    background: rgba(8, 6, 4, 0.95);
    border-bottom: 1px solid rgba(255,107,0,0.10);
    gap: 8px;
    position: relative;
    z-index: 5;
}

.game-ctrl-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Control buttons (SELECT, START, LOAD, SAVE) */
/* Override ALL legacy .btn and .btn.big styles */
#gamebody .game-top-bar .game-ctrl-btn,
#gamebody .game-top-bar .btn,
#gamebody .game-top-bar .btn.big {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 5px 12px !important;
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
    border-radius: 6px !important;
    color: var(--text-secondary, #9a8070) !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    transition: all 0.22s ease !important;
    user-select: none !important;
    /* Full override of legacy positioning */
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    background-image: none !important;
    background-repeat: unset !important;
    background-size: unset !important;
    text-align: center !important;
}

#gamebody .game-top-bar .game-ctrl-btn:hover,
#gamebody .game-top-bar .btn:hover {
    background: rgba(255,107,0,0.12) !important;
    border-color: rgba(255,107,0,0.30) !important;
    color: var(--orange-light, #ff9a3c) !important;
}

#gamebody .game-top-bar .game-ctrl-btn:active,
#gamebody .game-top-bar .btn:active {
    transform: scale(0.95) !important;
}

#gamebody .game-top-bar .game-ctrl-btn--secondary {
    background: rgba(255,107,0,0.08) !important;
    border-color: rgba(255,107,0,0.18) !important;
    color: var(--orange-light, #ff9a3c) !important;
}

/* ── Game screen override ─────────────────────────────────── */
#gamebody #screen {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - 44px) !important;
    flex: 1 !important;
    z-index: 1 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background-color: #000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}

/* Video and canvas fill the screen */
#gamebody .game-screen {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* Menu screen (pre-game selection) */
#gamebody #menu-screen {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-image: url('/img/screen_background5.png');
    background-size: cover;
    background-position: center;
    z-index: 2;
}

#gamebody #menu-container {
    position: absolute;
    width: 100%;
    top: calc(50% - 18px);
    left: 0;
}

#gamebody #menu-item-choice {
    width: 100%;
    height: 36px;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    background-color: rgba(255,107,0,0.25);
    mix-blend-mode: lighten;
    opacity: 0.8;
}

/* ── Notification box ─────────────────────────────────────── */
#gamebody #noti-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    background: rgba(255,107,0,0.15);
    border: 1px solid rgba(255,107,0,0.35);
    border-radius: 30px;
    color: var(--text-primary, #f5f0eb);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 20;
    backdrop-filter: blur(8px);
    white-space: nowrap;
    pointer-events: none;
}

/* ── Help overlay ─────────────────────────────────────────── */
#gamebody #help-overlay {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 50 !important;
}

/* ── Sidebar action buttons override for game room ───────── */
/* Override legacy .btn absolute positioning when inside game-sidebar */
#gamebody .game-sidebar .sidebar-actions,
#gamebody .game-sidebar .game-sidebar-actions {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle, rgba(255,107,0,0.12));
}

#gamebody .game-sidebar .action-icon-btn,
#gamebody .game-sidebar .btn {
    /* clear ALL legacy .btn styles */
    background-image: none !important;
    background-repeat: unset !important;
    background-size: unset !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    padding-top: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    /* Apply action-icon-btn base styles */
    flex: 1;
    padding: 10px 6px !important;
    background: rgba(0,0,0,0.30);
    border: 1px solid var(--border-subtle, rgba(255,107,0,0.12));
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    color: var(--text-secondary, #9a8070);
    text-decoration: none;
}

#gamebody .game-sidebar .action-icon-btn:hover,
#gamebody .game-sidebar .btn:hover {
    background: var(--orange-gradient-soft, linear-gradient(135deg,rgba(255,107,0,0.18),rgba(255,154,60,0.08))) !important;
    border-color: var(--orange-border, rgba(255,107,0,0.20)) !important;
    color: var(--orange-light, #ff9a3c) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 0 10px rgba(255,107,0,0.18) !important;
}

#gamebody .game-sidebar .action-icon-btn:active,
#gamebody .game-sidebar .btn:active {
    transform: scale(0.95) !important;
}

/* Specific override for #btn-settings inside game body to prevent legacy transform/floating style conflicts */
#gamebody .game-sidebar #btn-settings {
    transform: none !important;
    opacity: 1 !important;
    z-index: auto !important;
}
#gamebody .game-sidebar #btn-settings:hover {
    transform: translateY(-2px) !important;
}
#gamebody .game-sidebar #btn-settings:active {
    transform: scale(0.95) !important;
}

/* Danger variant (Quit button) */
.action-icon-btn--danger {
    border-color: rgba(220, 50, 50, 0.20) !important;
}
.action-icon-btn--danger:hover {
    background: rgba(220, 50, 50, 0.12) !important;
    border-color: rgba(220, 50, 50, 0.45) !important;
    color: #ffb5a7 !important;
}

/* ── Room strip ───────────────────────────────────────────── */
.game-room-strip {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.room-strip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.30);
    border: 1px solid var(--border-subtle, rgba(255,107,0,0.12));
    border-radius: 8px;
    padding: 8px 12px;
}

.room-strip-label {
    font-size: 0.6rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted, #5a4a3a);
    font-family: 'Outfit', sans-serif;
}

.room-strip-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--orange-light, #ff9a3c);
    font-family: monospace;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Player index display ─────────────────────────────────── */
.player-idx-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--orange-gradient, linear-gradient(135deg,#ff6b00,#ff9a3c));
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
    font-size: 0.8rem;
    box-shadow: 0 0 10px rgba(255,107,0,0.35);
    cursor: pointer;
    transition: all 0.22s ease;
    user-select: none;
    font-family: 'Outfit', sans-serif;
}

.player-idx-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 0 18px rgba(255,107,0,0.55);
}

/* Guest player: locked to server-assigned slot */
.player-idx-badge.player-idx-locked {
    background: linear-gradient(135deg, #663300, #994400) !important;
    box-shadow: 0 0 10px rgba(200,80,0,0.30) !important;
    cursor: not-allowed !important;
    position: relative;
}

.player-idx-badge.player-idx-locked::after {
    content: '🔒';
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.55rem;
    background: rgba(0,0,0,0.8);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 14px;
}

.player-idx-badge.player-idx-locked:hover {
    transform: none !important;
    box-shadow: 0 0 10px rgba(200,80,0,0.30) !important;
    animation: locked-shake 0.35s ease;
}

@keyframes locked-shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-3px); }
    75%       { transform: translateX(3px); }
}

/* ── Mobile / touch controls (hidden on desktop) ─────────── */
.touch-only {
    display: none !important;
}

@media (pointer: coarse) and (max-width: 768px) {
    .touch-only {
        display: block !important;
    }
    .game-sidebar {
        display: none;
    }
    .game-top-bar {
        height: 36px;
    }
}

/* ── Stats overlay fix inside new layout ─────────────────── */
#gamebody .screen__footer {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: calc(100% - 0.4rem) !important;
}




/* ── Override misc legacy elements ───────────────────────── */
/* Keep these in DOM but visually hidden */
#gamebody #room-txt,
#gamebody .dpad-toggle-label,
#gamebody #btn-help,
#gamebody #kbm,
#gamebody #w,
#gamebody #btn-rec,
#gamebody #user-name {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Circle pad and color buttons — hidden on desktop */
#gamebody #circle-pad-holder,
#gamebody #color-button-holder {
    display: none !important;
}

/* kbm2 button within screen footer — keep styled */
#gamebody #kbm2 {
    position: static !important;
}
