/* ═══════════════════════════════════════════════════════════════
   Karatatatu — Dark Mode Theme (adapted from mytemplate design)
   Fonts: Fraunces (serif) + Plus Jakarta Sans (sans)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Core palette — refined dark mode */
    --bg: #0a0a12;
    --bg2: #12121c;
    --cream: #111119;
    --sand: #14141e;
    --sand2: #1c1c28;
    --terra: #e07840;
    --terra-dark: #b85e30;
    --terra-pale: rgba(224,120,64,0.08);
    --teal: #2ec4a6;
    --teal-light: #44d6b8;
    --teal-pale: rgba(46,196,166,0.08);
    --ink: #e8e6e0;
    --ink-mid: #908880;
    --ink-light: #58524a;
    --white: #ffffff;
    --panel: #141420;
    --panel-border: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.06);
    --glass: rgba(20,20,32,0.75);
    --glass-border: rgba(255,255,255,0.08);
    --shadow: rgba(0,0,0,0.5);
    --shadow2: rgba(0,0,0,0.6);
    --radius: 12px;

    /* Game table */
    --table-top: #2e2218;
    --table-side: #221810;
    --table-rim: #3e2e1c;

    /* Status */
    --success: #2ecc71;
    --warning: #f5a623;
    --danger: #ef4444;

    /* Dimensions */
    --card-width: 100px;
    --card-height: 140px;
    --card-width-sm: 32px;
    --card-height-sm: 45px;
    --table-card-width: 60px;
    --table-card-height: 84px;
    --nav-w: 230px;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

h1, h2, h3 { font-weight: 600; }

a { color: var(--terra); text-decoration: none; }
a:hover { text-decoration: underline; }
.h-logo:hover { text-decoration: none; }

/* ── BUTTONS ── */
.btn {
    padding: 0.45rem 0.9rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--sand2);
    color: var(--ink);
    transition: all 0.15s;
}
.btn:hover { background: #22222e; }
.btn-primary {
    background: var(--terra);
    color: white;
    box-shadow: 0 3px 12px rgba(224,120,64,0.3);
}
.btn-primary:hover { background: var(--terra-dark); transform: translateY(-1px); }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.btn-warning { background: var(--warning); color: #000; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-teal {
    background: var(--teal);
    color: white;
    box-shadow: 0 3px 12px rgba(46,196,166,0.3);
}
.btn-teal:hover { background: var(--teal-light); transform: translateY(-1px); }
.btn-outline {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--ink-mid);
}
.btn-outline:hover { border-color: var(--ink-light); color: var(--ink); }

/* ── FORMS ── */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--ink-mid);
    margin-bottom: 7px;
    text-transform: uppercase;
}
.field-wrap { position: relative; }
.field-wrap i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--ink-light); font-size: 15px; transition: color 0.2s;
    pointer-events: none;
}
.field-wrap input,
.field-wrap select {
    width: 100%;
    padding: 13px 14px 13px 42px;
    background: var(--bg);
    border: 1.5px solid var(--sand2);
    border-radius: 12px;
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.field-wrap input:focus,
.field-wrap select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(42,124,111,0.2);
}
.field-wrap input:focus ~ i { color: var(--teal); }
/* Inputs without icon */
.field input:not(.field-wrap input),
.field select:not(.field-wrap select) {
    width: 100%;
    padding: 13px 14px;
    background: var(--bg);
    border: 1.5px solid var(--sand2);
    border-radius: 12px;
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}
.field input:not(.field-wrap input):focus,
.field select:not(.field-wrap select):focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(42,124,111,0.2);
}

/* Legacy form-group (used by some forms) */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    letter-spacing: 0.5px; color: var(--ink-mid);
    margin-bottom: 7px; text-transform: uppercase;
}
.form-group input,
.form-group select {
    width: 100%; padding: 13px 14px;
    background: var(--bg); border: 1.5px solid var(--sand2);
    border-radius: 12px; color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px; outline: none;
    transition: all 0.2s ease;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(42,124,111,0.2);
}

.errors p, .errorlist li {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}
.errorlist { list-style: none; }

/* ═══════════════════════════════════════════
   AUTH PAGE — kuingia style (login/register)
   ═══════════════════════════════════════════ */
