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

/* Ensure content sits above the overlay */
#app {
    position: relative;
    z-index: 1;
}

body {  
    
    font-family: "Rostenfly";
    src: url("/fonts/Rostenfly.woff") format("woff");
    background-image: url("/backgrounds/SPLPoker2.png");
    backdrop-filter: blur(2px);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    z-index: 0;
}

/* Semi-opaque overlay to preserve contrast/readability */
body::before {
    content: "";
    position: fixed;
    inset: 0; /* top:0; right:0; bottom:0; left:0; */
    background: rgba(35, 35, 35, 0.27); /* adjust opacity (0.25 - 0.6) as needed */
    z-index: 0;
    pointer-events: none;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Lobby Styles */
.lobby-container {
    max-width: 350px;
    margin: auto;
    text-align: center;
    animation: fadeIn 1s ease-in;
    justify-content:center;
    padding: 0px 0px 30px 0px;
    
}

.game-title {
    display: flex;
    height: 310px;
    justify-content: center;
    
}
    
.lobby-form {
    background: rgb(2 21 6 / 72%);
    backdrop-filter: blur(5px);
    border-radius: 150px;
    padding: 30px;
    box-shadow: 0px 0px 30px rgb(23 255 0 / 45%);
    border: 4px solid white;
}

.lobby-form h2 {
    font-size: 2em;
    padding: 20px;
}

.form-group {
    margin-bottom: 30px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid rgba(255, 255, 255, 0.567);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.381);
    color: #fff;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #00ffcc;
    background: rgba(230, 255, 234, 0.54);
}

.form-group input[type="text"]::placeholder {
    color: rgb(255 255 255 / 61%);
}

/* Avatar Selection */
.avatar-selection {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    justify-items: center;
}

.avatar-option {
    width: 70px;
    height: 70px;
    font-size: 2.5em;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: #4CAF50;
}

.avatar-option.selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.3);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

/* Table Selection */
.table-selection {
    display: grid;
    grid-template-columns: repeat(2);
    gap: 20px;
}

.table-card {
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 150px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.table-card:hover {
    transform: translateY(-5px);
    border-color: #4CAF50;
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.3);
}

.table-card.selected {
    border-color: #ffffff;
    background: rgb(245 255 245 / 30%);
}

.table-card h3 {
    font-size: 1.3em;
}

.table-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-count {
    font-size: 1em;
}

.table-status {
    padding: 5px 15px;
    background: #4CAF50;
    border-radius: 20px;
    font-size: 0.9em;
}

/* Buttons */
.btn {
    padding: 5px 10px;
    font-size: 1.1em;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.btn-primary:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background: #f44336;
    color: white;
}

.btn-secondary:hover {
    background: #da190b;
}

.btn-danger {
    background: #f44336;
    color: white;
    flex: 1;
}

.btn-success {
    background: #4CAF50;
    color: white;
    flex: 1;
}

.btn-warning {
    background: #ff9800;
    color: white;
    flex: 1;
}

/* Game Screen */
.game-header {
    padding: 5px 15px 5px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
}

.table-name {
    font-size: 1.5em;
    font-weight: bold;
}

/* Poker Table */
.poker-table {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    min-height: 60vh;
}

