/**
 * Tokutei Exams - Frontend Styles
 */

/* ===== FONT LOADING ===== */
/* Google Fonts - Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;900&display=swap');

/* Japanese Educational Font - UDDigiKyokashoN (Full version) */
@font-face {
    font-family: 'UDDigiKyokashoN-R';
    src: url('../fonts/UDDigiKyokashoN-R.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===== FONT SYSTEM ===== */
:root {
    --font-japanese: 'UDDigiKyokashoN-R', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'YuGothic', 'Meiryo', 'MS PGothic', sans-serif;
    --font-primary: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ===== LAYOUT ===== */
.te-app {
    font-family: 'Montserrat', sans-serif;
    color: #333333;
    line-height: 1.6;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Hide theme elements when inside shortcode */
.page-content .te-app {
    margin-top: -60px; /* Pull up to overlap theme page title */
}

.page-content > .te-app ~ * {
    display: none; /* Hide anything after plugin */
}

/* Hide theme page header when plugin is present */
.post-6736 .page-header,
.page-template .page-header {
    display: none;
}

/* Hide site header on exam pages only */
body.page-id-6736 #site-header {
    display: none;
}

/* Hide theme sidebar on exam pages */
body.page-id-6736 #sidebar,
body.page-id-6736 .sidebar,
body.page-id-6736 aside {
    display: none;
}

/* Make content full width when sidebar is hidden */
body.page-id-6736 #primary,
body.page-id-6736 .site-main,
body.page-id-6736 main {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Headings inside plugin use Montserrat with Japanese fallback */
.te-app h1,
.te-app h2,
.te-app h3,
.te-app h4,
.te-app h5,
.te-app h6 {
    font-family: 'Montserrat', 'UDDigiKyokashoN-R', sans-serif !important;
}

.te-app * {
    box-sizing: border-box;
}

.te-container {
    flex: 1;
    max-width: 1200px;
    margin: 0;
    padding: 20px;
    position: relative; /* For absolute positioned logo */
}

.te-main-content {
    width: 100%;
    max-width: 100%;
}

/* ===== GLOBAL HEADING STYLES ===== */
.te-app h1,
.te-app h2,
.te-app h3,
.te-app h4,
.te-app h5,
.te-app h6 {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    text-align: left;
}

/* Exception: Center align for card titles */
.te-app .te-level-card-title,
.te-app .te-exam-card-title {
    text-align: center !important;
    font-family: 'Montserrat', sans-serif !important;
    line-height: 1.4 !important;
}

/* ===== PAGE HEADER ===== */
.te-page-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f1f5f9;
    position: relative;
}

.te-page-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(to right, #8b5cf6, #a855f7);
}

.te-breadcrumb {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 15px;
}

.te-breadcrumb-item {
    margin-right: 10px;
}

.te-breadcrumb-item:not(:last-child)::after {
    content: ' › ';
    margin-left: 10px;
}

.te-breadcrumb-item.active {
    color: #7c3aed;
    font-weight: 600;
}

.te-breadcrumb-link {
    color: #3b82f6;
    cursor: pointer;
    transition: color 0.2s ease;
}

.te-breadcrumb-link:hover {
    color: #1e40af;
    text-decoration: underline;
}

/* Logo at top-right corner - aligned with page title, responsive */
.te-corner-logo {
    position: absolute;
    top: 50px;
    right: 30px;
    width: 120px;
    height: auto;
    z-index: 100;
    filter: drop-shadow(0 2px 8px rgba(124, 58, 237, 0.15));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease, width 0.3s ease, top 0.3s ease, right 0.3s ease;
}

.te-corner-logo:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 6px 16px rgba(124, 58, 237, 0.3));
}

@media (max-width: 1024px) {
    .te-corner-logo {
        width: 100px;
        top: 40px;
        right: 25px;
    }
}

@media (max-width: 768px) {
    .te-corner-logo {
        display: none;
    }
}

.te-app .te-page-title,
h1.te-page-title,
#te-page-title {
    font-size: 48px !important;
    font-weight: 700 !important;
    margin: 0 0 16px 0 !important;
    padding: 8px 0 !important;
    background: linear-gradient(135deg, #1e40af 0%, #7c3aed 50%, #4338ca 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    letter-spacing: 0.5px !important;
    /* Use Montserrat for BOTH Vietnamese and Japanese text */
    font-family: 'Montserrat', sans-serif !important;
    line-height: 1.4 !important;
    display: inline-block !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Ruby text in page title - use same font as parent (Montserrat) */
.te-app .te-page-title ruby,
.te-app h1.te-page-title ruby,
h1.te-page-title ruby,
#te-page-title ruby,
.te-page-title ruby {
    line-height: 1.4 !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    /* Use Montserrat for Japanese kanji too */
    font-family: 'Montserrat', sans-serif !important;
}

.te-app .te-page-title ruby rt,
h1.te-page-title ruby rt,
#te-page-title ruby rt {
    font-size: 18px !important;
    color: #ea580c !important;
    font-weight: 400 !important;
    font-family: 'UDDigiKyokashoN-R', sans-serif !important;
    /* Ruby annotation keeps orange color, base text inherits gradient */
    -webkit-text-fill-color: #ea580c !important;
    background: none !important;
}

.te-page-subtitle {
    font-size: 18px;
    color: #6b7280;
    font-weight: 500;
    margin: 16px 0 0 0;
    padding-left: 4px;
    border-left: 4px solid #1e40af;
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.05) 0%, transparent 100%);
    padding: 8px 0 8px 16px;
    border-radius: 0 6px 6px 0;
}

