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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

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

.screen.active {
    display: block;
}

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

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 20px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 18px 32px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.btn-small {
    padding: 12px 24px;
    font-size: 0.9rem;
    margin-top: 20px;
}

.icon {
    font-size: 1.5rem;
}

#qr-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
    padding: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

#qr-container canvas,
#qr-container img {
    max-width: 100%;
    height: auto;
}

.game-id {
    text-align: center;
    font-size: 1.2rem;
    margin: 20px 0;
    color: var(--text-secondary);
}

#game-id-display {
    color: var(--primary-color);
    font-weight: bold;
    font-family: monospace;
}

.info-box {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 15px;
    margin: 20px 0;
}

.info-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: center;
    margin: 0;
}

.info-text strong {
    color: var(--primary-color);
}

.waiting {
    text-align: center;
    margin: 30px 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--card-bg);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#scanner-container {
    margin: 20px 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--card-bg);
}

#scanner-container video {
    width: 100%;
    height: auto;
    display: block;
}

.game-header {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.player.active {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

.player-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.player-score {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.vs {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.turn-indicator {
    text-align: center;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 8px;
    font-weight: 600;
}

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

.card {
    aspect-ratio: 1;
    background: var(--card-bg);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.card.matched {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-face,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
}

.card-back {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    font-size: 2rem;
}

.card-face {
    background: white;
    font-size: 3rem;
    transform: rotateY(180deg);
}

.winner-display {
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--border-radius);
}

.final-scores {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

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

.score-item:last-child {
    border-bottom: none;
}

.score-label {
    font-size: 1.1rem;
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .game-board {
        grid-template-columns: repeat(3, 1fr);
    }

    .card-face {
        font-size: 2rem;
    }

    .btn {
        padding: 15px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .game-board {
        gap: 8px;
    }

    .card-face {
        font-size: 1.5rem;
    }
}