.table-felt {
    position: relative;
    width: 900px;
    height: 500px;
    background: radial-gradient(#0d8a0d 0%, #052b05 100%);
    border-radius: 275px / 225px;
    border: 15px solid #745202;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

/* Community Cards */
.community-cards {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.community-cards .card-slot {
    width: 70px;
    height: 100px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

/* Pot Display */
.pot-display {
    position: absolute;
    top: 76%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 150px;
    text-align: center;
}

.pot-label {
    font-size: 0.8em;
    font-weight: bold;
    opacity: .9;
}

.pot-amount {
    font-size: 1.4em;
    font-weight: bold;
    color: #ffd700;
}

/* Player Seats */
.player-seats {
    position: relative;
    width: 100%;
    height: 100%;
}

.player-seat {
    position: absolute;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50px;
    text-align: center;
    transition: all 0.3s ease;
}

.player-seat.empty {
    opacity: 0.3;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.player-seat.active {
    border: 5px solid #ffffff;
    box-shadow: 0 0 20px rgba(251, 255, 0, 0.666);
}

.player-seat.dealer::after {
    content: 'D';
    position: absolute;
    top: -10px;
    right: -1px;
    width: 30px;
    height: 30px;
    background: #ffffff;
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bolder;
}

/* Position seats around the table */
.seat-0 { top: -5%; left: 50%; transform: translateX(-50%); }
.seat-1 { top: -1%; left: 66%; }
.seat-2 { top: 30%; left: 86%; }
.seat-3 { top: 68%; left: 86%; }
.seat-4 { top: 90%; left: 68%; }
.seat-5 { top: 94%; left: 50%; transform: translateX(-50%); }
.seat-6 { top: 90%; left: 20%; }
.seat-7 { top: 68%; left: 0%; }
.seat-8 { top: 30%; left: 0%; }
.seat-9 { top: -1%; left: 20%; }

.player-info {
    margin-bottom: 10px;
}

.player-avatar {
    font-size: 2em;
    margin-bottom: -20px;
}

.player-name {
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 0px;
}

.player-chips {
    font-size: 0.9em;
    color: #ffd700;
}

.player-bet {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800;
    padding: 5px 5px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: bold;
}

.player-cards {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 5px;
}

.player-status {
    margin-top: 5px;
    font-size: 0.8em;
    font-style: italic;
    opacity: 0.8;
}

/* Card Styles */
.card {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #000;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: dealCard 0.3s ease-out;
}

.card.hearts, .card.diamonds {
    color: #d32f2f;
}

.card.clubs, .card.spades {
    color: #000;
}

.card-back {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1976D2 0%, #2196F3 100%);
    border-radius: 8px;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back::before {
    content: '🂠';
    font-size: 2em;
    color: white;
}

/* Action Controls */
.action-controls {
    position: fixed;
    bottom: -70px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-hand {
    display: flex;
    gap: 10px;
}

.player-hand .card-slot {
    width: 70px;
    height: 90px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
}

.action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    margin-left: 20px;
}

.action-buttons .btn {
    padding: 12px 30px;
    font-size: 1em;
}

.raise-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: 10px;
}

.raise-controls input[type="range"] {
    width: 150px;
}

.raise-controls input[type="number"] {
    width: 70px;
    padding: 8px;
    border-radius: 5px;
    border: none;
    font-size: 1em;
}

/* Winner Display */
.winner-display {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease-in;
}

.winner-content {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.5);
}

.winner-content h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #ffd700;
}

.winners-list {
    font-size: 1.3em;
    line-height: 1.8;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes dealCard {
    from {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes chipAnimation {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Avatar Chooser */
.avatar-chooser {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar-preview {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9em;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-panel {
    position: relative;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8em;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: #fff;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Avatar Gallery */
.avatar-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    justify-items: center;
}

.avatar-thumbnail {
    width: 100px;
    height: 100px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.avatar-thumbnail:hover {
    transform: scale(1.1);
    border-color: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.avatar-thumbnail.selected {
    border-color: #4CAF50;
    border-width: 4px;
    box-shadow: 0 0 25px rgba(76, 175, 80, 0.7);
}

.avatar-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loading-message {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.7);
}

/* Player Avatar Image Support */
.player-avatar img {
    width: 2em;
    height: 2em;
    object-fit: cover;
    border-radius: 50%;
}

/* Body no-scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 1024px) {
    .table-felt {
        width: 700px;
        height: 450px;
    }
    
    .player-seat {
        width: 70px;
        font-size: 0.9em;
    }
}

@media (max-width: 768px) {
    .lobby-container {
        padding: 20px 10px;
    }
    
    .game-title {
        font-size: 2em;
    }
    
    .avatar-selection {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .table-selection {
        grid-template-columns: 1fr;
    }
    
    .table-felt {
        width: 100%;
        height: 400px;
    }
    
    .modal-panel {
        width: 95%;
        max-height: 90vh;
    }
    
    .avatar-gallery {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }
    
    .avatar-thumbnail {
        width: 80px;
        height: 80px;
    }
}

/* Ready Button Styles */
.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-ready {
    background: #666;
    color: white;
    font-size: 1em;
}

.btn-ready:hover:not(:disabled) {
    background: #555;
}

.btn-ready.ready-active {
    background: #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    animation: glow 1.5s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.9);
    }
}

.btn-ready:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.ready-status {
    color: #4CAF50;
    font-size: 1.1em;
    font-weight: bold;
}

/* Mobile/Portrait Layout */
@media (max-width: 650px), (orientation: portrait) {
    body.mobile-portrait .poker-table {
        padding: 40px 25px 230px 25px;
        min-height: 100vh;
    }
    
    body.mobile-portrait .table-felt {
        width: 100%;
        max-width: 520px;
        height: 300px;
        border-radius: 175px / 100px;
        border-width: 10px;
    }
    
    body.mobile-portrait .community-cards {
        flex-direction: row;
        justify-content: center;
        gap: 5px;
    }
    
    body.mobile-portrait .community-cards .card-slot {
        width: 48px;
        height: 70px;
    }
    
    body.mobile-portrait .card {
        font-size: 1.5em;
        width: 50px;
        height: 70px;
    }
    
    body.mobile-portrait .pot-display {
        font-size: 0.8em;
        padding: 4px 10px;
        margin-top: 5px;
        border-radius: 50px;
    }

    body.mobile-portrait .player-seat {
        width: 17%;
        min-height: 0%;
        border-radius: 50px;
    }
    
    /* Mobile seat layout */
    body.mobile-portrait .seat-0 { top: -12%; left: 50%; transform: translateX(-50%); }
    body.mobile-portrait .seat-1 { top: -10%; left: 66%; }
    body.mobile-portrait .seat-2 { top: -2%; left: 90%; }
    body.mobile-portrait .seat-3 { top: 83%; left: 90%; }
    body.mobile-portrait .seat-4 { top: 88%; left: 66%; }
    body.mobile-portrait .seat-5 { top: 89%; left: 50%; transform: translateX(-50%); }
    body.mobile-portrait .seat-6 { top: 88%; left: 15%; }
    body.mobile-portrait .seat-7 { top: 83%; left: -9%; }
    body.mobile-portrait .seat-8 { top: -2%; left: -9%; }
    body.mobile-portrait .seat-9 { top: -10%; left: 15%; }
    
    body.mobile-portrait .player-info {
        flex-direction: row;
        align-items: center;
    }
    
    body.mobile-portrait .player-avatar {
        font-size: 1.4em;
        height: 30px;
    }
    
    body.mobile-portrait .player-name {
        font-size: 0.9em;
        padding: 25px 0px 0px 0px;
    }
    
    body.mobile-portrait .player-chips {
        font-size: 0.8em;
        padding: 0px 0px 5px 0px;
    }
    
    /* Stack action controls vertically */
    body.mobile-portrait .action-controls {
        display: absolute;
        bottom: 20px;        
        flex-direction: column;    
        gap: 10px;
        border-radius: 150px;
        background-color: rgb(0 0 0 / 58%);
        border: 3px solid rgb(255 255 255 / 30%);
    }
    
    
    body.mobile-portrait .player-hand {
        justify-content: center;
        gap: 10px;
        padding: 0px;
    }
    
    body.mobile-portrait .player-hand .card-slot {
        width: 50px;
        height: 70px;
        margin-left: -120px;
    }
    
    body.mobile-portrait .action-buttons {
        flex-direction: row;
        width: 100%;
        gap: 10px;
    }
    
    body.mobile-portrait .action-buttons button {
        width: 45%;
        padding: 7px;
        font-size: 1.2em;
        
    }
    
    body.mobile-portrait .raise-controls {
        flex-direction: column-reverse;
        width: 30%;
        gap: 10px;
        
    }
    
    body.mobile-portrait .raise-controls input {
        width: 100%;
        display: flex;
        border-top-right-radius: 30px;
/*FINISH HERE*/
    }
    
    /* Winner display on mobile */
    body.mobile-portrait .winner-display {
        padding: 15px;
    }
    
    body.mobile-portrait .winner-content {
        max-width: 100%;
        padding: 20px;
    }
    
    body.mobile-portrait .winner-content h2 {
        font-size: 1.5em;
    }
    
    body.mobile-portrait .winners-list {
        font-size: 0.9em;
    }
    
    /* Game header on mobile */
    body.mobile-portrait .game-header {
        flex-direction: row;
        gap: 30px;
        padding: 2px 15px 3px 10px;
        font-size: 0.6em;
    }
    
    body.mobile-portrait .header-controls {
        width: 60%;
        gap: 20px;
    }
    
    body.mobile-portrait .header-controls button {
        width: 100%;
    }
}
    body.mobile-portrait .btn-secondary {
        max-width: 70px;
        height: 25px;
        font-size: 1.4em;
    }
    body.mobile-portrait .btn-ready {
        max-width: 70px;
        height: 25px;
        font-size: 1.4em;

        
    }