.auth-page {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* Left branding panel */
.auth-left {
    width: 52%;
    background: var(--terra);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 48px;
}
.auth-left::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 10% 10%, rgba(255,255,255,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 85%, rgba(160,80,40,0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(200,100,50,0.3) 0%, transparent 70%);
}
.deco {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
}
.deco-1 { width: 300px; height: 300px; top: -80px; right: -80px; }
.deco-2 { width: 180px; height: 180px; top: 60px; right: 40px; }
.deco-3 { width: 200px; height: 200px; bottom: -60px; left: -60px; }
.deco-4 { width: 120px; height: 120px; bottom: 80px; left: 80px; background: rgba(255,255,255,0.05); }

.table-preview {
    position: relative; z-index: 2;
    width: 260px; height: 260px;
    margin-bottom: 36px;
}
.left-text { position: relative; z-index: 2; text-align: center; }
.left-logo {
    display: flex; align-items: center; gap: 10px;
    justify-content: center; margin-bottom: 20px;
}
.logo-mark {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    backdrop-filter: blur(8px);
    overflow: hidden;
}
.logo-mark img, .logo-mark svg {
    width: 100%; height: 100%; object-fit: contain;
}
.logo-name {
    font-family: 'Fraunces', serif;
    font-size: 36px; font-weight: 900;
    color: white; letter-spacing: -1px;
}
.left-tagline {
    font-family: 'Fraunces', serif;
    font-size: 22px; font-weight: 400; font-style: italic;
    color: rgba(255,255,255,0.9);
    line-height: 1.4; margin-bottom: 28px;
}
.left-pills { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pill {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px; padding: 7px 16px;
    font-size: 13px; color: rgba(255,255,255,0.9);
    display: flex; align-items: center; gap: 6px;
    backdrop-filter: blur(4px);
}
.pill i { font-size: 12px; }

/* Right form panel */
.auth-right {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 48px 40px;
    background: var(--bg);
    position: relative;
    overflow-y: auto;
}
.auth-right::before {
    content: '';
    position: absolute; top: 0; right: 0;
    width: 200px; height: 200px;
    background: radial-gradient(circle, var(--teal-pale) 0%, transparent 70%);
    opacity: 0.5;
}
.form-wrap {
    width: 100%; max-width: 400px;
    position: relative; z-index: 1;
    animation: fadeUp 0.6s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
.form-top { margin-bottom: 32px; }
.form-greeting {
    font-family: 'Fraunces', serif;
    font-size: 30px; font-weight: 700;
    color: var(--ink); margin-bottom: 6px;
    line-height: 1.2;
}
.form-sub { font-size: 15px; color: var(--ink-light); }

/* Tabs */
.tabs {
    display: flex;
    background: var(--sand);
    border-radius: 12px; padding: 4px;
    margin-bottom: 28px; gap: 4px;
}
.tab {
    flex: 1; padding: 10px 16px;
    border: none; cursor: pointer;
    border-radius: 9px; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px; font-weight: 600;
    transition: all 0.25s ease;
    background: transparent; color: var(--ink-light);
}
.tab.active {
    background: var(--panel);
    color: var(--terra);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.btn-main {
    width: 100%; padding: 12px 20px;
    background: linear-gradient(135deg, var(--terra), var(--terra-dark));
    border: none; border-radius: 10px;
    color: white; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 16px rgba(224,120,64,0.3);
}
.btn-main:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-main:disabled { opacity: 0.6; cursor: default; transform: none; filter: none; }

.sep {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; color: var(--ink-light); font-size: 13px;
}
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--sand2); }

.btn-google {
    width: 100%; padding: 13px 24px;
    background: var(--panel); border: 1.5px solid var(--sand2);
    border-radius: 12px; color: var(--ink-mid);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    text-decoration: none; line-height: 1.4;
}
.btn-google:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); text-decoration: none; }

.form-footer {
    margin-top: 24px; text-align: center;
    font-size: 13px; color: var(--ink-light);
}

/* Compact mobile header inside .auth-right (hidden on desktop) */
.auth-mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sand2);
}
.auth-mobile-header .logo-img {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--terra);
    padding: 6px;
    display: flex; align-items: center; justify-content: center;
}
.auth-mobile-header .logo-img img { width: 100%; height: 100%; object-fit: contain; }
.auth-mobile-header .brand-name {
    font-family: 'Fraunces', serif;
    font-size: 26px; font-weight: 900;
    color: var(--ink); letter-spacing: -0.5px;
}
.auth-mobile-header--always { display: flex !important; flex: 1; }
.auth-mobile-header--always .brand-name { flex: 1; }
.auth-mobile-header .header-logout {
    margin-left: auto;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    color: var(--ink-mid);
    background: var(--sand);
    text-decoration: none;
    transition: all 0.2s ease;
}
.auth-mobile-header .header-logout:hover { background: var(--terra); color: #fff; }

/* Solo auth page (home — no left branding) */
.auth-page--solo { justify-content: center; background: var(--bg); }
.auth-right--solo {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 40px 32px;
}

.form-hint {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--sand);
    border: 1px solid var(--sand2);
    border-radius: 10px;
    font-size: 12.5px;
    color: var(--ink-mid);
    line-height: 1.5;
    display: flex; align-items: flex-start; gap: 8px;
}
.form-hint i { color: var(--teal); margin-top: 2px; }

@media (max-width: 768px) {
    .auth-page { flex-direction: column; overflow: auto; min-height: 100vh; min-height: 100dvh; }
    .auth-left { display: none !important; }
    .auth-right { width: 100%; padding: 28px 22px; min-height: 100vh; min-height: 100dvh; }
    .auth-mobile-header { display: flex; }
}

/* ═══════════════════════════════════════════
   INVITE PAGE
   ═══════════════════════════════════════════ */
.invite-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 2rem;
}
.invite-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeUp 0.6s cubic-bezier(0.22,1,0.36,1) both;
}
.invite-card h1 {
    font-family: 'Fraunces', serif;
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}
.invite-card .room-code-display {
    display: inline-block;
    background: var(--terra-pale);
    color: var(--terra);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
}

/* ═══════════════════════════════════════════════════
   ROOM / GAME PAGE — mchezo style
   ═══════════════════════════════════════════════════ */