/* ===== CONTROL PANEL ===== */
.te-control-panel {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    padding: 20px 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.te-control-group {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 4px 0;
}

.te-control-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-right: 4px;
}

.te-control-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.te-control-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.te-control-btn[data-active="true"],
.te-control-btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: #10b981;
    color: white;
}

.te-control-icon {
    font-size: 12px;
}

.te-control-text {
    font-size: 12px;
}

.te-submit-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-color: #10b981;
    font-weight: 600;
    padding: 10px 20px;
}

.te-submit-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    border-color: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Exam Timer */
.te-exam-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 2px solid #7c3aed;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #7c3aed;
}

/* Level Cards Grid */
.te-levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.te-exams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.te-level-card,
.te-exam-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

/* Exam cards - smaller and more compact like level cards */
.te-exam-card {
    padding: 24px 20px;
}

/* Color-coded top borders for levels */
.te-level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: #7c3aed;
}

.te-level-card[data-level-id="1"]::before,
.te-level-card:nth-child(1)::before {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%); /* N5 - Red */
}

.te-level-card[data-level-id="2"]::before,
.te-level-card:nth-child(2)::before {
    background: linear-gradient(90deg, #f97316 0%, #ea580c 100%); /* N4 - Orange */
}

.te-level-card[data-level-id="3"]::before,
.te-level-card:nth-child(3)::before {
    background: linear-gradient(90deg, #eab308 0%, #ca8a04 100%); /* N3 - Yellow */
}

.te-level-card[data-level-id="4"]::before,
.te-level-card:nth-child(4)::before {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%); /* N2 - Green */
}

.te-level-card[data-level-id="5"]::before,
.te-level-card:nth-child(5)::before {
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%); /* N1 - Blue */
}

.te-level-card:hover,
.te-exam-card:hover {
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.15);
    transform: translateY(-5px);
}

/* Hover color glow for each level */
.te-level-card[data-level-id="1"]:hover,
.te-level-card:nth-child(1):hover {
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.2);
}

.te-level-card[data-level-id="2"]:hover,
.te-level-card:nth-child(2):hover {
    box-shadow: 0 10px 30px rgba(249, 115, 22, 0.2);
}

.te-level-card[data-level-id="3"]:hover,
.te-level-card:nth-child(3):hover {
    box-shadow: 0 10px 30px rgba(234, 179, 8, 0.2);
}

.te-level-card[data-level-id="4"]:hover,
.te-level-card:nth-child(4):hover {
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}

.te-level-card[data-level-id="5"]:hover,
.te-level-card:nth-child(5):hover {
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.2);
}

.te-level-card-icon,
.te-exam-card-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.te-level-card-title,
.te-exam-card-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 10px 0;
    font-family: 'Montserrat', sans-serif !important;
    line-height: 1.4 !important;
    text-align: center !important;
}

/* Ruby text in exam card title */
.te-exam-card-title ruby {
    line-height: 2.2 !important;
    font-size: inherit !important;
}

.te-exam-card-title ruby rt {
    font-size: 12px !important;
    color: #ea580c !important;
    font-weight: 400 !important;
}

.te-level-card-description,
.te-exam-card-description {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px 0;
    min-height: 40px;
}

.te-exam-info {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    padding: 15px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.te-exam-info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 13px;
}

.te-info-icon {
    font-size: 20px;
}

