/* FONT */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600;700&family=Poppins:wght@300;400;600;700&display=swap');

/* RESET & BASE STYLES */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #f7df1e;       /* JavaScript Yellow */
    --secondary: #323330;     /* JavaScript Dark */
    --tertiary: #2f3542;
    --accent: #5352ed;
    --success: #2ed573;
    --error: #ff4757;
    --warning: #ffa502;
    --bg-light: transparent;  /* Changed to transparent to show space background */
    --text-light: #f1f2f6;
    --text-dark: #f1f2f6;     /* Changed to light color for better visibility on dark background */
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    --card-bg: rgba(255, 255, 255, 0.1);  /* Semi-transparent white */
    --card-border: rgba(255, 255, 255, 0.2);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-light);
    line-height: 1.6;
    color: var(--text-light);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

code, pre {
    font-family: 'Fira Code', monospace;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* HEADER */
header {
    background: rgba(50, 51, 48, 0.7);  /* Semi-transparent background */
    backdrop-filter: blur(10px);        /* Blur effect */
    color: var(--primary);
    padding: 2rem 0;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(247, 223, 30, 0.3);
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(247, 223, 30, 0.2) 0%, rgba(247, 223, 30, 0) 70%);
    animation: pulse 15s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 0.2; }
}

.header-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.header-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 0 10px rgba(247, 223, 30, 0.5);
}

.header-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* MAIN CONTENT */
main {
    flex: 1;
    padding: 2rem 0;
    position: relative;
}

/* SCREEN SYSTEM */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: fadeIn 0.5s ease forwards;
}

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

/* Glass Morphism effect for all cards */
.glass-card {
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* WELCOME SCREEN */
.welcome-content {
    text-align: center;
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
}

.title-animation {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
    color: var(--primary);
    text-shadow: 0 0 15px rgba(247, 223, 30, 0.5);
}

.title-animation::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background-color: var(--primary);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(247, 223, 30, 0.8);
}

.input-group {
    margin-bottom: 2rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-light);
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(247, 223, 30, 0.3);
    background: rgba(30, 30, 40, 0.7);
    color: var(--text-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(247, 223, 30, 0.5);
}

.input-group input::placeholder {
    color: rgba(241, 242, 246, 0.6);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn i {
    font-size: 1.1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--secondary);
    box-shadow: 0 0 15px rgba(247, 223, 30, 0.3);
}

.btn-primary:hover {
    background-color: #e6d31c;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(247, 223, 30, 0.5);
}

.btn-secondary {
    background-color: rgba(50, 51, 48, 0.8);
    color: var(--text-light);
    border: 1px solid rgba(247, 223, 30, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 30, 30, 0.5);
    border-color: var(--primary);
}

/* INSTRUCTION SCREEN */
.instruction-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
}

.instruction-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(247, 223, 30, 0.3);
}

.rules-card {
    background: rgba(40, 40, 50, 0.5);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.rules-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    color: var(--primary);
}

.rules-card ul {
    list-style-type: none;
}

.rules-card ul li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.5rem;
}

.rules-card ul li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

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

.difficulty-selection h3 {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-difficulty {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(30, 30, 40, 0.5);
    border: 2px solid transparent;
    transition: var(--transition);
}

.btn-difficulty:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-difficulty span {
    font-size: 1.2rem;
    font-weight: 600;
}

.btn-difficulty .difficulty-info {
    font-size: 0.9rem;
    opacity: 0.8;
}

.btn-difficulty[data-difficulty="junior"] {
    color: #2ed573;
    border-color: rgba(46, 213, 115, 0.5);
}

.btn-difficulty[data-difficulty="junior"]:hover {
    background-color: rgba(46, 213, 115, 0.2);
    box-shadow: 0 0 15px rgba(46, 213, 115, 0.5);
}

.btn-difficulty[data-difficulty="mid"] {
    color: #ffa502;
    border-color: rgba(255, 165, 2, 0.5);
}

.btn-difficulty[data-difficulty="mid"]:hover {
    background-color: rgba(255, 165, 2, 0.2);
    box-shadow: 0 0 15px rgba(255, 165, 2, 0.5);
}

.btn-difficulty[data-difficulty="senior"] {
    color: #ff4757;
    border-color: rgba(255, 71, 87, 0.5);
}

.btn-difficulty[data-difficulty="senior"]:hover {
    background-color: rgba(255, 71, 87, 0.2);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.5);
}

/* QUIZ SCREEN */
#quiz-screen {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    position: relative;
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.quiz-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#question-counter {
    font-weight: 600;
    color: var(--text-light);
}

#difficulty-display {
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

#difficulty-display.junior {
    background-color: rgba(46, 213, 115, 0.2);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.5);
}

#difficulty-display.mid {
    background-color: rgba(255, 165, 2, 0.2);
    color: #ffa502;
    border: 1px solid rgba(255, 165, 2, 0.5);
}

