@font-face {
    font-family: 'Lobster';
    src: url('Lobster-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600;700&display=swap');

body {
    font-family: 'Lobster', cursive;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: manipulation;
    background: linear-gradient(135deg, var(--theme-bg-color-1, #4A148C), var(--theme-bg-color-2, #7B1FA2));
    position: relative;
    overflow: hidden;
}

/* Decorative background elements */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 8%),
        radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 6%),
        radial-gradient(circle at 40% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 10%),
        radial-gradient(circle at 70% 90%, rgba(255, 255, 255, 0.1) 0%, transparent 7%);
    z-index: -1;
}

.game-container {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 
                inset 0 2px 2px rgba(255, 255, 255, 0.2),
                inset 0 -2px 2px rgba(0, 0, 0, 0.1);
    padding: 25px;
    max-width: 500px;
    width: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
    background: linear-gradient(90deg, var(--theme-btn-color-1, #FF4081), var(--theme-btn-color-2, #F50057));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    gap: 10px;
}

.score-container, .moves-container {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: 20px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2), 
                inset 0 1px 2px rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.score-icon, .moves-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
}

#board {
    display: grid;
    gap: 5px;
    padding: 8px;
    background: linear-gradient(145deg, var(--theme-board-color-1, #303F9F), var(--theme-board-color-2, #1A237E));
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3),
                inset 0 2px 2px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.gem {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2),
                inset 0 2px 2px rgba(255, 255, 255, 0.3);
}

.gem.selected {
    transform: scale(0.85);
    box-shadow: 0 0 15px 5px rgba(255, 255, 255, 0.5);
}

.gem.matched {
    opacity: 0.2;
    transform: scale(0.8);
}

.gem.falling {
    animation: fall 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}

@keyframes fall {
    from {
        transform: translateY(-150%) rotate(-5deg);
        opacity: 0.5;
    }
    75% {
        transform: translateY(10%) rotate(3deg);
    }
    to {
        transform: translateY(0) rotate(0);
        opacity: 1;
    }
}

.score-popup {
    font-size: 1.4rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.combo-text {
    font-family: 'Lobster', cursive;
    background: linear-gradient(90deg, #FFD700, #FF4081);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(255, 64, 129, 0.9));
    pointer-events: none;
    letter-spacing: 2px;
}

.chain-combo-indicator {
    pointer-events: none;
}

.score-popup.combined, .chain-combo-indicator.combined {
    font-size: 2.5rem !important;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform-origin: center;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

/* Add leaderboard modal styles */
.leaderboard-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
    padding-right: 10px;
}

.leaderboard-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-user {
    display: flex;
    align-items: center;
    flex: 1;
    margin: 0 15px;
}

.leaderboard-username {
    color: white;
    font-weight: 600;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

.leaderboard-position {
    font-weight: bold;
    color: #FF4081;
    min-width: 30px;
}

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

.footer {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
}

button {
    background: linear-gradient(135deg, var(--theme-btn-color-1, #FF4081), var(--theme-btn-color-2, #F50057));
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3),
                inset 0 2px 2px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    font-family: var(--theme-font-family), cursive;
    letter-spacing: 1px;
}

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

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

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.4);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.audio-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.audio-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.audio-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

.audio-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.audio-button.muted svg path {
    fill: rgba(255, 255, 255, 0.5);
}

.mute-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2),
                inset 0 1px 2px rgba(255, 255, 255, 0.2);
    padding: 0;
    min-width: 45px;
}

.mute-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.mute-button:active {
    transform: scale(0.95);
}

.mute-button svg {
    width: 20px;
    height: 20px;
    stroke: white;
    transition: stroke 0.3s ease;
}

.mute-button.muted {
    background: rgba(255, 64, 129, 0.3);
}

.mute-button.muted svg {
    stroke: rgba(255, 255, 255, 0.7);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    max-width: 80%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    color: white;
}

.modal h2 {
    margin-bottom: 20px;
    color: white;
    font-size: 2.2rem;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.modal p {
    margin-bottom: 25px;
    font-size: 1.3rem;
    opacity: 0.9;
}

.score-value {
    font-size: 3rem;
    display: block;
    margin: 15px 0;
    background: linear-gradient(90deg, #FF4081, #F50057);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.star-rating {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.star {
    width: 40px;
    height: 40px;
    margin: 0 5px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Style the scrollbar for the leaderboard */
.leaderboard-container::-webkit-scrollbar {
    width: 8px;
}

.leaderboard-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.leaderboard-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.leaderboard-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}