.te-level-card-btn,
.te-exam-card-btn {
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.te-level-card-btn:hover,
.te-exam-card-btn:hover {
    background: #6d28d9;
}

/* ===== QUESTION GROUP STYLES ===== */
.te-question-group {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.te-question-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.te-question-title {
    font-size: 22px;
    font-weight: 600;
    color: #047857;
    margin: 0 0 16px 0;
    font-family: var(--font-japanese) !important;
    padding-bottom: 8px;
    border-bottom: 2px solid #10b981;
    line-height: 2.2 !important;
}

/* Ruby text in headings - Use !important to override user agent styles */
.te-question-title ruby,
h1.te-question-title ruby,
h2.te-question-title ruby,
h3.te-question-title ruby,
h4.te-question-title ruby {
    line-height: 2.2 !important;
    font-size: inherit !important;
}

.te-question-title ruby rt,
h1.te-question-title ruby rt,
h2.te-question-title ruby rt,
h3.te-question-title ruby rt,
h4.te-question-title ruby rt {
    font-size: 11px !important;
    color: #ea580c !important;
    font-weight: 400 !important;
}

/* ===== SECTION TITLE ===== */
.te-app .te-section-title,
h2.te-section-title,
.te-section-title {
    color: #1e40af !important;
    font-size: 1.8rem !important;
    font-weight: 600 !important;
    margin-bottom: 30px !important;
    margin-top: 40px !important;
    padding: 15px !important;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    border-radius: 10px !important;
    border-left: 5px solid #1e40af !important;
    /* Use Montserrat for section titles (like old plugin) */
    font-family: 'Montserrat', sans-serif !important;
    line-height: 2.2 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.te-section-title:first-child {
    margin-top: 0;
}

.te-section-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Ruby text in section titles */
.te-section-title ruby {
    line-height: 2.2 !important;
    font-size: inherit !important;
    /* Use Montserrat for ruby in section titles too */
    font-family: 'Montserrat', sans-serif !important;
}

.te-section-title ruby rt {
    font-size: 14px !important;
    color: #ea580c !important;
    font-weight: 400 !important;
}

.te-question-content {
    margin-bottom: 24px;
}

.te-question-number {
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 10px;
    font-size: 20px;
}

.te-question-text {
    background: linear-gradient(135deg, #f5f5f5 0%, #fbfbfb 100%);
    padding: 26px 20px 20px 20px;
    border-radius: 8px;
    font-family: var(--font-japanese) !important;
    font-size: 22px;
    line-height: 2.2 !important;
    margin-bottom: 16px;
    border-left: 4px solid #1e40af;
    color: #1e293b;
    font-weight: 500;
    text-indent: 1em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.te-question-vietnamese {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    padding: 16px;
    border-radius: 6px;
    color: #15803d;
    font-size: 15px;
    line-height: 1.7;
    font-style: italic;
    text-indent: 1em;
    margin-bottom: 16px;
}

/* ===== ANSWERS STYLES ===== */
.te-answers {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s ease;
}

.te-answers:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.te-answer-list {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 2x2 Grid layout for short answers */
.te-answer-list.te-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.te-answer-list.te-grid-2x2 .te-answer-option {
    margin-bottom: 0; /* Remove default margin in grid */
    height: auto;
    min-height: 60px; /* Ensure consistent height */
    display: flex;
    align-items: center;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    text-indent: 0 !important;
}

.te-answer-list.te-grid-2x2 .te-answer-content {
    width: 100%;
    overflow: hidden;
}

.te-answer-list.te-grid-2x2 .te-answer-japanese {
    word-break: break-all;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.te-answer-option {
    position: relative;
    padding: 18px 16px 16px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    background: #fafafa;
    transition: all 0.3s ease;
    overflow: visible;
    margin-bottom: 12px;
}

.te-answer-option:hover {
    border-color: #f59e0b;
    background: #fffbeb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.te-answer-option.selected,
.te-answer-option.te-selected {
    border-color: #f59e0b;
    background: #fffbeb;
}

.te-answer-option.te-selected .te-answer-letter {
    background: #d97706;
}

.te-answer-option.correct-answer,
.te-answer-option.te-correct-answer {
    background: #ecfdf5;
    border-color: #22c55e;
    animation: te-highlight 0.5s ease;
}

.te-answer-option.te-correct-answer .te-answer-letter {
    background: #22c55e;
}

.te-answer-option.wrong-answer,
.te-answer-option.te-wrong-answer {
    background: #fef2f2;
    border-color: #ef4444;
}

.te-answer-option.te-wrong-answer .te-answer-letter {
    background: #ef4444;
}

.te-answer-option.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.te-answer-letter {
    background: #f59e0b;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    position: absolute;
    top: -14px;
    left: -14px;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.te-answer-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    text-indent: 0;
}

.te-answer-japanese {
    font-family: var(--font-japanese) !important;
    font-size: 22px;
    line-height: 2.2 !important;
    color: #1e293b;
    font-weight: 500;
    text-align: justify;
    text-indent: 1em;
}

.te-answer-vietnamese {
    color: #64748b;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.4;
    margin-top: 4px;
}

@keyframes te-highlight {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.te-question-result {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
}

/* ===== PARAGRAPH STYLES ===== */
.te-paragraph {
    margin-bottom: 32px;
}

.te-paragraph:last-child {
    margin-bottom: 0;
}

.te-japanese-text {
    background: linear-gradient(135deg, #f5f5f5 0%, #fbfbfb 100%);
    border-left: 4px solid #a855f7;
    padding: 26px 20px 20px 20px;
    border-radius: 8px;
    font-family: var(--font-japanese) !important;
    font-size: 22px;
    line-height: 2.2 !important;
    color: #1e293b;
    text-indent: 1em;
    text-align: justify;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.te-text-content {
    background: linear-gradient(135deg, #f5f5f5 0%, #fbfbfb 100%);
    border-left: 4px solid #a855f7;
    padding: 26px 20px 20px 20px;
    border-radius: 8px;
    font-family: var(--font-japanese) !important;
    line-height: 2.2 !important;
    color: #1e293b;
    text-indent: 1em;
    text-align: justify;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.te-vietnamese {
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    padding: 16px;
    border-radius: 6px;
    color: #15803d;
    font-size: 15px;
    line-height: 1.7;
    text-indent: 1em;
    text-align: justify;
    margin-bottom: 16px;
}

.te-hints {
    background: linear-gradient(135deg, #f5f5f5 0%, #fbfbfb 100%);
    border-left: 4px solid #f59e0b;
    padding: 16px;
    border-radius: 6px;
    color: #92400e;
    font-style: italic;
    font-size: 15px;
    line-height: 1.6;
    text-align: justify;
    margin-bottom: 16px;
}

/* Image */
.te-image-content {
    text-align: center;
    margin: 20px 0;
}

.te-content-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.te-image-caption {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Results - New Design */
.te-result-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 10px;
    animation: fadeInUp 0.6s ease-out;
}

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

.te-result-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    max-width: 550px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}

.te-result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #10b981 0%, #3b82f6 50%, #8b5cf6 100%);
}

.te-result-card.failed::before {
    background: linear-gradient(90deg, #ef4444 0%, #f97316 100%);
}

/* Result Header */
.te-result-header {
    margin-bottom: 25px;
}

.te-result-icon-large {
    font-size: 60px;
    margin-bottom: 10px;
    animation: bounceIn 0.8s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.te-result-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #1a1a1a;
    font-family: 'Montserrat', sans-serif !important;
}

.te-result-performance {
    font-size: 16px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 16px;
    display: inline-block;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Score Circle */
.te-result-score-circle {
    position: relative;
    margin: 20px auto 30px;
    width: 160px;
    height: 160px;
}

.te-score-ring {
    transform: rotate(-90deg);
}

.te-score-ring-bg {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 12;
}

.te-score-ring-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dasharray 1.5s ease-out;
}

.te-score-ring-fill.passed {
    stroke: #10b981;
}

.te-score-ring-fill.failed {
    stroke: #ef4444;
}

.te-score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.te-score-percentage {
    font-size: 38px;
    font-weight: 900;
    color: #1a1a1a;
    line-height: 1;
    margin-bottom: 4px;
}

.te-score-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Statistics Grid */
.te-result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 30px;
}

.te-result-stat {
    background: white;
    padding: 15px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.te-result-stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.te-stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.te-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 3px;
}

.te-stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

/* Result Actions */
.te-result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.te-result-actions .te-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.te-btn-icon {
    font-size: 16px;
}

.te-result-actions .te-btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.te-result-actions .te-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
}

.te-result-actions .te-btn-secondary {
    background: white;
    color: #7c3aed;
    border: 2px solid #7c3aed;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.te-result-actions .te-btn-secondary:hover {
    transform: translateY(-2px);
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Generic buttons */
.te-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.te-btn-primary {
    background: #7c3aed;
    color: white;
}

.te-btn-primary:hover {
    background: #6d28d9;
}

.te-btn-secondary {
    background: #e5e7eb;
    color: #1a1a1a;
}

.te-btn-secondary:hover {
    background: #d1d5db;
}

/* Empty State */
.te-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.te-empty-logo {
    width: 150px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.2));
}

.te-empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.te-empty-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 10px 0;
}

.te-empty-description {
    font-size: 16px;
    color: #666;
    margin: 0;
}

/* Loading */
.te-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.te-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #7c3aed;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scroll to Top Button */
.te-scroll-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.te-scroll-to-top-btn:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .te-levels-grid,
    .te-exams-grid {
        grid-template-columns: 1fr;
    }

    .te-control-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .te-control-group {
        flex-wrap: wrap;
    }

    .te-result-actions {
        flex-direction: column;
    }

    .te-page-title {
        font-size: 24px;
    }
}

/* ============================================
   RUBY TEXT (FURIGANA) SUPPORT
   ============================================ */

/* Ruby text container */
ruby {
    line-height: 2.2;
    font-size: inherit;
    color: inherit !important;
}

/* Furigana text above kanji */
ruby rt {
    font-size: 11px;
    color: #ea580c; /* Orange color for furigana */
    font-weight: 400;
    user-select: none;
}

/* Ruby parentheses (fallback for non-supporting browsers) */
ruby rp {
    display: none !important;
}

/* Hide ruby when toggled off */
.te-content.hide-ruby ruby rt,
.te-content.hide-ruby ruby rp {
    display: none !important;
}

/* Vietnamese translation styling */
.te-vietnamese {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 6px;
    color: #92400e;
    font-size: 15px;
    font-style: italic;
    line-height: 1.6;
}

/* Question Vietnamese */
.te-question-vietnamese {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 4px;
    color: #92400e;
    font-size: 14px;
    font-style: italic;
}

/* Answer Vietnamese */
.te-answer-vietnamese {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    margin-top: 4px;
}

/* Japanese text blocks - Use !important to ensure font is applied */
.te-japanese-text,
.te-question-text,
.te-answer-japanese,
.te-text-content {
    font-family: var(--font-japanese) !important;
    line-height: 2.2 !important;
}

/* Text content in paragraphs */
.te-text-content {
    background: linear-gradient(135deg, #f5f5f5 0%, #fbfbfb 100%);
    border-left: 4px solid #a855f7;
    padding: 20px;
    border-radius: 8px;
    font-size: 18px;
    line-height: 2.2;
    color: #1e293b;
    margin-bottom: 16px;
}

/* Hints styling */
.te-hints {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    border-radius: 6px;
    color: #92400e;
    font-style: italic;
    font-size: 14px;
    margin: 8px 0;
}

.te-hint {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    padding: 10px 14px;
    border-radius: 4px;
    color: #92400e;
    font-size: 13px;
    margin-top: 8px;
}

/* ============================================
   SHORTCODE STYLING
   ============================================ */

/* Colored underlines */
.te-underline-red {
    text-decoration: underline;
    text-decoration-color: #e74c3c;
    text-decoration-thickness: 2px;
}

.te-underline-blue {
    text-decoration: underline;
    text-decoration-color: #3498db;
    text-decoration-thickness: 2px;
}

.te-underline-green {
    text-decoration: underline;
    text-decoration-color: #2ecc71;
    text-decoration-thickness: 2px;
}

/* Highlights */
.te-highlight {
    background-color: #fef08a;
    padding: 2px 4px;
    border-radius: 3px;
}

.te-highlight-red {
    background-color: #fecaca;
    padding: 2px 4px;
    border-radius: 3px;
}

.te-highlight-green {
    background-color: #bbf7d0;
    padding: 2px 4px;
    border-radius: 3px;
}

.te-highlight-blue {
    background-color: #bfdbfe;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Boxes */
.te-box {
    padding: 16px;
    border-radius: 8px;
    margin: 12px 0;
}

.te-box-black {
    border: 2px solid #1e293b;
}

.te-box-blue {
    border: 2px solid #3498db;
}

.te-box-red {
    border: 2px solid #e74c3c;
}

.te-box-dashed {
    border-style: dashed !important;
}

/* Alignment */
.te-align-left {
    display: block;
    text-align: left;
}

.te-align-center {
    display: block;
    text-align: center;
}

.te-align-right {
    display: block;
    text-align: right;
}

.te-align-justify {
    display: block;
    text-align: justify;
}

/* No indent */
.te-no-indent {
    text-indent: 0 !important;
}

/* Table styling */
.te-table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
}

.te-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.te-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.te-table th {
    padding: 12px 16px;
    font-weight: 600;
    text-align: left;
    border-bottom: 2px solid #667eea;
}

.te-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.te-table tbody tr:hover {
    background-color: #f8fafc;
}

/* ============================================
   AUDIO PLAYER SUPPORT
   ============================================ */

.te-audio-content {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid #0ea5e9;
    padding: 20px;
    border-radius: 8px;
    margin: 16px 0;
}

.te-audio-player {
    margin-bottom: 12px;
}

.te-audio-element {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    outline: none;
}

.te-audio-element::-webkit-media-controls-panel {
    background-color: #f8fafc;
}

.te-audio-title {
    font-size: 15px;
    font-weight: 600;
    color: #0369a1;
    margin-bottom: 8px;
}

.te-audio-transcript {
    margin-top: 12px;
    font-size: 14px;
}

/* Image content styling */
.te-image-content {
    padding: 16px;
    text-align: center;
    margin: 16px 0;
}

.te-content-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.te-image-caption {
    margin-top: 12px;
    font-size: 14px;
    color: #64748b;
    font-style: italic;
}


/* ===== UNIFIED FONT SIZE SYSTEM ===== */
/* This system provides clean, conflict-free font sizing with 3 main sizes */

/* Default font size when no font class is applied */
#te-exam-content .te-japanese-text,
#te-exam-content .te-text-content,
#te-exam-content .te-question-text,
#te-exam-content .te-answer-japanese,
#te-exam-content .te-vietnamese {
    font-size: 22px; /* Default medium size */
}

/* Base font sizes applied to #te-exam-content with classes */
#te-exam-content.font-small,
#te-exam-content.font-small .te-japanese-text,
#te-exam-content.font-small .te-text-content,
#te-exam-content.font-small .te-question-text,
#te-exam-content.font-small .te-answer-japanese,
#te-exam-content.font-small .te-vietnamese {
    font-size: 18px !important;
}

#te-exam-content.font-medium,
#te-exam-content.font-medium .te-japanese-text,
#te-exam-content.font-medium .te-text-content,
#te-exam-content.font-medium .te-question-text,
#te-exam-content.font-medium .te-answer-japanese,
#te-exam-content.font-medium .te-vietnamese {
    font-size: 22px !important;
}

#te-exam-content.font-large,
#te-exam-content.font-large .te-japanese-text,
#te-exam-content.font-large .te-text-content,
#te-exam-content.font-large .te-question-text,
#te-exam-content.font-large .te-answer-japanese,
#te-exam-content.font-large .te-vietnamese {
    font-size: 24px !important;
}

/* ===== RUBY TEXT SYSTEM ===== */
/* Ruby base element (kanji) inherits main text size */
#te-exam-content ruby {
    line-height: 2.2;
    font-size: inherit; /* Inherits from parent font size */
    color: inherit !important; /* Force inherit parent color */
}

/* Default ruby text size when no font class is applied */
#te-exam-content ruby rt {
    font-size: 11px; /* 50% of default 22px */
    color: #ea580c;
    font-weight: 400;
}

/* Ruby text (rt) is always 50% of main text size */
#te-exam-content.font-small ruby rt {
    font-size: 9px !important; /* 50% of 18px */
}

#te-exam-content.font-medium ruby rt {
    font-size: 11px !important; /* 50% of 22px */
}

#te-exam-content.font-large ruby rt {
    font-size: 12px !important; /* 50% of 24px */
}

