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

:root {
    --bg-body: #f5f5f5;
    --bg-subtle: #ebebeb;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f5f5f5;
    --bg-input: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    --bg-stats-bar: #e0e0e0;
    --bg-streak: #ffffff;
    --bg-table: #ffffff;
    --bg-table-header: #333333;
    --bg-exam-results: #ffffff;
    --bg-exam-summary: #f9f9f9;
    --bg-exam-toggle: #f0f0f0;
    --bg-choice-selected: #bdc3c7;
    --bg-choice-selected-border: #95a5a6;
    --bg-auth-dropdown: #ffffff;

    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-inverse: #ffffff;
    --text-btn-subtle: #555555;

    --border-strong: #333333;
    --border-default: #dddddd;
    --border-subtle: #eeeeee;
    --border-input: #dddddd;
    --border-streak-dot: #dddddd;
    --border-auth-dropdown: #dddddd;
    --border-toggle: #cccccc;
    --border-btn-subtle: #888888;

    --shadow-menu: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-auth-modal: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-auth-dropdown: 0 2px 8px rgba(0,0,0,0.15);

    --scrollbar-thumb: rgba(0,0,0,0.25);

    --btn-primary-bg: #333333;
    --btn-primary-hover-bg: #555555;
    --btn-primary-text: #ffffff;
    --btn-disabled-bg: #999999;
    --btn-disabled-border: #999999;
    --btn-ghost-text: #666666;
    --btn-ghost-hover-text: #333333;

    --slider-track: #333333;
    --slider-ring-bg: #ffffff;
    --slider-ring-border: #333333;
    --slider-thumb: #333333;
    --slider-label: #666666;

    --color-success: #4CAF50;
    --color-success-hover: #45a049;
    --color-success-bg-light: #c8e6c9;
    --color-success-bg-partial: #dcedc8;
    --color-success-bg-option: #e8f5e9;
    --color-error: #f44336;
    --color-info: #2196F3;
    --color-info-hover: #1976D2;
    --color-info-bg: #BBDEFB;
    --color-warning: #e67e22;
    --color-warning-hover: #d35400;
    --color-danger: #e74c3c;
}

[data-theme="dark"] {
    --bg-body: #121212;
    --bg-subtle: #2a2a2a;
    --bg-surface: #1e1e1e;
    --bg-surface-hover: #2a2a2a;
    --bg-input: #2a2a2a;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-stats-bar: #2a2a2a;
    --bg-streak: #1e1e1e;
    --bg-table: #1e1e1e;
    --bg-table-header: #111111;
    --bg-exam-results: #1e1e1e;
    --bg-exam-summary: #2a2a2a;
    --bg-exam-toggle: #333333;
    --bg-choice-selected: #444444;
    --bg-choice-selected-border: #666666;
    --bg-auth-dropdown: #1e1e1e;

    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --text-muted: #777777;
    --text-inverse: #ffffff;
    --text-btn-subtle: #aaaaaa;

    --border-strong: #555555;
    --border-default: #444444;
    --border-subtle: #333333;
    --border-input: #444444;
    --border-streak-dot: #444444;
    --border-auth-dropdown: #444444;
    --border-toggle: #555555;
    --border-btn-subtle: #666666;

    --shadow-menu: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-auth-modal: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-auth-dropdown: 0 2px 8px rgba(0,0,0,0.4);

    --scrollbar-thumb: rgba(255,255,255,0.25);

    --btn-primary-bg: #444444;
    --btn-primary-hover-bg: #555555;
    --btn-primary-text: #ffffff;
    --btn-disabled-bg: #444444;
    --btn-disabled-border: #444444;
    --btn-ghost-text: #aaaaaa;
    --btn-ghost-hover-text: #e0e0e0;

    --slider-track: #555555;
    --slider-ring-bg: #2a2a2a;
    --slider-ring-border: #555555;
    --slider-thumb: #555555;
    --slider-label: #aaaaaa;

    --color-success-bg-light: #1e3320;
    --color-success-bg-partial: #1e3320;
    --color-success-bg-option: #1e3320;
}

[data-theme="dark"] .question svg,
[data-theme="dark"] .choice-svg svg {
    filter: invert(0.85);
}

[data-theme="dark"] .prev-question-text svg {
    filter: invert(0.85);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    padding: 0;
}

