* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

:root {
    scroll-behavior: smooth;
    --primary-color: #006672;
    --primary-hover: #005963;
    --success-color: #34d34e;
    --error-color: #ca4949;
    --border-color: #e2e8f0;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
}

body {
    background: linear-gradient(160deg, #afdee4 0%, #42deea 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
}

/* Start Screen */
#startScreen {
    background: white;
    border-radius: 20px;
    padding: clamp(20px, 5vw, 40px);
    text-align: center;
    max-width: 500px;
    width: 95%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.5s ease-out;
}

#gameLogo {
    height: clamp(220px, 3vw, 300px);
    width: auto;
    margin-bottom: 20px;
}

.game-title {
    color: #006672;
    font-size: clamp(1.8em, 4vw, 2.5em);
    margin-bottom: 15px;
    font-weight: 700;
}

.game-subtitle {
    color: #383f49;
    margin-bottom: 25px;
    font-size: clamp(1em, 2vw, 1.1em);
    opacity: 0;
    animation: fadeIn 0.5s ease-out 0.3s forwards;
}

/* Quiz Container */
#quizWrap {
    background: white;
    border-radius: 20px;
    width: 95%;
    max-width: 800px;
    margin: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 98vh;
    animation: slideUp 0.5s ease-out;
}

.quiz-header {
    padding: 20px;
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
}

.quiz-logo {
    height: clamp(60px, 10vw, 80px);
    width: auto;
}

.quiz-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    margin-bottom: 20px;
    width: 100%;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.question-counter {
    background: #f8f9fa;
    color: #4a5568;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    border: 1px solid #e2e8f0;
}

.question-counter strong {
    color: #006672;
    font-weight: 800;
}

.score-display {
    background: #006672;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sound Toggle */
.sound-toggle {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle:hover {
    background: #e5e7eb;
    color: #087f8d;
}

/* Question Section */
.question-section {
    text-align: center;
    padding: 20px 0;
}

#quizQn {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

/* Answer Grid */
.answer-grid {
    display: grid;
    gap: 15px;
    width: 100%;
}

.answer-option {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    border: 2px solid rgba(226, 232, 240, 0.8) !important;
    color: #4a5568 !important;
    border-radius: 16px;
    padding: 16px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 54px;
    width: 100%;
    position: relative;
    text-align: center;
    animation: scaleIn 0.3s ease-out backwards;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.answer-option:nth-child(1) {
    animation-delay: 0.1s;
}
.answer-option:nth-child(2) {
    animation-delay: 0.2s;
}
.answer-option:nth-child(3) {
    animation-delay: 0.3s;
}
.answer-option:nth-child(4) {
    animation-delay: 0.4s;
}

.answer-option::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.4) 40%,
        rgba(255, 255, 255, 0.4) 60%,
        transparent 70%
    );
    transform: rotate(45deg);
    transition: all 0.3s ease;
    opacity: 0;
}

.answer-option:hover {
    border-color: rgba(8, 127, 141, 0.4) !important;
    background: linear-gradient(135deg, #ffffff 0%, #e8f7f8 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 7px rgba(0, 0, 0, 0.05);
}

/* Selected state styles */
.answer-option.correct {
    background: linear-gradient(135deg, #34d34e 0%, #28a745 100%) !important;
    color: white !important;
    border-color: #28a745 !important;
    box-shadow: 0 4px 7px rgba(40, 167, 69, 0.1);
}

.answer-option.wrong {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
    color: white !important;
    border-color: #c82333 !important;
    box-shadow: 0 4px 7px rgba(220, 53, 69, 0.1);
}

/* Results Section */
.results-container {
    padding: 40px;
    text-align: center;
    animation: scaleIn 0.5s ease-out;
}

.results-header {
    color: #2d3748;
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.score-highlight {
    font-size: 1.4rem;
    color: #4a4a4a;
    background: #f0f0f0;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    font-weight: 600;
}

.results-summary {
    font-size: 1.1rem;
    color: #4a5568;
    margin-bottom: 30px;
}

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

/* Try Again Button */
.try-again-btn {
    background: #f3f4f6 !important;
    color: #087f8d !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.try-again-btn:hover {
    background: #e5e7eb !important;
    color: #087f8d !important;
    transform: translateY(-2px);
}

/* Popup Styles */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.popup-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

.popup-title {
    color: #2d3748;
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #4a5568;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #4a4a4a;
}

.error-message {
    color: #ca4949;
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

/* Thank You Popup */
.thank-you-content {
    text-align: center;
}

.success-icon {
    color: #34d399;
    font-size: 3rem;
    margin-bottom: 20px;
}

.thank-you-message {
    color: #4a5568;
    font-size: 1.1rem;
    margin: 20px 0;
    line-height: 1.5;
}

/* Buttons */
.btn {
    background: #006672;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    background: #005963;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.close-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    padding: 5px;
}

.close-popup:hover {
    color: #4a5568;
}

/* Terms & Conditions */
.terms-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 102, 114, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 9999; /* Increased z-index to ensure it's above everything */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    user-select: none; /* Prevent text selection */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.terms-link:hover {
    background: rgba(0, 102, 114, 1);
    transform: translateY(-2px);
}

.terms-popup {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.terms-content {
    font-size: 0.8rem;
    color: #4a5568;
    line-height: 1.4;
    text-align: left;
}

.terms-content ol {
    padding-left: 20px;
    margin: 0;
}

.terms-content li {
    margin-bottom: 10px;
}

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

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

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

@keyframes highlightBorder {
    0% {
        border-color: var(--border-color);
    }
    50% {
        border-color: var(--primary-color);
    }
    100% {
        border-color: var(--border-color);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .quiz-content {
        padding: 15px;
    }

    .status-bar {
        padding: 0 8px;
    }

    .status-right {
        gap: 8px;
    }

    .question-counter,
    .score-display {
        padding: 6px 12px;
        font-size: 0.9rem;
    }

    .answer-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .results-container {
        padding: 20px;
    }

    .popup-content {
        padding: 20px;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .quiz-title {
        font-size: 1.3rem;
    }

    .terms-content {
        font-size: 0.75rem;
    }

    .terms-popup {
        max-height: 80vh;
    }

    #quizQn {
        font-size: 1rem;
        padding: 12px 15px;
    }

    .answer-option {
        min-height: 44px;
        font-size: 0.85rem;
        padding: 12px;
    }

    .results-header {
        font-size: 1.3rem;
    }

    .score-highlight {
        font-size: 1.1rem;
        padding: 15px;
    }

    .popup-title {
        font-size: 1.3rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
}

/* Quiz Complete State */
.quiz-complete .status-bar,
.quiz-complete .question-section {
    display: none !important;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
