:root {
    --bg-color: #0a0b10;
    --text-color: #e0e0e0;
    --accent-color: #ffd700;
    --card-bg: #fff;
    --surface-color: #1a1c25;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

.hidden {
    display: none !important;
}

#login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background: radial-gradient(circle at center, #1f222e 0%, #0a0b10 100%);
}

#login-screen h1 {
    font-size: 8vmin;
    margin-bottom: 5vmin;
    background: linear-gradient(to bottom, #fff, #999);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.login-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 90%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

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

.join-group {
    display: flex;
    gap: 10px;
}

.join-group input {
    flex: 1;
    margin: 0;
}

input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--accent-color);
}

/* Add separator */
.separator {
    display: flex;
    align-items: center;
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    margin: 10px 0;
}

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

.separator::before {
    margin-right: 10px;
}

.separator::after {
    margin-left: 10px;
}

button {
    background: var(--accent-color);
    color: black;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#game-ui {
    padding: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #1a1c25 0%, #0a0b10 100%);
    overflow-y: auto;
    /* Allow scrolling if content gets too tall */
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    padding-bottom: 140px;
    /* Space for fixed footer */
}

#room-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.status-info,
#game-status {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid #333;
    margin-top: 20px;
    /* Make space for room code */
}

#players-list {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px 0;
    flex-wrap: wrap;
    margin-top: 80px;
    width: 100%;
    /* Remove max-height here so it uses main page scroll, or keep it. 
       Let's remove max-height so the whole page scrolls naturally, but controls stay fixed. */
}

.lobby-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(10, 11, 16, 0.95);
    /* Matches bg color, slight borders */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 0;
    z-index: 2000;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    /* Flex alignment carried over from inline styles, but good to reinforce */
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Custom Scrollbar */
#players-list::-webkit-scrollbar {
    width: 8px;
}

#players-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#players-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.player-pill {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 140px;
    text-align: center;
    transition: all 0.3s ease;
}

.active-turn {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.1);
    transform: scale(1.05);
}

#game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
}

.trick-area {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    height: 300px;
}

.card {
    width: 80px;
    height: 120px;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    border-radius: 8px;
    color: black;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    box-sizing: border-box;
    font-weight: bold;
    font-size: 1.4em;
    position: relative;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.card .rank {
    align-self: flex-start;
}

.card .suit {
    align-self: flex-end;
    font-size: 1.2em;
}

.card-H,
.card-D {
    color: #e74c3c;
}

.card-C,
.card-S {
    color: #2c3e50;
}

.hand-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: min(20px, 2vh);
    height: 140px;
    width: 100%;
}

.hand-container .card {
    transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    margin: 0 -15px;
    /* Overlap */
    cursor: pointer;
}

.hand-container .card:hover {
    transform: translateY(-30px) rotate(2deg);
    z-index: 100;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.bid-overlay {
    position: absolute;
    top: 35%;
    /* Moved up from 50% to avoid card overlap */
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(16, 18, 27, 0.95);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--accent-color);
    text-align: center;
    z-index: 1000;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.trick-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: dealCard 0.3s ease-out;
}

@keyframes dealCard {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.card-owner {
    font-size: 0.9em;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* Winner Highlight */
.winner-highlight .card {
    box-shadow: 0 0 20px #ffd700;
    /* Gold Glow */
    border: 2px solid #ffd700;
    transform: scale(1.1);
    z-index: 10;
}

.win-badge {
    position: absolute;
    top: -15px;
    background: #ffd700;
    color: black;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    z-index: 20;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* Bidding Grid */
.bid-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    max-width: 300px;
}

.bid-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.1rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.bid-btn:hover {
    background: var(--accent-color);
    color: black;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(231, 76, 60, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: bold;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: fade-in-out 3s ease forwards;
    pointer-events: none;
}

100% {
    opacity: 0;
    transform: translate(-50%, -20px);
}
}

/* --- Mobile / Responsive Tweaks --- */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        /* Base scale down */
    }

    /* Lobby Improvements */
    #players-list {
        margin-top: 60px;
        /* Reduced from 80px */
        gap: 10px;
    }

    .player-pill {
        min-width: 100px;
        padding: 8px 15px;
        font-size: 0.9em;
    }

    #room-info {
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 80%;
        text-align: center;
        font-size: 1.2rem;
        padding: 5px 15px;
    }

    /* Game Board Compactness */
    .trick-area {
        height: 200px;
        /* Reduced from 300px */
        gap: 10px;
    }

    /* Smaller Cards */
    .card {
        width: 60px;
        height: 90px;
        font-size: 1em;
    }

    .card .suit {
        font-size: 1em;
    }

    /* Hand container adjustments */
    .hand-container {
        height: 100px;
        margin-bottom: 10px;
    }

    .hand-container .card:hover {
        transform: translateY(-15px) rotate(2deg);
        /* Less lift on mobile */
    }

    /* Bidding Menu - Ensure it fits */
    .bid-overlay {
        width: 85%;
        padding: 20px;
        top: 40%;
    }

    .bid-grid {
        gap: 5px;
    }

    .bid-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    /* Status Info Bar */
    .status-info,
    #game-status {
        font-size: 0.9em;
        padding: 10px;
        margin-top: 10px;
    }
}

/* Very Small Screens (iPhone SE etc) */
@media (max-height: 600px) {
    .trick-area {
        height: 160px;
    }

    .hand-container {
        height: 90px;
    }

    #room-info {
        position: static;
        margin-top: 10px;
        background: none;
        box-shadow: none;
        border: none;
    }

    #players-list {
        margin-top: 10px;
    }
}