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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

h2 {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.menu-card, .lobby-card, .game-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.error-message {
    color: #dc3545;
    margin-top: 10px;
    text-align: center;
    min-height: 20px;
    font-weight: 500;
}

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

.lobby-info p {
    color: #666;
    margin-bottom: 10px;
}

.code-display {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 3px;
    cursor: pointer;
    transition: transform 0.2s;
}

.code-display:hover {
    transform: scale(1.05);
}

.players-list {
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.player-item {
    background: #f8f9fa;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-item.current-player {
    background: #e7f3ff;
    border: 2px solid #667eea;
}

.host-badge {
    background: #ffc107;
    color: #333;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.you-badge {
    color: #667eea;
    font-weight: bold;
    margin-left: 10px;
}

.lobby-actions {
    display: flex;
    gap: 10px;
}

.lobby-actions .btn {
    margin-bottom: 0;
}

.lobbies-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.lobby-item {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lobby-item:hover {
    background: #e7f3ff;
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.lobby-item-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lobby-item-info strong {
    font-size: 18px;
    color: #667eea;
}

.lobby-item-info span {
    color: #666;
    font-size: 14px;
}

.lobby-item-players {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.loading, .no-lobbies {
    text-align: center;
    color: #666;
    padding: 30px;
    font-style: italic;
}

.game-content {
    text-align: center;
    margin-bottom: 20px;
}

.game-content h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.game-content p {
    color: #666;
    margin-bottom: 20px;
}

.game-players {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.game-players h4 {
    color: #333;
    margin-bottom: 15px;
}

.game-player {
    background: white;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-weight: 500;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* ============ BLACKJACK GAME STYLES ============ */

.blackjack-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.game-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-header h2 {
    margin: 0;
    color: #333;
    text-shadow: none;
}

.round-info {
    font-size: 18px;
    font-weight: 600;
    color: #667eea;
}

/* Betting Phase */
.betting-phase {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.betting-phase h3 {
    color: #333;
    margin-bottom: 20px;
}

.bet-controls {
    max-width: 400px;
    margin: 0 auto;
}

.bet-controls input[type="number"] {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 18px;
    text-align: center;
}

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

.bet-btn {
    padding: 12px;
    background: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-weight: 600;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s;
}

.bet-btn:hover {
    background: #667eea;
    color: white;
}

.waiting-message {
    padding: 20px;
    background: #fff3cd;
    border-radius: 8px;
    color: #856404;
    font-weight: 600;
}

.broke-message {
    padding: 20px;
    background: #f8d7da;
    border-radius: 8px;
    color: #721c24;
    font-weight: 600;
}

/* Game Table */
.game-table {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.dealer-section {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-radius: 12px;
    margin-bottom: 30px;
}

.dealer-section h3 {
    color: white;
    margin-bottom: 15px;
}

.score {
    color: #ffc107;
    font-weight: bold;
}

.card-hand {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 120px;
    align-items: center;
}

/* Playing Cards */
.card {
    width: 80px;
    height: 110px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    animation: dealCard 0.3s ease-out;
}

@keyframes dealCard {
    from {
        opacity: 0;
        transform: translateY(-20px) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
}

.card.red {
    color: #dc3545;
}

.card.black {
    color: #000;
}

.card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 48px;
}

/* Players Section */
.players-section {
    margin-bottom: 20px;
}

.all-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.player-box {
    background: #f8f9fa;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s;
}

.player-box.current-user {
    background: #e7f3ff;
    border-color: #667eea;
}

.player-box.active-turn {
    border-color: #ffc107;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 193, 7, 0.8);
    }
}

.player-info-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.player-name {
    font-weight: 600;
    color: #333;
}

.player-chips {
    font-weight: 600;
    color: #28a745;
}

.player-bet {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 10px;
}

.player-hand {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    min-height: 80px;
}

.player-hand .card {
    width: 60px;
    height: 85px;
    font-size: 18px;
}

.player-score {
    font-weight: 600;
    color: #333;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 8px;
}

.badge-win {
    background: #28a745;
    color: white;
}

.badge-lose {
    background: #dc3545;
    color: white;
}

.badge-push {
    background: #6c757d;
    color: white;
}

.badge-blackjack {
    background: #ffc107;
    color: #333;
}

.badge-bust {
    background: #dc3545;
    color: white;
}

.badge-stand {
    background: #17a2b8;
    color: white;
}

/* Player Actions */
.player-actions {
    text-align: center;
    padding: 20px;
    background: #e7f3ff;
    border-radius: 12px;
    margin-bottom: 20px;
}

.player-actions h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.action-buttons .btn {
    width: auto;
    min-width: 150px;
    margin: 0;
}

/* Round End */
.round-end {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin-top: 20px;
}

.round-end h3 {
    color: #667eea;
    margin-bottom: 20px;
}

.result-details {
    margin-bottom: 20px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.result-item.current-user {
    background: #e7f3ff;
    border: 2px solid #667eea;
}

.result-player {
    font-weight: 600;
    color: #333;
}

.result-chips {
    font-weight: bold;
    font-size: 18px;
}

.result-chips.positive {
    color: #28a745;
}

.result-chips.negative {
    color: #dc3545;
}

.result-total {
    font-weight: 600;
    color: #667eea;
}

.next-round-timer {
    margin-top: 20px;
    padding: 15px;
    background: #e7f3ff;
    border-radius: 8px;
}

.timer-text {
    color: #667eea;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

/* ============ SCOREBOARD STYLES ============ */

.scoreboard-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.scoreboard-card {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.winner-announcement {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 15px;
    margin-bottom: 30px;
    animation: winnerGlow 2s infinite alternate;
}

@keyframes winnerGlow {
    0% {
        box-shadow: 0 5px 20px rgba(255, 215, 0, 0.5);
    }
    100% {
        box-shadow: 0 5px 40px rgba(255, 215, 0, 0.8);
    }
}

.trophy {
    font-size: 72px;
    margin-bottom: 10px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.winner-announcement h3 {
    color: #333;
    font-size: 32px;
    margin: 10px 0;
}

.winner-chips {
    color: #28a745;
    font-size: 28px;
    font-weight: bold;
    margin: 0;
}

.scoreboard-card h4 {
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
}

.rankings-list {
    margin-bottom: 30px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.ranking-item.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    font-weight: bold;
}

.ranking-item.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    font-weight: bold;
}

.ranking-item.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #e8a57c 100%);
    font-weight: bold;
}

.ranking-item.current-user {
    border: 3px solid #667eea;
    box-shadow: 0 3px 15px rgba(102, 126, 234, 0.3);
}

.rank-medal {
    font-size: 32px;
    margin-right: 15px;
    min-width: 50px;
}

.rank-player {
    flex: 1;
    font-size: 20px;
    color: #333;
}

.rank-chips {
    font-size: 24px;
    font-weight: bold;
    color: #28a745;
}

.scoreboard-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.scoreboard-actions .btn {
    width: auto;
    min-width: 200px;
    margin: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    h1 {
        font-size: 2em;
    }
    
    h2 {
        font-size: 1.5em;
    }
    
    .menu-card, .lobby-card, .game-card {
        padding: 20px;
    }
    
    .code-display {
        font-size: 22px;
        padding: 12px 20px;
    }
    
    .blackjack-container {
        max-width: 100%;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .all-players {
        grid-template-columns: 1fr;
    }
    
    .bet-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card {
        width: 60px;
        height: 85px;
        font-size: 18px;
    }
    
    .player-hand .card {
        width: 50px;
        height: 70px;
        font-size: 14px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}
