* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Login Screen */
.login-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    text-align: center;
    min-width: 400px;
    max-width: 600px;
}

.login-container h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5rem;
}

.login-form input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: #667eea;
}

.button-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.button-group button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#createGameBtn {
    background: #4CAF50;
    color: white;
}

#createGameBtn:hover {
    background: #45a049;
}

#refreshGamesBtn {
    background: #2196F3;
    color: white;
}

#refreshGamesBtn:hover {
    background: #0b7dda;
}

/* Available Games Section */
.available-games {
    margin: 25px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.available-games h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.games-list {
    max-height: 200px;
    overflow-y: auto;
}

.game-item {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    cursor: pointer;
}

.game-item:hover {
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.2);
}

.game-info-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.game-id-item {
    font-weight: bold;
    font-family: monospace;
    font-size: 16px;
    color: #333;
}

.game-details {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.join-game-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.join-game-btn:hover {
    background: #45a049;
}

.no-games {
    text-align: center;
    color: #666;
    font-style: italic;
    margin: 20px 0;
}

/* Manual Join Section */
.manual-join {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

#joinGameBtn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    width: 100%;
}

#joinGameBtn:hover {
    background: #e68900;
}

.join-input {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

#confirmJoinBtn {
    padding: 15px 20px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

#confirmJoinBtn:hover {
    background: #e68900;
}

/* Lobby Screen */
.lobbyScreen {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5%;
}

.lobby-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    min-width: 400px;
    text-align: center;
}

.game-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.game-id {
    font-family: monospace;
    font-size: 24px;
    font-weight: bold;
    background: #f0f0f0;
    padding: 10px 15px;
    border-radius: 8px;
    letter-spacing: 2px;
}

#copyGameIdBtn {
    padding: 10px 15px;
    background: #333;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.players-list h3 {
    margin: 20px 0 10px 0;
    color: #333;
}

#playersList {
    list-style: none;
    padding: 0;
}

#playersList li {
    background: #f9f9f9;
    padding: 10px;
    margin: 5px 0;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.start-game-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

.start-game-btn:hover {
    background: #45a049;
}

.waiting-message {
    color: #666;
    font-style: italic;
    margin-top: 15px;
}

/* Game Screen */
#gameScreen.active {
    display: block;
    align-items: flex-start;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.current-player {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 18px;
    font-weight: bold;
}

.turn-indicator {
    width: 20px;
    height: 20px;
    background: #4CAF50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.game-status {
    display: flex;
    align-items: center;
    gap: 20px;
}

.direction-indicator {
    font-size: 24px;
    font-weight: bold;
}

.draw-count {
    background: #ff5722;
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 18px;
}

.game-board {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    min-height: 300px;
}

.opponents {
    flex: 1;
}

#opponentsList {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.opponent {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.opponent-name {
    font-weight: bold;
    min-width: 100px;
}

.opponent-cards {
    display: flex;
    gap: 2px;
}

.opponent-card {
    width: 20px;
    height: 30px;
    background: #333;
    border-radius: 3px;
    border: 1px solid #555;
}

.center-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0 40px;
}

.deck-area {
    display: flex;
    gap: 30px;
    align-items: center;
}

.card {
    width: 80px;
    height: 120px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid #333;
    position: relative;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.card.playable {
    cursor: pointer;
    border-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.card.playable:hover {
    transform: translateY(-15px);
    box-shadow: 0 15px 25px rgba(76, 175, 80, 0.4);
}

.card-back {
    background-image: url('./cards/card_back.svg');
    cursor: pointer;
}

.card-back-pattern {
    display: none; /* Hide text since we're using SVG */
}

/* Fixed SVG scaling for all cards */
.card.red, .card.blue, .card.green, .card.yellow, .card.black {
    background: transparent;
}

.player-card.red, .player-card.blue, .player-card.green, .player-card.yellow, .player-card.black {
    background: transparent;
}

.wild-card {
    background: transparent;
}

.current-color {
    font-size: 18px;
    font-weight: bold;
    padding: 15px 25px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.player-hand {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.player-hand h3 {
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.cards-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    min-height: 140px;
    align-items: center;
}

.player-card {
    width: 70px;
    height: 105px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #333;
    position: relative;
    user-select: none;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.player-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.player-card.playable {
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.player-card.playable:hover {
    transform: translateY(-15px);
    box-shadow: 0 15px 25px rgba(76, 175, 80, 0.4);
}

.card-value {
    font-size: 16px;
    font-weight: bold;
}

.hand-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.draw-btn {
    padding: 15px 30px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.draw-btn:hover {
    background: #e68900;
}

.draw-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.uno-btn {
    padding: 15px 30px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    animation: pulseUno 2s infinite;
}

.uno-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

@keyframes pulseUno {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

.uno-challenge {
    background: #fff3cd;
    border: 2px solid #ffeaa7;
    border-radius: 10px;
    padding: 20px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.uno-challenge p {
    font-size: 18px;
    font-weight: bold;
    color: #856404;
    margin-bottom: 15px;
}

#challengeButtons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.challenge-btn {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.challenge-btn:hover {
    background: #c82333;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.color-options {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.color-btn {
    width: 60px;
    height: 60px;
    border: 3px solid #333;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.red { background: #f44336; }
.color-btn.blue { background: #2196F3; }
.color-btn.green { background: #4CAF50; }
.color-btn.yellow { background: #ffeb3b; color: black; text-shadow: none; }

#newGameBtn {
    padding: 15px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

#newGameBtn:hover {
    background: #45a049;
}

/* Error Messages */
.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #f44336;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 1001;
    max-width: 300px;
}

.error-message.show {
    transform: translateX(0);
}

.error-message.success {
    background: #4CAF50;
}

.error-message.warning {
    background: #ff9800;
}

.error-message.error {
    background: #f44336;
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }

    .game-board {
        flex-direction: column;
        gap: 20px;
    }

    .center-area {
        padding: 0;
    }

    .cards-container {
        gap: 5px;
    }

    .player-card {
        width: 60px;
        height: 90px;
        font-size: 12px;
    }

    .card {
        width: 60px;
        height: 90px;
        font-size: 14px;
    }

    .deck-area {
        gap: 15px;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .login-container {
        margin: 0 20px;
        padding: 30px 20px;
        min-width: unset;
        width: 100%;
        max-width: 400px;
    }

    .button-group {
        flex-direction: column;
    }

    .color-options {
        flex-wrap: wrap;
        gap: 10px;
    }

    .color-btn {
        width: 50px;
        height: 50px;
    }

    .game-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .join-game-btn {
        align-self: stretch;
    }
}

@media (max-width: 480px) {
    .player-card {
        width: 50px;
        height: 75px;
        font-size: 10px;
    }

    .cards-container {
        gap: 3px;
    }

    .game-container {
        padding: 5px;
    }

    .player-hand {
        padding: 15px;
    }
}