#difficulty-display.senior {
    background-color: rgba(255, 71, 87, 0.2);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.5);
}

#timer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: var(--text-light);
}

#timer i {
    animation: timerPulse 1s infinite;
    color: var(--primary);
}

@keyframes timerPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.code-container {
    background-color: rgba(20, 20, 30, 0.9);
    color: #f1f2f6;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.code-container pre {
    margin: 0;
    white-space: pre-wrap;
    font-size: 1rem;
    line-height: 1.5;
}

.code-container code {
    color: #e6e6e6;
}

.question-prompt {
    margin-top: 1rem;
    font-weight: 600;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(247, 223, 30, 0.3);
}

.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.option-btn {
    padding: 1rem;
    text-align: left;
    background: rgba(30, 30, 40, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
    font-family: 'Fira Code', monospace;
    word-break: break-word;
    color: var(--text-light);
}

.option-btn:hover {
    background: rgba(50, 50, 60, 0.7);
    transform: translateY(-2px);
    border-color: rgba(247, 223, 30, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.option-btn.selected {
    border-color: var(--accent);
    background: rgba(83, 82, 237, 0.2);
    box-shadow: 0 0 15px rgba(83, 82, 237, 0.3);
}

.option-btn.correct {
    border-color: var(--success);
    background: rgba(46, 213, 115, 0.2);
    box-shadow: 0 0 15px rgba(46, 213, 115, 0.3);
}

.option-btn.incorrect {
    border-color: var(--error);
    background: rgba(255, 71, 87, 0.2);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

.feedback {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
    display: none;
    animation: fadeIn 0.3s ease;
}

.feedback.correct {
    background: rgba(46, 213, 115, 0.1);
    color: var(--success);
    border-left: 4px solid var(--success);
    display: block;
}

.feedback.incorrect {
    background: rgba(255, 71, 87, 0.1);
    color: var(--error);
    border-left: 4px solid var(--error);
    display: block;
}

#next-btn {
    display: none;
    margin-left: auto;
}

/* RESULT SCREEN */
.result-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    background: rgba(30, 30, 40, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
}

.result-animation {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    animation: bounceIn 1s ease;
    text-shadow: 0 0 20px rgba(247, 223, 30, 0.5);
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.player-info {
    margin-bottom: 2rem;
}

.player-info h3 {
    display: inline-block;
    margin: 0 1rem;
    color: var(--text-light);
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.score-card {
    background: rgba(40, 40, 50, 0.5);
    padding: 1.5rem;
    border-radius: 10px;
    min-width: 150px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-color: rgba(247, 223, 30, 0.3);
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(247, 223, 30, 0.3);
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-light);
    opacity: 0.8;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* FOOTER */
footer {
    background: rgba(50, 51, 48, 0.7);
    backdrop-filter: blur(10px);
    color: var(--text-light);
    padding: 1.5rem 0;
    text-align: center;
    margin-top: 2rem;
    border-top: 1px solid rgba(247, 223, 30, 0.3);
}

footer p {
    font-size: 0.9rem;
    opacity: 0.8;
}

footer i.fa-heart {
    color: var(--error);
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* RESPONSIVE STYLES */
@media (max-width: 768px) {
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .header-content p {
        font-size: 1rem;
    }
    
    .welcome-content, 
    .instruction-content, 
    #quiz-screen, 
    .result-content {
        padding: 1.5rem;
    }
    
    .title-animation {
        font-size: 1.8rem;
    }
    
    .options-container {
        grid-template-columns: 1fr;
    }
    
    .quiz-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .score-container {
        flex-direction: column;
        align-items: center;
    }
    
    .score-card {
        width: 100%;
        max-width: 300px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* CODE HIGHLIGHTING */
.keyword { color: #ff79c6; }
.string { color: #f1fa8c; }
.number { color: #bd93f9; }
.function { color: #50fa7b; }
.comment { color: #6272a4; }
.operator { color: #ff79c6; }
.variable { color: #8be9fd; }
.property { color: #f8f8f2; }
.bracket { color: #f8f8f2; }

/* ANIMATIONS */
@keyframes codeTyping {
    from { width: 0; }
    to { width: 100%; }
}

.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--primary);
    animation: codeTyping 2s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary); }
}

/* Custom Space Animations */
@keyframes floating {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0px); }
}

.float-element {
    animation: floating 6s ease-in-out infinite;
}

.glow {
    text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary), 0 0 15px var(--primary);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% { text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary); }
    50% { text-shadow: 0 0 20px var(--primary), 0 0 30px var(--primary); }
    100% { text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary); }
}

/* Star twinkle animation */
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: white;
    border-radius: 50%;
    animation: twinkle 5s infinite;
}

@keyframes twinkle {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}