/* --- STYLES for v1.9.2 - COMPLETE & FULLY VERIFIED UI --- */

/* --- Part 1: Selector, Icons, and Buttons (Restored and Verified) --- */
#ahoreal-jlpt-selector {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #eef2f5;
    padding: 40px 10px;
    border-radius: 20px;
}

.level-icons-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
}

.level-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
}

.level-icon {
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease-in-out;
    -webkit-transition: all 0.2s ease-in-out;
    position: relative;
    box-shadow: 8px 8px 16px #d3d8db, -8px -8px 16px #ffffff;
    -webkit-box-shadow: 8px 8px 16px #d3d8db, -8px -8px 16px #ffffff;
}

/* Distinct Background Colors */
.level-icon[data-level-slug="n5"] { background-color: #e0f1ff; color: #006bb3; }
.level-icon[data-level-slug="n4"] { background-color: #e3fcef; color: #007a5a; }
.level-icon[data-level-slug="n3"] { background-color: #fff8e1; color: #b38600; }
.level-icon[data-level-slug="n2"] { background-color: #ffefe6; color: #cc5200; }
.level-icon[data-level-slug="n1"] { background-color: #f3e5f5; color: #6a1b9a; }

/* Sizing for the new layout */
.level-row-1 .level-icon { width: 90px; height: 90px; font-size: 24px; }  /* Small */
.level-row-2 .level-icon { width: 120px; height: 120px; font-size: 32px; } /* Medium */
.level-row-3 .level-icon { width: 150px; height: 150px; font-size: 40px; } /* Large */

/* Active "Pressed" Effect for Level Icons */
.level-icon.active {
    box-shadow: inset 8px 8px 16px rgba(0,0,0,0.1), inset -8px -8px 16px rgba(255,255,255,0.7);
    -webkit-box-shadow: inset 8px 8px 16px rgba(0,0,0,0.1), inset -8px -8px 16px rgba(255,255,255,0.7);
    transform: translateY(2px);
    -webkit-transform: translateY(2px);
}

/* General Container Style for Year & Topic sections */
.ahoreal-container {
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: max-height 0.7s ease-in-out, padding 0.7s ease-in-out, margin 0.7s ease-in-out;
    max-height: 0;
    padding: 0 10px;
    border-radius: 15px;
    margin: 0;
}

.ahoreal-container.open {
    max-height: 1000px;
    padding: 30px 10px;
    margin-top: 20px;
    background-color: #eef2f5;
    box-shadow: inset 6px 6px 12px #d3d8db, inset -6px -6px 12px #ffffff;
    -webkit-box-shadow: inset 6px 6px 12px #d3d8db, inset -6px -6px 12px #ffffff;
}

.ahoreal-container .container-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #5b6271;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #d3d8db;
}

/* General List Style */
.ahoreal-list {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 15px;
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.5s ease-out 0.3s, transform 0.5s ease-out 0.3s;
}

.ahoreal-container.open .ahoreal-list {
    opacity: 1; transform: translateY(0);
}

/* General 3D Button Style for Year & Topic */
.ahoreal-button {
    padding: 10px 15px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    -webkit-transition: all 0.2s ease-in-out;
    display: inline-block;
    text-align: center;
    border: none;
    cursor: pointer;
    color: #333;
    box-shadow: 4px 4px 8px #d3d8db, -4px -4px 8px #ffffff;
    -webkit-box-shadow: 4px 4px 8px #d3d8db, -4px -4px 8px #ffffff;
}
.ahoreal-button:hover {
    transform: translateY(-2px);
    -webkit-transform: translateY(-2px);
}
.ahoreal-button:active, .ahoreal-button.active {
    box-shadow: inset 4px 4px 8px #d3d8db, inset -4px -4px 8px #ffffff;
    -webkit-box-shadow: inset 4px 4px 8px #d3d8db, inset -4px -4px 8px #ffffff;
    transform: translateY(1px);
    -webkit-transform: translateY(1px);
}

/* Message Style */
.ahoreal-message { font-weight: bold; color: #5b6271; padding: 10px; }
.ahoreal-message.error { color: #c0392b; }
.ahoreal-loader { border: 4px solid #d3d8db; border-top: 4px solid #3d8fcc; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 20px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Part 2: Quiz Page Styles (Verified) --- */
/* REMOVED user-select: none to allow text highlighting for everyone */
#ahoreal-jlpt-quiz { max-width: 800px; margin: 20px auto; padding: 20px; background: #fff; border: 1px solid #ccc; font-family: 'Times New Roman', Times, serif; color: #000; }
#ahoreal-jlpt-quiz .quiz-title, #ahoreal-jlpt-quiz .quiz-topic h2 { font-size: 1.1em; font-weight: bold; text-align: center; border-bottom: 1px solid #ccc; padding-bottom: 15px; margin-bottom: 25px; }
#ahoreal-jlpt-quiz .quiz-title { font-size: 1.2em; border-bottom-style: double; border-bottom-width: 3px; }
.quiz-topic { display: none; } 
.quiz-topic.active { display: block; }
.quiz-question { margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px dashed #ccc; position: relative; } 
.quiz-question p { font-size: 1em; margin-bottom: 15px; }

/* FIX: Ensure strong tag is always bold on all devices */
.quiz-question p strong { font-weight: bold !important; }

/* NEW: Styles for Lesson Content */
.quiz-lesson-content {
    margin-bottom: 25px;
    padding: 15px;
    background-color: #f9f9f9;
    border-left: 4px solid #3d8fcc;
    line-height: 1.6;
}
.quiz-lesson-content p:last-child {
    margin-bottom: 0;
}
/* End New Styles */

.quiz-options label { display: block; margin-bottom: 10px; cursor: pointer; font-size: 1em; } 
.quiz-options input { margin-right: 10px; }
#quiz-navigation { text-align: center; margin-top: 30px; display: flex; justify-content: space-between; align-items: center; } 
#quiz-navigation button { padding: 10px 20px; font-size: 16px; cursor: pointer; }
.quiz-results-view .quiz-question { border-bottom: 1px solid #ccc; }
.quiz-options .result-correct { background-color: #d4edda; color: #155724; } 
.quiz-options .result-incorrect { background-color: #f8d7da; color: #721c24; }
.quiz-options .user-choice::before { content: '➔ '; font-weight: bold; }
.quiz-explanation { margin-top: 15px; padding: 10px; background: #f1f1f1; border: 1px solid #ddd; border-left: 4px solid #0073aa; }
#quiz-score-summary { margin-top: 20px; border-collapse: collapse; width: 100%; }
#quiz-score-summary th, #quiz-score-summary td { border: 1px solid #000; padding: 8px; text-align: left; }
#quiz-score-summary th { background-color: #f2f2f2; }
#redo-quiz-btn { display: block; margin: 0 auto; padding: 12px 30px; font-size: 18px; font-weight: bold; cursor: pointer; border: none; border-radius: 5px; background-color: #0073aa; color: white; transition: background-color 0.2s; }
#redo-quiz-btn:hover { background-color: #005a87; }
.feedback-icon { background: none; border: none; cursor: pointer; font-size: 18px; position: absolute; top: -5px; right: 0; opacity: 0.6; transition: opacity 0.2s; padding: 5px; }
.feedback-icon:hover { opacity: 1; }

#quiz-results-navigation { text-align: center; margin-top: 30px; }
#redo-quiz-btn { display: inline-block; vertical-align: middle; }
#cross-year-next-btn { background-color: #28a745; color: white; border: none; padding: 10px 30px; font-size: 18px; cursor: pointer; border-radius: 5px; margin-left: 10px; }
#cross-year-next-btn:hover { background-color: #218838; }


/* --- LEADERBOARD AND LOGIN PROMPT STYLES --- */
.ahoreal-login-prompt {
    padding: 15px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    margin: 20px auto;
    max-width: 800px;
    text-align: center;
    font-size: 1em;
}
.ahoreal-login-prompt span {
    margin-right: 15px;
    font-weight: bold;
    color: #856404;
}
.ahoreal-login-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: #007bff;
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.2s;
}
.ahoreal-login-button:hover {
    background-color: #0056b3;
}

.quiz-topic-leaderboard {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}
.leaderboard-table-wrapper {
    overflow-x: auto; /* Make table scrollable on small screens */
}
.quiz-topic-leaderboard h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #343a40;
}
.ahoreal-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Prevent table from collapsing too much */
}
.ahoreal-leaderboard-table th, 
.ahoreal-leaderboard-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
    white-space: nowrap; /* Prevent content from wrapping */
}
.ahoreal-leaderboard-table th {
    background-color: #e9ecef;
    font-weight: bold;
}
.ahoreal-leaderboard-table tr:last-child td {
    border-bottom: none;
}
/* New Top 3 Colors */
.ahoreal-leaderboard-table tr.top-1 { background-color: #fce1d4; font-weight: bold; } /* Pink/Rose */
.ahoreal-leaderboard-table tr.top-2 { background-color: #fff3cd; font-weight: bold; } /* Yellow/Orange */
.ahoreal-leaderboard-table tr.top-3 { background-color: #d4edda; font-weight: bold; } /* Green */

.leaderboard-medal {
    font-size: 1.2em;
    margin-right: 5px;
}
.leaderboard-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}
.leaderboard-name-cell {
    display: flex;
    align-items: center;
}


@media print { body * { display: none !important; visibility: hidden !important; } }