/* --- Root Variables & Themes --- */
:root {
    --bg-dark: #0b0f19;
    --bg-card: rgba(20, 30, 48, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #334155;
    --success-color: #10b981;
    --warning-color: #cca21b;
    --danger-color: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --table-felt: radial-gradient(circle at center, #15803d 0%, #166534 55%, #0f3e23 85%, #062f17 100%);
    --wood-border: #2c1209;
    --gold-accent: #b89327;
    --gold-glow: rgba(184, 147, 39, 0.35);
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Helper Classes --- */
.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

/* --- Glassmorphism Panel --- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* --- Button Styles --- */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #334155;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #047857;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #1e293b;
}

.btn-warning:hover {
    background-color: #d97706;
}

/* --- Screen Transitions --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
}

/* --- LOBBY DESIGN --- */
#lobby-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #102613 0%, #060b13 100%);
    overflow: hidden;
    position: relative;
}

/* Background Aces Fan Artwork */
.lobby-bg-cards-art {
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 450px;
    height: 450px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.15;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: floatAces 8s ease-in-out infinite alternate;
}

@keyframes floatAces {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-15px) rotate(2deg); }
}

.bg-card-art {
    position: absolute;
    width: 170px;
    height: 250px;
    background: linear-gradient(to bottom, #ffffff 0%, #f7f5f0 100%);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px;
    transform-origin: bottom center;
    border: 1px solid rgba(0,0,0,0.1);
}

.bg-card-art::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    pointer-events: none;
}

.bg-card-art .bg-card-value {
    font-size: 1.6rem;
    font-weight: 850;
    line-height: 1;
}

.bg-card-art .bg-card-suit {
    font-size: 5.5rem;
    align-self: center;
    margin-top: auto;
    margin-bottom: auto;
}

.bg-card-art.card-spade {
    transform: rotate(-22deg) translate(-80px, 15px);
    color: #111827;
}

.bg-card-art.card-heart {
    transform: rotate(-7deg) translate(-25px, -5px);
    color: #dc2626;
}

.bg-card-art.card-diamond {
    transform: rotate(8deg) translate(30px, -5px);
    color: #dc2626;
}

.bg-card-art.card-club {
    transform: rotate(23deg) translate(85px, 15px);
    color: #111827;
}

.lobby-card {
    width: 440px;
    max-width: 95%;
    padding: 35px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(212, 175, 55, 0.25); /* Elegant thin gold border */
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.7);
    z-index: 10;
    position: relative;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
}

.lobby-header {
    text-align: center;
    margin-bottom: 25px;
}

.lobby-logo {
    font-size: 3rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #cca21b 0%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 10px rgba(204, 162, 27, 0.45));
    animation: pulseLogo 2.5s infinite alternate;
}

@keyframes pulseLogo {
    0% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(204, 162, 27, 0.3)); }
    100% { transform: scale(1.04); filter: drop-shadow(0 0 15px rgba(204, 162, 27, 0.7)); }
}

