/* =====================================================
 * STYLE.CSS — Prism Engine Platform Stylesheet
 * =====================================================
 * Thiết kế giao diện hiện đại phong cách Cyber-Arcade Dark Theme.
 * Chứa toàn bộ Base Layout, Components chung và 4 Màn hình Nền tảng.
 * 
 * LƯU Ý KIẾN TRÚC:
 *   CSS của từng game được bóc tách riêng tại css/games/<gameId>.css
 *   và chỉ được GameLoader nạp động khi vào trận.
 * ===================================================== */

/* =====================================================
 * 1. RESET & CSS VARIABLES (HỆ THỐNG MÀU SẮC ĐỒNG BỘ)
 * ===================================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Bảng màu nền sâu (Deep Dark Space) */
    --bg-primary: #0a0f16;
    --bg-secondary: #121c27;
    --bg-card: #182535;
    --bg-card-hover: #1e3044;
    --bg-input: #0e1622;

    /* Bảng màu chữ (Typography Colors) */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Màu điểm nhấn (Cyber Accent Palette) */
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --accent-glow: rgba(56, 189, 248, 0.28);
    --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
    --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);

    /* Màu ngữ nghĩa trạng thái (Semantic Colors) */
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.3);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.3);

    /* Viền & Đổ bóng (Borders & Shadows) */
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.16);
    --border-accent: rgba(56, 189, 248, 0.45);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(99, 102, 241, 0.04) 0%, transparent 40%);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =====================================================
 * 2. LAYOUT CHUNG & HEADER
 * ===================================================== */
.main-content {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    padding: 16px;
}

.app-header {
    width: 100%;
    padding: 14px 24px;
    background: rgba(18, 28, 39, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    transition: padding 0.3s ease;
}

.app-header h1 {
    font-size: 1.55rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.app-header .subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 3px;
    letter-spacing: 0.5px;
}

/* Chế độ thu gọn Header khi đang trong trận đấu */
body.in-gameplay .app-header,
body:has(#screen-game.active) .app-header {
    padding: 6px 16px;
}

body.in-gameplay .app-header h1,
body:has(#screen-game.active) .app-header h1 {
    font-size: 1.15rem;
    letter-spacing: 1.5px;
}

body.in-gameplay .app-header .subtitle,
body:has(#screen-game.active) .app-header .subtitle {
    display: none;
}

body.in-gameplay .main-content,
body:has(#screen-game.active) .main-content {
    overflow: hidden;
    padding: 6px 12px;
}

/* =====================================================
 * 3. ROUTER MÀN HÌNH (SCREEN MANAGEMENT)
 * ===================================================== */
.screen {
    display: none;
    width: 100%;
    max-width: 960px;
    animation: screenFadeIn 0.25s ease-out;
}

.screen.active {
    display: block;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
 * 4. CARDS & PANELS
 * ===================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 26px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    transition: border-color 0.25s ease;
}

.card:hover {
    border-color: var(--border-light);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.divider-text {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 16px 0;
    font-weight: 600;
    letter-spacing: 1.5px;
}

/* =====================================================
 * 5. BUTTONS (NÚT BẤM HIỆN ĐẠI)
 * ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(40%);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
    filter: brightness(1.1);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--success-glow);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.55);
    filter: brightness(1.1);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--error-glow);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-unready {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--warning-glow);
}

.btn-unready:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.55);
    filter: brightness(1.1);
}

.btn-join {
    background: var(--primary-gradient);
    color: #ffffff;
    font-weight: 600;
}

.btn-join:hover:not(:disabled) {
    filter: brightness(1.15);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

/* =====================================================
 * 6. FORMS & INPUTS
 * ===================================================== */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-secondary);
}

/* =====================================================
 * 7. BADGES & CHIPS
 * ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-accent {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-turn {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-waiting {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-playing {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =====================================================
 * 8. MÀN 1: DANH MỤC GAME (GAME CATALOG)
 * ===================================================== */
.profile-card {
    background: linear-gradient(135deg, rgba(24, 37, 53, 0.9) 0%, rgba(18, 28, 39, 0.95) 100%);
    border: 1px solid var(--border-light);
}

.profile-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.game-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-accent);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent-glow);
    background: var(--bg-card-hover);
}

.game-card:hover::before {
    opacity: 1;
}

.game-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.game-card .game-icon {
    font-size: 2.2rem;
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    background: rgba(56, 189, 248, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.game-card .game-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.game-card .game-name {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--text-primary);
}

.game-card .game-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.game-card .game-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* =====================================================
 * 9. MÀN 2: SẢNH PHÒNG (GAME LOBBY)
 * ===================================================== */
.lobby-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 18px;
    margin-bottom: 18px;
}

.lobby-active-game {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.highlight-game {
    font-weight: 700;
    color: var(--accent);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    text-align: left;
}

thead {
    background: rgba(14, 22, 34, 0.85);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =====================================================
 * 10. MÀN 3: PHÒNG CHỜ (WAITING ROOM)
 * ===================================================== */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 20px;
    gap: 12px;
}

.room-code-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.room-code {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    background: var(--bg-input);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    letter-spacing: 1px;
}

/* Node Badge (Chứng minh kiến trúc Data Plane Node) */
.node-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.node-badge .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: statusPulse 1.8s infinite;
}