.container {
    width: 90%;
    max-width: 600px;
    padding: 20px 0 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left {
    flex: 1;
}

.header-right {
    flex: 1;
    justify-content: flex-end;
}

.exam-timer {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.chapters {
    position: relative;
    display: inline-block;
}

.chapters-btn {
    font-size: clamp(0.8rem, 3vw, 1rem);
    background: none;
    border: 2px solid var(--border-strong);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.chapters-btn:hover {
    background: var(--btn-primary-bg);
    color: var(--text-inverse);
}

.chapters-dropdown {
    --indent: 1.4em;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    max-height: 60vh;
    overflow-y: scroll;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 2px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-menu);
    z-index: 100;
    font-size: clamp(1rem, 4vw, 1.5rem);
    text-align: left;
}

.chapters-dropdown::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 8px;
}

.chapters-dropdown::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--scrollbar-thumb);
}

.chapters-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.chapters-dropdown.show {
    display: block;
}

.chapter-group-header {
    padding: 8px 15px 8px 0.2em;
    font-size: clamp(0.8rem, 3.5vw, 1.2rem);
    font-weight: bold;
    cursor: pointer;
    background: var(--bg-subtle);
    color: var(--text-primary);
    user-select: none;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    position: relative;
}

.chapter-group-header:hover {
    background: var(--border-default);
}

.chapter-group-header.active {
    color: var(--color-success);
    background: var(--color-success-bg-light);
}

.chapter-group-header.partial {
    color: var(--color-success);
    background: var(--color-success-bg-partial);
}

.collapse-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 1.2em;
    text-align: center;
    font-weight: bold;
    margin-right: 0.25em;
}

.selection-indicator {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    user-select: none;
}

.topic-header .selection-indicator {
    font-size: 0.9em;
}

.chapter-group-header span:not(.collapse-toggle):not(.selection-indicator),
.topic-header span:not(.collapse-toggle):not(.selection-indicator) {
    flex: 1;
}

.chapter-group-content {
    /* visibility toggled via JS style.display */
}

.topic-header {
    padding: 6px 15px 6px 0.6em;
    font-size: clamp(0.8rem, 3.5vw, 1.15rem);
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-subtle);
    color: var(--text-secondary, var(--text-primary));
    user-select: none;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    position: relative;
}

.topic-header:hover {
    background: var(--border-default);
}

.topic-header.active {
    color: var(--color-success);
    background: var(--color-success-bg-light);
}

.topic-header.partial {
    color: var(--color-success);
    background: var(--color-success-bg-partial);
}

.chapter-option {
    padding: 10px 15px 10px 1.5em;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s;
    font-size: clamp(0.7rem, 3vw, 1rem);
}

.chapter-option:hover {
    background: var(--bg-surface-hover);
}

.chapter-option.active {
    color: var(--color-success);
    font-weight: bold;
    background: var(--color-success-bg-option);
}

.close-btn {
    background: none;
    border: 2px solid var(--border-strong);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 5px 15px;
    cursor: pointer;
    font-size: clamp(0.8rem, 3vw, 1rem);
    font-weight: bold;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--btn-primary-bg);
    color: var(--text-inverse);
}

.menu-btn {
    background: none;
    border: 2px solid var(--border-strong);
    border-radius: 20px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: all 0.2s;
}

.menu-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--border-strong);
    border-radius: 1px;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: var(--btn-primary-bg);
}

.menu-btn:hover span {
    background: var(--btn-primary-text);
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-surface);
    border: 2px solid var(--border-default);
    border-radius: 8px;
    box-shadow: var(--shadow-menu);
    z-index: 100;
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
}

.menu-dropdown.show {
    display: block;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    color: var(--text-primary);
    transition: background 0.2s;
}

.menu-item:hover {
    background: var(--bg-surface-hover);
}

.menu-label {
    font-weight: normal;
}

.menu-value {
    font-weight: bold;
    margin-left: 10px;
    position: relative;
}

.menu-value.tts-disabled::after {
    content: '🚫';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1em;
    opacity: 0.85;
    pointer-events: none;
}

.menu-divider {
    height: 1px;
    background: var(--border-default);
    margin: 0 5%;
}

#questionContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#questionContainer:not(:has(.exam-navigation))::before,
#questionContainer:not(:has(.exam-navigation))::after {
    content: '';
    flex: 1;
}

#statsView {
    flex: 1;
}

  .question {
    font-size: clamp(0.5rem, 6vw, 2.8rem);
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--text-primary);
    word-wrap: break-word;
    text-align: center;
}