.lobby-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
    background: linear-gradient(to bottom, #ffffff 40%, #cca21b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lobby-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

.lobby-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(212, 175, 55, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group input {
    padding: 13px 20px;
    background: rgba(11, 15, 25, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: var(--warning-color);
    box-shadow: 0 0 15px rgba(204, 162, 27, 0.25);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#btn-create-room {
    background: linear-gradient(135deg, #d4af37 0%, #b89327 100%);
    color: #0b0f19;
    font-weight: 800;
    border-radius: 50px;
    padding: 14px 24px;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.25);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

#btn-create-room:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.45);
    filter: brightness(1.08);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 5px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.divider span {
    padding: 0 12px;
}

.join-group {
    display: flex;
    background: rgba(11, 15, 25, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    padding: 4px 4px 4px 18px;
    transition: all 0.3s ease;
    align-items: center;
}

.join-group:focus-within {
    border-color: var(--warning-color);
    box-shadow: 0 0 15px rgba(204, 162, 27, 0.25);
}

.join-group input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 0;
    color: white;
    outline: none;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

#btn-join-room {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50px;
    padding: 10px 22px;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#btn-join-room:hover {
    background: white;
    color: #0b0f19;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.active-rooms-container {
    background: rgba(0, 0, 0, 0.15);
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 5px;
}

.active-rooms-container h3 {
    font-size: 0.78rem;
    color: rgba(212, 175, 55, 0.8);
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.rooms-list-empty {
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.room-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(11, 15, 25, 0.55);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.room-item-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--warning-color);
    transition: width 0.2s ease;
}

.room-item-row:hover {
    background: rgba(20, 30, 48, 0.8);
    border-color: rgba(204, 162, 27, 0.25);
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.room-item-row:hover::before {
    width: 3px;
}

.room-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.room-item-code {
    font-weight: 850;
    color: var(--warning-color);
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.room-item-players {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

@media (max-width: 480px) {
    .lobby-card {
        width: 100%;
        max-width: 95%;
        padding: 25px 20px;
    }
}

/* --- GAME SCREEN LAYOUT --- */
.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    height: 100vh;
    width: 100vw;
}

.game-sidebar {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(11, 15, 25, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.left-sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-left: none;
}

.right-sidebar {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: none;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-accent), transparent);
    opacity: 0.4;
}

.sidebar-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-main);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 15px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

/* --- SCORE TABLE --- */
.score-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    font-size: 0.85rem;
}

.score-table th, .score-table td {
    padding: 10px 6px;
    text-align: center;
}

.score-table td:first-child,
.score-table th:first-child {
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-table th {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
}

.score-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.score-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.01);
}

.score-table tr.active-bidder td {
    background: linear-gradient(90deg, rgba(204, 162, 27, 0.12) 0%, rgba(204, 162, 27, 0.02) 100%);
    color: var(--warning-color);
    font-weight: 700;
    border-top: 1px solid rgba(204, 162, 27, 0.2);
    border-bottom: 1px solid rgba(204, 162, 27, 0.2);
}

.score-table tr.active-bidder td:first-child {
    border-left: 3px solid var(--warning-color);
}

.round-history h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-list {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.8rem;
}

.history-row-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 4px;
    text-align: center;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
}

.history-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s ease;
}

.history-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.history-row-header div,
.history-row div {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
}

/* --- GAME TABLE CONTAINER --- */
.table-container {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0 20px;
    justify-content: flex-start;
    gap: 0;
    align-items: center;
    background: radial-gradient(circle at center, #0e1e12 0%, #060b13 100%);
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    overflow: hidden;
}

#room-info-display {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.7);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: 12px;
    margin-bottom: 8px;
}

/* --- BATAK TABLE FELT --- */
.batak-table {
    width: 98%;
    flex: 1;
    min-height: 0;
    max-width: 98%;
    background: radial-gradient(circle at center, rgba(21, 128, 61, 0.22) 0%, rgba(20, 83, 45, 0.45) 60%, rgba(6, 47, 23, 0.7) 100%), rgba(11, 15, 25, 0.5);
    border: 1.5px solid rgba(212, 175, 55, 0.3); /* Thin gold border */
    border-radius: 28px;
    box-shadow: 
        inset 0 0 50px rgba(0, 0, 0, 0.7), 
        0 20px 40px rgba(0, 0, 0, 0.6);
    position: relative;
    margin: 0 0 1px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.batak-table::before {
    content: '';
    position: absolute;
    width: 78%;
    height: 68%;
    border: 2px dashed rgba(255, 255, 255, 0.035);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.01);
}

#table-status-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 20;
}

#game-phase-indicator {
    background: rgba(15, 23, 42, 0.9);
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid rgba(204, 162, 27, 0.35);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    color: var(--warning-color);
}

#koz-indicator {
    position: absolute;
    top: 25px;
    right: 25px;
    background: linear-gradient(to bottom, #ffffff 0%, #f1f5f9 100%);
    padding: 10px 20px;
    border-radius: 16px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    z-index: 100;
    border: 1.5px solid var(--gold-accent);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
}

#koz-indicator #koz-val {
    font-size: 2.3rem;
    font-weight: bold;
}

/* --- PLAYER SLOTS --- */
.player-slot {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100px;
    z-index: 10;
}

