:root {
    --primary-pink: #ff85a2;
    --primary-pink-hover: #ff6384;
    --accent-purple: #c084fc;
    --accent-purple-hover: #a855f7;
    --bg-dark: #0f0717;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    --hud-glass: rgba(15, 7, 23, 0.4);
    --white: #ffffff;
    --font-cute: 'Fredoka', sans-serif;
    --font-ui: 'Outfit', sans-serif;
}

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

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1b0e2b 0%, #07030b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-ui);
    color: var(--white);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Scalable 16:9 Wrapper */
.game-wrapper {
    position: relative;
    width: 1280px;
    height: 720px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    position: relative;
    width: 1280px;
    height: 720px;
    background-color: var(--bg-dark);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8),
                0 0 40px rgba(255, 133, 162, 0.15);
    border-radius: 20px;
    overflow: hidden;
    /* Scale transformation origin in the center */
    transform-origin: center center;
    transition: transform 0.1s ease;
}

/* Canvas styling */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    background: linear-gradient(to bottom, #2b1055, #7597de);
    display: block;
}

/* Overlay Base */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: rgba(12, 6, 19, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 580px;
    box-shadow: 0 20px 50px var(--glass-shadow),
                inset 0 0 12px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    text-align: center;
    animation: cardEntrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

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

/* Start Card specific elements */
.start-card {
    max-width: 640px;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    gap: 15px;
}

.emoji-title {
    font-size: 3rem;
    animation: float 3s ease-in-out infinite;
}

.game-title {
    font-family: var(--font-cute);
    font-size: 3.2rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary-pink), var(--accent-purple), #ffccd5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(255, 133, 162, 0.25);
    letter-spacing: -1px;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-8px) rotate(5deg); }
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 25px;
    line-height: 1.5;
}

.highscore-badge {
    display: inline-flex;
    flex-direction: column;
    background: rgba(255, 133, 162, 0.15);
    border: 1px dashed rgba(255, 133, 162, 0.4);
    border-radius: 16px;
    padding: 12px 24px;
    margin-bottom: 25px;
}

.highscore-badge span {
    font-size: 0.8rem;
    letter-spacing: 1.5px;
    color: var(--primary-pink);
    font-weight: 600;
}

.highscore-badge strong {
    font-family: var(--font-cute);
    font-size: 1.8rem;
    color: var(--white);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.instructions {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.instructions h3 {
    font-family: var(--font-cute);
    font-size: 1.15rem;
    color: var(--accent-purple);
    margin-bottom: 12px;
}

.instructions ul {
    list-style-type: none;
}

.instructions li {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons and Micro-animations */
.button-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.button-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 250px;
    margin: 25px auto 0;
}

.btn {
    font-family: var(--font-cute);
    font-size: 1.15rem;
    font-weight: 600;
    padding: 14px 28px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-pink) 0%, #ff527b 100%);
    color: var(--white);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(255, 133, 162, 0.45);
    background: linear-gradient(135deg, #ff9bb5 0%, var(--primary-pink-hover) 100%);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.99);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(255, 255, 255, 0.05);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* In-game HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#hud.hidden {
    opacity: 0;
}

.hud-left, .hud-right, .hud-center {
    background: var(--hud-glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.hud-center {
    flex-direction: column;
    padding: 8px 30px;
    min-width: 180px;
}

/* Hearts Container */
.hearts-container {
    display: flex;
    gap: 8px;
}

.heart {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 5px rgba(255, 133, 162, 0.3));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heart.lost {
    transform: scale(0);
    opacity: 0.3;
}

.heart.pulse {
    animation: heartBeat 0.4s ease-out;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Score displays */
.score-label {
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 700;
}

.score-value {
    font-family: var(--font-cute);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--white);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    transition: transform 0.15s ease-out;
}

.score-value.pop {
    transform: scale(1.25);
    color: var(--primary-pink);
}

/* Combo display */
.combo-badge {
    position: absolute;
    bottom: -35px;
    background: linear-gradient(135deg, #a855f7 0%, #701a75 100%);
    border: 1px solid rgba(192, 132, 252, 0.4);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    border-radius: 20px;
    padding: 4px 15px;
    font-family: var(--font-cute);
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    animation: comboPulse 1.5s infinite alternate;
}

.combo-badge.hidden {
    display: none;
}

@keyframes comboPulse {
    from {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
    }
    to {
        transform: scale(1.08) rotate(1deg);
        box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
    }
}

/* Level Indicator */
.level-label {
    font-family: var(--font-cute);
    font-size: 1.1rem;
    color: var(--accent-purple);
    font-weight: 700;
}

.level-label span {
    color: var(--white);
    margin-left: 5px;
}

/* Damage Flash overlay */
#damageFlash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    background-color: rgba(255, 0, 50, 0.25);
    border: 8px solid rgba(255, 0, 50, 0.6);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

#damageFlash.flash {
    opacity: 1;
    animation: flashFade 0.4s ease-out forwards;
}

@keyframes flashFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Game Over Card specific elements */
.game-over-title {
    font-family: var(--font-cute);
    font-size: 2.8rem;
    color: #ff527b;
    margin-bottom: 8px;
}

.game-over-msg {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 25px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-val {
    font-family: var(--font-cute);
    font-size: 1.8rem;
    color: var(--white);
    font-weight: 700;
}

.new-highscore-alert {
    background: linear-gradient(45deg, #ffd700, #ff85a2);
    border-radius: 12px;
    padding: 10px;
    font-family: var(--font-cute);
    font-weight: 700;
    color: #0f0717;
    margin-bottom: 30px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
    animation: goldGlow 1.2s ease-in-out infinite alternate;
}

@keyframes goldGlow {
    from {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
        transform: scale(1);
    }
    to {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 0 0 8px rgba(255, 133, 162, 0.6);
        transform: scale(1.03);
    }
}
