:root {
    --bg-color: #0f172a;
    --accent-color: #3b82f6;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-color: #f8fafc;
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.2) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.2) 0%, transparent 20%);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.view.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

h1 {
    font-weight: 600;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    letter-spacing: 2px;
}

h2 {
    margin-bottom: 1rem;
}

input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-family: inherit;
}

input:focus {
    outline: 2px solid var(--accent-color);
}

button {
    background: var(--accent-color);
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    width: 100%;
}

button:active {
    transform: scale(0.95);
}

#qr-container {
    margin: 20px 0;
    background: white;
    padding: 10px;
    border-radius: 10px;
    display: inline-block;
}

#qr-code {
    width: 150px;
    height: 150px;
    display: block;
}

.subtext {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-top: 5px;
}

#player-list {
    margin-bottom: 20px;
    width: 100%;
    text-align: left;
}

.player-item {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
}

.player-item.ready {
    color: #4ade80;
}

/* Hand View */
#view-hand {
    justify-content: flex-end;
    padding-bottom: 40px;
}

.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.2);
}

#player-name-display {
    color: var(--accent-color);
    font-size: 1rem;
}

#phase-indicator {
    flex: 1;
    text-align: center;
}

.hand-container {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 20px 60px;
    width: 100%;
    scroll-snap-type: x mandatory;
    justify-content: flex-start;
    height: 60%;
    align-items: center;
    -webkit-overflow-scrolling: touch;
}

.hand-container::before,
.hand-container::after {
    content: '';
    min-width: 40px;
    height: 1px;
}

.card {
    flex: 0 0 auto;
    width: 200px;
    /* Adjust based on viewport */
    height: 300px;
    background: #333;
    border-radius: 15px;
    scroll-snap-align: center;
    position: relative;
    transition: transform 0.3s;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    background-size: cover;
    background-position: center;
    cursor: pointer;
}

.zoom-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s, background 0.2s;
    backdrop-filter: blur(5px);
}

.zoom-icon:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.zoom-icon:active {
    transform: scale(0.95);
}

.table-zoom-icon {
    width: 30px;
    height: 30px;
    font-size: 1rem;
    top: 5px;
    right: 5px;
}

.card.selected {
    transform: translateY(-30px) scale(1.05);
    border: 4px solid var(--accent-color);
    box-shadow: 0 15px 40px rgba(59, 130, 246, 0.6);
}

.card.new-card {
    animation: newCardPulse 1s ease-in-out 3;
    border: 3px solid #4ade80;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.8);
}

@keyframes newCardPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.8);
    }
    50% {
        box-shadow: 0 0 30px rgba(74, 222, 128, 1);
    }
}

.card.played {
    opacity: 0.5;
    pointer-events: none;
}

/* Table View */
#view-table {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 15px;
}

.table-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    width: 100%;
    padding-bottom: 100px;
}

#review-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
}

#review-controls.hidden {
    display: none;
}

.table-card-wrapper {
    position: relative;
    width: 120px;
    height: 180px;
    cursor: pointer;
}

.table-card {
    width: 100%;
    height: 100%;
    background: #444;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.table-card.face-down {
    background-image: repeating-linear-gradient(45deg, #1e293b, #1e293b 10px, #334155 10px, #334155 20px);
    background-color: #334155;
    background-size: initial;
    display: grid;
    place-items: center;
}

.table-card.face-down::after {
    content: '?';
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.2);
}

.table-card-wrapper:hover .table-card {
    transform: scale(1.05);
}

.table-card-wrapper.voted {
    border: 4px solid #4ade80;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.6);
    animation: votePulse 0.5s ease-out;
}

@keyframes votePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.owner-label {
    position: absolute;
    bottom: -25px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    padding: 2px 0;
}

.bids-label {
    position: absolute;
    bottom: -50px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: #4ade80;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    padding: 2px 0;
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 1.5rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.toast.show {
    opacity: 1;
}

#zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#zoom-overlay.hidden {
    display: none;
}

#zoomed-card {
    max-width: 95%;
    max-height: 90%;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

#btn-close-zoom {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.leader-card-display {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 80px;
    height: 120px;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent-color);
    z-index: 50;
    display: none;
}

.leader-card-label {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: var(--accent-color);
    font-weight: 600;
}

.scoring-messages {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 20px 30px;
    border-radius: 15px;
    border: 2px solid var(--accent-color);
    max-width: 90%;
    z-index: 100;
    display: none;
}

.scoring-messages h3 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
    font-size: 1.2rem;
}

.scoring-messages p {
    margin: 5px 0;
    font-size: 1rem;
    color: var(--text-color);
}

@media (min-width: 768px) {
    .card {
        width: 250px;
        height: 350px;
    }

    .table-card-wrapper {
        width: 150px;
        height: 225px;
    }

    .leader-card-display {
        width: 100px;
        height: 150px;
    }
}