/* --- Design System & CSS Variables --- */
:root {
    --bg-main: #0b0f19;
    --bg-gradient: linear-gradient(135deg, #090d16 0%, #111827 50%, #1e1b4b 100%);
    --neon-blue: #0ea5e9;
    --neon-blue-glow: rgba(14, 165, 233, 0.5);
    --neon-purple: #8b5cf6;
    --neon-purple-glow: rgba(139, 92, 246, 0.5);
    --neon-pink: #ec4899;
    --neon-pink-glow: rgba(236, 72, 153, 0.5);
    --neon-green: #10b981;
    --neon-green-glow: rgba(16, 185, 129, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(16px);
    --glass-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
    
    --font-primary: 'Outfit', 'Noto Sans KR', sans-serif;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Resets & Global Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-main);
    background-image: var(--bg-gradient);
    font-family: var(--font-primary);
    color: var(--text-primary);
}

/* --- Container Layout --- */
#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Canvas Container */
#canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
}

canvas {
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 12px;
    background: transparent;
}

/* --- Screen Overlay System --- */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 10;
}

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

/* --- Glassmorphism UI Card --- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
    pointer-events: none;
}

/* --- Home / Main Menu Screen --- */
.game-title {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 0 20px var(--neon-blue-glow);
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-align: center;
}

.game-title .highlight {
    background: linear-gradient(to right, var(--neon-blue), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px var(--neon-purple-glow));
}

.game-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    text-align: center;
}

/* Menu Hero Character container */
.menu-hero-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-hero-glow {
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    filter: blur(20px);
    opacity: 0.6;
    animation: pulseGlow 3s infinite alternate;
}

#menu-hero-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
    transform: rotate(-5deg);
    animation: floatCharacter 4s ease-in-out infinite;
}

/* --- Level Select Screen --- */
.section-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 1rem;
}

.level-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    aspect-ratio: 1;
    justify-content: space-between;
    position: relative;
}

.level-card:not(.locked):hover {
    transform: translateY(-8px);
    border-color: var(--neon-blue);
    box-shadow: 0 8px 20px var(--neon-blue-glow);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.2);
}

.level-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.level-stars {
    display: flex;
    gap: 4px;
    font-size: 0.8rem;
    color: #eab308; /* Star yellow */
}

.level-status {
    font-size: 1rem;
    color: var(--text-muted);
}

.level-card:not(.locked) .level-status {
    color: var(--neon-green);
}

/* --- HUD Interface --- */
#game-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}

.hud-left, .hud-right, .score-container {
    pointer-events: auto;
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.hud-left {
    gap: 15px;
}

.hud-right {
    gap: 10px;
}

.level-indicator {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 1px;
    color: var(--neon-blue);
}

.score-container {
    gap: 20px;
    padding: 6px 20px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-item .label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.score-item .value {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

#score-txt {
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

#best-score-txt {
    color: var(--neon-purple);
}

/* HUD Buttons */
.hud-btn, .btn-circle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

.hud-btn:hover, .btn-circle:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
    border-color: var(--neon-blue);
    color: var(--neon-blue);
}

.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
}

/* Bottom Bird Dock */
#bird-dock {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 8px 14px;
    border-radius: 20px;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.hud-bird-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* HUD Skill Tip */
.hud-tip {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14, 165, 233, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3);
    z-index: 100;
    pointer-events: none;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.hud-tip.hide {
    opacity: 0;
    transform: translate(-50%, -10px);
}

/* --- Buttons Styles --- */
.btn {
    font-family: var(--font-primary);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.85rem 2rem;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
    width: 100%;
}

