/* ============================================
   STELLAR LOVE — Cosmic Heart Catcher
   Design System & Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-deep: #0a0015;
    --bg-mid: #120025;
    --nebula-pink: #ff2d7b;
    --nebula-purple: #a855f7;
    --nebula-blue: #3b82f6;
    --nebula-cyan: #06d6a0;
    --heart-pink: #ff6b9d;
    --heart-gold: #fbbf24;
    --heart-crystal: #67e8f9;
    --heart-rainbow: linear-gradient(135deg, #ff6b9d, #fbbf24, #06d6a0, #3b82f6, #a855f7);
    --heart-broken: #6b7280;
    --glow-primary: rgba(255, 45, 123, 0.6);
    --glow-gold: rgba(251, 191, 36, 0.6);
    --glow-cyan: rgba(103, 232, 249, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-accent: #ff6b9d;
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --transition-fast: 0.15s ease;
    --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    font-family: var(--font-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: none;
}

/* --- Canvas Layers --- */
#bgCanvas, #gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#bgCanvas {
    z-index: 0;
}

#gameCanvas {
    z-index: 1;
}

/* --- UI Overlay --- */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#ui-overlay .btn,
#ui-overlay .screen {
    pointer-events: auto;
}

/* --- Glass Panels --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px var(--glass-shadow),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.glass-panel-lg {
    background: rgba(10, 0, 30, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 107, 157, 0.15);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5),
                0 0 60px rgba(255, 45, 123, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* --- HUD --- */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 20;
}

#hud-left, #hud-right {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.hud-item {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 80px;
}

.hud-label {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.hud-value {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 0 20px var(--glow-primary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.hud-value.pop {
    transform: scale(1.3);
    color: var(--heart-gold);
}

/* Combo Bar */
.combo-bar-bg {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 4px;
    overflow: hidden;
}

.combo-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--nebula-pink), var(--nebula-purple));
    width: 0%;
    transition: width var(--transition-fast);
    box-shadow: 0 0 10px var(--glow-primary);
}

/* Lives Hearts */
#lives-hearts {
    display: flex;
    gap: 4px;
    font-size: 18px;
}

.life-heart {
    transition: transform var(--transition-med), opacity var(--transition-med);
    filter: drop-shadow(0 0 4px rgba(255, 107, 157, 0.6));
}

.life-heart.lost {
    transform: scale(0) rotate(180deg);
    opacity: 0;
}

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.screen.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

/* --- Menu Screen --- */
.menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    animation: fadeInUp 0.8s var(--transition-slow) both;
}

.logo-container {
    position: relative;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 45, 123, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: breathe 4s ease-in-out infinite;
    pointer-events: none;
}

.game-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 10vw, 80px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -2px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-star {
    font-size: 0.5em;
    color: var(--heart-gold);
    animation: twinkle 2s ease-in-out infinite;
    text-shadow: 0 0 20px var(--glow-gold);
}

.title-star:last-child {
    animation-delay: 1s;
}

.title-text {
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-love {
    background: linear-gradient(135deg, var(--nebula-pink), var(--nebula-purple), var(--heart-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(255, 45, 123, 0.4));
}

.game-subtitle {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-top: 12px;
}

/* --- Buttons --- */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 280px;
}

.btn {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    border: none;
    border-radius: var(--radius-lg);
    padding: 16px 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-med);
    position: relative;
    overflow: hidden;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--nebula-pink), var(--nebula-purple));
    color: white;
    box-shadow: 0 8px 30px rgba(255, 45, 123, 0.3),
                0 0 0 1px rgba(255, 107, 157, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 40px rgba(255, 45, 123, 0.5),
                0 0 0 1px rgba(255, 107, 157, 0.4),
                0 0 60px rgba(255, 45, 123, 0.2);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    font-size: 18px;
}

.pulse-glow {
    animation: pulseGlow 2.5s ease-in-out infinite;
}

/* --- Menu Footer --- */
.menu-footer {
    opacity: 0.5;
}

.footer-text {
    font-size: 13px;
    letter-spacing: 1px;
}

/* --- How to Play Screen --- */
.how-content {
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: fadeInUp 0.5s ease both;
}