.room-page {
    display: grid;
    grid-template-rows: 52px 1fr;
    grid-template-columns: 240px 1fr 280px;
    grid-template-areas:
        "header header header"
        "sidebar game chat";
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* Header */
.room-header {
    grid-area: header;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}
.h-logo {
    display: flex; align-items: center; gap: 8px;
    font-family: 'Fraunces', serif;
    font-size: 20px; font-weight: 900;
    color: var(--terra);
    text-decoration: none; cursor: pointer;
    letter-spacing: -0.5px;
}
/* poker icon span hidden */
.h-divider { width: 1px; height: 20px; background: var(--panel-border); }
.room-tag {
    font-size: 12px; font-weight: 600;
    color: var(--ink-mid); display: flex; align-items: center; gap: 6px;
}
.room-code-badge {
    background: var(--terra-pale); color: var(--terra);
    padding: 2px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 1.5px;
    border: 1px solid rgba(224,120,64,0.15);
}
.h-gap { flex: 1; }
.h-chip {
    background: var(--sand2);
    border: 1px solid var(--panel-border);
    border-radius: 8px; padding: 4px 10px;
    font-size: 11px; font-weight: 600; color: var(--ink-mid);
    display: flex; align-items: center; gap: 5px;
}
.h-chip i { color: var(--teal); font-size: 10px; }
.h-icon-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--panel-border); background: var(--sand2);
    color: var(--ink-light); font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.15s;
}
.h-icon-btn:hover { color: var(--terra); border-color: rgba(224,120,64,0.3); background: var(--terra-pale); }
.h-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--terra), var(--terra-dark));
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

/* Profile dropdown */
.profile-dropdown-wrap {
    position: relative;
}
.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 900;
    padding: 6px;
    flex-direction: column;
}
.profile-dropdown.open { display: flex; }
.profile-dropdown .pd-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 8px;
}
.profile-dropdown .pd-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white;
    text-transform: uppercase;
    flex-shrink: 0;
}
.profile-dropdown .pd-name {
    font-weight: 600; font-size: 14px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-dropdown .pd-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}
.profile-dropdown button {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    color: var(--ink-mid);
    font-size: 13px; font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.profile-dropdown button:hover {
    background: var(--terra-pale);
    color: var(--ink);
}
.profile-dropdown button i {
    width: 16px; text-align: center; font-size: 13px;
}
.profile-dropdown button.pd-danger {
    color: #e74c3c;
}
.profile-dropdown button.pd-danger:hover {
    background: rgba(231,76,60,0.1);
    color: #c0392b;
}

/* Sidebar */
.player-sidebar {
    grid-area: sidebar;
    background: var(--cream);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.player-sidebar::-webkit-scrollbar { width: 2px; }
.player-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.s-section {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.s-title {
    font-size: 10px; letter-spacing: 1.2px;
    text-transform: uppercase; font-weight: 700;
    color: var(--ink-light); margin-bottom: 10px;
}
.player-sidebar h3 {
    font-size: 10px; letter-spacing: 1.2px;
    text-transform: uppercase; font-weight: 700;
    color: var(--ink-light); margin-bottom: 0;
    padding: 14px 14px 10px;
    display: flex; align-items: center; gap: 6px;
}
.player-sidebar h3 i {
    font-size: 10px;
    color: var(--teal);
}

/* Player rows in sidebar */
.player-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 12px;
    transition: background 0.15s; cursor: default;
    margin-bottom: 2px;
}
.player-row:hover { background: var(--bg2); }
.player-row.active { background: var(--teal-pale); }

#player-list { list-style: none; padding: 6px 10px; }
#player-list li.player-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    margin-bottom: 2px;
    transition: background 0.15s;
    border: 1px solid transparent;
}
#player-list li.player-card:hover { background: rgba(255,255,255,0.03); }
#player-list li.player-card.current-turn {
    background: var(--teal-pale);
    border-color: rgba(46,196,166,0.15);
}

/* Player card avatar */
.pc-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}
.player-card.current-turn .pc-avatar {
    box-shadow: 0 0 0 2px var(--teal);
}

/* Player card info */
.pc-info { flex: 1; min-width: 0; }
.pc-name {
    font-size: 13px; font-weight: 600; color: var(--ink);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-host-badge {
    font-size: 9px; font-weight: 700;
    background: var(--terra-pale);
    color: var(--terra);
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.pc-status {
    font-size: 11px; color: var(--ink-light);
    margin-top: 1px;
}
.pc-status.pc-active { color: var(--teal); }

/* Player card actions */
.pc-action {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: none;
    border: 1px solid transparent;
    color: var(--ink-light);
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    opacity: 0;
}
.player-card:hover .pc-action { opacity: 0.6; }
.pc-action:hover {
    opacity: 1 !important;
    color: var(--danger);
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
}

/* Spectator player card */
.player-card.spectator { opacity: 0.5; }
.player-card.spectator .pc-status { font-style: italic; }

.p-av {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white;
    flex-shrink: 0;
}

/* Vote-kick button */
.btn-kick {
    background: none; border: none;
    color: var(--danger); font-size: 0.8rem;
    cursor: pointer; padding: 0.1rem 0.3rem;
    border-radius: 4px; opacity: 0.4; transition: opacity 0.2s;
    margin-left: auto;
}
.btn-kick:hover { opacity: 1; background: rgba(229,57,53,0.15); }

.s-footer { margin-top: auto; padding: 12px 14px; }
.leave-btn {
    width: 100%; padding: 8px;
    background: transparent; border: 1px solid rgba(239,68,68,0.2);
    border-radius: 8px; color: var(--danger);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    opacity: 0.7;
}
.leave-btn:hover { opacity: 1; background: rgba(239,68,68,0.06); border-color: var(--danger); }

/* ── GAME AREA ── */
.game-area {
    grid-area: game;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.table-scene {
    flex: 1; position: relative;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.table-scene::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(46,196,166,0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 70%, rgba(224,120,64,0.03) 0%, transparent 50%);
    background-color: var(--bg);
}

/* Game table (round stool) */
.game-table {
    position: relative;
    width: min(380px, 80vw);
    height: min(380px, 80vw);
    flex-shrink: 0;
    z-index: 2;
}
.stool {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 180px; height: 180px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 35% 30%, var(--table-rim) 0%, var(--table-top) 50%, var(--table-side) 100%);
    box-shadow:
        0 0 0 4px rgba(60,44,28,0.6),
        0 0 0 8px rgba(30,20,10,0.5),
        0 16px 48px rgba(0,0,0,0.6),
        inset 0 2px 6px rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    z-index: 5;
}
.stool::before {
    content: '';
    position: absolute; inset: 10px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.06);
    background: repeating-conic-gradient(
        rgba(255,255,255,0.02) 0deg, transparent 1deg,
        transparent 9deg, rgba(255,255,255,0.02) 10deg
    );
}

.pile-area {
    position: relative; z-index: 2;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.pile-label {
    font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase;
    color: rgba(255,255,255,0.4); font-weight: 600;
}
.cards-stack { position: relative; display: flex; gap: 20px; align-items: center; }

/* Table center (legacy fallback + new layout) */
#table-center {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 6;
}

/* Draw pile */
#draw-pile {
    width: var(--table-card-width); height: var(--table-card-height);
    border-radius: 8px;
    background: linear-gradient(145deg, #3a4880, #2a3668);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
#draw-pile:hover { transform: scale(1.04); box-shadow: 0 6px 20px rgba(0,0,0,0.6); }
#draw-pile::after { content: '🂠'; }

/* Discard pile — scattered cards like a real table */
#discard-pile {
    position: relative;
    width: var(--table-card-width); height: var(--table-card-height);
}
#discard-pile .card {
    width: var(--table-card-width); height: var(--table-card-height);
    position: absolute;
    top: 0; left: 0;
}
#discard-pile .card.discard-fly {
    animation: cardFlyIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.discard-old {
    background: linear-gradient(135deg, #3d4a8a, #2d3a6e);
    border: 1px solid rgba(255,255,255,0.1);
}
@keyframes cardFlyIn {
    from { transform: translateY(120px) scale(0.5) rotate(0deg); opacity: 0; }
    to { transform: translateY(0) scale(1) rotate(var(--rot, 0deg)); opacity: 1; }
}
@keyframes cardLand {
    from { transform: scale(0.7) rotate(-15deg); opacity: 0; }
    to { transform: scale(1) rotate(var(--rot, 0deg)); opacity: 1; }
}

#direction-indicator {
    position: absolute;
    top: -2rem; left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    color: var(--ink-light);
}

