/* ============================================
   COSMIC TYPER - Space Typing Adventure
   Main Stylesheet
   ============================================ */

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

:root {
    /* Space Theme Colors */
    --space-dark: #0a0a1a;
    --space-blue: #1a1a3e;
    --nebula-purple: #4a1a6b;
    --nebula-pink: #8b1a6b;
    --star-yellow: #ffd700;
    --star-white: #ffffff;
    --laser-green: #00ff88;
    --laser-cyan: #00ffff;
    --danger-red: #ff4444;
    --success-green: #44ff88;
    --energy-blue: #4488ff;
    
    /* UI Colors */
    --panel-bg: rgba(10, 10, 30, 0.9);
    --panel-border: rgba(100, 150, 255, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #88aaff;
    --text-accent: #ffd700;
    
    /* Fonts */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Exo 2', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--space-dark);
    font-family: var(--font-body);
    color: var(--text-primary);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
}

#ui-overlay.game-active {
    pointer-events: none;
}

#ui-overlay.game-active > * {
    pointer-events: auto;
}

/* ============================================
   WELCOME SCREEN
   ============================================ */

.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(30, 30, 80, 0.8) 0%, rgba(10, 10, 30, 0.95) 100%);
    animation: fadeIn 1s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-logo {
    margin-bottom: 20px;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-logo h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 5rem);
    font-weight: 900;
    text-align: center;
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 25%, #ff6b6b 50%, #c44dff 75%, #00d4ff 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.game-logo .subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.8rem, 2.5vw, 1.5rem);
    color: var(--text-secondary);
    text-align: center;
    letter-spacing: 4px;
    margin-top: 10px;
}

.rocket-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rocketBounce 2s ease-in-out infinite;
}

@keyframes rocketBounce {
    0%, 100% { transform: translateY(0) rotate(-45deg); }
    50% { transform: translateY(-15px) rotate(-45deg); }
}

/* ============================================
   NAME INPUT SCREEN
   ============================================ */

.name-input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(100, 150, 255, 0.2),
                inset 0 0 30px rgba(100, 150, 255, 0.05);
    animation: panelSlideUp 0.5s ease-out;
}

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

.name-input-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-accent);
    text-align: center;
}

.name-input-container p {
    color: var(--text-secondary);
    text-align: center;
    max-width: 300px;
}

.cosmic-input {
    width: 280px;
    padding: 15px 20px;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--panel-border);
    border-radius: 10px;
    outline: none;
    text-align: center;
    transition: all 0.3s ease;
}

.cosmic-input:focus {
    border-color: var(--laser-cyan);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.cosmic-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   BUTTONS
   ============================================ */

.cosmic-btn {
    padding: 15px 40px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--nebula-purple), var(--nebula-pink));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 2px;
}

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

.cosmic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(139, 26, 107, 0.6);
}

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

.cosmic-btn:active {
    transform: scale(0.98);
}

.cosmic-btn.primary {
    background: linear-gradient(135deg, #00aaff, #00ffaa);
}

.cosmic-btn.primary:hover {
    box-shadow: 0 0 30px rgba(0, 255, 170, 0.6);
}

.cosmic-btn.secondary {
    background: rgba(100, 150, 255, 0.2);
    border: 2px solid var(--panel-border);
}

.cosmic-btn.secondary:hover {
    background: rgba(100, 150, 255, 0.4);
}

.cosmic-btn.danger {
    background: linear-gradient(135deg, #ff4444, #ff8844);
}

.cosmic-btn.small {
    padding: 10px 25px;
    font-size: 0.9rem;
}

/* ============================================
   MAIN MENU
   ============================================ */

.main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(30, 30, 80, 0.8) 0%, rgba(10, 10, 30, 0.95) 100%);
}

.player-welcome {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeIn 0.5s ease-out;
}

.player-welcome h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.player-welcome .player-name {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-accent);
    margin-top: 5px;
}

.player-stats {
    display: flex;
    gap: 30px;
    margin-top: 15px;
}

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

