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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.quiz-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: clamp(20px, 3vh, 40px);
    max-width: 800px;
    width: 100%;
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease;
    z-index: 1;
}

.fullscreen-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #667eea;
}

.fullscreen-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.6);
    transform: scale(1.05);
    color: #764ba2;
}

.fullscreen-btn:active {
    transform: scale(0.95);
}

.fullscreen-btn svg {
    width: 20px;
    height: 20px;
}

.language-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.lang-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.6);
    transform: scale(1.05);
}

.lang-btn.active {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.flag-icon {
    width: 28px;
    height: 28px;
    display: block;
    object-fit: contain;
}

.unicorn {
    position: fixed;
    top: 0;
    left: 0;
    font-size: clamp(4em, 10vw, 6em);
    z-index: 0;
    pointer-events: none;
    opacity: 0.25;
    display: block;
    will-change: transform;
    filter: blur(0.5px);
    user-select: none;
    transform-origin: center center;
}

.unicorn.visible {
    display: block;
}

@keyframes unicornSpawn {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.4) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes unicornMoveToBackground {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    }
    50% {
        transform: translate(calc(var(--target-x) - 50%), calc(var(--target-y) - 50%)) scale(0.8) rotate(180deg);
        opacity: 0.6;
    }
    100% {
        transform: translate(calc(var(--target-x) - 0.5em), calc(var(--target-y) - 0.5em)) scale(0.7) rotate(360deg);
        opacity: 0.25;
        filter: blur(0.5px);
    }
}

@keyframes unicornConfettiBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y)) scale(0);
        opacity: 0;
    }
}

@keyframes unicornMove {
    0% {
        transform: translate(calc(var(--start-x) - 50%), calc(var(--start-y) - 50%)) rotate(0deg);
    }
    25% {
        transform: translate(calc(var(--mid1-x) - 50%), calc(var(--mid1-y) - 50%)) rotate(90deg);
    }
    50% {
        transform: translate(calc(var(--end-x) - 50%), calc(var(--end-y) - 50%)) rotate(180deg);
    }
    75% {
        transform: translate(calc(var(--mid2-x) - 50%), calc(var(--mid2-y) - 50%)) rotate(270deg);
    }
    100% {
        transform: translate(calc(var(--start-x) - 50%), calc(var(--start-y) - 50%)) rotate(360deg);
    }
}

.quiz-container.quiz-started {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: clamp(15px, 2vh, 30px);
}

.quiz-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: sparkle 20s linear infinite;
    pointer-events: none;
}

@keyframes sparkle {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(50px, 50px) rotate(360deg); }
}

