@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600&display=swap');

:root { 
    --primary: #D91E18; /* Peruvian Red */
    --primary-light: #ff4d4d;
    --success: #00c853; 
    --danger: #ff1744; 
    --pink: #ff4081;
    --pink-light: #ff79b0;
    --bg-dark: #0a0a0a;
    --card-bg: #121212;
    --border-color: #333;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
}
.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
    position: relative;
}
header {
    background: #fff;
    color: #000;
    padding: 16px 40px;
    border-bottom: 4px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 24px 24px 0 0; /* Match container top radius */
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}
header h1 { 
    font-family: 'Space Grotesk', sans-serif; 
    font-size: 20px; 
    font-weight: 800;
    margin: 0;
    color: #000;
    letter-spacing: -0.5px;
}
.badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}
.header-category {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    margin-left: 8px;
    display: inline-block;
}
.main-nav {
    display: flex;
    gap: 12px;
}
.nav-link {
    background: #f5f5f5;
    border: 1px solid #eee;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-link:hover {
    background: #eee;
    transform: translateY(-1px);
}
.nav-link span {
    display: inline-block;
}

@media (max-width: 600px) {
    body { padding: 0; }
    .container { border-radius: 0; min-height: 100vh; border: none; }
    header { padding: 12px 16px; }
    .header-content { gap: 8px; }
    header h1 { font-size: 16px; }
    .nav-link { padding: 6px 10px; font-size: 12px; }
    .nav-link span { display: none; }
    
    .screen { padding: 24px 16px; }
    .selection-controls { flex-direction: column; gap: 16px; padding: 20px; }
    .control-group select { min-width: 100%; }
    
    .quiz-controls-top { flex-direction: column; align-items: stretch; gap: 12px; }
    .jump-control select { width: 100%; }

    .question { font-size: 20px; }
    .option { padding: 16px 20px; font-size: 16px; }
    .option-letter { width: 32px; height: 32px; font-size: 14px; }
    
    .navigation-btns { flex-direction: row; gap: 12px; }
    .prev-btn, .next-btn { width: auto; padding: 18px 10px; font-size: 14px; }

    .score-circle { width: 180px; height: 180px; font-size: 48px; }
    .start-btn, .study-btn { width: 100%; padding: 18px 20px; font-size: 16px; }
}

.screen { padding: 40px 32px; display: none; }
.screen.active { display: block; }

.start-screen-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 32px;
    text-align: center;
    color: #fff;
    letter-spacing: -0.5px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
    text-align: left;
}
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.setting-info strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}
.setting-info p {
    font-size: 13px;
    color: #888;
    margin: 0;
}

/* Switch Component */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #333;
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 4px; bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:focus + .slider { box-shadow: 0 0 1px var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

.quiz-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.timer {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'Space Grotesk', monospace;
}
.timer.warning {
    color: var(--danger);
    animation: blink 1s infinite;
}
@keyframes blink {
    50% { opacity: 0.5; }
}

.quiz-mode-indicator {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 12px;
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    letter-spacing: 1px;
}
.exam-mode {
    background: rgba(217, 30, 24, 0.15);
    color: var(--primary-light);
}
.study-mode {
    background: rgba(0, 200, 83, 0.15);
    color: var(--success);
}
.flash-mode {
    background: rgba(255, 64, 129, 0.15);
    color: var(--pink-light);
}

.quiz-controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}
.quiz-controls-top .progress {
    flex: 1;
    margin-bottom: 0;
}
.jump-control {
    display: flex;
    align-items: center;
    gap: 10px;
}
.jump-control label {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
}
.jump-control select {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #444;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    min-width: 60px;
    text-align: center;
}

.selection-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    flex: 1;
}
.control-group label {
    font-size: 13px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.control-group select {
    background: #1a1a1a;
    color: #fff;
    border: 2px solid #333;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    min-width: 180px;
    width: 100%;
    transition: all 0.2s;
}
.control-group select:hover {
    border-color: #555;
}
.control-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(217, 30, 24, 0.2);
}

.info-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 20px;
    margin-bottom: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}
.info-card p {
    margin-bottom: 12px;
    font-size: 16px;
}
.parts-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
.part-info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 10px;
}
.part-info-item:last-child {
    border-bottom: none;
}
.part-info-item span {
    color: #aaa;
    padding-right: 10px;
    line-height: 1.4;
}
.part-info-item strong {
    white-space: nowrap;
    flex-shrink: 0;
}
.info-card .sub-info {
    color: #888;
    font-size: 13px;
    margin-bottom: 0;
    font-style: italic;
}

.part-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-left: 4px solid #444;
}

.question-image-container {
    margin-bottom: 24px;
    text-align: center;
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    display: none;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.question-image-container img {
    max-width: 100%;
    max-height: 350px;
    border-radius: 12px;
}

.start-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: 100%;
}