/* Ruby parentheses (rp) always hidden */
#te-exam-content ruby rp {
    display: none !important;
}

/* Ruby toggle functionality - hides ruby when .hide-ruby class is applied */
#te-exam-content.hide-ruby ruby rt,
#te-exam-content.hide-ruby ruby rp {
    display: none !important;
}

/* ===== CONTENT HEADINGS ===== */
/* Question Group titles (h3) - responsive to font size controls */
#te-exam-content h3.te-question-title {
    font-size: 22px; /* Default size */
}

#te-exam-content.font-small h3.te-question-title {
    font-size: 18px;
}

#te-exam-content.font-medium h3.te-question-title {
    font-size: 22px;
}

#te-exam-content.font-large h3.te-question-title {
    font-size: 26px;
}



/* ===== RESPONSIVE DESIGN ===== */

/* Tablet and below - adjust grid */
@media (max-width: 768px) {
    .te-answer-list.te-grid-2x2 {
        gap: 12px; /* Smaller gap on mobile */
    }

    .te-answer-list.te-grid-2x2 .te-answer-option {
        min-height: 50px; /* Smaller height on mobile */
        padding: 14px 12px 12px 12px;
    }

    .te-answer-list.te-grid-2x2 .te-answer-japanese {
        font-size: 18px !important; /* Smaller font on mobile */
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    .te-answer-list.te-grid-2x2 {
        gap: 10px; /* Even smaller gap */
    }

    .te-answer-list.te-grid-2x2 .te-answer-option {
        min-height: 45px;
        padding: 12px 10px 10px 10px;
    }

    .te-answer-list.te-grid-2x2 .te-answer-japanese {
        font-size: 16px !important;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .te-levels-grid {
        grid-template-columns: 1fr;
    }

    .te-exams-grid {
        grid-template-columns: 1fr;
    }

    /* Reduce page title size significantly on mobile */
    .te-app .te-page-title,
    h1.te-page-title,
    #te-page-title {
        font-size: 22px !important;
        line-height: 1.3 !important;
        margin-bottom: 10px !important;
        padding-right: 0 !important;
    }

    .te-page-subtitle {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }

    /* Fix page-title ruby size on mobile */
    .te-app .te-page-title ruby,
    .te-app h1.te-page-title ruby,
    h1.te-page-title ruby,
    #te-page-title ruby {
        line-height: 1.3 !important;
    }

    .te-app .te-page-title ruby rt,
    h1.te-page-title ruby rt,
    #te-page-title ruby rt {
        font-size: 10px !important;  /* Giảm từ 18px → 10px */
    }

    /* Center align and reduce exam/level card title on mobile */
    .te-level-card-title,
    .te-exam-card-title {
        font-size: 18px !important;
        line-height: 1.5 !important;
        margin-bottom: 8px !important;
        text-align: center !important;
    }

    .te-exam-card-title ruby rt {
        font-size: 10px !important;
    }

    .te-container {
        padding: 10px;
    }

    /* Reposition logo on mobile - smaller and in safe area */
    .te-corner-logo {
        top: 10px !important;
        right: 10px !important;
        width: 60px !important;
    }

    /* Fix section title overflow on mobile */
    .te-app .te-section-title,
    h2.te-section-title,
    .te-section-title {
        font-size: 1.3rem !important;
        padding: 12px 10px !important;
        margin-bottom: 20px !important;
        margin-top: 25px !important;
        line-height: 1.6 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
    }

    .te-section-title ruby rt {
        font-size: 10px !important;
    }

    /* Reduce question and answer font sizes to match on mobile */
    .te-question-text {
        font-size: 18px !important;
        padding: 20px 12px 16px 12px !important;
        line-height: 1.8 !important;
    }

    .te-answer-japanese {
        font-size: 18px !important;
        line-height: 1.8 !important;
    }

    .te-answer-option {
        padding: 14px 12px 12px 12px !important;
    }

    /* Reduce question number size */
    .te-question-number {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }

    /* Reduce question content padding */
    .te-question-content {
        margin-bottom: 20px !important;
    }

    .te-question-group {
        padding: 16px 12px !important;
        margin-bottom: 20px !important;
    }
}