.stat-item .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.stat-item .stat-value {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-accent);
}

.stat-item .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 280px;
}

/* ============================================
   LEVEL SELECT
   ============================================ */

.level-select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(30, 30, 80, 0.8) 0%, rgba(10, 10, 30, 0.95) 100%);
    padding: 20px;
}

.level-select h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-accent);
    margin-bottom: 30px;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 900px;
    width: 100%;
    padding: 0 20px;
}

.level-card {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(100, 150, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.level-card:hover {
    transform: translateY(-5px);
    border-color: var(--laser-cyan);
    box-shadow: 0 10px 40px rgba(0, 255, 255, 0.2);
}

.level-card:hover::before {
    opacity: 1;
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-card.locked:hover {
    transform: none;
    border-color: var(--panel-border);
    box-shadow: none;
}

.level-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.level-card h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.level-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.level-difficulty {
    display: flex;
    gap: 5px;
    margin-top: 15px;
}

.difficulty-star {
    color: var(--star-yellow);
    font-size: 1rem;
}

.difficulty-star.empty {
    opacity: 0.3;
}

.level-progress {
    margin-top: 15px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--laser-green), var(--laser-cyan));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.back-btn {
    margin-top: 30px;
}

/* ============================================
   GAME HUD
   ============================================ */

.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: rgba(10, 10, 30, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 25px;
    font-family: var(--font-display);
}

.hud-item .icon {
    font-size: 1.2rem;
}

.hud-item .value {
    font-size: 1.1rem;
    color: var(--text-accent);
    min-width: 50px;
}

.hud-item .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.combo-display {
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    text-align: right;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.combo-display.active {
    opacity: 1;
}

.combo-count {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-accent);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: comboPulse 0.3s ease;
}

@keyframes comboPulse {
    0% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.combo-label {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 3px;
}

.combo-multiplier {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--laser-cyan);
    margin-top: 5px;
}

/* ============================================
   PAUSE MENU
   ============================================ */

.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.pause-overlay h2 {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--text-accent);
    margin-bottom: 40px;
    animation: pausePulse 2s ease-in-out infinite;
}

@keyframes pausePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pause-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 250px;
}

/* ============================================
   GAME OVER / LEVEL COMPLETE
   ============================================ */

.result-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.result-screen h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.result-screen h2.victory {
    color: var(--success-green);
    text-shadow: 0 0 30px rgba(68, 255, 136, 0.5);
}

.result-screen h2.defeat {
    color: var(--danger-red);
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.result-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
    padding: 30px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
}

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

.result-stat .value {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-accent);
}

.result-stat .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.stars-earned {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.star-large {
    font-size: 3rem;
    color: var(--star-yellow);
    opacity: 0.2;
    transition: all 0.5s ease;
}

.star-large.earned {
    opacity: 1;
    animation: starEarn 0.5s ease;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

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

.result-buttons {
    display: flex;
    gap: 15px;
}

/* ============================================
   ACHIEVEMENTS POPUP
   ============================================ */

.achievement-popup {
    position: fixed;
    top: 20px;
    right: -400px;
    width: 350px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(74, 26, 107, 0.95), rgba(139, 26, 107, 0.95));
    border: 2px solid var(--star-yellow);
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: right 0.5s ease;
    z-index: 100;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.achievement-popup.show {
    right: 20px;
}

.achievement-icon {
    font-size: 2.5rem;
}

.achievement-info h4 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--star-yellow);
    margin-bottom: 5px;
}

.achievement-info h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.achievement-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   SKILL ASSESSMENT
   ============================================ */

.skill-assessment {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(30, 30, 80, 0.8) 0%, rgba(10, 10, 30, 0.95) 100%);
}

.assessment-container {
    text-align: center;
    max-width: 500px;
    padding: 40px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
}

.assessment-container h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--text-accent);
    margin-bottom: 15px;
}

.assessment-container p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
}