/* Opponents (top area) */
#other-players {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    position: absolute;
    top: 8px; left: 0; right: 0;
    z-index: 10;
}
.opponent {
    text-align: center;
    font-size: 0.75rem;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.opponent .opp-avatar {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.opponent.current-turn .opp-avatar {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px var(--teal-pale), 0 0 12px rgba(46,196,166,0.25);
}
.opponent .card-count {
    background: var(--sand2);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 10px;
    border: 1px solid var(--panel-border);
}
.opponent.current-turn .card-count {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
}

/* Player's hand — fan radiating from a single pivot below */
#my-hand {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--card-height) + 40px);
    z-index: 10;
    pointer-events: none;
}
#my-hand .card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 10px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.2);
    cursor: pointer;
    transform-origin: center bottom;
    pointer-events: auto;
    border: 2px solid transparent;
    position: absolute;
    left: 50%;
    bottom: -20px;
}
#my-hand .card img {
    width: 100%; height: 100%;
    object-fit: cover;
    pointer-events: none;
}
#my-hand .card.active-card {
    cursor: pointer;
}
#my-hand .card.active-card:hover {
    box-shadow: 0 0 0 3px var(--teal), 0 8px 24px rgba(42,124,111,0.5);
    z-index: 100;
}
#my-hand .card.waiting-card {
    cursor: default;
}
#my-hand .card.combo-selected {
    border: 2px solid var(--warning);
    box-shadow: 0 0 0 3px var(--warning), 0 8px 20px rgba(0,0,0,0.3);
    z-index: 100;
}

/* Selected cards — multi-select highlight */
#my-hand .card.card-selected {
    box-shadow: 0 0 0 3px var(--teal), 0 0 16px rgba(42,124,111,0.6), 0 8px 20px rgba(0,0,0,0.3);
    z-index: 99;
}

#combo-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--warning);
    padding: 0.3rem;
    position: absolute;
    bottom: 130px; left: 0; right: 0;
    z-index: 11;
}

/* Card base */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: transform 0.15s;
}
.card img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.card-back {
    width: var(--card-width-sm);
    height: var(--card-height-sm);
    border-radius: 6px;
    background: linear-gradient(145deg, #3a4880 0%, #2a3668 50%, #3a4880 100%);
    background-size: 200% 200%;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    flex-shrink: 0;
}
.card-back::after { content: '🂠'; }

/* Opponent hand — small face-down fan (top pivot, fanning downward) */
.opp-cards {
    position: relative;
    height: calc(var(--card-height-sm) + 10px);
    width: 80px;
    margin-top: 4px;
}
.opp-cards .card-back {
    position: absolute;
    left: 50%;
    top: 0;
    transform-origin: center top;
}

/* Action bar */
.action-bar {
    background: var(--cream);
    border-top: 1px solid var(--panel-border);
    padding: 12px 20px;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 -2px 8px var(--shadow);
    flex-shrink: 0;
}

/* Lobby (waiting) — inside game-area */
.lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--ink-light);
    position: absolute;
    inset: 0;
    z-index: 15;
    background: var(--bg);
}
.lobby p { font-size: 13px; }
.game-area {
    position: relative;
}