/* ===== INLINE SUBMIT BUTTON (At end of exam) ===== */
.te-submit-container {
    margin: 60px 0 40px;
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    border-radius: 16px;
    border: 2px solid #fecaca;
}

.te-submit-exam-btn-inline {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 20px 60px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 24px rgba(245, 158, 11, 0.5);
        transform: scale(1.02);
    }
}

.te-submit-exam-btn-inline:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.6);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.te-submit-exam-btn-inline:active {
    transform: translateY(-1px) scale(1.02);
}

.te-submit-icon {
    font-size: 24px;
}

.te-submit-text {
    font-weight: 700;
}

/* ===== FLOATING RUBY TOGGLE BUTTON (Like old plugin) ===== */
.te-floating-ruby-btn {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .te-floating-ruby-btn {
        bottom: 4.5rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .te-ruby-icon {
        font-size: 16px;
    }
}

.te-floating-ruby-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 24px rgba(234, 88, 12, 0.4);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.te-floating-ruby-btn[data-active="true"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.te-floating-ruby-btn[data-active="true"]:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.te-ruby-icon {
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    display: block;
    text-align: center;
}

/* ===== TIMER REPOSITIONED ===== */
.te-exam-timer {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #7c3aed;
    border-radius: 50px;
    font-size: 20px;
    font-weight: 700;
    color: #7c3aed;
    z-index: 9997;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.2);
    transition: all 0.3s ease;
}

.te-exam-timer:hover {
    transform: scale(1.05);
}

/* ===== SIDEBAR NAVIGATION ===== */
.te-sidebar-nav {
    position: sticky;
    top: 100px;
    width: 280px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    z-index: 9996;
    overflow-y: auto;
    font-family: 'Montserrat', sans-serif;
    align-self: flex-start;
    margin: 20px 20px 20px 0;
    flex-shrink: 0;
}

/* Responsive: Fix sidebar on mobile screens */
@media (max-width: 1200px) {
    .te-app {
        flex-direction: column;
    }

    .te-sidebar-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 300px;
        max-height: 100vh;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 10000;
        border-radius: 0;
    }

    .te-sidebar-nav.mobile-visible {
        transform: translateX(0);
    }

    /* Add overlay when sidebar is open on mobile */
    .te-sidebar-nav.mobile-visible::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

.te-sidebar-header {
    position: sticky;
    top: 0;
    background: #ffffff;
    padding: 16px;
    border-bottom: 2px solid #e5e7eb;
    z-index: 1001;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.te-sidebar-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.4;
    color: #ef4444;
    text-align: center;
}

.te-sidebar-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 700;
    background: #ffffff;
    color: #1f2937;
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.te-sidebar-content {
    padding: 16px;
}

/* Big Section (e.g., 言語知識（文字・語彙）) */
.te-sidebar-big-section {
    margin-bottom: 24px;
}

.te-sidebar-big-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e40af;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    padding: 10px 12px;
    margin: 0 -16px 12px -16px;
    border-left: 4px solid #1e40af;
    text-align: left;
    line-height: 1.6;
    font-family: 'Montserrat', sans-serif !important;
}