.how-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 28px;
    background: linear-gradient(135deg, var(--nebula-pink), var(--heart-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.how-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.how-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-med);
}

.how-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 107, 157, 0.2);
    transform: translateY(-2px);
}

.how-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.how-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.how-text strong {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
}

.how-text span {
    font-size: 11px;
    color: var(--text-secondary);
}

.how-controls {
    margin-bottom: 24px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 107, 157, 0.05);
    border: 1px solid rgba(255, 107, 157, 0.1);
    font-size: 14px;
    color: var(--text-secondary);
}

/* --- Game Over Screen --- */
.gameover-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: fadeInUp 0.6s ease both;
}

.gameover-anim {
    animation: heartBreak 0.8s ease both;
}

.broken-heart-icon {
    font-size: 64px;
    filter: drop-shadow(0 0 20px rgba(255, 45, 123, 0.4));
}

.gameover-title {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--nebula-pink), var(--nebula-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gameover-stats {
    padding: 24px 32px;
    width: 300px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 15px var(--glow-primary);
}

/* --- Grade Display --- */
.gameover-grade {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.grade-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--text-secondary);
}

.grade-letter {
    font-family: var(--font-display);
    font-size: 64px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--heart-gold), var(--nebula-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(251, 191, 36, 0.4));
    animation: gradeReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* --- Level Up Notification --- */
#level-up {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    pointer-events: none;
}

.level-up-content {
    text-align: center;
    animation: levelUpAnim 2s ease both;
}

.level-up-text {
    display: block;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 8px;
    color: var(--text-secondary);
}

.level-up-number {
    display: block;
    font-family: var(--font-display);
    font-size: 80px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--heart-gold), var(--nebula-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 40px rgba(251, 191, 36, 0.5));
}

/* --- Power-up Notification --- */
#powerup-notify {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    pointer-events: none;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--heart-crystal);
    text-shadow: 0 0 20px var(--glow-cyan);
    animation: powerupAnim 1.5s ease both;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
    50% { opacity: 0.4; transform: scale(0.8) rotate(180deg); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 8px 30px rgba(255, 45, 123, 0.3), 0 0 0 1px rgba(255, 107, 157, 0.2); }
    50% { box-shadow: 0 8px 40px rgba(255, 45, 123, 0.5), 0 0 60px rgba(255, 45, 123, 0.15), 0 0 0 1px rgba(255, 107, 157, 0.4); }
}

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

@keyframes heartBreak {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes gradeReveal {
    from { transform: scale(0) rotate(-30deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes levelUpAnim {
    0% { opacity: 0; transform: scale(0.5); }
    20% { opacity: 1; transform: scale(1.1); }
    40% { transform: scale(1); }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.5) translateY(-30px); }
}

@keyframes powerupAnim {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-5px) rotate(-0.5deg); }
    20% { transform: translateX(5px) rotate(0.5deg); }
    30% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    50% { transform: translateX(-2px); }
    60% { transform: translateX(2px); }
    70% { transform: translateX(-1px); }
}

.screen-shake {
    animation: screenShake 0.4s ease;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .game-title {
        font-size: clamp(36px, 12vw, 56px);
        gap: 8px;
    }

    .game-subtitle {
        font-size: 13px;
        letter-spacing: 4px;
    }

    .how-grid {
        grid-template-columns: 1fr;
    }

    .how-content {
        padding: 24px;
    }

    #hud {
        padding: 10px 12px;
    }

    .hud-item {
        padding: 8px 10px;
        min-width: 60px;
    }

    .hud-value {
        font-size: 18px;
    }

    .hud-label {
        font-size: 8px;
    }

    .menu-buttons {
        width: 240px;
    }

    .btn {
        padding: 14px 24px;
        font-size: 14px;
    }

    .gameover-stats {
        width: 260px;
        padding: 20px;
    }

    .grade-letter {
        font-size: 48px;
    }

    .gameover-title {
        font-size: 32px;
    }
}

@media (max-width: 380px) {
    .hud-item {
        padding: 6px 8px;
        min-width: 50px;
    }

    .hud-value {
        font-size: 16px;
    }

    #hud-left, #hud-right {
        gap: 6px;
    }
}