.symbol-logic-block {
    display: inline-block;
    text-align: left;
}

.question svg {
    width: 100%;
    max-width: 210px;
    height: auto;
    display: block;
    margin: 8px auto 0;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    width: 100%;
}

.choice {
    padding: 20px 10px;
    font-size: clamp(1.2rem, 5vw, 2.5rem);
    font-weight: bold;
    border: 2px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.choice:hover {
    border-color: var(--text-secondary);
    transform: scale(1.02);
}

.choice.correct {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--text-inverse);
}

.choice.incorrect {
    background: var(--color-error);
    border-color: var(--color-error);
    color: var(--text-inverse);
}

.choice:disabled {
    cursor: not-allowed;
}

.choice.choice-svg {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-svg svg {
    width: 100%;
    max-width: 140px;
    height: auto;
}

.manual-mode {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.answer-input {
    width: 100%;
    padding: 20px 10px;
    font-size: clamp(1.2rem, 5vw, 2.5rem);
    font-weight: bold;
    text-align: center;
    border: 2px solid var(--border-input);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.answer-input:focus {
    outline: none;
    border-color: var(--border-strong);
}

.answer-input.correct {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--text-inverse);
}

.answer-input.incorrect {
    background: var(--color-error);
    border-color: var(--color-error);
    color: var(--text-inverse);
}

.submit-btn {
    padding: 15px;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: bold;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    cursor: pointer;
    transition: all 0.2s;
}

.submit-btn:hover {
    background: var(--btn-primary-hover-bg);
}

.submit-btn:disabled {
    background: var(--btn-disabled-bg);
    border-color: var(--btn-disabled-border);
    cursor: not-allowed;
}

.manual-mode-buttons {
    display: flex;
    gap: 15px;
}

.manual-mode-buttons .submit-btn {
    flex: 1;
}

.help-btn {
    padding: 15px;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: bold;
    border: 2px solid var(--color-info);
    border-radius: 10px;
    background: var(--color-info);
    color: var(--text-inverse);
    cursor: pointer;
    transition: all 0.2s;
}

.help-btn:hover {
    background: var(--color-info-hover);
}

.answer-input.help {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info-hover);
}

.stats {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(0.8rem, 3vw, 1rem);
    background: var(--bg-stats-bar);
    color: var(--text-primary);
    border-radius: 8px;
}

.stats-text {
    text-align: left;
}

.reset-btn {
    background: none;
    border: none;
    color: var(--btn-ghost-text);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
}

.reset-btn:hover {
    color: var(--btn-ghost-hover-text);
}

.stats-btn {
    background: none;
    border: none;
    color: var(--btn-ghost-text);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    margin-left: 10px;
}

.stats-btn:hover {
    color: var(--btn-ghost-hover-text);
}

.stats-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.stats-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--bg-table);
    border-radius: 8px;
    overflow: hidden;
    min-width: 420px;
}

.stats-table, .stats-table th, .stats-table td {
    box-sizing: border-box;
}

.stats-table th {
    background: var(--bg-table-header);
    color: var(--text-inverse);
    white-space: nowrap;
    min-width: 60px;
}

.stats-table th:first-child {
    min-width: 120px;
}

.stats-table th, .stats-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    min-width: 60px;
}

.stats-table th {
    background: var(--bg-table-header);
    color: var(--text-inverse);
}

.stats-table td:first-child {
    text-align: left;
    font-weight: bold;
    color: var(--text-primary);
    min-width: 80px;
    white-space: normal;
}

@media (max-width: 600px) {
    .stats-tables {
        overflow-x: auto;
    }
    
    .stats-table th:not(:first-child) {
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        min-width: 30px;
        max-width: 30px;
        padding: 4px;
    }
    
    .stats-table th:first-child {
        min-width: 120px;
    }
}

.back-btn {
    padding: 15px 30px;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: bold;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--btn-primary-hover-bg);
}

.streak-container {
    display: flex;
    justify-content: center;
    gap: 3px;
    flex-wrap: wrap;
    flex-direction: row-reverse;
}

.streak-wrapper {
    background: var(--bg-streak);
    border-radius: 8px;
    padding: 12px 8px;
    margin-bottom: 20px;
}

.streak-label {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.streak-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--border-streak-dot);
    flex-shrink: 0;
    position: relative;
    cursor: default;
}

.streak-dot::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--btn-primary-bg);
    color: var(--text-inverse);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 100;
}