/* Support ruby text in big section title */
.te-sidebar-big-section-title ruby {
    line-height: 2 !important;
    font-size: inherit !important;
}

.te-sidebar-big-section-title ruby rt {
    font-size: 9px !important;
    color: #ea580c !important;
    font-weight: 400 !important;
}

/* Mondai within section */
.te-sidebar-section {
    margin-bottom: 20px;
    margin-left: 8px;
}

.te-sidebar-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #047857;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #10b981;
    display: flex;
    align-items: center;
    gap: 8px;
}

.te-sidebar-section-stats {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    margin-left: auto;
}

.te-sidebar-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.te-sidebar-question-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.te-sidebar-question-num {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    min-width: 28px;
}

.te-sidebar-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    flex: 1;
}

.te-sidebar-option {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.te-sidebar-option:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.te-sidebar-option.selected {
    background: #3b82f6;
    border-color: #2563eb;
    color: white;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.te-sidebar-option.correct {
    background: #ef4444;
    border-color: #dc2626;
    color: white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.te-sidebar-option.incorrect {
    background: #10b981;
    border-color: #059669;
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.te-timer-icon {
    font-size: 24px;
}

/* ===== FONT SIZE & DISPLAY CONTROLS ===== */
.te-control-label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    margin-right: 8px;
    white-space: nowrap;
}

/* Font size classes for exam content */
#te-exam-content {
    font-size: 22px;
}

#te-exam-content.font-small {
    font-size: 18px;
}

#te-exam-content.font-medium {
    font-size: 22px;
}