/* ── CHAT ── */
.chat-sidebar {
    grid-area: chat;
    background: var(--cream);
    border-left: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-sidebar h3 {
    display: none; /* replaced by tabs */
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    line-height: 1.45;
}
.chat-messages::-webkit-scrollbar { width: 2px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }
.chat-messages .msg { margin-bottom: 0.2rem; }
.chat-messages .msg-system { color: var(--ink-light); font-style: italic; font-size: 11px; }
.chat-messages .msg-nick { color: var(--terra); font-weight: 700; font-size: 11px; }
.chat-form {
    padding: 10px 12px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    gap: 6px;
}
.chat-form input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}
.chat-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(46,196,166,0.1); }
.chat-form input::placeholder { color: var(--ink-light); }

/* Typing indicator */
.typing-indicator {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--ink-light);
    display: flex;
    align-items: center;
    gap: 6px;
}
.typing-dots {
    display: inline-flex;
    gap: 3px;
}
.typing-dots span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--ink-light);
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}
.chat-form button {
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--teal); border: none; color: white; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; transition: all 0.15s;
}
.chat-form button:hover { background: var(--teal-light); }

/* Spectator banner */
.spectator-banner {
    background: rgba(245,166,35,0.06);
    color: var(--warning);
    text-align: center;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 11px;
    border-bottom: 1px solid rgba(245,166,35,0.15);
}
/* Tournament banner */
.tournament-banner {
    background: rgba(46,204,113,0.06);
    color: var(--success);
    text-align: center;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 11px;
    border-bottom: 1px solid rgba(46,204,113,0.15);
}

/* ═══════════════════════════════════════════
   MODAL (demand / leave)
   ═══════════════════════════════════════════ */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-content {
    background: var(--panel);
    border: 1px solid var(--glass-border);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    max-width: 380px;
    width: 90%;
}
.demand-group { margin-bottom: 1rem; }
.demand-group h4 {
    font-size: 0.85rem;
    color: var(--ink-light);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.demand-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════
   TOAST (hidden — bot announcer is the sole notification system)
   ═══════════════════════════════════════════ */
.toast-container {
    display: none;
}
.toast {
    background: rgba(26,26,40,0.92);
    backdrop-filter: blur(8px);
    color: var(--ink);
    padding: 8px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
    animation: toast-in 0.3s ease, toast-out 0.4s ease 2.2s forwards;
    pointer-events: auto;
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap;
}
.toast.toast-success { border-color: rgba(39,174,96,0.4); color: var(--success); }
.toast.toast-warning { border-color: rgba(243,156,18,0.4); color: var(--warning); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-16px); }
}

/* ═══════════════════════════════════════════════════
   ADMIN DASHBOARD — admin.html style
   ═══════════════════════════════════════════════════ */
.admin-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Nav */
.admin-nav {
    width: var(--nav-w);
    background: var(--cream);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0; overflow-y: auto;
}
.nav-brand {
    padding: 22px 18px 18px;
    border-bottom: 1px solid var(--border);
}
.brand-row {
    display: flex; align-items: center; gap: 8px;
    font-family: 'Fraunces', serif;
    font-size: 20px; font-weight: 900; color: var(--terra);
    margin-bottom: 4px;
}
.admin-lbl {
    font-size: 11px; color: var(--ink-light); font-weight: 500;
    padding-left: 2px;
}
.nav-section { padding: 14px 10px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 10px;
    font-size: 13px; font-weight: 600;
    color: var(--ink-mid); cursor: pointer;
    transition: all 0.15s; text-decoration: none;
    margin-bottom: 1px;
}
.nav-item i { width: 16px; text-align: center; font-size: 13px; color: var(--ink-light); }
.nav-item:hover { background: var(--bg2); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--terra-pale); color: var(--terra); }
.nav-item.active i { color: var(--terra); }

.nav-footer {
    margin-top: auto; padding: 14px 10px;
    border-top: 1px solid var(--border);
}

/* Admin main area */
.admin-main {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden;
}
.admin-topbar {
    height: 56px; background: var(--cream);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 14px;
    box-shadow: 0 1px 4px var(--shadow); flex-shrink: 0;
}
.page-ttl {
    font-family: 'Fraunces', serif;
    font-size: 18px; font-weight: 700;
}

.admin-content { flex: 1; overflow-y: auto; padding: 24px; }

/* Stat grid */
.stat-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 22px;
}
.stat-card {
    background: var(--panel); border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px; position: relative; overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--shadow); }
