:root {
    --primary-color: #ffd700;
    --secondary-color: #e6e6e6;
    --bg-dark: #0f172a;
    --table-green: #1a4d2e;
    --accent-red: #ef4444;
    --text-light: #f8fafc;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,215,0,0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,215,0,0.5); }

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
}

#game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

header {
    height: 60px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
}

.ad-container {
    width: 100%;
    display: flex;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    overflow: hidden;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: 2px;
    background: linear-gradient(to right, #ffd700, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-board { display: flex; gap: 12px; }
.score-item {
    background: var(--glass);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    border: 1px solid var(--glass-border);
}
.score-item span { font-weight: bold; color: var(--primary-color); }

#table {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.table-surface {
    width: 90%;
    height: 75%;
    max-width: 1100px;
    background: radial-gradient(circle at center, #2d5a3f 0%, #1a3c2a 100%);
    border: 14px solid #3d2b1f;
    border-radius: 200px;
    box-shadow: 0 40px 80px rgba(0,0,0,0.6), inset 0 0 100px rgba(0,0,0,0.4);
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    z-index: 1;
}

.table-surface::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('poker_table_background.png');
    background-size: cover;
    opacity: 0.3;
    pointer-events: none;
}

.player {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

#player-2 { top: 30px; left: 50%; transform: translateX(-50%); }
#player-1 { bottom: 30px; left: 50%; transform: translateX(-50%); }

.avatar {
    background: rgba(0,0,0,0.7);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--glass-border);
}

.avatar.active {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.hand-container {
    display: flex;
    justify-content: center;
    height: 150px;
    padding: 0 40px;
}

.card {
    width: 85px;
    height: 120px;
    background: #fdfaf0;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    margin-left: -35px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    border: 1px solid #b3b3b3;
    font-family: 'Outfit', sans-serif;
    color: #000;
    z-index: 5;
}

.card:first-child { margin-left: 0; }

.card.selected {
    transform: translateY(-30px);
    border: 3px solid var(--primary-color);
    box-shadow: 0 15px 25px rgba(0,0,0,0.6);
}

.card.hidden {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #475569;
    cursor: default;
    pointer-events: none; /* Disable all interactions for opponent cards */
}

.card .rank { position: absolute; top: 6px; left: 8px; font-size: 1.2rem; font-weight: 900; }
.card .suit { position: absolute; top: 26px; left: 8px; font-size: 1.2rem; }
.card.red { color: #dc2626 !important; }

.card::after {
    content: attr(data-suit);
    position: absolute;
    top: 55%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.05;
    pointer-events: none;
}

#center-area {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 500;
}

.played-card {
    position: absolute;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    z-index: 600;
    pointer-events: auto;
}

.card-label {
    position: absolute;
    top: -24px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
}

#game-log {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 240px;
    height: 120px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;
    font-size: 0.8rem;
    z-index: 200;
    border: 1px solid var(--glass-border);
}

.log-entry { margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 4px; }

#join-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-dark);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}

#join-screen .modal {
    width: 700px;
    background: rgba(255,255,255,0.02);
    backdrop-filter: blur(20px);
    padding: 30px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lobby-content { display: flex; flex-direction: column; gap: 16px; }
.lobby-main { 
    background: rgba(255,255,255,0.03); 
    padding: 24px; 
    border-radius: 20px; 
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#auth-tabs {
    display: flex;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.auth-tab.active { background: var(--primary-color); color: #000; }

.auth-form-content { display: flex; flex-direction: column; gap: 10px; min-height: 80px; justify-content: center; }
.auth-form-content button { 
    padding: 12px 16px; 
    font-size: 0.95rem; 
    height: 46px; /* Match input height */
    align-self: flex-start; /* Don't stretch */
}
#reg-confirm { margin-top: 6px; }

.auth-switch { font-size: 0.8rem; color: #94a3b8; text-align: center; margin-top: 8px; }
.list-placeholder { text-align: center; color: #64748b; font-size: 0.8rem; padding-top: 20px; }

.lobby-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.lobby-footer span {
    font-size: 0.75rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.lobby-footer span:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Modals */
.u-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.u-modal-content {
    background: #1e293b;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.u-modal-content h2 { color: var(--primary-color); font-family: 'Outfit', sans-serif; }
.u-modal-content h3 { font-size: 1rem; color: #cbd5e1; margin-top: 15px; }

.scrollable-text {
    overflow-y: auto;
    padding-right: 15px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #94a3b8;
}

.scrollable-text p { margin-bottom: 12px; }
.scrollable-text ul { padding-left: 20px; margin-bottom: 12px; }

.close-modal {
    position: absolute;
    top: 20px; right: 20px;
    font-size: 2rem;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover { color: white; }
.auth-switch span { color: var(--primary-color); cursor: pointer; font-weight: bold; text-decoration: underline; }

.user-badge { 
    display: flex; flex-direction: column; align-items: center; gap: 4px; 
    background: rgba(255,215,0,0.1); 
    padding: 12px; 
    border-radius: 12px; 
    border: 1px solid rgba(255,215,0,0.2);
}
.user-badge span { font-size: 0.7rem; text-transform: uppercase; opacity: 0.7; }
.user-badge strong { font-size: 1.2rem; color: var(--primary-color); }

.link-btn {
    background: none; border: none; color: #94a3b8; cursor: pointer; 
    font-size: 0.8rem; text-decoration: underline; margin-top: 8px;
}
.link-btn:hover { color: white; }

.room-actions-unified {
    display: flex; align-items: flex-end; gap: 15px;
    padding-top: 15px; border-top: 1px solid var(--glass-border);
}

.input-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.input-group label { font-size: 0.7rem; text-transform: uppercase; color: #94a3b8; padding-left: 4px; }

.u-hidden { display: none !important; }

#join-screen input {
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-family: 'Inter', sans-serif;
    outline: none;
    font-size: 0.95rem;
    height: 46px;
    transition: all 0.2s;
}
#join-screen input:focus { border-color: var(--primary-color); background: rgba(255, 255, 255, 0.08); }

.lobby-lists { display: flex; gap: 20px; height: 180px; }
.lobby-column { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.lobby-column h3 { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }

.scroll-list {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
}

.lobby-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}
.lobby-item:hover { background: rgba(255,255,255,0.1); }
.lobby-item span { color: var(--primary-color); font-weight: bold; }

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
}

.btn.sm { padding: 8px 16px; font-size: 0.75rem; }
.btn.primary { background: var(--primary-color); color: #000; }
.btn.success { background: #22c55e; color: #fff; }
.btn.secondary { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid var(--glass-border); }

.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }

/* MOBILE STYLES */
@media (max-width: 768px) {
    /* Join Screen / Lobby */
    #join-screen .modal { 
        width: 95%; 
        max-height: 95vh;
        overflow-y: auto;
        padding: 20px; 
        gap: 15px; 
        border-radius: 20px;
    }
    
    #join-screen h1 { font-size: 2rem; margin-bottom: 0; }
    
    .lobby-content { gap: 12px; }
    .lobby-main { padding: 15px; border-radius: 15px; }
    
    .lobby-lists { 
        flex-direction: column; 
        height: auto; 
        gap: 15px; 
    }
    .scroll-list { height: 120px; }

    .room-actions-unified {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .room-actions-unified button { width: 100%; height: 50px; }

    /* Gameplay */
    header { height: 50px; padding: 0 12px; }
    .logo { font-size: 1.1rem; }
    #game-status { 
        font-size: 0.7rem; 
        text-align: center; 
        max-width: 40%; 
        padding: 4px 8px; 
        background: rgba(255,255,255,0.05); 
        border-radius: 6px;
    }
    
    .score-board { gap: 4px; }
    .score-item { 
        padding: 4px 6px; 
        font-size: 0.65rem; 
        border-radius: 8px; 
        display: flex;
        flex-direction: column;
        align-items: center;
        min-width: 60px;
    }
    .score-colon { display: none; }
    .score-item span:first-child { 
        max-width: 50px; 
        overflow: hidden; 
        text-overflow: ellipsis; 
        white-space: nowrap; 
    }
    .score-item span:last-child { font-size: 0.8rem; margin-top: -2px; }

    .table-surface { 
        width: 100%; 
        height: 55%; 
        border-radius: 40px; 
        border-width: 8px;
        top: 45%;
    }

    .hand-container { height: 110px; padding: 0 10px; }
    .card { 
        width: 65px; 
        height: 95px; 
        margin-left: -30px; 
        border-radius: 6px;
    }
    .card .rank, .card .suit { font-size: 0.9rem; }
    .card .rank { top: 4px; left: 5px; }
    .card .suit { top: 20px; left: 5px; }
    .card::after { font-size: 2rem; }

    .card.selected { transform: translateY(-20px); }

    #player-2 { top: 10px; }
    #player-1 { bottom: 50px; } /* Lifted significantly for browser bars */

    .avatar { padding: 4px 12px; font-size: 0.7rem; border-radius: 12px; }

    .player-controls {
        bottom: 160px; /* Lifted above the hand */
        flex-direction: row;
        gap: 8px;
    }
    .player-controls .btn { padding: 10px 15px; font-size: 0.75rem; min-width: 80px; }

    #game-log { 
        width: 140px; 
        height: 80px; 
        font-size: 0.65rem; 
        right: 10px; 
        bottom: 110px; /* Lifted */
        pointer-events: none;
        opacity: 0.8;
    }

    #center-area { transform: translate(-50%, -60%) scale(0.85); }

    .ad-container.top-ad {
        max-height: 60px; /* Keep it slim on mobile */
    }
}

/* Specific landscape fix if needed */
@media (max-width: 900px) and (orientation: landscape) {
    .table-surface { height: 85%; width: 70%; top: 50%; }
    #player-2 { left: 10%; top: 50%; transform: translateY(-50%); }
    #player-1 { right: 10%; bottom: 50%; transform: translateY(50%); left: auto; }
}