.primary-btn {
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    color: #fff;
    box-shadow: 0 4px 15px var(--neon-blue-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--neon-blue-glow);
    background: linear-gradient(135deg, #0284c7, #7c3aed);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.alarm-btn {
    background: linear-gradient(135deg, var(--neon-pink), #be185d);
    color: #fff;
    box-shadow: 0 4px 15px var(--neon-pink-glow);
}

.alarm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--neon-pink-glow);
    background: linear-gradient(135deg, #db2777, #9d174d);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
}

/* --- Modals Overlay --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 12, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 200;
}

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

.modal-content {
    max-width: 420px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
    margin-top: 1.5rem;
}

.text-center {
    text-align: center;
}

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 1.5rem;
}

/* --- How To Modal Details --- */
.how-to-steps {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: left;
    margin-top: 1.5rem;
    width: 100%;
}

.step {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.step-icon {
    background: rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(14, 165, 233, 0.25);
    color: var(--neon-blue);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.step-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.step-text strong {
    color: #fff;
}

.step-text ul {
    margin-top: 5px;
    padding-left: 18px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.step-text li strong {
    color: var(--text-secondary);
}

/* --- Clear / Fail Popup Effects --- */
.clear-title-effect {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(to right, #34d399, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.4));
    margin-bottom: 1.5rem;
    animation: titleBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.fail-title-effect {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(to right, var(--neon-pink), #ef4444);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px var(--neon-pink-glow));
    margin-bottom: 0.5rem;
    animation: titleBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.fail-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.star-wrapper {
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.1);
    transform: scale(0.5);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s ease, opacity 0.5s ease;
}

.star-wrapper.active {
    color: #fbbf24;
    transform: scale(1.1);
    opacity: 1;
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.6));
}

.star-wrapper.star-1 { transition-delay: 0.2s; }
.star-wrapper.star-2 { transition-delay: 0.4s; }
.star-wrapper.star-3 { transition-delay: 0.6s; }

.score-display {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 12px 30px;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    width: 100%;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.score-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 1px;
}

/* --- Animations --- */
.pulse {
    animation: pulseButton 2s infinite;
}

.animate-zoom {
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pulseButton {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 8px 25px var(--neon-blue-glow); }
    100% { transform: scale(1); }
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); opacity: 0.5; }
    100% { transform: scale(1.05); opacity: 0.8; }
}

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

@keyframes zoomIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes titleBounce {
    0% { transform: translateY(-30px); opacity: 0; }
    60% { transform: translateY(10px); }
    100% { transform: translateY(0); opacity: 1; }
}

/* --- Mobile Responsive & Touch Styles --- */
body, html {
    touch-action: none;
    -webkit-overflow-scrolling: auto;
}

canvas {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
    touch-action: none;
}

/* Orientation Warning Overlay */
#orientation-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0b0f19;
    color: #fff;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    text-align: center;
    padding: 20px;
}

.warning-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.rotate-icon {
    font-size: 4.5rem;
    color: var(--neon-blue);
    animation: rotateDevice 2.5s ease-in-out infinite;
    text-shadow: 0 0 20px var(--neon-blue-glow);
}

#orientation-warning h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 10px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#orientation-warning p {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 280px;
    line-height: 1.4;
}

/* Trigger Orientation Screen when in Portrait on Mobile Devices */
@media screen and (orientation: portrait) and (max-device-width: 1024px) {
    #orientation-warning {
        display: flex;
    }
}

/* Extra Mobile HUD Scaling */
@media screen and (max-width: 768px) {
    #game-hud {
        top: 10px;
        left: 10px;
        right: 10px;
        height: 50px;
    }
    
    .hud-left, .hud-right, .score-container {
        padding: 4px 10px;
        border-radius: 20px;
    }
    
    .score-container {
        padding: 4px 12px;
        gap: 10px;
    }
    
    .level-indicator {
        font-size: 0.9rem;
    }
    
    .score-item .value {
        font-size: 0.9rem;
    }
    
    .hud-btn {
        width: 32px;
        height: 32px;
    }
    
    #bird-dock {
        bottom: 10px;
        left: 10px;
        padding: 6px 10px;
    }
    
    .hud-bird-icon {
        width: 26px;
        height: 26px;
    }
}

@keyframes rotateDevice {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(-90deg); }
    70% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