.player-avatar {
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.35rem;
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.player-name {
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    color: #f8fafc;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.player-tricks {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--warning-color);
    background: rgba(204, 162, 27, 0.08);
    border: 1px solid rgba(204, 162, 27, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

.player-slot {
    position: absolute;
    background: rgba(11, 15, 25, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1.5px solid rgba(184, 147, 39, 0.25);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

/* Active turn state */
.player-slot.active-turn {
    border-color: var(--warning-color);
    box-shadow: 0 0 22px rgba(204, 162, 27, 0.45);
    background: linear-gradient(135deg, rgba(204, 162, 27, 0.15) 0%, rgba(30, 41, 59, 0.85) 100%);
}

.player-slot.active-turn .player-avatar {
    animation: avatarPulse 2.0s infinite ease-in-out;
}

@keyframes avatarPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(204, 162, 27, 0.3);
        border-color: rgba(212, 175, 55, 0.3);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 22px rgba(204, 162, 27, 0.7);
        border-color: var(--warning-color);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(204, 162, 27, 0.3);
        border-color: rgba(212, 175, 55, 0.3);
    }
}

.player-bubble {
    position: absolute;
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
    color: #0b0f19;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    z-index: 20;
    pointer-events: none;
    white-space: nowrap;
}

/* Position-specific slot layouts and bubble animations */
.slot-top {
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 92px;
    height: 108px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
}
.slot-top .player-name {
    max-width: 80px;
}
.slot-top .player-bubble {
    left: 100%;
    margin-left: 4px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
}
.slot-top .player-bubble.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.slot-left {
    left: 35px;
    top: 50%;
    transform: translateY(-50%);
    width: 145px;
    height: 75px;
    display: grid !important;
    grid-template-columns: 1fr 50px;
    grid-template-rows: auto auto;
    align-items: center;
    justify-items: end;
    gap: 2px 8px;
    padding: 8px 12px;
}
.slot-left .player-avatar {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 50px;
    height: 50px;
}
.slot-left .player-name {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    text-align: right;
}
.slot-left .player-tricks {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
}
.slot-left .player-bubble {
    left: 100%;
    margin-left: 4px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
}
.slot-left .player-bubble.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.slot-right {
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    width: 145px;
    height: 75px;
    display: grid !important;
    grid-template-columns: 50px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    justify-items: start;
    gap: 2px 8px;
    padding: 8px 12px;
}
.slot-right .player-avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 50px;
    height: 50px;
}
.slot-right .player-name {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    text-align: left;
}
.slot-right .player-tricks {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
}
.slot-right .player-bubble {
    right: 100%;
    margin-right: 4px;
    left: auto;
    top: 50%;
    transform: translateY(-50%) translateX(4px);
}
.slot-right .player-bubble.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.slot-bottom {
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 92px;
    height: 108px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
}
.slot-bottom .player-name {
    max-width: 80px;
}
.slot-bottom .player-bubble {
    left: 100%;
    margin-left: 4px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
}
.slot-bottom .player-bubble.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* --- CENTER TRICK CARDS PLAYED AREA --- */
.center-trick-area {
    position: relative;
    width: 280px;
    height: 250px;
    z-index: 30;
}

.played-card {
    position: absolute;
    width: 100px;
    height: 145px;
    background: linear-gradient(to bottom, #ffffff 0%, #faf8f5 100%);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    opacity: 0;
    transform: scale(0.6) rotate(0deg);
    z-index: 35;
}

.played-card::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    pointer-events: none;
}

.played-card.show {
    opacity: 1;
    transform: scale(1);
}

/* Placing played cards relative to players (with a tiny natural rotation angle) */
.pt-top {
    top: 0;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
}
.pt-top.show {
    transform: translateX(-50%) translateY(20px) rotate(182deg);
}

.pt-left {
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(90deg);
}
.pt-left.show {
    transform: translateY(-50%) translateX(45px) rotate(88deg);
}

.pt-right {
    top: 50%;
    right: 0;
    transform: translateY(-50%) rotate(-90deg);
}
.pt-right.show {
    transform: translateY(-50%) translateX(-45px) rotate(-92deg);
}

.pt-bottom {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) rotate(0deg);
}
.pt-bottom.show {
    transform: translateX(-50%) translateY(-20px) rotate(2deg);
}

#trick-winner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(11, 15, 25, 0.92);
    color: var(--warning-color);
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 800;
    border: 1px solid rgba(204, 162, 27, 0.45);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65), 0 0 15px rgba(204, 162, 27, 0.25);
    z-index: 100;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#trick-winner-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* --- OVERLAYS: BIDDING & KOZ SELECT --- */