.header {
    text-align: center;
    margin-bottom: clamp(15px, 2vh, 25px);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.title {
    font-size: clamp(1.8em, 5vw, 2.5em);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s ease infinite;
    margin-bottom: clamp(10px, 1.5vh, 15px);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

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

.progress-container {
    margin-top: clamp(10px, 1.5vh, 15px);
}

.progress-bar {
    width: 100%;
    height: clamp(20px, 3vh, 25px);
    background: linear-gradient(90deg, #e0e0e0, #f5f5f5);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 200% 100%;
    border-radius: 15px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: progressShimmer 2s ease infinite;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

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

.progress-text {
    margin-top: clamp(5px, 1vh, 8px);
    font-size: clamp(1em, 2.5vw, 1.2em);
    font-weight: bold;
    color: #555;
}

.loading {
    text-align: center;
    font-size: 1.5em;
    color: #667eea;
    padding: 40px;
}

.quiz-content {
    min-height: 200px;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-container {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    min-height: 300px;
    position: relative;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-inner.flipped {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

.module-selection-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.module-selection-title {
    font-size: clamp(1.8em, 5vw, 2.5em);
    color: #667eea;
    margin-bottom: 40px;
    font-weight: bold;
}

.module-buttons-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.module-btn {
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 200%;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 40px 60px;
    font-size: clamp(1.2em, 4vw, 1.8em);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-width: 200px;
    animation: gradientShift 3s ease infinite;
}

.module-btn:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
    background-position: 100% 50%;
}

.module-btn:active {
    transform: translateY(-4px) scale(0.98);
}

.module-number {
    font-size: clamp(2.5em, 8vw, 4em);
    font-weight: bold;
    line-height: 1;
}

.module-label {
    font-size: clamp(1em, 3vw, 1.3em);
    font-weight: 600;
}

.nickname-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: slideIn 0.5s ease-out;
    position: relative;
}

.nickname-title {
    font-size: clamp(1.8em, 5vw, 2.5em);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s ease infinite;
    margin-bottom: 30px;
    font-weight: bold;
}

.nickname-input {
    padding: 15px 25px;
    font-size: clamp(1.1em, 3vw, 1.5em);
    border: 3px solid #667eea;
    border-radius: 25px;
    width: 100%;
    max-width: 400px;
    margin-bottom: 25px;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.nickname-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    transform: scale(1.02);
}

.nickname-submit-btn {
    padding: 15px 50px;
    font-size: clamp(1.2em, 3vw, 1.5em);
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 200%;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
    animation: startButtonGlow 2s ease infinite;
}

.nickname-submit-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.7);
}

.nickname-submit-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.start-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-container {
    margin-bottom: 30px;
}

.loading-bar-container {
    width: 100%;
    max-width: 400px;
    height: 25px;
    background: linear-gradient(90deg, #e0e0e0, #f5f5f5);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0 auto 20px;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 200% 100%;
    border-radius: 15px;
    animation: progressShimmer 1s ease infinite;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
    transition: width 0.1s linear;
}

.loading-text {
    font-size: 1.3em;
    color: #667eea;
    font-weight: bold;
    margin-top: 15px;
}

.start-btn {
    padding: 20px 50px;
    font-size: 1.5em;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 200%;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
    animation: startButtonGlow 2s ease infinite, fadeInScale 0.5s ease;
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

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

.start-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.7);
    animation: startButtonGlow 1s ease infinite, fadeInScale 0.5s ease;
}

.start-btn:hover::before {
    width: 400px;
    height: 400px;
}

.start-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.error {
    text-align: center;
    font-size: 1.3em;
    color: #ff6b6b;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(238, 90, 111, 0.1));
    border-radius: 15px;
    border: 2px solid rgba(255, 107, 107, 0.3);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.question-container {
    animation: slideIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

/* When a question includes an image, allow the main area to scroll instead of clipping. */
.question-container-scrollable {
    overflow-y: auto;
}

.question-container-scrollable .options-container {
    /* Let the options container grow to its content height, so scrolling works correctly. */
    flex: 0 0 auto;
    overflow: visible;
}

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

.question-image-container {
    margin-bottom: clamp(10px, 2vh, 20px);
    text-align: center;
    flex-shrink: 0;
}

.question-image {
    max-width: 100%;
    max-height: 40vh;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    object-fit: contain;
}

.question-text {
    font-size: clamp(0.7em, calc(4vw - 0.5em), 1.5em);
    color: #333;
    margin-bottom: clamp(10px, 2vh, 20px);
    text-align: center;
    font-weight: bold;
    line-height: 1.3;
    padding: clamp(10px, 2vh, 20px);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

.options-container {
    display: grid;
    gap: clamp(8px, 1.5vh, 15px);
    margin-bottom: clamp(10px, 2vh, 20px);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.option-btn {
    padding: clamp(10px, 2vh, 15px) clamp(15px, 3vw, 20px);
    font-size: clamp(0.65em, calc(2.5vw - 0.25em), 1.05em);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    text-align: center;
    min-height: clamp(50px, 8vh, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
}

.option-btn.option-btn-overflow {
    /* Only used when we detect that the button's content would otherwise be clipped. */
    min-height: clamp(80px, 12vh, 120px);
    align-items: flex-start;
    padding-top: clamp(14px, 2.5vh, 22px);
    padding-bottom: clamp(14px, 2.5vh, 22px);
    font-size: calc(clamp(0.65em, calc(2.5vw - 0.25em), 1.05em) - 2pt);
}

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

.option-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

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

.option-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.option-btn.selected {
    background: linear-gradient(135deg, #f9ca24, #f0932b);
    box-shadow: 0 4px 20px rgba(249, 202, 36, 0.6);
    transform: scale(1.05);
}

.option-btn.selected:hover {
    transform: scale(1.08) translateY(-3px);
}

.option-btn.correct {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    animation: correctPulse 0.6s ease;
    box-shadow: 0 0 30px rgba(78, 205, 196, 0.8);
}

.option-btn.incorrect {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    animation: shake 0.5s ease;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.submit-btn {
    display: block;
    margin: clamp(10px, 2vh, 20px) auto 0;
    padding: clamp(12px, 2vh, 15px) clamp(30px, 5vw, 40px);
    font-size: clamp(1em, 2.5vw, 1.2em);
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.submit-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.6);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.submit-btn {
    display: block;
    margin: clamp(10px, 2vh, 20px) auto 0;
    padding: clamp(12px, 2vh, 15px) clamp(30px, 5vw, 40px);
    font-size: clamp(1em, 2.5vw, 1.2em);
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.submit-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.6);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.next-btn {
    display: block;
    margin: clamp(10px, 2vh, 20px) auto 0;
    padding: clamp(12px, 2vh, 15px) clamp(30px, 5vw, 40px);
    font-size: clamp(1em, 2.5vw, 1.2em);
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.next-btn.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    animation: bounceIn 0.5s ease;
}

.next-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(20px);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15vh;
    z-index: 1000;
    pointer-events: none;
}

.celebration.show {
    display: flex;
}

.celebration-text {
    font-size: 5em;
    font-weight: bold;
    color: #4ecdc4;
    text-shadow: 0 0 20px rgba(78, 205, 196, 0.8);
    animation: celebrationPop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1003;
    position: relative;
}

@keyframes celebrationPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    animation: confettiFall 3s linear infinite;
}

.confetti:nth-child(1) {
    left: 10%;
    background: #ff6b6b;
    animation-delay: 0s;
}

.confetti:nth-child(2) {
    left: 20%;
    background: #4ecdc4;
    animation-delay: 0.3s;
}

.confetti:nth-child(3) {
    left: 30%;
    background: #45b7d1;
    animation-delay: 0.6s;
}

.confetti:nth-child(4) {
    left: 40%;
    background: #f9ca24;
    animation-delay: 0.9s;
}

.confetti:nth-child(5) {
    left: 50%;
    background: #f0932b;
    animation-delay: 1.2s;
}

.confetti:nth-child(6) {
    left: 60%;
    background: #eb4d4b;
    animation-delay: 1.5s;
}

.confetti:nth-child(7) {
    left: 70%;
    background: #6c5ce7;
    animation-delay: 1.8s;
}

.confetti:nth-child(8) {
    left: 80%;
    background: #a29bfe;
    animation-delay: 2.1s;
}

.confetti:nth-child(9) {
    left: 90%;
    background: #fd79a8;
    animation-delay: 2.4s;
}

.confetti:nth-child(10) {
    left: 95%;
    background: #00b894;
    animation-delay: 2.7s;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes rainFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.3;
    }
    100% {
        transform: translateY(calc(100vh + 50px)) rotate(360deg);
        opacity: 0;
    }
}

.results {
    text-align: center;
    animation: slideIn 0.5s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 60px; /* Space for the credits link */
}

.results h2 {
    font-size: 2.25em;
    color: #333;
    margin-bottom: 30px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s ease infinite;
}

.score-display {
    font-size: 1.25em;
    font-weight: bold;
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 20px;
    color: #333;
}

.score-emoji {
    font-size: 1.25em;
    margin-bottom: 10px;
}

.score-text {
    font-size: 1.25em;
    margin-bottom: 10px;
}

.score-percentage {
    font-size: 1.25em;
    margin-bottom: 10px;
}

.download-btn {
    padding: 15px 40px;
    font-size: 1.05em;
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
    transition: all 0.3s ease;
    margin-top: 20px;
}

.download-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.6);
}

.download-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.firebase-message {
    margin-top: 20px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    font-size: clamp(0.2em, calc(1vw - 0.25em), 0.3em);
    color: #555;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.restart-btn {
    padding: 15px 40px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    margin-top: 20px;
}

.restart-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* Battle Animation Styles */
.battle-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #1a1a2e, #16213e, #0f3460);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sunrise-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sun {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, #ffd700, #ff8c00);
    border-radius: 50%;
    position: absolute;
    bottom: -100px;
    animation: sunrise 3s ease-out forwards;
    box-shadow: 0 0 100px rgba(255, 215, 0, 0.8);
}

@keyframes sunrise {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0.3;
    }
    100% {
        transform: translateY(-60vh) scale(1);
        opacity: 1;
    }
}

.sunrise-text {
    position: absolute;
    top: 20%;
    font-size: clamp(2em, 5vw, 3em);
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: fadeIn 2s ease-in;
    z-index: 10;
}

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

.battle-field {
    position: absolute;
    bottom: 20%;
    width: 100%;
    height: 40%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 10%;
}

.unicorn-army, .frog-army {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.battle-unicorn, .battle-frog {
    font-size: clamp(3em, 6vw, 5em);
    animation: spawnIn 0.5s ease-out forwards;
    opacity: 0;
    transform: scale(0);
    position: relative;
    will-change: transform;
}

@keyframes spawnIn {
    0% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(360deg);
    }
}

.battle-charge {
    animation: charge 2s ease-in forwards;
}

@keyframes charge {
    0% {
        transform: translateX(0) translateY(0);
    }
    100% {
        transform: translateX(calc(var(--direction, 1) * 35vw)) translateY(0) scale(1.1);
    }
}

.battle-unicorn.battle-charge {
    --direction: 1;
}

.battle-frog.battle-charge {
    --direction: -1;
}

.battle-move-to-center {
    animation: moveToCenter 1.5s ease-in forwards;
    position: relative;
    animation-fill-mode: backwards;
}

@keyframes moveToCenter {
    from {
        transform: translateX(var(--start-x, calc(var(--direction, 1) * 35vw))) translateY(0) scale(1.1);
        opacity: 1;
    }
    to {
        transform: translateX(0) translateY(0) scale(1);
        opacity: 1;
    }
}

.battle-unicorn.battle-move-to-center {
    --direction: 1;
}

.battle-frog.battle-move-to-center {
    --direction: -1;
}

.battle-chaos {
    position: fixed;
    /* left and top will be set inline - don't override */
    transform: translate(-50%, -50%);
    animation: chaos 0.8s ease-in-out infinite;
    z-index: 50;
    opacity: 1;
}

@keyframes chaos {
    0% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 40px), calc(var(--chaos-y, 0) * 40px)) rotate(0deg) scale(1);
    }
    12.5% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 60px), calc(var(--chaos-y, 0) * 0px)) rotate(45deg) scale(1.2);
    }
    25% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 40px), calc(var(--chaos-y, 0) * -40px)) rotate(90deg) scale(1.1);
    }
    37.5% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 0px), calc(var(--chaos-y, 0) * -60px)) rotate(135deg) scale(1.3);
    }
    50% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * -40px), calc(var(--chaos-y, 0) * -40px)) rotate(180deg) scale(0.9);
    }
    62.5% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * -60px), calc(var(--chaos-y, 0) * 0px)) rotate(225deg) scale(1.2);
    }
    75% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * -40px), calc(var(--chaos-y, 0) * 40px)) rotate(270deg) scale(1.1);
    }
    87.5% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 0px), calc(var(--chaos-y, 0) * 60px)) rotate(315deg) scale(1.3);
    }
    100% {
        transform: translate(-50%, -50%) translate(calc(var(--chaos-x, 0) * 40px), calc(var(--chaos-y, 0) * 40px)) rotate(360deg) scale(1);
    }
}