#te-exam-content.font-large {
    font-size: 26px;
}

/* Section titles with different font sizes */
#te-exam-content.font-small .te-section-title {
    font-size: 1.5rem !important;
}

#te-exam-content.font-medium .te-section-title {
    font-size: 1.8rem !important;
}

#te-exam-content.font-large .te-section-title {
    font-size: 2.2rem !important;
}

/* Ruby font sizes */
#te-exam-content.font-small ruby rt {
    font-size: 9px !important;
}

#te-exam-content.font-medium ruby rt {
    font-size: 11px !important;
}

#te-exam-content.font-large ruby rt {
    font-size: 13px !important;
}

/* Question text font sizes */
#te-exam-content.font-small .te-question-text,
#te-exam-content.font-small .te-answer-japanese,
#te-exam-content.font-small .te-japanese-text {
    font-size: 18px !important;
}

#te-exam-content.font-large .te-question-text,
#te-exam-content.font-large .te-answer-japanese,
#te-exam-content.font-large .te-japanese-text {
    font-size: 26px !important;
}


/* ===== RESULTS MODAL ===== */
.te-results-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
}

.te-results-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.te-results-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.te-results-modal-header {
    padding: 24px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.te-results-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.te-results-modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.te-results-modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.te-results-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.te-results-modal-footer {
    padding: 20px 24px;
    border-top: 2px solid #e5e7eb;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.te-results-modal-footer .te-btn {
    min-width: 120px;
}

/* Modal Results Content */
.te-modal-results-score {
    text-align: center;
    padding: 32px 0;
}

.te-modal-score-circle {
    width: 180px;
    height: 180px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.3);
}

.te-modal-score-number {
    font-size: 56px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
}

.te-modal-score-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 8px;
}

.te-modal-score-message {
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.te-modal-score-details {
    font-size: 16px;
    color: #6b7280;
}

.te-modal-results-stats {
    margin-top: 24px;
}

.te-modal-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.te-modal-stat-label {
    font-size: 15px;
    color: #4b5563;
    font-weight: 500;
}

.te-modal-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
}

.te-modal-stat-value.correct {
    color: #10b981;
}

.te-modal-stat-value.incorrect {
    color: #ef4444;
}

/* Section breakdown in modal */
.te-modal-section-stats {
    margin-top: 24px;
}

.te-modal-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
}

.te-modal-section-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.te-modal-section-name {
    font-size: 14px;
    color: #4b5563;
    font-weight: 500;
}

.te-modal-section-score {
    font-size: 14px;
    font-weight: 600;
    color: #7c3aed;
}