.stat-card::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.c-terra::after { background: var(--terra); }
.stat-card.c-teal::after { background: var(--teal); }
.stat-card.c-blue::after { background: #2471a3; }
.stat-card.c-red::after { background: var(--danger); }
.stat-icon-bg {
    position: absolute; right: 16px; top: 20px;
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.stat-card.c-terra .stat-icon-bg { background: var(--terra-pale); color: var(--terra); }
.stat-card.c-teal .stat-icon-bg { background: var(--teal-pale); color: var(--teal); }
.stat-card.c-blue .stat-icon-bg { background: rgba(36,113,163,0.15); color: #2471a3; }
.stat-card.c-red .stat-icon-bg { background: rgba(229,57,53,0.15); color: var(--danger); }
.stat-lbl { font-size: 12px; font-weight: 600; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.stat-val { font-family: 'Fraunces', serif; font-size: 34px; font-weight: 900; color: var(--ink); line-height: 1; margin-bottom: 6px; }
.stat-sub { font-size: 12px; color: var(--ink-light); }

/* Admin rooms table */
.tbl-panel {
    background: var(--panel); border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 14px;
    overflow: hidden;
}
.tbl-topbar {
    padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.04);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.tbl-topbar-title { font-size: 15px; font-weight: 700; }

/* Legacy admin container (for old templates referencing it) */
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}
.admin-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
}
.admin-header h1 {
    font-family: 'Fraunces', serif;
    font-size: 1.5rem;
}
.admin-header div { display: flex; gap: 0.5rem; }
.admin-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 1.5rem;
}

table.admin-table { width: 100%; border-collapse: collapse; }
table.admin-table th {
    text-align: left; padding: 10px 16px;
    font-size: 11px; letter-spacing: 0.5px;
    text-transform: uppercase; color: var(--ink-light);
    font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.04);
    background: rgba(255,255,255,0.01);
}
table.admin-table td {
    padding: 12px 16px; font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
table.admin-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
    border: 1px solid;
}
.b-green { background: rgba(39,174,96,0.12); color: #27ae60; border-color: rgba(39,174,96,0.3); }
.b-red { background: rgba(229,57,53,0.12); color: #e53935; border-color: rgba(229,57,53,0.3); }
.b-terra { background: var(--terra-pale); color: var(--terra); border-color: rgba(201,107,58,0.3); }
.b-teal { background: var(--teal-pale); color: var(--teal); border-color: rgba(42,124,111,0.3); }
.b-gray { background: var(--bg2); color: var(--ink-mid); border-color: var(--sand2); }

.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
}
.status-waiting { background: var(--sand2); color: var(--ink-mid); }
.status-playing { background: rgba(39,174,96,0.12); color: var(--success); }
.status-finished { background: var(--bg2); color: var(--ink-light); }
.status-banned { background: rgba(229,57,53,0.12); color: var(--danger); }
.row-banned { opacity: 0.6; }

.actions { display: flex; gap: 0.3rem; }
.btn-inline {
    background: none; border: none; cursor: pointer;
    font-size: 0.85rem; padding: 0;
}

.player-list-inline {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    padding: 8px 16px;
}
.player-tag {
    display: inline-flex; align-items: center; gap: 0.25rem;
    background: var(--bg); padding: 0.2rem 0.5rem;
    border-radius: 8px; font-size: 0.8rem;
}
.player-banned { text-decoration: line-through; opacity: 0.6; }
.kick-badge {
    background: var(--warning);
    color: #000;
    font-size: 0.7rem;
    padding: 0 0.3rem;
    border-radius: 3px;
    font-weight: 700;
}

/* Avatar colors */
.av-t { background: var(--terra); }
.av-tl { background: var(--teal); }
.av-p { background: #7c5cbf; }
.av-b { background: #2471a3; }
.av-g { background: #229954; }
.av-r { background: #e53935; }

/* Game area status — hidden, use toasts instead */
#game-status {
    display: none;
}

/* Last card button */
#last-card-btn, #mchimbo-btn {
    position: absolute;
    bottom: 120px; right: 20px;
    z-index: 20;
}
#mchimbo-btn {
    right: auto; left: 20px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #e74c3c;
}

/* ═══════════════════════════════════════════
   TURN INDICATOR (hidden — bot announces turns)
   ═══════════════════════════════════════════ */
.turn-indicator {
    display: none;
}

/* Current turn highlight — handled by .player-card.current-turn above */

/* Glow on player hand when it's their turn */
#my-hand.my-turn-glow::before {
    content: '';
    position: absolute;
    bottom: 0; left: 10%; right: 10%;
    height: 60px;
    background: radial-gradient(ellipse at center bottom, rgba(42,124,111,0.25) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    animation: handGlow 2s ease-in-out infinite;
}
@keyframes handGlow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ═══════════════════════════════════════════
   MOBILE TOGGLE BUTTONS
   ═══════════════════════════════════════════ */
.mobile-toggle {
    display: none;
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: var(--cream);
    color: var(--ink-light);
    font-size: 14px;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.mobile-toggle:hover { color: var(--terra); border-color: var(--terra); }
.mobile-toggle .badge-dot {
    position: absolute; top: -2px; right: -2px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════════════ */

/* ── Small screens (up to 768px) ── */
@media (max-width: 768px) {
    :root {
        --card-width: 70px;
        --card-height: 98px;
        --card-width-sm: 22px;
        --card-height-sm: 31px;
        --table-card-width: 44px;
        --table-card-height: 62px;
    }

    /* Room page — single column, game area fills screen */
    .room-page {
        grid-template-columns: 1fr;
        grid-template-rows: 44px auto 1fr;
        grid-template-areas:
            "header"
            "game"
            "game";
        height: 100vh;
        height: 100dvh;
    }

    /* Header compact */
    .room-header {
        padding: 0 10px;
        gap: 6px;
    }
    .room-header .h-logo { font-size: 15px; }
    .room-header .h-divider { display: none; }
    .room-header .room-tag { display: none; }
    .room-header .h-chip { display: none; }
    .room-header .h-gap { flex: 1; }
    .room-header .h-avatar { width: 26px; height: 26px; font-size: 9px; border-radius: 6px; }
    .room-code-badge { font-size: 10px; padding: 2px 8px; }

    /* Show mobile toggle buttons */
    .mobile-toggle { display: flex; }

    /* Sidebar becomes a slide-over drawer */
    .player-sidebar {
        position: fixed;
        top: 44px; left: 0; bottom: 0;
        width: 260px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.6);
    }
    .player-sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0; top: 44px;
        background: rgba(0,0,0,0.6);
        z-index: 199;
    }
    .sidebar-overlay.open { display: block; }

    /* Chat becomes a slide-up drawer */
    .chat-sidebar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 50vh;
        z-index: 200;
        transform: translateY(100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        border-top: 1px solid var(--panel-border);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.6);
    }
    .chat-sidebar.open {
        transform: translateY(0);
    }
    .chat-overlay {
        display: none;
        position: fixed;
        inset: 0; top: 44px;
        background: rgba(0,0,0,0.6);
        z-index: 199;
    }
    .chat-overlay.open { display: block; }

    /* Game area fills available space */
    .game-area {
        grid-area: game;
        min-height: 0;
    }

    /* Smaller stool */
    .stool {
        width: 130px; height: 130px;
    }
    .game-table {
        width: min(280px, 85vw);
        height: min(320px, 70vh);
    }

    /* Opponents compact */
    #other-players {
        gap: 0.7rem;
        top: 4px;
        padding: 0 8px;
    }
    .opponent .opp-avatar {
        width: 30px; height: 30px;
        font-size: 10px;
        border-radius: 8px;
    }
    .opp-cards .card-back {
        width: var(--card-width-sm);
        height: var(--card-height-sm);
    }

    /* Hand closer to bottom, tighter */
    #my-hand {
        bottom: 0;
    }

    /* Draw pile / discard smaller */
    #draw-pile {
        width: var(--table-card-width);
        height: var(--table-card-height);
        font-size: 18px;
    }
    #discard-pile {
        width: var(--table-card-width);
        height: var(--table-card-height);
    }
    #discard-pile .card {
        width: var(--table-card-width);
        height: var(--table-card-height);
    }

    /* Direction indicator */
    #direction-indicator {
        font-size: 1.2rem;
        top: -1.5rem;
    }

    /* Action bar */
    .action-bar { padding: 8px 12px; }

    /* Last card / mchimbo button */
    #last-card-btn, #mchimbo-btn {
        bottom: 90px; right: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
    #mchimbo-btn { right: auto; left: 10px; }

    /* Combo hint */
    #combo-hint {
        bottom: 100px;
        font-size: 0.7rem;
    }

    /* Modal */
    .modal-content {
        padding: 1.5rem;
        max-width: 90vw;
    }
    .demand-options { gap: 0.3rem; }
    .demand-options button { font-size: 0.8rem; padding: 6px 10px; }

    /* Spectator/tournament banners */
    .spectator-banner, .tournament-banner {
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Stat grids (admin) */
    .stat-grid, .admin-stats { grid-template-columns: 1fr; }
}

