* {
    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 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.2);
    text-align: center;
    max-width: 500px;
    width: 100%;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.container:hover {
    transform: translateY(-5px);
}

h1 {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    font-size: 2.8em;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.join-form input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.join-form input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: linear-gradient(135deg, #ccc, #999);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

button:disabled::before {
    display: none;
}

.players-list {
    margin: 20px 0;
    text-align: left;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: #f5f5f5;
    border-radius: 5px;
}

.player-item.ready {
    background: #d4edda;
    border-left: 4px solid #28a745;
}

.ready-status {
    font-weight: bold;
    color: #28a745;
}

/* Game Screen */
#gameScreen {
    display: none;
    flex-direction: column;
    padding: 20px;
}

#gameScreen.active {
    display: flex;
}

.game-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 12px;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 50px;
}

.stat {
    text-align: center;
    position: relative;
}

.stat .label {
    display: block;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat span:last-child {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: block;
    animation: statUpdate 0.3s ease;
}

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

.game-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 100px;
    width: 100%;
    margin: 0 auto;
}

.card {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    transition: transform 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    transform-style: preserve-3d;
}

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

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    opacity: 0.6;
    transform: scale(0.9);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 3rem;
}

.card-front {
    background: #667eea;
    color: white;
    font-size: 0.8em;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    border: 2px solid #eee;
}

.players-progress {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 12px;
    margin-top: 20px;
}

.player-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 10px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.player-progress:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    width: 90%;
}

/* Loaders */
.loader, .suspense-loader {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Podium */
#podium {
    display: flex;
    justify-content: center;
    align-items: end;
    gap: 20px;
    margin: 30px 0;
}

.podium-place {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    min-width: 120px;
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.5s ease;
}

.podium-place.show {
    opacity: 1;
    transform: translateY(0);
}

.podium-place.winner {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    transform: scale(1.1);
    position: relative;
}

.podium-place .rank {
    font-size: 1em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
    line-height: 1.2;
}

.podium-place.winner .rank {
    color: #ffd700;
    font-size: 1.2em;
}

.podium-place .player-name {
    font-size: 1.2em;
    font-weight: bold;
}

.crown {
    font-size: 2em;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

/* Confetti Canvas */
#confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .memory-grid {
        gap: 10px;
    }
    
    .card {
        font-size: 2em;
    }
    
    .game-stats {
        gap: 30px;
        flex-wrap: wrap;
    }
    
    .stat span:last-child {
        font-size: 1.5em;
    }
    
    h1 {
        font-size: 2.2em;
    }
    
    .container {
        padding: 30px 20px;
        margin: 10px;
    }
    
    #podium {
        flex-direction: column;
        align-items: center;
    }
    
    .podium-place {
        width: 100%;
        max-width: 250px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .memory-grid {
        gap: 8px;
    }
    
    .card {
        font-size: 1.8em;
    }
    
    .game-stats {
        gap: 20px;
    }
    
    .stat span:last-child {
        font-size: 1.3em;
    }
}

@media only screen and (min-width: 1024px) {
    
    .memory-grid {
        gap: 20px;
        max-width: 500px;
    }
    
    .card {
        font-size: 3.5em;
    }
    
    .game-stats {
        gap: 40px;
    }
}