.streak-dot:hover::after {
    opacity: 1;
}

@keyframes panda-bounce {
    0% {
        transform: translateX(-50%) translateY(100%);
    }
    100% {
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes panda-hide {
    0% {
        transform: translateX(-50%) translateY(0);
    }
    100% {
        transform: translateX(-50%) translateY(100%);
    }
}

.panda-animation {
    position: fixed;
    bottom: 50%;
    left: 50%;
    width: 360px;
    pointer-events: none;
    z-index: 1000;
    animation: panda-bounce 0.3s ease-out forwards;
}

.panda-animation.hide {
    animation: panda-hide 0.5s ease-in forwards;
}

.reset-confirm-input {
  padding: 10px;
  width: 100%;
  color: var(--text-primary);
  margin-bottom: 15px;
  border: 2px solid var(--border-input);
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
}

.menu-checkbox-item {
  cursor: pointer;
  user-select: none;
}

.menu-checkbox-item .menu-value {
    margin-left: 0;
    font-weight: normal;
}

.menu-checkbox-item input[type="checkbox"] {
  display: none;
}

.checkbox-symbol {
  margin-left: auto;
  font-size: 1.1em;
  user-select: none;
}

.menu-checkbox-item input[type="checkbox"]:checked ~ .checkbox-symbol::before {
  content: '☑';
}

.menu-checkbox-item input[type="checkbox"] ~ .checkbox-symbol::before {
  content: '☐';
}

.menu-difficulty {
  padding: calc(14px + 0.5em) calc(15px + 0.5em) 12px;
}

.difficulty-slider {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.difficulty-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--slider-track);
  border-radius: 1px;
}

.difficulty-label {
  position: absolute;
  top: calc(-16px + 0.5em);
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--slider-label);
  white-space: nowrap;
  user-select: none;
}

.difficulty-label-easy {
  left: 0.5em;
  transform: translateX(-50%);
}

.difficulty-label-hard {
  right: 0.5em;
  transform: translateX(50%);
}

.difficulty-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--slider-ring-border);
  background: var(--slider-ring-bg);
  transform: translateX(-50%);
  z-index: 1;
  cursor: pointer;
}

.difficulty-thumb {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: grab;
  padding: 0;
  border: none;
  transition: left 0.15s ease;
  transform: translate(-50%, -50%);
  top: 50%;
  z-index: 2;
}

.difficulty-thumb:active {
  cursor: grabbing;
}

.menu-speed {
  padding: calc(14px + 0.5em) calc(15px + 0.5em) 12px;
}

.speed-slider {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.speed-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--slider-track);
  border-radius: 1px;
}

.speed-label {
  position: absolute;
  top: calc(-16px + 0.5em);
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--slider-label);
  white-space: nowrap;
  user-select: none;
}

.speed-label-left {
  left: 0.5em;
  transform: translateX(-50%);
}

.speed-label-center {
  left: 50%;
  transform: translateX(-50%);
}

.speed-label-right {
  right: 0.5em;
  transform: translateX(50%);
}

.speed-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--slider-ring-border);
  background: var(--slider-ring-bg);
  transform: translateX(-50%);
  z-index: 1;
  cursor: pointer;
}

.speed-thumb {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: grab;
  padding: 0;
  border: none;
  transition: left 0.15s ease;
  transform: translate(-50%, -50%);
  top: 50%;
  z-index: 2;
}

.speed-thumb:active {
  cursor: grabbing;
}

.timer-bar-container {
  width: 100%;
  margin: 10px 0;
  height: 1px;
}

@keyframes timer-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.timer-bar {
  height: 1px;
  background: var(--color-success);
  width: 100%;
  transform-origin: center;
}