.assessment-letters {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--text-primary);
    letter-spacing: 10px;
    margin: 30px 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.assessment-letter {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 150, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.assessment-letter.typed {
    background: var(--success-green);
    border-color: var(--success-green);
    color: var(--space-dark);
    transform: scale(0.9);
}

.assessment-letter.current {
    border-color: var(--laser-cyan);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    animation: currentPulse 1s ease-in-out infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 255, 255, 0.5); }
    50% { box-shadow: 0 0 30px rgba(0, 255, 255, 0.8); }
}

.assessment-progress {
    margin-top: 30px;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--laser-green), var(--laser-cyan));
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* ============================================
   KEYBOARD HINT
   ============================================ */

.keyboard-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    background: rgba(10, 10, 30, 0.9);
    border: 2px solid var(--panel-border);
    border-radius: 15px;
    text-align: center;
}

.hint-letter {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--text-accent);
    margin-bottom: 5px;
}

.hint-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--space-dark);
}

.loading-spinner {
    width: 80px;
    height: 80px;
    border: 4px solid rgba(100, 150, 255, 0.2);
    border-top-color: var(--laser-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-family: var(--font-display);
    color: var(--text-secondary);
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(30, 30, 80, 0.8) 0%, rgba(10, 10, 30, 0.95) 100%);
}

.settings-panel {
    width: 90%;
    max-width: 400px;
    padding: 30px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
}

.settings-panel h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--text-accent);
    text-align: center;
    margin-bottom: 30px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 1rem;
    color: var(--text-primary);
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: var(--laser-green);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active::after {
    transform: translateX(24px);
}

/* Slider */
.setting-slider {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--laser-cyan);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.settings-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 30px;
}

/* ============================================
   FLOATING PARTICLES (CSS)
   ============================================ */

.floating-particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: float linear infinite;
}

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

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

@media (max-width: 768px) {
    .game-logo h1 {
        font-size: 2.5rem;
    }
    
    .name-input-container {
        padding: 30px 20px;
        margin: 0 20px;
    }
    
    .cosmic-input {
        width: 240px;
    }
    
    .levels-grid {
        grid-template-columns: 1fr;
    }
    
    .level-card {
        padding: 20px;
    }
    
    .hud-item {
        padding: 5px 10px;
        font-size: 0.9rem;
    }
    
    .combo-display {
        right: 15px;
    }
    
    .combo-count {
        font-size: 2rem;
    }
    
    .result-stats {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .result-buttons {
        flex-direction: column;
    }
    
    .assessment-letter {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
}

/* ============================================
   SPECIAL EFFECTS
   ============================================ */

.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.flash-success {
    animation: flashSuccess 0.3s ease;
}

@keyframes flashSuccess {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(68, 255, 136, 0.2); }
}

.flash-danger {
    animation: flashDanger 0.3s ease;
}

@keyframes flashDanger {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 68, 68, 0.2); }
}

/* ============================================
   LEVEL SPECIFIC STYLES
   ============================================ */

/* Asteroid Defense specific */
.earth-health-bar {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    text-align: center;
}

.health-label {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.health-bar-container {
    height: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--panel-border);
}

.health-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger-red), var(--success-green));
    border-radius: 8px;
    transition: width 0.3s ease;
}

/* ============================================
   LEVEL INTRO ANIMATION
   ============================================ */

.level-intro {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 30, 0.95);
    z-index: 50;
}

.level-intro h1 {
    font-family: var(--font-display);
    font-size: 4rem;
    color: var(--text-accent);
    animation: levelIntroTitle 1s ease-out;
}

