* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f3f1;
    color: #333;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* =========================================
   LOGIN & AUTHENTICATION
   ========================================= */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a8442 0%, #00375a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.login-box h2 {
    color: #333;
    margin-bottom: 20px;
}

#login-form,
#set-password-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#login-form input,
#add-user-form input,
#set-password-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

#login-form input:focus,
#add-user-form input:focus,
#set-password-form input:focus {
    border-color: #0A8442;
}

.error-text {
    color: #cc0000;
    font-size: 14px;
    margin-bottom: 5px;
}

.success-text {
    color: #0A8442;
    font-size: 14px;
    margin-top: 10px;
}

/* =========================================
   BACKOFFICE (ADMIN)
   ========================================= */
.backoffice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f6f8;
    z-index: 4000;
    overflow-y: auto;
    padding: 40px 20px;
}

.backoffice-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.backoffice-header {
    background: #00375a;
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.backoffice-header h2 {
    font-weight: 500;
}

.logout-btn {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 6px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: white;
    color: #00375a;
}

.backoffice-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

@media (max-width: 768px) {
    .backoffice-content {
        grid-template-columns: 1fr;
    }
}

.add-user-card,
.users-list-card {
    background: #fdfdfd;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.add-user-card h3,
.users-list-card h3 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #0A8442;
    padding-bottom: 10px;
    display: inline-block;
}

#add-user-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.users-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.users-list li {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.users-list li:last-child {
    border-bottom: none;
}

.user-item-info {
    display: flex;
    flex-direction: column;
}

.user-item-name {
    font-weight: bold;
    color: #333;
}

.user-item-login {
    font-size: 13px;
    color: #777;
}

.delete-user-btn {
    color: #cc0000;
    background: #ffebeb;
    border: 1px solid #ffcdcd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.delete-user-btn:hover {
    background: #cc0000;
    color: white;
    border-color: #cc0000;
}

/* Actions group (checkbox + delete btn) */
.user-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.seed-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 5px 10px;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
    user-select: none;
}

.seed-toggle:hover {
    background: #eaf5ef;
    border-color: #0A8442;
}

.seed-toggle input[type="checkbox"] {
    accent-color: #0A8442;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.seed-toggle-label {
    font-weight: 500;
}

/* =========================================
   STATISTICS SCREEN
   ========================================= */
.stats-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f6f8;
    z-index: 4500;
    overflow-y: auto;
    overflow-x: hidden;  /* never let canvas push the page wider */
    padding: 40px 20px;
    box-sizing: border-box;
}

.stats-container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    /* Prevent container from stretching beyond viewport */
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.stats-header {
    background: linear-gradient(135deg, #0A8442 0%, #006633 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.stats-content {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 0;
    min-height: 500px;
    /* Prevent grid from overflowing */
    overflow: hidden;
    min-width: 0;
}

@media (max-width: 900px) {
    .stats-content {
        grid-template-columns: 1fr;
    }
}

.stats-panel {
    padding: 28px;
    min-width: 0; /* Critical: prevents panel from expanding beyond grid cell */
    box-sizing: border-box;
    overflow: hidden;
}

.ranking-panel {
    border-right: 1px solid #eee;
    overflow-y: auto;
}

.stats-panel h3 {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid #0A8442;
    display: inline-block;
}

/* Ranking list */
.stats-ranking-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fafafa;
    border: 1px solid #eee;
    transition: transform 0.15s, box-shadow 0.15s;
}

.ranking-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.ranking-item.rank-pass {
    border-left: 4px solid #0A8442;
}

.ranking-item.rank-fail {
    border-left: 4px solid #cc0000;
}

.rank-medal {
    font-size: 24px;
    flex-shrink: 0;
    width: 34px;
    text-align: center;
}

.rank-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rank-name {
    font-weight: 700;
    font-size: 14px;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-attempts {
    font-size: 12px;
    color: #999;
}

.rank-score-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rank-status-icon svg {
    width: 22px;
    height: 22px;
}

.rank-score {
    font-size: 20px;
    font-weight: 900;
    color: #333;
    line-height: 1;
}

.rank-score small {
    font-size: 11px;
    color: #999;
    font-weight: 400;
}

.ranking-empty {
    text-align: center;
    color: #aaa;
    font-size: 14px;
    padding: 40px 20px;
    line-height: 1.8;
}

/* Chart section */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.chart-select {
    padding: 7px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: #333;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.chart-select:focus {
    border-color: #0A8442;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 10px 0 10px;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #0A8442 #f0f0f0;
}

.chart-wrapper::-webkit-scrollbar {
    height: 6px;
}
.chart-wrapper::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}
.chart-wrapper::-webkit-scrollbar-thumb {
    background: #0A8442;
    border-radius: 3px;
}