.table-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.table-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-card {
    padding: 30px;
    width: 380px;
    max-width: 90%;
    text-align: center;
    background: rgba(15, 23, 42, 0.75);
    border: 1.5px solid rgba(212, 175, 55, 0.25);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 25px 50px rgba(0, 0, 0, 0.65);
    border-radius: 20px;
}

.overlay-card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.overlay-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

#bot-info-modal h2 {
    color: #60a5fa !important;
}
#bot-info-modal p {
    color: #f1f5f9 !important;
}
#bot-info-modal strong {
    color: #60a5fa !important;
}

.bid-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.koz-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.btn-suit {
    padding: 15px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    background: #111827;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    color: white;
    transition: all 0.2s ease;
}

.btn-suit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.suit-spades:hover { border-color: #3b82f6; color: #3b82f6; }
.suit-hearts:hover { border-color: #ef4444; color: #ef4444; }
.suit-diamonds:hover { border-color: #cca21b; color: #cca21b; }
.suit-clubs:hover { border-color: #10b981; color: #10b981; }

/* --- CARD DESIGN --- */
.card-unit {
    width: 115px;
    height: 172px;
    background: linear-gradient(to bottom, #ffffff 0%, #f7f5f0 100%);
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.35);
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.25s ease, background-color 0.2s ease;
    position: relative;
    user-select: none;
    z-index: 1;
}

.card-unit::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    pointer-events: none;
}

/* Suit colors */
.card-unit.suit-spades, .card-unit.suit-clubs {
    color: #111827;
}

.card-unit.suit-hearts, .card-unit.suit-diamonds {
    color: #dc2626;
}

/* Played card suit color styles */
.played-card.suit-spades, .played-card.suit-clubs {
    color: #111827;
}
.played-card.suit-hearts, .played-card.suit-diamonds {
    color: #dc2626;
}

/* Card Corner Positioning */
.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    z-index: 2;
}

/* Position each corner */
.card-corner.top-left {
    top: 8px;
    left: 8px;
}
.card-corner.bottom-right {
    bottom: 8px;
    right: 8px;
    transform: rotate(180deg);
}

/* Typography for corners */
.card-corner .card-val-text {
    font-size: 1.25rem;
    font-weight: 800;
}
.card-corner .card-suit-text {
    font-size: 0.95rem;
}

/* Center symbol styling */
.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.6rem;
    pointer-events: none;
    z-index: 1;
    opacity: 0.95;
}

/* Played card overrides (smaller size) */
.played-card .card-corner .card-val-text {
    font-size: 1rem;
}
.played-card .card-corner .card-suit-text {
    font-size: 0.75rem;
}
.played-card .card-center {
    font-size: 2.8rem;
}

/* Full image card specific styling (All 52 cards) */
.full-img-card {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    filter: drop-shadow(0px 3px 5px rgba(0,0,0,0.3));
    background-size: 100% 100% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

.full-img-card::after {
    display: none !important;
}

/* --- PLAYER HAND --- */
.player-hand-container {
    width: 100%;
    background: rgba(11, 15, 25, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1.5px solid rgba(212, 175, 55, 0.3);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    transition: all 0.3s ease;
}

/* Glow when active turn */
.player-hand-container:not(.disabled-turn) {
    border-top-color: var(--warning-color);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35), 0 -4px 15px rgba(204, 162, 27, 0.25);
}

.hand-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

#turn-warning-text {
    color: var(--warning-color);
    display: none;
    font-weight: 800;
    animation: pulseWarn 1.2s infinite alternate ease-in-out;
}

@keyframes pulseWarn {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.cards-wrapper {
    display: flex;
    justify-content: center;
    gap: 8px;
    height: 182px;
    padding-top: 5px;
}

/* Fan overlap styling */
.cards-wrapper .card-unit {
    margin-right: -42px; /* Overlap cards slightly */
}

.cards-wrapper .card-unit:last-child {
    margin-right: 0;
}

.cards-wrapper .card-unit:hover {
    transform: translateY(-26px) scale(1.06);
    z-index: 100;
    box-shadow: 0 15px 30px rgba(0,0,0,0.55);
}

/* Grayed out / disabled hand when not player's turn */
.player-hand-container.disabled-turn {
    opacity: 0.7;
}

.player-hand-container.disabled-turn .cards-wrapper .card-unit {
    cursor: default;
    pointer-events: none;
}

/* Highlight playable cards optional style */
.card-unit.unplayable {
    pointer-events: none;
    background: #e2e8f0; /* Non-transparent darker color to keep opaque overlap */
}
.card-unit.unplayable .card-corner,
.card-unit.unplayable .card-center {
    opacity: 0.25;
}

/* --- CHAT & LOBBY PANEL --- */
.chat-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0 !important;
}

.room-controls-box {
    padding: 16px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.players-status {
    margin-bottom: 14px;
    font-size: 0.82rem;
}

#lobby-players-list {
    list-style: none;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#lobby-players-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.8rem;
    font-weight: 500;
}

#lobby-players-list li .status-dot {
    font-size: 0.72rem;
    color: var(--text-muted);
}

