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

/* Global no-scroll rules */
html, body {
    overflow: hidden !important;
    height: 100vh !important;
    max-height: 100vh !important;
    position: fixed !important;
    width: 100% !important;
    -webkit-overflow-scrolling: auto !important;
}

/* Ensure viewport stability on mobile */
@supports (-webkit-touch-callout: none) {
    html {
        height: -webkit-fill-available;
        overflow: hidden;
    }
    
    body {
        height: -webkit-fill-available;
        overflow: hidden;
    }
    
    .container {
        height: calc(-webkit-fill-available - 40px);
        max-height: calc(-webkit-fill-available - 40px);
    }
}

/* Prevent any scroll bounce or overscroll */
html {
    overscroll-behavior: none;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    overscroll-behavior: none;
}

* {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

html {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #333;
    overflow: hidden;
    margin: 0;
    box-sizing: border-box;
    touch-action: pan-y;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    width: 100%;
    max-width: 500px;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.progress-bar {
    height: 6px;
    background: #e0e0e0;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 25%;
    transition: width 0.6s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.quiz-container {
    position: relative;
    flex: 1;
    overflow: hidden;
    padding-bottom: 0;
    box-sizing: border-box;
}

.question-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 40px 30px 30px 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-sizing: border-box;
}

.question-card.active {
    opacity: 1;
    transform: translateX(0);
}

.question-card.slide-out {
    opacity: 0;
    transform: translateX(-100%);
}

.question-title {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 20px;
    color: #2c3e50;
    text-align: center;
}

.question-number {
    font-size: 14px;
    color: #7f8c8d;
    text-align: center;
    margin-bottom: 30px;
    font-weight: 500;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    flex: 1;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.option-btn {
    padding: 18px 20px;
    border: 2px solid #e0e6ed;
    border-radius: 12px;
    background: white;
    color: #34495e;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
}

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

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

.option-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.option-btn.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

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

.next-btn {
    padding: 18px 30px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: auto;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 15;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-height: 56px;
    touch-action: manipulation;
    user-select: none;
}

.next-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;
}

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

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.next-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    visibility: visible !important;
    opacity: 1 !important;
}

.next-btn:disabled::before {
    display: none;
}

.loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.6s ease;
}

.loading-screen.active {
    opacity: 1;
    visibility: visible;
}

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

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

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

.loading-content h2 {
    font-size: 20px;
    color: #2c3e50;
    line-height: 1.4;
    font-weight: 600;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        max-width: 100%;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        border-radius: 15px;
    }
    
    .question-card {
        padding: 20px 20px 80px 20px;
        height: 100%;
        overflow: hidden;
    }
    
    .question-title {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .question-number {
        margin-bottom: 15px;
        font-size: 14px;
    }
    
    .options {
        gap: 12px;
        margin-bottom: 20px;
        flex: 1;
        overflow-y: auto;
    }
    
    .option-btn {
        padding: 16px 18px;
        font-size: 15px;
    }
    
    .next-btn {
        padding: 16px 25px;
        font-size: 15px;
        position: absolute;
        bottom: 20px;
        left: 20px;
        right: 20px;
        margin: 0;
        background: linear-gradient(135deg, #667eea, #764ba2);
        z-index: 15;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        min-height: 50px;
    }
    
    .loading-content {
        padding: 30px 20px;
    }
    
    .loading-content h2 {
        font-size: 18px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    body {
        padding: 5px;
    }
    
    .container {
        height: calc(100vh - 10px);
        max-height: calc(100vh - 10px);
        border-radius: 10px;
    }
    
    .question-card {
        padding: 15px 15px 70px 15px;
        height: 100%;
        overflow: hidden;
    }
    
    .question-title {
        font-size: 18px;
        margin-bottom: 10px;
        line-height: 1.2;
    }
    
    .question-number {
        margin-bottom: 12px;
        font-size: 13px;
    }
    
    .options {
        gap: 10px;
        margin-bottom: 15px;
        flex: 1;
        overflow-y: auto;
    }
    
    .option-btn {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .next-btn {
        padding: 14px 20px;
        font-size: 14px;
        position: absolute;
        bottom: 15px;
        left: 15px;
        right: 15px;
        margin: 0;
        background: linear-gradient(135deg, #667eea, #764ba2);
        z-index: 999;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        min-height: 48px;
        border-radius: 12px;
        border: none;
        color: white;
        font-weight: 600;
    }
    
    .next-btn:disabled {
        background: #bdc3c7;
    }
}

/* Extra small phones */
@media (max-width: 320px) {
    body {
        padding: 5px;
    }
    
    .container {
        height: calc(100vh - 10px);
        max-height: calc(100vh - 10px);
    }
    
    .question-card {
        padding: 12px 10px 60px 10px;
        overflow: hidden;
    }
    
    .question-title {
        font-size: 16px;
        margin-bottom: 8px;
        line-height: 1.1;
    }
    
    .question-number {
        margin-bottom: 10px;
        font-size: 12px;
    }
    
    .options {
        gap: 8px;
        margin-bottom: 12px;
        flex: 1;
        overflow-y: auto;
    }
    
    .option-btn {
        padding: 12px 14px;
        font-size: 13px;
    }
    
    .next-btn {
        padding: 12px 18px;
        font-size: 13px;
        min-height: 44px;
        bottom: 10px;
        left: 10px;
        right: 10px;
        position: absolute;
        z-index: 999;
        background: linear-gradient(135deg, #667eea, #764ba2);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-radius: 12px;
        border: none;
        color: white;
        font-weight: 600;
        margin: 0;
    }
    
    .next-btn:disabled {
        background: #bdc3c7;
    }
}

/* Short screens optimization */
@media (max-height: 550px) and (max-width: 480px) {
    .question-card {
        padding: 15px 20px 70px 20px;
    }
    
    .question-title {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .question-number {
        margin-bottom: 12px;
        font-size: 13px;
    }
    
    .options {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .option-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .next-btn {
        bottom: 15px;
        min-height: 44px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Final optimizations */
@media (max-width: 480px) {
    .next-btn {
        touch-action: manipulation;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    /* Ensure loading screen is above button when active */
    .loading-screen.active {
        z-index: 10000;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        max-width: 600px;
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
    }
    
    .question-card {
        height: 100%;
        padding: 35px 25px 80px 25px;
        overflow: hidden;
    }
    
    .next-btn {
        position: absolute;
        bottom: 25px;
        left: 25px;
        right: 25px;
        margin: 0;
        min-height: 54px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    html, body {
        overflow: hidden;
        touch-action: manipulation;
        -webkit-overflow-scrolling: touch;
    }
    
    .option-btn:hover {
        transform: none;
        box-shadow: none;
        border-color: #e0e6ed;
        color: #34495e;
    }
    
    .option-btn:hover::before {
        left: -100%;
    }
    
    .next-btn:hover {
        transform: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .next-btn:hover::before {
        left: -100%;
    }
}

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

/* Focus states for keyboard navigation */
.option-btn:focus,
.next-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .option-btn {
        border-width: 3px;
    }
    
    .option-btn.selected {
        border-color: #000;
        background: #000;
    }
} 