#stats-chart {
    display: block;
    /* width set dynamically by JS */
}

.chart-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.82);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.chart-no-data {
    text-align: center;
    color: #bbb;
    font-size: 14px;
    padding: 60px 20px;
}

/* =========================================
   TEST SELECTION VIEW
   ========================================= */
.test-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a8442 0%, #e2ebf0 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 3000;
    overflow-y: auto;
    padding: 40px 20px;
}

.test-selection-overlay.hidden {
    display: none !important;
}

.test-selection-container {
    width: 100%;
    max-width: 1100px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    margin-bottom: 40px;
}

.test-selection-header {
    background: white;
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

.test-selection-header h2 {
    color: #0A8442;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-menu-container {
    position: relative;
    display: inline-block;
}

.btn-user-menu.pill {
    background: white;
    border: 1px solid #ddd;
    height: 46px;
    border-radius: 23px; /* Pill shape */
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 0 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    gap: 12px;
}

.user-name-text {
    font-weight: 700;
    color: #111;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.avatar-wrapper {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-user-menu.pill:hover {
    background: #f8f9fa;
    border-color: #ccc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.user-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-width: 170px;
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    width: 100%;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 15px;
    font-family: inherit;
    color: #333;
    transition: background 0.2s;
    text-align: left;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.dropdown-logout {
    color: #cc0000;
    font-weight: 500;
}

.dropdown-logout:hover {
    background: #ffebeb;
}

.test-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #eef2f5;
}

.test-card {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 110px;
    background-color: #001a33;
}

.test-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.test-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.75;
    transition: opacity 0.2s;
    filter: brightness(0.9);
}

.test-card:hover img {
    opacity: 1;
}

.test-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 8px;
    font-size: 13px;
    font-weight: bold;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.paused-indicator {
    background: rgba(255, 255, 255, 0.95);
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    z-index: 10;
}

.paused-bar {
    width: 5px;
    height: 16px;
    background-color: #0A8442;
    border-radius: 2px;
}

/* Result stats badges on test cards */
.result-stats-indicator {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.65);
    border-radius: 20px;
    padding: 2px 7px 2px 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.stat-badge svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.stat-badge span {
    color: white;
    font-weight: 800;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.5px;
}