#lobby-players-list li.ready-true {
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

#lobby-players-list li.ready-true .status-dot {
    color: var(--success-color);
}

.action-buttons-wrapper {
    display: flex;
    gap: 10px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(11, 15, 25, 0.1);
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.chat-msg.system {
    align-self: center;
    background: rgba(204, 162, 27, 0.08);
    color: var(--warning-color);
    border: 1px solid rgba(204, 162, 27, 0.2);
    font-size: 0.78rem;
    text-align: center;
    max-width: 95%;
    font-weight: 500;
    box-shadow: none;
    padding: 6px 14px;
    border-radius: 10px;
}

.chat-msg.self {
    align-self: flex-end;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-msg.other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-msg-sender {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--warning-color);
    margin-bottom: 2px;
}

.chat-msg.self .chat-msg-sender {
    color: #93c5fd;
}

.chat-input-wrapper {
    display: flex;
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.chat-input-wrapper input {
    flex: 1;
    padding: 10px 16px;
    background: rgba(11, 15, 25, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    color: white;
    font-size: 0.86rem;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

#btn-send-chat {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.version-badge {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 15px;
    opacity: 0.5;
}

.copyright-notice {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    opacity: 0.45;
    letter-spacing: 0.5px;
}

/* --- RESPONSIVE HEIGHT STYLES --- */
@media (max-height: 850px) {
    .table-container {
        padding: 10px;
    }
    #koz-indicator {
        top: 10px;
        right: 10px;
        padding: 10px 20px;
        font-size: 1.5rem;
    }
    #koz-indicator #koz-val {
        font-size: 2.0rem;
    }
    .batak-table {
        width: min(900px, 95%);
        height: min(460px, 52vh);
        border-radius: 24px;
    }
    .player-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
    }
    .player-name {
        font-size: 0.78rem;
        max-width: 90px;
    }
    .player-tricks {
        font-size: 0.68rem;
    }
    .player-slot {
        width: 85px;
    }
    .slot-top { top: 10px; }
    .slot-bottom { bottom: 10px; }
    .slot-left { left: 15px; }
    .slot-right { right: 15px; }
    .slot-left, .slot-right { width: max-content; }
    
    .center-trick-area {
        width: 220px;
        height: 190px;
    }
    .played-card {
        width: 90px;
        height: 130px;
        padding: 8px;
    }
    .pt-left.show { transform: translateY(-50%) translateX(30px) rotate(90deg); }
    .pt-right.show { transform: translateY(-50%) translateX(-30px) rotate(-90deg); }
    .pt-top.show { transform: translateX(-50%) translateY(12px) rotate(180deg); }
    .pt-bottom.show { transform: translateX(-50%) translateY(-12px) rotate(0deg); }
    
    .card-unit {
        width: 105px;
        height: 155px;
        border-radius: 10px;
        padding: 10px;
    }
    .cards-wrapper {
        height: 165px;
        gap: 6px;
    }
    .cards-wrapper .card-unit {
        margin-right: -38px;
    }
    .card-corner .card-val-text {
        font-size: 1rem;
    }
    .card-corner .card-suit-text {
        font-size: 0.75rem;
    }
    .card-center {
        font-size: 3.2rem;
    }
}