.prev-question-btn {
  padding: 8px 20px;
  font-size: clamp(0.8rem, 3vw, 1rem);
  font-weight: bold;
  border: 2px solid var(--border-btn-subtle);
  border-radius: 20px;
  background: none;
  color: var(--text-btn-subtle);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.prev-question-btn:hover {
  background: var(--border-btn-subtle);
  border-color: var(--border-btn-subtle);
  color: var(--text-inverse);
}

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

.prev-question-text {
  font-size: clamp(0.5rem, 6vw, 2.8rem);
  font-weight: bold;
  margin-bottom: 20px;
  color: var(--text-btn-subtle);
  word-wrap: break-word;
}

.prev-question-text svg {
  width: 100%;
  max-width: 210px;
  height: auto;
  display: block;
  margin: 8px auto 0;
}

.prev-question-container {
  display: none;
  flex-direction: column;
  align-items: center;
}

.prev-question-container.visible {
  display: flex;
}

.prev-question-container .choice {
  opacity: 0.85;
}

.prev-question-container .choice.correct {
  opacity: 1;
}

.prev-question-container .choice.incorrect {
  opacity: 1;
}

.prev-question-container .answer-input {
  opacity: 0.85;
}

.prev-question-container .answer-input.correct,
.prev-question-container .answer-input.incorrect,
.prev-question-container .answer-input.help {
  opacity: 1;
}

.prev-question-container .manual-mode-buttons button {
  opacity: 0.7;
  pointer-events: none;
}

.stats-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.toggle-btn {
  padding: 6px 16px;
  border: 1px solid var(--border-toggle);
  border-radius: 20px;
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.toggle-btn:hover {
  border-color: var(--border-strong);
}

.toggle-btn.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--border-strong);
}

/* ─── Exam Mode ─────────────────────────────────────────────────── */

.exam-btn {
  font-size: clamp(0.8rem, 3vw, 1rem);
  background: none;
  border: 2px solid var(--color-warning);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--color-warning);
  font-weight: bold;
  transition: all 0.2s;
}

.exam-btn:hover {
  background: var(--color-warning);
  color: var(--text-inverse);
}

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

.exam-timer {
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  font-weight: bold;
  color: var(--color-warning);
  font-variant-numeric: tabular-nums;
}

.exam-timer.warning {
  color: var(--color-danger);
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.exam-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 1em 0 10px;
  flex-shrink: 0;
}

.exam-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.exam-nav-btn {
  padding: 8px 20px;
  font-size: clamp(0.8rem, 3vw, 1rem);
  font-weight: bold;
  border: 2px solid var(--border-btn-subtle);
  border-radius: 20px;
  background: none;
  color: var(--text-btn-subtle);
  cursor: pointer;
  transition: all 0.2s;
}

.exam-nav-btn:hover:not(:disabled) {
  background: var(--border-btn-subtle);
  border-color: var(--border-btn-subtle);
  color: var(--text-inverse);
}

.exam-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.exam-nav-counter {
  font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  font-weight: bold;
  color: var(--text-primary);
}

.finish-btn {
  font-size: clamp(0.8rem, 3vw, 1rem);
  background: none;
  border: 2px solid var(--color-danger);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--color-danger);
  font-weight: bold;
  transition: all 0.2s;
}

.finish-btn:hover {
  background: var(--color-danger);
  color: var(--text-inverse);
}

/* ─── Exam Config Popup ─────────────────────────────────────────── */

.exam-config-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.exam-config-dialog {
  background: var(--bg-surface);
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  font-size: 16px;
  max-width: 320px;
  width: 90%;
}

.exam-config-title {
  margin: 0 0 20px;
  font-weight: bold;
  font-size: 18px;
  color: var(--text-primary);
}

.exam-config-section {
  margin-bottom: 20px;
}

.exam-config-label {
  display: block;
  margin-bottom: 10px;
  font-weight: bold;
  font-size: 14px;
  color: var(--text-btn-subtle);
}

.exam-time-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.exam-time-btn {
  padding: 8px 14px;
  border: 2px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s;
}

.exam-time-btn:hover {
  border-color: var(--color-warning);
}

.exam-time-btn.active {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: var(--text-inverse);
}

.exam-difficulty-options {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.exam-diff-btn {
  padding: 8px 18px;
  border: 2px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s;
}

.exam-diff-btn:hover {
  border-color: var(--color-warning);
}

.exam-diff-btn.active {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: var(--text-inverse);
}

.exam-config-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 25px;
}

.exam-config-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.exam-config-start {
  background: var(--color-warning);
  color: var(--text-inverse);
  padding: 15px 36px;
}

.exam-config-start:hover {
  background: var(--color-warning-hover);
}

.exam-config-cancel {
  background: none;
  border: 2px solid var(--border-strong);
  color: var(--text-primary);
}

.exam-config-cancel:hover {
  background: var(--btn-primary-bg);
  color: var(--text-inverse);
}

/* ─── Exam Results ──────────────────────────────────────────────── */

.exam-results {
  background: var(--bg-exam-results);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.exam-results-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 15px;
  text-align: center;
  color: var(--text-primary);
}