@keyframes levelIntroTitle {
    0% { transform: scale(3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.level-intro h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-primary);
    margin-top: 10px;
    animation: levelIntroSubtitle 1s ease-out 0.3s both;
}

@keyframes levelIntroSubtitle {
    0% { transform: translateY(30px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.level-intro .mission-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-top: 15px;
    max-width: 500px;
    text-align: center;
    line-height: 1.6;
    padding: 0 20px;
    animation: levelIntroSubtitle 1s ease-out 0.6s both;
}

.level-intro-header {
    text-align: center;
}

.level-intro-header h1 {
    margin-bottom: 0;
}

.level-intro-header h2 {
    margin-top: 10px;
}

.countdown-container {
    margin-top: 20px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ready-text {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--text-secondary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ============================================
   LEVEL TIPS (Extended Instructions)
   ============================================ */

.level-tips {
    margin-top: 25px;
    padding: 20px 30px;
    background: rgba(100, 150, 255, 0.1);
    border: 2px solid var(--panel-border);
    border-radius: 15px;
    max-width: 500px;
    animation: levelIntroSubtitle 1s ease-out 0.9s both;
    transition: opacity 0.5s ease;
}

.level-tips h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-accent);
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 2px;
}

.level-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.level-tips li {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-primary);
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    line-height: 1.4;
}

.level-tips li::before {
    content: '⭐';
    position: absolute;
    left: 0;
    font-size: 0.8rem;
}

.level-tips li:nth-child(2)::before { content: '🎯'; }
.level-tips li:nth-child(3)::before { content: '⚠️'; }
.level-tips li:nth-child(4)::before { content: '💡'; }

/* ============================================
   COUNTDOWN
   ============================================ */

.countdown {
    font-family: var(--font-display);
    font-size: 6rem;
    color: var(--text-accent);
    text-shadow: 0 0 50px rgba(255, 215, 0, 0.5);
    animation: countdownPulse 1s ease-in-out;
}

@keyframes countdownPulse {
    0% { transform: scale(1.5); opacity: 0; }
    30% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.countdown-go {
    font-size: 5rem;
    color: var(--success-green);
    text-shadow: 0 0 50px rgba(68, 255, 136, 0.5);
}

/* ============================================
   MOBILE WARNING
   ============================================ */

.mobile-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.mobile-warning-modal {
    background: linear-gradient(135deg, var(--space-blue), var(--nebula-purple));
    border: 2px solid var(--panel-border);
    border-radius: 20px;
    padding: 30px;
    max-width: 450px;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.mobile-warning-modal .warning-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: pulse 2s ease-in-out infinite;
}

.mobile-warning-modal h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-accent);
    margin-bottom: 15px;
}

.mobile-warning-modal p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.mobile-warning-modal ul {
    list-style: none;
    text-align: left;
    margin: 20px 0;
    padding: 0;
}

.mobile-warning-modal li {
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-warning-modal li:last-child {
    border-bottom: none;
}

.warning-buttons {
    margin-top: 25px;
}

.warning-buttons .cosmic-btn {
    min-width: 180px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   RESULT SCREEN
   ============================================ */

.result-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.98), rgba(30, 10, 50, 0.98));
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.5s ease-out;
}

.result-screen h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.result-screen h2.victory {
    color: var(--star-yellow);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.result-screen h2.defeat {
    color: var(--danger-red);
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.result-subtitle {
    font-family: var(--font-body);
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.stars-earned {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 30px;
    min-height: 80px;
}

.star-large {
    font-size: 3.5rem;
    transition: all 0.3s ease;
}

.star-large.empty {
    opacity: 0.2;
    filter: grayscale(100%);
}

.star-large.earned.pending {
    opacity: 0;
    transform: scale(0);
}

.star-large.earned.revealed {
    opacity: 1;
    animation: starReveal 0.5s ease-out forwards;
}

@keyframes starReveal {
    0% { 
        opacity: 0; 
        transform: scale(0) rotate(-180deg);
    }
    50% { 
        opacity: 1; 
        transform: scale(1.5) rotate(10deg);
    }
    70% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% { 
        opacity: 1; 
        transform: scale(1) rotate(0deg);
    }
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    max-width: 500px;
    width: 100%;
}

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

.result-stat .value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--laser-cyan);
    margin-bottom: 5px;
}

.result-stat .label {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.result-buttons .cosmic-btn {
    min-width: 140px;
}