/* ── Medium screens (769px–1024px) ── */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --card-width: 80px;
        --card-height: 112px;
        --card-width-sm: 30px;
        --card-height-sm: 42px;
        --table-card-width: 50px;
        --table-card-height: 70px;
    }

    .room-page {
        grid-template-columns: 200px 1fr 240px;
    }

    .stool {
        width: 160px; height: 160px;
    }
    .game-table {
        width: min(340px, 85vw);
        height: min(340px, 85vw);
    }

    .stat-grid, .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Auth page responsive ── */
@media (max-width: 768px) {
    .auth-page { flex-direction: column; overflow: auto; }
    .auth-left { display: none !important; }
    .auth-right { padding: 24px 20px; }
    .form-greeting { font-size: 24px; }
}

/* ── Admin page responsive ── */
@media (max-width: 768px) {
    .admin-page { flex-direction: column; }
    .admin-nav { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .nav-section { display: flex; gap: 4px; padding: 8px; }
    .nav-brand { padding: 10px; border-bottom: none; border-right: 1px solid var(--border); }
    .admin-content { padding: 12px; }
}

/* ── Activity Feed (left sidebar) ── */
.activity-feed {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.activity-feed::-webkit-scrollbar { width: 2px; }
.activity-feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-mid);
    background: rgba(255,255,255,0.02);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1.4;
}
.activity-item.visible {
    opacity: 1;
    transform: translateX(0);
}
.activity-item i {
    margin-top: 1px;
    font-size: 10px;
    flex-shrink: 0;
    color: var(--ink-light);
}
.activity-item.activity-success {
    color: var(--teal);
    background: var(--teal-pale);
}
.activity-item.activity-success i { color: var(--teal); }
.activity-item.activity-warning {
    color: var(--warning);
    background: rgba(245,166,35,0.06);
}
.activity-item.activity-warning i { color: var(--warning); }

/* ── Right Sidebar Tabs ── */
.right-tabs {
    display: flex;
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}
.right-tab {
    flex: 1;
    padding: 10px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ink-light);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.right-tab:hover { color: var(--ink-mid); background: rgba(255,255,255,0.02); }
.right-tab.active {
    color: var(--terra);
    border-bottom-color: var(--terra);
}
.right-tab i { font-size: 10px; }
.tab-badge {
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: white;
    line-height: 1;
}
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.right-panel #player-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 0 10px;
}
.right-panel .chat-messages { flex: 1; }

/* ── Hand Points ── */
.hand-points {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-mid);
    padding: 2px 12px;
    background: var(--surface);
    border-radius: 99px;
    border: 1px solid var(--border);
    display: inline-block;
    margin: 0 auto 4px;
    width: fit-content;
}

/* ── Mchimbo Banner (hidden — bot announces mchimbo) ── */
.mchimbo-banner {
    display: none;
}

/* ═══════════════════════════════════════════
   DM (PRIVATE MESSAGE) PANEL
   ═══════════════════════════════════════════ */
