:root {
    --primary-color: #ff4d6d;
    --secondary-color: #ff8fa3;
    --bg-color: #2b0c16;
    --text-color: #ffe5ec;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Poppins', sans-serif;
    --gold-text: linear-gradient(to bottom, #cfc09f 22%, #634f2c 24%, #cfc09f 26%, #cfc09f 27%, #ffecb3 40%, #3a2c0f 78%);
    /* A simpler gold gradient for text */
    --gold-gradient: linear-gradient(45deg, #FFD700, #FDB931, #C0C0C0, #FDB931);
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    background: radial-gradient(circle at center, #590d22 0%, #2b0c16 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-heart {
    font-size: 5rem;
    animation: heartbeat 1s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 77, 109, 0.8));
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.15);
    }

    50% {
        transform: scale(1);
    }

    75% {
        transform: scale(1.1);
    }
}

.loading-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    margin: 1rem 0;
    background: linear-gradient(to right, #BF953F, #FCF6BA, #B38728);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.loading-bar-container {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 1.5rem auto;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff4d6d, #ff8fa3, #ffd700);
    border-radius: 3px;
    animation: load-progress 1.5s ease-out forwards;
}

@keyframes load-progress {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

.loading-text {
    font-size: 1.1rem;
    font-family: var(--font-heading);
    letter-spacing: 4px;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 10px;

    /* Shimmer Effect */
    background: linear-gradient(90deg, #ff4d6d 0%, #ffd700 50%, #ff4d6d 100%);
    background-size: 200% auto;

    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;

    animation: shimmer 2.5s linear infinite;
}

@keyframes shimmer {
    to {
        background-position: 200% center;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    color: var(--text-color);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #590d22 0%, #2b0c16 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
}

h1 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    font-weight: 800;

    /* Gold Text Effect */
    background: linear-gradient(to right, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.instruction {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0.5rem 0;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.warning {
    color: #ff4d6d;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 77, 109, 0.3);
}

.game-btn {
    margin-top: 2rem;
    padding: 1rem 3rem;
    font-size: 1.4rem;
    font-family: var(--font-heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #590d22;

    /* Gold Metallic Background */
    background: linear-gradient(to bottom, #fcf6ba 0%, #bf953f 100%);
    border: 1px solid #aa771c;
    border-radius: 5px;
    /* Boxy luxury look vs rounded playfulness */
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

.game-btn:hover::before {
    left: 100%;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(191, 149, 63, 0.4);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.game-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.game-btn.secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1rem;
    font-size: 1.1rem;
    padding: 0.8rem 2rem;
    background: rgba(0, 0, 0, 0.2);
}

.game-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
}

#hud {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    padding: 0 30px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    z-index: 5;
    pointer-events: none;
}

.powerup-box {
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}

.final-score {
    font-size: 4rem;
    font-family: var(--font-heading);
    font-weight: 800;
    color: #fff;
    margin: 1rem 0;
    text-shadow: 0 0 15px rgba(255, 77, 109, 0.6);
}

.rewards {
    font-size: 1.8rem;
    color: #ffd700;
    margin-top: 1rem;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    font-family: var(--font-heading);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

#start-btn {
    animation: pulse 2s infinite;
}

/* Premium Leaderboard Styles */
#leaderboard-list {
    width: 90%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 10px;
    margin: 10px 0;
    max-height: 55vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 0.95rem;
    color: #fff;
    transition: transform 0.2s, background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.2);
}

.leaderboard-item:last-child {
    margin-bottom: 0;
}

.leaderboard-item.header {
    background: rgba(255, 77, 109, 0.8);
    background: linear-gradient(90deg, #ff4d6d 0%, #ff8fa3 100%);
    box-shadow: 0 2px 10px rgba(255, 77, 109, 0.3);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: white;
    margin-bottom: 10px;
    border: none;
}

/* Column Widths */
.leaderboard-item span:nth-child(1) {
    width: 15%;
    text-align: center;
    font-weight: bold;
}

/* Rank */

.leaderboard-item span:nth-child(2) {
    flex: 1;
    text-align: left;
    padding-left: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Name */

.leaderboard-item span:nth-child(3) {
    width: 25%;
    text-align: right;
    font-weight: 800;
    font-family: monospace;
    font-size: 1.2rem;
}

/* Score */

.leaderboard-loading {
    padding: 30px;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Rank Medals/Colors */
.rank-1 span:nth-child(1) {
    font-size: 1.5rem;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rank-1 {
    border: 1px solid rgba(255, 215, 0, 0.5);
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.rank-1 span:nth-child(3) {
    color: #ffd700;
}

.rank-2 span:nth-child(1) {
    font-size: 1.4rem;
}

.rank-2 {
    border: 1px solid rgba(192, 192, 192, 0.5);
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.rank-2 span:nth-child(3) {
    color: #e0e0e0;
}

.rank-3 span:nth-child(1) {
    font-size: 1.3rem;
}

.rank-3 {
    border: 1px solid rgba(205, 127, 50, 0.5);
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.rank-3 span:nth-child(3) {
    color: #ffb580;
}

/* Scrollbar */
#leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

#leaderboard-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Reward Timer */
#reward-timer {
    font-size: 1rem;
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    display: inline-block;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}