.battle-dead {
    animation: die 0.8s ease-out forwards;
}

.battle-fade-out {
    animation: fadeOut 3s ease-out forwards, chaos 0.8s ease-in-out infinite;
    opacity: 1;
}

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

@keyframes die {
    0% {
        transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) translate(calc(var(--death-x, 0) * 50px), calc(var(--death-y, 1) * 100px)) rotate(360deg) scale(0.7);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) translate(calc(var(--death-x, 0) * 150px), calc(var(--death-y, 1) * 400px)) rotate(1080deg) scale(0.2);
        opacity: 0;
    }
}

.victory-winner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20000;
    text-align: center;
    opacity: 0;
    animation: winnerFadeIn 3s ease-in forwards;
}

@keyframes winnerFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.winner-emoji {
    font-size: clamp(8em, 15vw, 12em);
    animation: victorySpin 1s ease-out;
}

@keyframes victorySpin {
    0% {
        transform: scale(0) rotate(0deg);
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

.winner-text {
    font-size: clamp(2em, 5vw, 3em);
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    margin-top: 20px;
    animation: fadeIn 1s ease-in 0.5s both;
}

.skip-battle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    font-size: 1.1em;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 5px;
}

.skip-battle-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.next-to-results-btn {
    position: absolute;
    bottom: 10%;
    padding: 15px 40px;
    font-size: 1.5em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    animation: fadeIn 1s ease-in forwards;
    z-index: 300;
}

.next-to-results-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.feedback-container {
    animation: slideIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.feedback-title {
    font-size: clamp(1.5em, 4vw, 2.5em);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s ease infinite;
    margin-bottom: clamp(15px, 3vh, 25px);
    text-align: center;
    font-weight: bold;
    flex-shrink: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.feedback-content-wrapper {
    display: flex;
    gap: clamp(15px, 3vw, 30px);
    flex: 1;
    min-height: 0;
    margin-bottom: clamp(15px, 3vh, 25px);
}

.feedback-image-container {
    flex: 0 0 45%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.feedback-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.feedback-unicorn-fallback {
    font-size: clamp(6em, 15vw, 10em);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.feedback-text-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.feedback-explanation {
    font-size: clamp(1em, 2.5vw, 1.3em);
    color: #555;
    margin-bottom: clamp(15px, 3vh, 25px);
    text-align: left;
    line-height: 1.6;
    padding: clamp(15px, 3vh, 25px);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 15px;
    flex: 1;
    overflow-y: auto;
}

.feedback-source {
    font-size: clamp(0.65em, calc(2vw - 0.25em), 0.85em);
    color: #888;
    text-align: left;
    font-style: italic;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .quiz-container {
        padding: 20px;
    }
    
    .title {
        font-size: clamp(1.5em, 6vw, 2.5em);
    }
    
    .question-text {
        font-size: clamp(0.7em, calc(5vw - 0.5em), 1.3em);
        padding: 15px;
    }
    
    .option-btn {
        font-size: clamp(0.65em, calc(4vw - 0.25em), 0.95em);
        padding: 12px 15px;
        min-height: 50px;
    }
    
    .celebration-text {
        font-size: clamp(2em, 8vw, 3em);
    }
    
    .start-btn {
        font-size: clamp(1.2em, 5vw, 1.5em);
        padding: 15px 40px;
    }
    
    .loading-text {
        font-size: clamp(1em, 4vw, 1.3em);
    }
}

/* Card flip container */
.card-container {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    min-height: 300px;
    position: relative;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-inner.flipped {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

/* Credits link styling */
.credits-link {
    position: absolute;
    bottom: 15px;
    right: 15px;
    color: #667eea;
    text-decoration: none;
    font-size: 0.85em;
    transition: color 0.3s ease;
    cursor: pointer;
    z-index: 10;
    pointer-events: auto;
}

.credits-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.credits-link-results {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: #667eea;
    text-decoration: none;
    font-size: 0.65em;
    transition: color 0.3s ease;
    cursor: pointer;
}

.credits-link-results:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Credits screen styling */
.credits-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 300px;
}

.credits-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.credits-title {
    font-size: clamp(1.8em, 5vw, 2.5em);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow 3s ease infinite;
    margin-bottom: 30px;
    font-weight: bold;
}

.credits-top {
    font-size: clamp(1em, 2.5vw, 1.2em);
    color: #555;
    margin-bottom: 20px;
    line-height: 1.6;
    font-weight: 500;
}

.credits-text {
    font-size: clamp(1.1em, 3vw, 1.4em);
    color: #333;
    margin-bottom: 30px;
    line-height: 1.6;
}

.credits-list {
    font-size: clamp(1em, 2.5vw, 1.2em);
    color: #555;
    line-height: 2;
}

.credits-list p {
    margin: 10px 0;
}

.credits-bottom {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    font-size: clamp(0.85em, 2vw, 1em);
    color: #666;
    line-height: 1.6;
}

.credits-bottom-text {
    margin-bottom: 8px;
}

.credits-license-link {
    color: #667eea;
    text-decoration: none;
    word-break: break-all;
}

.credits-license-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.back-link {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: #667eea;
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.3s ease;
    cursor: pointer;
}

.back-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Credits overlay for results page */
.credits-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.credits-overlay-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 600px;
    width: 90%;
    position: relative;
    animation: slideIn 0.3s ease;
}

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

