/* --- THEME VARIABLES --- */
:root {
    --primary: #2e7d32;
    --primary-dark: #1b5e20;
    --primary-light: #e8f5e9;
    --primary-hover: #256629;
    --accent: #1976d2;
    --accent-light: #e3f2fd;
    --accent-dark: #0d47a1;
    --text-main: #1f2d3d;
    --text-muted: #606f7b;
    --bg-page: #f2f8f3;
    --card-bg: #ffffff;
    --border-color: #d7ebd9;
    --border-focus: #4caf50;
    --wrong: #d32f2f;
    --wrong-bg: #fde8e8;
    --correct: #2e7d32;
    --correct-bg: #e8f5e9;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* --- HEADER --- */
.app-header {
    background: #ffffff;
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    background: var(--primary-dark);
    padding: 6px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #c8e6c9;
    transform: scale(1.05);
}

.btn-pill {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-admin-locked {
    background: #f1f3f5;
    color: var(--text-muted);
    border-color: #dee2e6;
}

.btn-admin-locked:hover {
    background: #e9ecef;
    color: var(--text-main);
}

.btn-admin-unlocked {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #a5d6a7;
}

.btn-admin-unlocked:hover {
    background: #c8e6c9;
}

/* --- MAIN CONTAINER --- */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.hidden {
    display: none !important;
}

/* --- ADMIN BANNER --- */
.admin-banner {
    background: #e8f5e9;
    border: 2px solid #a5d6a7;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.admin-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.admin-status {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.badge-active {
    font-weight: 800;
    font-size: 0.82rem;
    color: #1b5e20;
    letter-spacing: 0.5px;
}

.admin-status small {
    color: #2e7d32;
    font-size: 0.82rem;
}

.admin-quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- BUTTONS --- */
.btn-action {
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-action:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.btn-secondary {
    background: var(--accent);
    color: #ffffff;
}

.btn-secondary:hover {
    background: var(--accent-dark);
}

.btn-danger {
    background: #d32f2f;
    color: #ffffff;
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-light {
    background: #f1f3f5;
    color: var(--text-main);
    border: 1px solid #ced4da;
}

.btn-light:hover {
    background: #e9ecef;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* --- FILTER BAR --- */
.filter-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.search-input-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    font-size: 1rem;
    background: #fbfdfb;
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
    border-color: var(--border-focus);
    background: #ffffff;
}

.filters-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-dark);
    min-width: 80px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-muted);
    transition: all 0.2s;
}

.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* --- QUIZZES GRID --- */
.quizzes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.quiz-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s ease;
    position: relative;
}

.quiz-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: #a5d6a7;
}

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

.quiz-badge-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge-curso {
    background: #e3f2fd;
    color: #1565c0;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.badge-asig {
    background: #f1f8e9;
    color: #2e7d32;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.badge-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.quiz-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
    line-height: 1.35;
}

.quiz-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.card-play-row {
    display: flex;
    gap: 8px;
}

.card-play-row .btn-primary {
    flex: 1;
}

.card-admin-row {
    display: flex;
    gap: 6px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
    margin-top: 6px;
}

/* --- QUIZ PLAYER --- */
.quiz-player-container {
    max-width: 760px;
    margin: 0 auto;
}

.player-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 0;
}

.btn-back:hover {
    text-decoration: underline;
}