@media (max-height: 700px) {
    #koz-indicator {
        top: 8px;
        right: 8px;
        padding: 8px 16px;
        font-size: 1.3rem;
    }
    #koz-indicator #koz-val {
        font-size: 1.8rem;
    }
    .batak-table {
        width: min(750px, 95%);
        height: min(390px, 48vh);
        border-radius: 20px;
    }
    .player-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }
    .player-name {
        font-size: 0.72rem;
        max-width: 80px;
    }
    .player-slot {
        width: 75px;
    }
    .slot-top { top: 6px; }
    .slot-bottom { bottom: 6px; }
    .slot-left { left: 8px; }
    .slot-right { right: 8px; }
    .slot-left, .slot-right { width: max-content; }

    .center-trick-area {
        width: 180px;
        height: 160px;
    }
    .played-card {
        width: 80px;
        height: 115px;
        padding: 8px;
    }
    .pt-left.show { transform: translateY(-50%) translateX(25px) rotate(90deg); }
    .pt-right.show { transform: translateY(-50%) translateX(-25px) rotate(-90deg); }
    .pt-top.show { transform: translateX(-50%) translateY(8px) rotate(180deg); }
    .pt-bottom.show { transform: translateX(-50%) translateY(-8px) rotate(0deg); }
    
    .card-unit {
        width: 95px;
        height: 140px;
        border-radius: 10px;
    }
    .cards-wrapper {
        height: 150px;
        gap: 6px;
    }
    .cards-wrapper .card-unit {
        margin-right: -34px;
    }
    .card-corner .card-val-text {
        font-size: 0.9rem;
    }
    .card-corner .card-suit-text {
        font-size: 0.7rem;
    }
    .card-center {
        font-size: 2.6rem;
    }
}

/* --- LIGHT MODE THEME --- */
body.light-mode {
    --bg-dark: #f0f4f8;
    --bg-card: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.1);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #e2e8f0;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --text-main: #0f172a;
    --text-muted: #475569;
    --table-felt: radial-gradient(circle at center, #34d399 0%, #22c55e 55%, #16a34a 85%, #15803d 100%);
    --wood-border: #8b4513;
    --gold-accent: #92400e;
    --gold-glow: rgba(146, 64, 14, 0.2);
    background-color: var(--bg-dark);
}

body.light-mode .player-bubble,
body.light-mode .game-sidebar,
body.light-mode .player-hand-container,
body.light-mode .overlay-content,
body.light-mode .lobby-card {
    background: var(--bg-card) !important;
    color: var(--text-main) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    border-color: var(--border-color) !important;
}

body.light-mode .btn-secondary {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

body.light-mode .btn-secondary:hover {
    background: #cbd5e1 !important;
}

body.light-mode .chat-input-wrapper input {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
}

body.light-mode .player-slot {
    background: rgba(255, 255, 255, 0.65) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

body.light-mode .player-slot.active-turn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
    border-color: var(--warning-color) !important;
    box-shadow: 0 0 15px rgba(217, 119, 6, 0.3) !important;
}

body.light-mode .player-score-table th {
    background: rgba(0,0,0,0.05) !important;
}

body.light-mode .player-score-table tr {
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
}

body.light-mode .table-container {
    background: radial-gradient(circle at center, #ffffff 0%, #e2e8f0 100%) !important;
    border-color: var(--wood-border) !important;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.05), 0 20px 40px rgba(0,0,0,0.1) !important;
}

body.light-mode .player-name, 
body.light-mode .score-header h3,
body.light-mode h1,
body.light-mode h2,
body.light-mode p {
    color: var(--text-main) !important;
}

body.light-mode .player-tricks, body.light-mode .player-bid {
    color: var(--text-main) !important;
}

body.light-mode .batak-table {
    background: radial-gradient(circle at center, rgba(74, 222, 128, 0.3) 0%, rgba(34, 197, 94, 0.6) 50%, rgba(21, 128, 61, 0.8) 100%), rgba(255, 255, 255, 0.2) !important;
}

body.light-mode .batak-table::before {
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05) !important;
}

body.light-mode #game-phase-indicator {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #b45309 !important;
    border-color: rgba(217, 119, 6, 0.4) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

body.light-mode #room-info-display {
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--text-main) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
    font-weight: 500;
}