.dm-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 300;
    display: flex;
    flex-direction: column;
}
.dm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--cream);
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}
.dm-close {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: var(--cream);
    color: var(--ink-light);
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.dm-close:hover { color: var(--terra); border-color: var(--terra); }
.dm-target-label {
    font-size: 14px;
    color: var(--ink-mid);
}
.dm-target-label strong {
    color: var(--terra);
    font-weight: 700;
}
.dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dm-msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.dm-mine {
    align-self: flex-end;
    background: var(--terra);
    color: white;
    border-bottom-right-radius: 4px;
}
.dm-theirs {
    align-self: flex-start;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.dm-form {
    padding: 12px 16px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    gap: 8px;
    background: var(--cream);
    flex-shrink: 0;
}
.dm-form input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg);
    border: 1.5px solid var(--panel-border);
    border-radius: 12px;
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.dm-form input:focus { border-color: var(--teal); }
.dm-form input::placeholder { color: var(--ink-light); }
.dm-form button {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--teal); border: none; color: white;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: all 0.2s;
}
.dm-form button:hover { background: var(--teal-light); }

/* DM badge on player name */
.dm-badge {
    color: var(--teal);
    font-size: 8px;
    margin-left: 4px;
    animation: dmPulse 1.5s ease-in-out infinite;
}
@keyframes dmPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Desktop-only class */
.desktop-only {}

/* ═══════════════════════════════════════════
   MOBILE FLOATING CHAT BUTTON
   ═══════════════════════════════════════════ */
.mobile-chat-fab {
    display: none;
    position: fixed;
    bottom: calc(66px + env(safe-area-inset-bottom, 0));
    right: 12px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--terra);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 240;
    font-size: 18px;
    align-items: center;
    justify-content: center;
}
.mobile-chat-fab:active {
    transform: scale(0.92);
}
.fab-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--danger);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
    line-height: 1;
}

/* ═══════════════════════════════════════════
   MOBILE CHAT DRAWER (FAB-only, chat-only)
   ═══════════════════════════════════════════ */
.mobile-chat-drawer {
    display: none;
    position: fixed;
    left: 0; right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0));
    height: 45vh;
    background: var(--cream);
    border-top: 1px solid var(--panel-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.6);
    z-index: 245;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.mobile-chat-drawer.open {
    display: flex;
    transform: translateY(0);
}
.mcd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}
.mcd-header button {
    background: none;
    border: none;
    color: var(--ink-light);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
}
.mcd-header button:hover { color: var(--ink); }
.mobile-chat-drawer .chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.mobile-chat-drawer .chat-form {
    flex-shrink: 0;
}
.mobile-chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 244;
}
.mobile-chat-overlay.open {
    display: block;
}

/* ═══════════════════════════════════════════
   MOBILE BOTTOM NAVBAR
   ═══════════════════════════════════════════ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
    z-index: 250;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-bottom-nav .nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--ink-light);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s;
    position: relative;
    padding: 4px 0;
}
.mobile-bottom-nav .nav-tab i {
    font-size: 16px;
    transition: color 0.15s;
}
.mobile-bottom-nav .nav-tab.active {
    color: var(--terra);
}
.mobile-bottom-nav .nav-tab.active i {
    color: var(--terra);
}
.nav-badge {
    position: absolute;
    top: 2px; right: 50%;
    transform: translateX(14px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: white;
    line-height: 1;
    border: 2px solid var(--cream);
}

/* Mobile More Menu */
.mobile-more-menu {
    position: fixed;
    bottom: 62px;
    bottom: calc(62px + env(safe-area-inset-bottom, 0));
    right: 8px;
    background: var(--panel);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 4px;
    z-index: 251;
    flex-direction: column;
    gap: 1px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    min-width: 170px;
}
.mobile-more-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s;
}
.mobile-more-menu button:hover {
    background: rgba(255,255,255,0.03);
}
.mobile-more-menu button i {
    width: 16px;
    text-align: center;
    color: var(--ink-light);
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE — BOTTOM NAV UPDATES
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Show bottom navbar */
    .mobile-bottom-nav {
        display: flex;
    }

    /* Hide old mobile-toggle buttons from header on mobile — use bottom nav instead */
    .mobile-toggle {
        display: none !important;
    }

    /* Hide desktop-only buttons */
    .desktop-only {
        display: none !important;
    }

    /* Adjust game area for bottom nav */
    .room-page {
        grid-template-rows: 44px 1fr;
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px - env(safe-area-inset-bottom, 0));
    }

    /* Chat drawer above bottom nav — compact */
    .chat-sidebar {
        bottom: 56px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0));
        height: 40vh;
        border-radius: 16px 16px 0 0;
    }

    /* Hide tab bar in right sidebar on mobile — only players shown */
    .chat-sidebar .right-tabs {
        display: none;
    }

    /* Show floating chat button on mobile */
    .mobile-chat-fab.visible {
        display: flex !important;
    }

    /* Player sidebar above bottom nav */
    .player-sidebar {
        bottom: 56px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0));
        top: 44px;
    }

    /* Toast — hidden (bot is sole notification) */
    .toast-container {
        display: none;
    }

    /* Last card / mchimbo button above bottom nav */
    #last-card-btn, #mchimbo-btn {
        bottom: 100px;
        bottom: calc(100px + env(safe-area-inset-bottom, 0));
    }
    #mchimbo-btn { right: auto; left: 10px; }

    /* DM panel respects bottom nav */
    .dm-panel {
        bottom: 56px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0));
    }

    /* Header even more compact */
    .room-header {
        padding: 0 8px;
        gap: 5px;
    }
    .room-header .h-logo { font-size: 14px; }
    .room-header .h-icon-btn {
        width: 28px; height: 28px;
        font-size: 11px;
        border-radius: 6px;
    }
    .h-avatar { width: 24px; height: 24px; font-size: 9px; border-radius: 6px; }

    /* Show room code in header on mobile */
    .room-header .room-tag {
        display: flex;
        font-size: 10px;
    }
}
