:root {
    --primary: #ff4d6d;
    --primary-hover: #ff758f;
    --secondary: #7209b7;
    --bg-dark: #121212;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #b0b0b0;
    --card-back: linear-gradient(135deg, #7209b7 0%, #ff4d6d 100%);
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top right, #1a1a2e, #0f0f0f);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

.main-layout {
    display: flex;
    gap: 30px;
    width: 95%;
    max-width: 1300px;
    align-items: flex-start;
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 40px;
    flex: 1;
    box-shadow: var(--shadow-premium);
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 30px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar h3 {
    font-family: 'Pacifico', cursive;
    color: var(--primary);
    margin-bottom: 5px;
    font-size: 1.5rem;
}

.phase-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.rank-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-pos {
    font-weight: 600;
    color: var(--primary);
    width: 20px;
}

.rank-name {
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.rank-time {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.music-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.music-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

h1 {
    font-family: 'Pacifico', cursive;
    font-size: 3rem;
    background: linear-gradient(to right, #ff4d6d, #f8edeb);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-weight: 300;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 25px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.stat-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-item .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    perspective: 1000px;
    margin-bottom: 40px;
}

/* For larger screens, limit columns */
@media (min-width: 600px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
    }
}

.card {
    height: 180px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 15px;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    cursor: default;
    animation: pulse 0.5s ease-in-out;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    border: 2px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.card-front {
    background: var(--card-back);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.2);
}

.card-front::after {
    content: "❤️";
    font-size: 3rem;
    opacity: 0.3;
}

.card-back {
    background: #000;
    transform: rotateY(180deg);
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.controls {
    display: flex;
    justify-content: center;
}

.btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 77, 109, 0.4);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1a1a1a;
    padding: 40px;
    border: 2px solid var(--primary);
    border-radius: 30px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 77, 109, 0.3);
    animation: modalIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pre-title {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.modal h2 {
    font-family: 'Pacifico', cursive;
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 2.8rem;
}

.final-stats {
    margin: 30px 0;
    font-size: 1.2rem;
}

@keyframes pulse {
    0% {
        transform: scale(1) rotateY(180deg);
    }

    50% {
        transform: scale(1.05) rotateY(180deg);
    }

    100% {
        transform: scale(1) rotateY(180deg);
    }
}

@keyframes modalIn {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.player-label {
    color: var(--primary);
    font-weight: 600;
    margin-top: 5px;
    font-size: 1.1rem;
}

.input-group {
    margin: 25px 0;
    width: 100%;
}

#player-name-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    padding: 15px 20px;
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    transition: all 0.3s ease;
}

#player-name-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 1000px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }

    .sidebar {
        width: 100%;
        order: 2;
        position: static;
    }
}

@media (max-width: 480px) {
    .glass-container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .game-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .card {
        height: 120px;
    }

    .stat-item {
        min-width: 80px;
        padding: 10px;
    }
}