.exam-results-summary {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
  padding: 15px;
  background: var(--bg-exam-summary);
  border-radius: 8px;
}

.exam-result-item {
  text-align: center;
}

.exam-result-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
}

.exam-result-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.exam-details-toggle {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  color: var(--text-primary);
  background: var(--bg-exam-toggle);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  margin-top: 10px;
}

.exam-details-toggle:hover {
  background: var(--bg-stats-bar);
}

.exam-details-list {
  display: none;
  margin-top: 10px;
}

.exam-details-list.visible {
  display: block;
}

.exam-detail-item {
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
}

.exam-detail-item:last-child {
  border-bottom: none;
}

.exam-detail-question {
  font-weight: bold;
  margin-bottom: 4px;
}

.exam-detail-answer.correct {
  color: var(--color-success);
}

.exam-detail-answer.incorrect {
  color: var(--color-danger);
}

.exam-detail-item.not-attempted {
  color: var(--text-muted);
}

.exam-detail-item.not-attempted .exam-detail-question {
  font-weight: normal;
}

.exam-detail-item.not-attempted .exam-detail-answer {
  font-style: italic;
}

.exam-back-btn {
  display: block;
  margin: 20px auto 0;
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  cursor: pointer;
  transition: all 0.2s;
}

.exam-back-btn:hover {
  background: var(--btn-primary-hover-bg);
}

/* ─── Exam mode choice styling (gray selected) ──────────────────── */

.exam-mode .choice.selected {
  background: var(--bg-choice-selected);
  border-color: var(--bg-choice-selected-border);
  color: var(--text-inverse);
}

.exam-mode .choice.selected:hover {
  border-color: var(--bg-choice-selected-border);
  transform: none;
}

/* ─── Menu visibility ───────────────────────────────────────────── */

.menu-dropdown [data-visible-in].hidden {
  display: none !important;
}

/* ─── Auth modal ──────────────────────────────────────────────── */

.auth-btn {
  padding: 6px 14px;
  border: 2px solid var(--color-success);
  border-radius: 8px 0 0 8px;
  background: none;
  color: var(--color-success);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn:hover {
  background: var(--color-success);
  color: var(--text-inverse);
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-success);
}

.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
}

.auth-modal-content {
  position: relative;
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 30px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-auth-modal);
}

.auth-modal-content h3 {
  margin: 0 0 20px;
  font-size: 20px;
  color: var(--text-primary);
}

.auth-modal-body {
  margin-bottom: 20px;
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-input);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-input:focus {
  border-color: var(--color-success);
}

.auth-error {
  color: var(--color-danger);
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
}

.auth-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.auth-modal-content.centered h3 {
  text-align: center;
}

.auth-modal-content.centered .auth-error {
  text-align: center;
}

.auth-modal-content.centered .auth-modal-actions {
  justify-content: center;
}

.auth-btn-secondary {
  padding: 10px 20px;
  border: 2px solid var(--border-default);
  color: var(--text-primary);
  border-radius: 8px;
  background: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn-secondary:hover {
  border-color: var(--text-muted);
}

.auth-btn-login {
  padding: 10px 20px;
  border: 2px solid var(--color-success);
  border-radius: 8px;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-success);
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn-login:hover {
  background: var(--color-success);
  color: var(--text-inverse);
}

.auth-btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--color-success);
  color: var(--text-inverse);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn-primary:hover {
  background: var(--color-success-hover);
}

.auth-btn-primary:disabled {
  background: var(--border-toggle);
  cursor: not-allowed;
}

.auth-btn-wrapper {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.auth-arrow-btn {
  width: 24px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--color-success);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: none;
  color: var(--color-success);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  margin-left: -1px;
}

.auth-arrow-btn:hover {
  background: var(--color-success);
  color: var(--text-inverse);
}

.auth-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-auth-dropdown);
  border: 1px solid var(--border-auth-dropdown);
  border-radius: 6px;
  box-shadow: var(--shadow-auth-dropdown);
  z-index: 100;
  overflow: hidden;
  min-width: 120px;
}

.auth-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.auth-dropdown button:hover {
  background: var(--bg-surface-hover);
}

.pool-warning {
  background: rgba(254,243,229,0.7);
  border: 1px solid rgba(245,158,11,0.4);
  color: #92400e;
  padding: 0.4rem;
  border-radius: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  opacity: 0.8;
}

::placeholder {
    color: var(--text-muted);
}