.stat-pass svg circle { fill: #0A8442; }
.stat-fail svg circle { fill: #cc0000; }


/* Start Overlay (Seleccion de Modo) */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0A8442;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.start-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.junta-logo {
    height: 100px;
    margin-bottom: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.logo-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-badge {
    background-color: #0A8442;
    color: white;
    padding: 2px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: -10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.start-box h2 {
    color: #0A8442;
    margin-bottom: 15px;
    font-size: 28px;
    font-weight: 900;
    text-transform: uppercase;
}

.start-box p {
    color: #666;
    margin-bottom: 30px;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-btn:hover {
    border-color: #0A8442;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(10, 132, 66, 0.2);
}

.mode-icon {
    font-size: 40px;
    color: #0A8442;
    margin-bottom: 15px;
}

.mode-btn h3 {
    margin-bottom: 10px;
    color: #333;
}

.mode-btn p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.change-test-btn {
    margin-top: 30px;
    background: transparent;
    border: 1px solid #0A8442;
    color: #0A8442;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.change-test-btn:hover {
    background-color: #0A8442;
    color: white;
}

/* Base Layout */
#app-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100vh;
}

/* Header Styles */
.header {
    background-color: #0A8442;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: white;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-titles {
    display: flex;
    flex-direction: column;
}

.test-title {
    font-size: 14px;
    opacity: 0.9;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.timer {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    align-items: flex-end;
}

#time-display {
    font-size: 16px;
    font-weight: bold;
}

.finish-btn {
    background-color: white;
    color: #cc0000;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.finish-btn:hover {
    background-color: #f0f0f0;
}

/* Main Layout */
.main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 150px;
    background-color: #ffffff;
    border-right: 4px solid #0A8442;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.side-btn {
    background-color: #888888;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: opacity 0.2s;
}

.side-btn:hover {
    opacity: 0.9;
}

/* Content Area */
.content {
    flex: 1;
    background-color: #ffffff;
    padding: 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#quiz-container {
    flex: 1;
}

.question-header {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    font-size: 20px;
}

.question-number {
    font-weight: bold;
}

.question-text {
    line-height: 1.4;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-left: 20px;
}

.option-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Mode Exam States */
.mode-examen .option-row:not(.disabled):hover .option-letter {
    background-color: #d35400;
}

.mode-examen .option-row.selected .option-letter {
    background-color: #e67e22;
    /* Naranja = contestada (igual que el panel) */
    color: white;
}

.mode-examen .option-row.selected .option-text {
    font-weight: 600;
    color: #e67e22;
}

/* Mode Ayuda / Review States */
.option-row.disabled {
    cursor: default;
}

.option-row.correct .option-letter {
    background-color: #28a745 !important;
    color: white;
}

.option-row.correct .option-text {
    color: #28a745;
    font-weight: 500;
}

.option-row.wrong .option-letter {
    background-color: #dc3545 !important;
    color: white;
}

.option-row.wrong .option-text {
    color: #dc3545;
}

.option-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #888888;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;
    transition: background 0.3s;
}

.option-text {
    font-size: 16px;
    line-height: 1.5;
    padding-top: 3px;
}

/* Navigation */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.nav-btn {
    padding: 10px 20px;
    background-color: #0A8442;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.nav-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

/* Bottom Panel Pagination */
.bottom-panel {
    background-color: #e5e5e5;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.toggle-panel-btn {
    width: 100%;
    background: #f8f9fa;
    border: none;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 8px 15px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.toggle-panel-btn:hover {
    background: #e9ecef;
    color: #0A8442;
}

.panel-content {
    padding: 10px;
    overflow-y: auto;
    max-height: 180px;
    display: flex;
    background: white;
}

.panel-content.collapsed {
    display: none !important;
}

.grid-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: flex-start;
    width: 100%;
}

.grid-item {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: transform 0.1s;
}

.grid-item:hover {
    transform: scale(1.1);
}

.grid-item.st-current {
    box-shadow: inset 0 0 0 3px #0A8442, 0 0 5px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* Status colors map to screenshots */
.grid-item.st-unanswered {
    background-color: #777;
}

.grid-item.st-answered {
    background-color: #e67e22;
}

.grid-item.st-correct {
    background-color: #28a745;
}

.grid-item.st-wrong {
    background-color: #cc0000;
}

.legend {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 5px 10px;
    background: #f0f3f1;
    font-size: 11px;
    color: #555;
    border-top: 1px solid #ccc;
}

.legend-title {
    font-weight: bold;
}

.box-leg {
    display: inline-flex;
    align-items: center;
    padding: 2px 5px;
    color: white;
    font-weight: bold;
}

.box-leg.leg-answered {
    background-color: #e67e22;
}

.box-leg.leg-unanswered {
    background-color: #777;
}

.box-leg.leg-correct {
    background-color: #28a745;
}

.box-leg.leg-wrong {
    background-color: #cc0000;
}

/* Modal */
.modal-overlay {
    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;
}

.modal-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    width: 450px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.confirmation-box {
    padding: 30px;
}

.modal-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.warning-icon {
    color: #f39c12;
}

.info-icon {
    color: #3498db;
}

.save-icon {
    color: #0A8442;
}

.warning-text {
    color: #cc0000;
    font-weight: 500;
    margin-top: 10px;
    margin-bottom: 25px !important;
}

.confirmation-box h2 {
    color: #333;
    font-size: 22px;
    margin-bottom: 10px;
}

.confirmation-box p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.danger-btn {
    background-color: #fee;
    color: #c00 !important;
    border: 1px solid #fcc;
}

.danger-btn:hover {
    background-color: #fdd;
}

.modal-box h2 {
    margin-bottom: 20px;
    color: #0A8442;
}

.score-text {
    font-size: 18px;
    margin-bottom: 15px;
}

.status-pass {
    color: #28a745;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
}

.status-fail {
    color: #cc0000;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn.primary {
    background-color: #0A8442;
    color: white;
}

.btn.secondary {
    background-color: #eee;
    color: #333;
}

/* Score Breakdown (Modal CAP) */
.score-breakdown {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    text-align: left;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 8px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    gap: 10px;
}

.score-row:last-child {
    border-bottom: none;
}

.score-row-total {
    background: #e8f5e9;
    border-radius: 6px;
    font-weight: bold;
    font-size: 15px !important;
    margin-top: 4px;
    padding: 10px 8px;
    color: #0A8442;
}

.score-row-total.fail {
    background: #ffebee;
    color: #cc0000;
}

.score-row-bonus {
    background: #fff8e1;
    border-radius: 6px;
    font-size: 12px !important;
    color: #888;
    padding: 6px 8px;
    margin-top: 4px;
}

.pass-note {
    font-size: 12px;
    color: #888;
    margin-bottom: 15px;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {

    /* dvh = dynamic viewport height: se adapta a la barra del navegador móvil */
    body {
        height: 100dvh;
        overflow: hidden;
    }

    #app-content {
        height: 100dvh;
        overflow: hidden;
    }

    /* Header compacto */
    .header {
        flex-wrap: nowrap;
        padding: 6px 10px;
        gap: 6px;
        flex-shrink: 0;
    }

    .header-left {
        gap: 8px;
        min-width: 0;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .header-titles {
        min-width: 0;
    }

    .test-title {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-name {
        font-size: 9px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .finish-btn {
        padding: 5px 8px;
        font-size: 10px;
        gap: 4px;
    }

    .timer {
        font-size: 9px;
    }

    #time-display {
        font-size: 12px;
    }

    /* Sidebar: ocultar */
    .sidebar {
        display: none;
    }

    /* Layout principal: columna flexible */
    .main-wrapper {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    .main-container {
        display: flex;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    /* Zona de contenido: scroll interno (no de página) */
    .content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 15px 12px 20px 12px;
        min-height: 0;
    }

    /* Pregunta */
    .question-header {
        font-size: 15px;
        gap: 8px;
        margin-bottom: 15px;
    }

    .question-text {
        line-height: 1.35;
    }

    /* Opciones */
    .options-container {
        gap: 14px;
        padding-left: 0;
    }

    .option-row {
        gap: 10px;
    }

    .option-letter {
        width: 26px;
        height: 26px;
        font-size: 12px;
        min-width: 26px;
        flex-shrink: 0;
    }

    .option-text {
        font-size: 13px;
        line-height: 1.4;
    }

    /* Navegación Anterior/Siguiente */
    .navigation-buttons {
        margin-top: 20px;
        padding-top: 12px;
        gap: 8px;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
        gap: 5px;
    }

    .pagination-info {
        font-size: 11px;
    }

    /* Panel inferior: al fondo pero NO se superpone */
    .bottom-panel {
        position: relative !important;
        flex-shrink: 0;
        border-top: 3px solid #0A8442;
    }

    .toggle-panel-btn {
        padding: 10px 15px;
        font-size: 14px;
        font-weight: 700;
        background: #f0f3f1;
    }

    .panel-content {
        max-height: 110px;
    }

    .grid-item {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }

    /* Ocultar leyenda para ganar espacio */
    .legend {
        display: none !important;
    }

    /* Modal */
    .modal-box {
        width: 90%;
        padding: 25px 18px;
    }

    .score-text {
        font-size: 15px;
    }

    .status-pass,
    .status-fail {
        font-size: 18px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions .btn {
        width: 100%;
    }

    /* Selección de test */
    .test-selection-overlay {
        padding: 10px;
    }

    .test-selection-container {
        margin-top: 5px;
    }

    .test-selection-header h2 {
        font-size: 18px;
    }

    .test-selection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
    }

    .test-card {
        height: 80px;
    }

    .test-card-label {
        font-size: 11px;
        padding: 3px 6px;
    }

    /* Pantalla de selección de modo */
    .start-box {
        padding: 20px 15px;
        width: 95%;
    }

    .start-box h2 {
        font-size: 18px;
    }

    .start-box p {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .junta-logo {
        height: 50px;
    }

    .mode-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .mode-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }

    .mode-btn {
        padding: 14px;
    }

    .mode-btn h3 {
        font-size: 14px;
    }

    .mode-btn p {
        font-size: 12px;
    }
}