.node-badge.disconnected {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

.node-badge.disconnected .status-dot {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.section-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Danh sách người chơi trong phòng (Player Slot Cards) */
.member-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.member-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.member-item.is-me {
    border-color: var(--border-accent);
    background: rgba(56, 189, 248, 0.05);
}

.member-item.member-item-empty {
    border: 1px dashed var(--border);
    background: rgba(14, 22, 34, 0.35);
    opacity: 0.6;
}

.member-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-status {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.member-status.ready {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.member-status.not-ready {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Cài đặt phòng động (Room Settings) */
.room-settings-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.room-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.room-settings-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.room-settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.room-settings-hint.is-host {
    color: #34d399;
    font-weight: 600;
}

.room-settings-hint.is-guest {
    color: var(--text-muted);
}

.room-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.setting-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.setting-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.setting-select:focus:not(:disabled) {
    border-color: var(--accent);
}

.setting-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.room-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* =====================================================
 * 11. MÀN 4: TRẬN ĐẤU (GAMEPLAY SCREEN)
 * ===================================================== */
#screen-game {
    max-width: 1200px;
    width: 98%;
    height: 100%;
    max-height: 100%;
    padding: 4px 8px;
    box-sizing: border-box;
    min-height: 0;
}

#screen-game.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.game-card-container {
    padding: 8px 14px;
    position: relative;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

.game-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.game-status-bar::-webkit-scrollbar {
    display: none;
}

.game-title-badge {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.game-meta-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.gameplay-scoreboard {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.scoreboard-vs {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.scoreboard-vs .sb-colon {
    color: var(--accent);
}

.scoreboard-vs .sb-score {
    font-size: 1.05rem;
    color: #ffffff;
}

.scoreboard-vs .is-me .sb-name {
    color: var(--accent);
}

.sb-tag-you {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(56, 189, 248, 0.25);
    color: var(--accent);
    margin-left: 2px;
}

.scoreboard-multi {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.scoreboard-multi .sb-chip {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.scoreboard-multi .sb-chip.is-me {
    border-color: var(--accent);
}

.game-canvas-wrapper {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Modal Game Over */
.game-over-modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 22, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.25s ease;
}

.game-over-content {
    background: var(--bg-card);
    border: 2px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 28px 36px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 32px var(--accent-glow);
    max-width: 440px;
    width: 90%;
    animation: bounceIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-over-title {
    font-size: 1.45rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.game-over-desc {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.game-over-timer {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* =====================================================
 * 12. NETWORK INSPECTOR WIDGET (CHẨN ĐOÁN MẠNG)
 * ===================================================== */
.network-inspector {
    position: relative;
    width: 100%;
    z-index: 100;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.inspector-resizer {
    width: 100%;
    height: 7px;
    cursor: row-resize;
    background: transparent;
    transition: background 0.2s;
    user-select: none;
}

.inspector-resizer:hover, .inspector-resizing .inspector-resizer {
    background: var(--accent);
}

body.inspector-resizing {
    user-select: none !important;
    cursor: row-resize !important;
}

body.inspector-resizing * {
    user-select: none !important;
    cursor: row-resize !important;
}

body.inspector-resizing .inspector-body {
    transition: none !important;
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 18px;
    background: rgba(14, 22, 34, 0.95);
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
}

.inspector-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text-primary);
}

.inspector-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.inspector-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.inspector-telemetry {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.inspector-body {
    height: var(--inspector-height, 160px);
    overflow-y: auto;
    background: #080c12;
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.network-inspector.collapsed .inspector-body {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top: none;
    overflow: hidden;
}

.inspector-logs {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.log-entry {
    line-height: 1.45;
    word-break: break-all;
}

.log-in  { color: #fde047; } /* Vàng cho Inbound */
.log-out { color: #86efac; } /* Xanh lá cho Outbound */
.log-sys { color: #94a3b8; } /* Xám cho System */
.log-err { color: #fca5a5; } /* Đỏ cho Error */

/* =====================================================
 * 13. TOAST & CONFIRM MODAL
 * ===================================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent);
    font-size: 0.88rem;
    font-weight: 600;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}

.toast-info    { border-left-color: var(--accent); }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }
.toast-hide    { opacity: 0; transform: translateX(20px); }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

.confirm-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 22, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.confirm-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.confirm-modal-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.confirm-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-modal-message {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.confirm-modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* =====================================================
 * 14. RESPONSIVE MEDIA QUERIES
 * ===================================================== */
@media (max-width: 640px) {
    .main-content { padding: 10px; }
    .card { padding: 16px; }
    .game-grid { grid-template-columns: 1fr; }
    .room-header { flex-direction: column; align-items: flex-start; }
    .form-row { flex-direction: column; align-items: stretch; }
    .inspector-telemetry { display: none; }
}


/* =====================================================
 * 15. RECONNECT OVERLAY & DUPLICATE TAB & PAUSE TURN
 * ===================================================== */
.pause-turn-banner {
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    color: #fef08a;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 14px;
    margin-bottom: 10px;
    text-align: center;
    animation: pulsePause 2s infinite ease-in-out;
}

@keyframes pulsePause {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.5; }
}

.reconnect-overlay,
.duplicate-tab-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 22, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.reconnect-card,
.duplicate-tab-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.reconnect-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px auto;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.reconnect-title,
.duplicate-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.reconnect-msg,
.duplicate-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.duplicate-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.duplicate-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.member-item.is-disconnected {
    opacity: 0.7;
    border-color: rgba(239, 68, 68, 0.4);
}

