/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DynaPuff:wght@400..700&display=swap');

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'DynaPuff', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

html {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'DynaPuff', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #acb8e5 100%);
    height: 100%;
    width: 100%;
    position: relative;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Screen Container */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen.hidden {
    display: none !important;
}

/* Explicitly ensure only one screen shows at a time */
#quiz-screen {
    z-index: 1;
}

#results-screen {
    z-index: 2;
    background: white;
}

/* Loading Screen */
#loading-screen {
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 18px;
    color: #666;
}

/* Error Screen */
#error-screen {
    align-items: center;
    justify-content: center;
}

.error-content {
    text-align: center;
    padding: 30px;
}

.error-content h1 {
    font-size: 48px;
    margin-bottom: 20px;
}

#error-message {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.error-instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    text-align: left;
}

.error-instructions h3 {
    margin-bottom: 15px;
    color: #333;
}

.error-instructions p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.error-instructions code {
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

/* Quiz Screen */
#quiz-screen {
    display: flex;
}

/* Header */
.quiz-header {
    background: white;
    padding: 12px 20px 8px;
    border-bottom: 1px solid #e0e0e0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.quiz-title {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
}

.quiz-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

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

.stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
}

.timer-bar-container {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 100%;
    transition: width 0.1s linear;
}

.timer-bar.warning {
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

/* Question Container */
.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.image-container {
    width: 100%;
    background: #313b45;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: hidden;
    border-top: 3px solid #363636;
    border-bottom: 3px solid #363636;
}

.question-image {
    width: auto;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    box-shadow: 0 0 10px 12px rgba(0, 0, 0, 0.3);
}

.question-text-container {
    padding: 12px 20px;
    background: white;
    flex-shrink: 0;
}

.question-text {
    font-size: 16px;
    line-height: 1.4;
    color: #333;
    text-align: center;
    font-weight: 600;
}

/* Answers Container */
.answers-container {
    padding: 15px 20px 20px;
    background: #5f6987;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex-shrink: 0;
}

/* 3 answers - single column layout */
.answers-container.answers-3 {
    grid-template-columns: 1fr;
}

.answer-button {
    width: 100%;
    min-height: 60px;
    padding: 12px 16px;
    border: 2px solid #c9c9c9;
    border-radius: 12px;
    background: #f6f9f9;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.3;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-button:active {
    transform: scale(0.98);
}

.answer-button:disabled {
    cursor: not-allowed;
}

.answer-button.correct {
    background: #4caf50 !important;
    border-color: #4caf50;
    color: white;
    animation: correctPulse 0.4s ease;
}

.answer-button.incorrect {
    background: #f44336 !important;
    border-color: #f44336;
    color: white;
    animation: incorrectShake 0.4s ease;
}

.answer-button.disabled {
    opacity: 0.5;
}

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

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

/* Feedback Message */
.feedback-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 32px;
    border-radius: 24px;
    font-size: 20px;
    font-weight: 600;
    z-index: 1000;
    animation: fadeInScale 0.3s ease;
    white-space: nowrap;
}

.feedback-message.hidden {
    display: none;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Results Screen */
#results-screen {
    align-items: center;
    justify-content: center;
}

.results-content {
    text-align: center;
    padding: 30px;
    width: 100%;
}

.results-content h1 {
    font-size: 42px;
    margin-bottom: 30px;
    color: #333;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.result-stat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 16px;
    min-width: 140px;
    color: white;
}

.result-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-label {
    font-size: 14px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-message {
    font-size: 20px;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
}

.restart-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 56px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.restart-button:active {
    transform: scale(0.98);
}

.restart-button:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Tablet and larger screens */
@media (min-width: 768px) {
    .screen {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        height: auto;
        max-height: 100vh;
        border-radius: 0px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .quiz-title {
        font-size: 26px;
    }

    .question-text {
        font-size: 18px;
    }

    .answer-button {
        font-size: 16px;
        min-height: 64px;
    }

    .answer-button:hover {
        border-color: #667eea;
        background: #f8f9fa;
    }
    
    .answers-container {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .answers-container.answers-3 {
        grid-template-columns: 1fr;
    }
}