.player-meta-badges {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-title {
    background: #e8f5e9;
    color: var(--primary-dark);
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-score-pill {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    color: var(--text-muted);
}

.live-score-pill strong {
    color: var(--primary);
    font-size: 1.05rem;
}

.progress-bar-wrapper {
    background: #e0e0e0;
    height: 10px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 14px;
}

.progress-bar-fill {
    background: linear-gradient(90deg, #4caf50, #2e7d32);
    height: 100%;
    transition: width 0.35s ease;
}

.player-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.toggle-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.question-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.question-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 26px;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-option {
    background: #f8faf8;
    border: 2px solid #d0e4d2;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-option:hover:not(:disabled) {
    background: #eef7ef;
    border-color: var(--primary);
    transform: translateX(4px);
}

.btn-option:disabled {
    cursor: default;
}

.btn-option.correct {
    background: var(--correct-bg) !important;
    border-color: var(--correct) !important;
    color: var(--primary-dark) !important;
    font-weight: 700;
}

.btn-option.wrong {
    background: var(--wrong-bg) !important;
    border-color: var(--wrong) !important;
    color: #900 !important;
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* --- FEEDBACK BOX --- */
.feedback-box {
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-left: 5px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-top: 20px;
    animation: fadeIn 0.3s ease;
}

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

.feedback-status {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.feedback-status.msg-correct {
    color: var(--correct);
}

.feedback-status.msg-wrong {
    color: var(--wrong);
}

.feedback-explanation {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
    margin-bottom: 16px;
    background: #f4fbf5;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
}

.feedback-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-next {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* --- RESULTS SECTION --- */
.results-container {
    max-width: 680px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 36px 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    text-align: center;
}

.results-badge-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.results-header h2 {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.results-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 24px;
}

.score-circle-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 6px solid var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.2);
}

.score-circle span {
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--primary-dark);
    line-height: 1;
}

.score-circle small {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: #f8faf8;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
}

.text-green { color: var(--correct); }
.text-red { color: var(--wrong); }

.ranking-input-card {
    background: #f1f8e9;
    border: 1px solid #c8e6c9;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 28px;
    text-align: left;
}

.ranking-input-card h3 {
    font-size: 1.05rem;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.ranking-form-row {
    display: flex;
    gap: 10px;
}

.ranking-form-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #a5d6a7;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
}

.ranking-form-row input:focus {
    border-color: var(--primary);
}

.msg-success {
    margin-top: 8px;
    color: var(--correct);
    font-weight: 700;
    font-size: 0.9rem;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* --- REVIEW SECTION --- */
.review-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: left;
}

.btn-toggle-review {
    width: 100%;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.review-list {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.review-item {
    background: #fafdfa;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.review-item.wrong-item {
    border-left: 4px solid var(--wrong);
}

.review-item.correct-item {
    border-left: 4px solid var(--correct);
}

.review-q-title {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.review-ans-row {
    font-size: 0.88rem;
    margin-bottom: 4px;
}

.review-exp {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #ffffff;
    padding: 8px 10px;
    border-radius: 4px;
    margin-top: 6px;
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: zoomIn 0.25s ease;
}

.modal-card-large {
    max-width: 900px;
    max-height: 90vh;
}

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

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #edf2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8faf8;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--primary-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--wrong);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #edf2f7;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8faf8;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-error {
    color: var(--wrong);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 6px;
}

/* --- EDITOR SPECIFICS --- */
.editor-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-section-card {
    background: #fafdfa;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
}

.editor-section-card h4 {
    font-size: 1rem;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

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

.section-help-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.section-help-text code {
    background: #eef7ef;
    padding: 2px 6px;
    border-radius: 4px;
    color: #1b5e20;
    font-size: 0.8rem;
}

.editor-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

#bulk-text-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 0.88rem;
    margin-bottom: 10px;
}

.bulk-text-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-questions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 14px;
}

.editor-q-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
}

.editor-q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.editor-q-num {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.9rem;
}

.editor-q-actions {
    display: flex;
    gap: 6px;
}

.opt-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.opt-radio {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.opt-text-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* --- RANKING TABLE --- */
.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 2px solid #edf2f7;
}

.ranking-table td {
    padding: 10px;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.92rem;
}

.rank-badge {
    display: inline-block;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.82rem;
}

.rank-1 { background: #fef3c7; color: #b45309; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #fed7aa; color: #c2410c; }

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.92rem;
    font-weight: 600;
    z-index: 200;
    animation: slideUp 0.3s ease;
}

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

/* --- SPINNER --- */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

.loader-box {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .editor-grid-2 {
        grid-template-columns: 1fr;
    }
    .header-container {
        padding: 6px 12px;
    }
    .brand-logo {
        width: 30px;
        height: 30px;
    }
    .brand-text h1 {
        font-size: 1.1rem;
    }
    .brand-subtitle {
        display: none;
    }
    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .main-content {
        padding: 8px 10px 24px;
    }

    /* Quiz Player mobile optimization */
    .quiz-player-container {
        max-width: 100%;
    }

    .player-top-bar {
        margin-bottom: 6px;
        gap: 6px;
    }

    .btn-back {
        font-size: 0.82rem;
        padding: 2px 0;
    }

    .player-meta-badges {
        gap: 6px;
    }

    .badge-title {
        font-size: 0.78rem;
        padding: 3px 8px;
        max-width: 160px;
    }

    .live-score-pill {
        font-size: 0.78rem;
        padding: 3px 8px;
    }

    .live-score-pill strong {
        font-size: 0.88rem;
    }

    .progress-bar-wrapper {
        height: 5px;
        margin-bottom: 6px;
    }

    .player-info-row {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }

    .question-card {
        padding: 14px 12px;
        border-radius: var(--radius-md);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    }

    .question-title {
        font-size: 1.02rem;
        line-height: 1.35;
        margin-bottom: 12px;
    }

    .options-grid {
        gap: 7px;
        margin-bottom: 10px;
    }

    .btn-option {
        padding: 10px 12px;
        font-size: 0.88rem;
        font-weight: 500;
        line-height: 1.3;
        border-width: 1.5px;
        word-break: break-word;
    }

    .btn-option:hover:not(:disabled) {
        transform: none;
    }

    .feedback-box {
        padding: 10px 12px;
        margin-top: 10px;
    }

    .feedback-status {
        font-size: 0.92rem;
        margin-bottom: 4px;
    }

    .feedback-explanation {
        font-size: 0.82rem;
        line-height: 1.35;
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    .btn-next {
        width: 100%;
        padding: 9px 16px;
        font-size: 0.88rem;
    }

    .results-container {
        padding: 20px 16px;
    }
}

@media (max-width: 420px) {
    .question-title {
        font-size: 0.95rem;
        line-height: 1.3;
        margin-bottom: 10px;
    }

    .btn-option {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .badge-title {
        max-width: 125px;
    }
}

/* --- HELP MODAL SPECIFICS --- */
.help-step-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.help-step-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.prompt-display-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-md);
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    user-select: text;
    border: 1px solid #334155;
    max-height: 280px;
    overflow-y: auto;
}