.start-btn, .study-btn, .flash-btn {
    padding: 20px 60px;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    max-width: 400px;
}

.start-btn {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 16px rgba(217, 30, 24, 0.3);
}
.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(217, 30, 24, 0.4);
    background: var(--primary-light);
}

.study-btn {
    background: var(--success);
    color: #000;
    box-shadow: 0 8px 16px rgba(0, 200, 83, 0.2);
    border: none;
}
.study-btn:hover {
    background: #00e676;
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(0, 200, 83, 0.3);
}

.flash-btn {
    background: var(--pink);
    color: #fff;
    box-shadow: 0 8px 16px rgba(255, 64, 129, 0.3);
    border: none;
}
.flash-btn:hover {
    background: var(--pink-light);
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(255, 64, 129, 0.4);
}

.question { 
    font-size: 24px; 
    line-height: 1.5; 
    margin-bottom: 32px; 
    font-weight: 600; 
    color: #fff;
}
.options { display: flex; flex-direction: column; gap: 14px; }
.option {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 18px;
    padding: 20px 28px;
    font-size: 17px;
    display: flex;
    align-items: flex-start; /* Change to flex-start for better alignment with wrapped text */
    gap: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.option:hover { 
    border-color: #666; 
    background: #222;
    transform: translateX(6px); 
}
.option.flashcard-no-hover:hover {
    transform: none;
    border-color: #333;
}
.option span:last-child {
    flex: 1;
    line-height: 1.5;
}
.option-letter {
    width: 36px; height: 36px; background: #333; color: #fff;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.option.correct { 
    border-color: var(--success); 
    background: rgba(0,200,83,0.1); 
}
.option.correct .option-letter {
    background: var(--success);
    color: #000;
}
.option.wrong { 
    border-color: var(--danger); 
    background: rgba(255,23,68,0.1); 
}
.option.wrong .option-letter {
    background: var(--danger);
}
.option.selected-exam {
    border-color: var(--primary);
    background: rgba(217, 30, 24, 0.05);
}
.option.selected-exam .option-letter {
    background: var(--primary);
}

#feedback { 
    margin: 24px 0; 
    padding: 20px 28px; 
    border-radius: 18px; 
    font-size: 17px; 
    font-weight: 500;
    line-height: 1.6;
}

.navigation-btns {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    width: 100%;
}
.prev-btn, .next-btn {
    flex: 1; /* Both take equal space */
    border: none;
    padding: 20px 20px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    text-align: center;
}
.prev-btn {
    background: #333;
    color: #fff;
}
.prev-btn:hover {
    background: #444;
}
.next-btn {
    background: var(--success); 
    color: #000;
}
.next-btn:hover {
    background: #00e676;
    transform: translateY(-2px);
}

.score-circle {
    width: 220px; height: 220px; border-radius: 50%; margin: 40px auto;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 64px; font-weight: 800; border: 16px solid var(--success);
    background: rgba(0,200,83,0.05);
    box-shadow: 0 10px 30px rgba(0,200,83,0.2);
}
.score-circle small {
    font-size: 18px;
    font-weight: 600;
    color: #888;
    margin-top: -8px;
}
.restart-btn {
    background: #fff; color: #000; border: none; padding: 20px 60px;
    font-size: 18px; font-weight: 700; border-radius: 16px; cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.restart-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.results-text {
    font-size: 18px;
    margin-bottom: 32px;
    color: #aaa;
}
.results-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.review-btn {
    background: #ff1744;
    color: #fff;
    border: none;
    padding: 20px 60px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 400px;
}
.review-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

.share-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 20px 60px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 400px;
}
.share-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.history-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
    text-align: left;
}
.history-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #888;
}
.chart-container {
    background: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 16px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.history-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.history-item .score {
    font-weight: 800;
    color: var(--success);
}
.clear-history-btn {
    background: transparent;
    color: #666;
    border: 1px solid #333;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
}
.clear-history-btn:hover {
    color: #888;
    border-color: #444;
}

footer {
    padding: 60px 24px;
    text-align: center;
    background: #000;
    border-top: 1px solid #222;
    color: #666;
    margin-top: auto; /* Push to bottom of container */
    border-radius: 0 0 24px 24px; /* Match container bottom radius */
}
.footer-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.footer-content p {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    margin: 0;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
}
.footer-links a {
    color: #888;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    padding: 5px 10px;
    border-radius: 6px;
}
.footer-links a:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}
.footer-content small {
    font-size: 11px;
    opacity: 0.5;
    letter-spacing: 0.5px;
}

.save-settings-btn {
    background: #000;
    color: #fff;
    border: none;
    padding: 20px 40px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 400px;
    margin: 20px auto 0; /* Center button */
    display: block; /* Ensure it's block for auto margins */
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.save-settings-btn:hover {
    background: #222;
    transform: translateY(-2px);
}
