/*
 * Frontend styles for Nihongo Vocabulary plugin
 * Version: 1.4.4
 */

/* Nhúng font từ file cung cấp */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;1,400&display=swap');

@font-face {
    font-family: 'UDDigiKyokashoN-R';
    src: url('../fonts/UDDigiKyokashoN-R.woff2') format('woff2'),
         url('../fonts/UDDigiKyokashoN-R.woff') format('woff');
    font-display: swap;
}

/* Tông màu và biến */
:root {
    --primary: #1E3A8A;
    --success: #10B981;
    --danger: #EF4444;
    --purple: #6b46c1;
    --accent: #E59866;
    --section-color: #6A1B9A;
    --bg: #ffffff;
    --text: #4B5563;
    --border: #e2e8f0;
    --highlight: #fefcbf;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.05);
    --border-radius: 10px;
    --border-radius-lg: 15px;
    --border-radius-xl: 20px;
    --transition: all 0.3s ease;
    --learned-btn-color: #059669;
    --unmark-btn-color: #5B2CA9;
    --not-learned-btn-color: #DC2626;
    --shuffle-btn-color: #D97706;
    --auto-study-btn-color: #1E40AF;
    --reload-btn-color: #1E3A8A;
    --kanji-font-size: 80px; /* Kích thước chữ Kanji */
    --kanji-padding: calc(var(--kanji-font-size) * 0.5); /* Padding = 1/2 kích thước chữ */
}

/* Chế độ tối */
html.dark-mode {
    --bg: #1a202c;
    --text: #e2e8f0;
    --border: #4a5568;
    --highlight: #4a5568;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Animation keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes cardFlip {
    from { transform: rotateY(0); }
    to { transform: rotateY(180deg); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes bounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes content-slide-next {
    0% { opacity: 0; transform: translateX(10px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes content-slide-prev {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOutRight {
    0% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(10px); }
}
@keyframes fadeInLeft {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOutLeft {
    0% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(-10px); }
}
@keyframes fadeInRight {
    0% { opacity: 0; transform: translateX(10px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Base styles */
.vocab-container, .content-frame, .flashcard, .quiz, .match, .kanji-study, .modal-content, .btn, .settings-btn, .confirm-btn, .cancel-btn, .result-panel, .spinner {
    font-family: -apple-system, BlinkMacMacSystemFont, 'Montserrat', 'UDDigiKyokashoN-R', sans-serif;
    font-weight: 400;
    border-radius: var(--border-radius);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

/* Tối ưu hóa toàn cục */
* {
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Spinner */
.spinner {
    text-align: center;
    padding: 20px;
    color: var(--primary);
    font-size: 18px;
}

/* Container */
.vocab-container {
    max-width: 1000px;
    margin: 16px auto;
    padding: 20px;
    background: var(--bg);
    min-height: calc(100vh - 32px);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow-x: hidden; /* Giữ thuộc tính này để tránh scroll ngang không mong muốn */
    position: relative;
}
.vocab-container .vocab-jlpt {
    display: none !important; /* Ẩn .vocab-jlpt trong .vocab-container */
}

/* Header */
.vocab-header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
}
.vocab-title {
    font-size: 36px;
    color: var(--primary);
    font-weight: 600;
    margin-top: 8px;
    padding-top: 120px;
    line-height: 1.3;
}
.vocab-title::after {
    content: "";
    display: block;
    width: 80px;
    height: 3px;
    background: var(--accent);
    margin: 12px auto;
    border-radius: 2px;
}
.logo {
    position: absolute;
    top: 0;
    width: 160px;
    height: 160px;
    object-fit: contain;
    z-index: 10;
}
.logo-left {
    left: 16px;
}
.vocab-header .logo-right {
    right: 16px;
    z-index: 12; /* Đảm bảo logo-right không bị che */
}
.vocab-subject {
    font-size: 18px;
    color: var(--success);
    font-weight: 600;
    margin-top: 8px;
}

/* Controls */
.vocab-controls {
    position: absolute;
    right: 16px;
    top: 120px;
    display: block;
    z-index: 15; /* Tăng z-index để nút click được */
}
.settings-btn {
    background: var(--bg);
    border: 2px solid var(--accent);
    padding: 8px 16px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 48px;
    width: 180px;
    color: var(--primary);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer; /* Rõ ràng hitbox */
    pointer-events: auto; /* Đảm bảo click được */
}
.settings-btn:hover, .btn:hover, .confirm-btn:hover, .cancel-btn:hover, .result-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(229, 152, 102, 0.3);
}
.settings-btn:active, .btn:active, .confirm-btn:active, .cancel-btn:active, .result-action-btn:active {
    transform: scale(0.98);
}
.settings-btn:focus, .btn:focus, .confirm-btn:focus, .cancel-btn:focus, .result-action-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.settings-btn i {
    font-size: 18px;
}
.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 20px;
    z-index: 20;
    max-width: 480px;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg);
}
.settings-dropdown::-webkit-scrollbar {
    width: 6px;
}
.settings-dropdown::-webkit-scrollbar-track {
    background: var(--bg);
}
.settings-dropdown::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}
.settings-dropdown.active {
    display: block;
    animation: slideDown 0.25s ease;
}
.dropdown-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.dropdown-section:last-child {
    border-bottom: none;
}
.dropdown-section h4 {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 8px;
    font-weight: 700;
}
.dropdown-section select, .dropdown-section label, .dropdown-section button {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    box-sizing: border-box;
}
.dropdown-section label {
    margin-bottom: 8px;
}
.dropdown-section button {
    display: flex;
    align-items: center;
    gap: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    max-width: 200px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.2;
}
.dropdown-section button i {
    font-size: 10px;
}
.apply-filters-btn {
    justify-content: center;
    background: var(--bg);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 8px 12px;
    font-size: 14px;
}
.apply-filters-btn:hover {
    background: linear-gradient(135deg, var(--primary), #1e3a8a80);
    color: #fff;
    border-color: var(--primary);
}
.apply-filters-btn:hover i {
    color: #fff;
}
.apply-filters-btn:active {
    transform: scale(0.98);
}
.reset-progress-btn {
    max-width: 200px;
    justify-content: center;
}
.reset-progress-btn i {
    color: var(--danger);
}
.dropdown-section select {
    margin-bottom: 12px;
}
.dropdown-section label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px;
}
.dropdown-section input[type="checkbox"] {
    width: 18px;
    height: 18px;
}
.btn-primary, .confirm-btn, .replay-btn {
    color: var(--primary);
}
.btn-danger, .reset-progress-btn {
    color: var(--danger);
}
.btn-success, .cancel-btn, .back-btn {
    color: var(--success);
}
.btn-learned {
    color: var(--learned-btn-color);
}
.btn-learned i {
    color: var(--learned-btn-color);
}
.btn-unmark {
    color: var(--unmark-btn-color);
}
.btn-unmark i {
    color: var(--unmark-btn-color);
}
.btn-not-learned {
    color: var(--not-learned-btn-color);
}
.btn-not-learned i {
    color: var(--not-learned-btn-color);
}
.btn-auto-study {
    color: var(--auto-study-btn-color);
}
.btn-auto-study i {
    color: var(--auto-study-btn-color);
}
.btn-shuffle {
    color: var(--shuffle-btn-color);
}
.btn-shuffle i {
    color: var(--shuffle-btn-color);
}
.btn-reload {
    color: var(--reload-btn-color);
}
.btn-reload i {
    color: var(--reload-btn-color);
}

/* Progress */
.vocab-progress {
    width: 100%;
    max-width: 600px;
    margin: 40px auto 32px;
    text-align: center;
}
.vocab-progress p {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 12px;
}
.vocab-progress .total-words, .learned, .correct-rate {
    color: var(--primary);
    font-weight: 600;
}
.progress-bar {
    background: var(--border);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.progress-fill {
    background: var(--success);
    height: 100%;
    transition: width 0.4s ease;
}

/* Content Frame */
.content-frame {
    width: 100%;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin: 0 auto;
    box-sizing: border-box;
    position: relative;
}
html.dark-mode .content-frame {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}
.quiz.content-frame {
    min-height: 400px;
    padding-top: 30px;
    min-width: 350px;
}
#vocab-content {
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: relative;
}
#vocab-content.fadeOut {
    animation: fadeOut 0.2s ease forwards;
}
#vocab-content.fadeIn {
    animation: fadeIn 0.2s ease forwards;
}
#vocab-content.content-slide-next {
    animation: content-slide-next 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
#vocab-content.content-slide-prev {
    animation: content-slide-prev 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
#vocab-content .flashcard {
    width: min(90vw, 600px) !important;
    min-width: min(90vw, 600px) !important;
    max-width: min(90vw, 600px) !important;
    height: min(60vw, 400px) !important;
    min-height: min(60vw, 400px) !important;
    padding: 0 !important;
    display: block;
    position: relative;
    margin: 0 auto; /* Đảm bảo căn giữa */
}
.vocab-container .flashcard.fadeOutLeft {
    animation: fadeOutLeft 0.2s ease forwards !important;
}
.vocab-container .flashcard.fadeInRight {
    animation: fadeInRight 0.2s ease forwards !important;
}
.vocab-container .flashcard.fadeOutRight {
    animation: fadeOutRight 0.2s ease forwards !important;
}
.vocab-container .flashcard.fadeInLeft {
    animation: fadeInLeft 0.2s ease forwards !important;
}
.match .content-frame {
    max-width: 1000px;
}

/* Content Wrapper */
.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Flashcard */
.vocab-container .flashcard {
    text-align: center;
    perspective: 1000px;
    border: none;
    cursor: pointer;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    /* overflow: hidden; */ /* Giữ lại nếu muốn nội dung bị cắt, hoặc bỏ đi để mũi tên nằm ngoài */
    background: var(--bg);
}
.card-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-style: preserve-3d;
    box-sizing: border-box;
    will-change: transform;
}
.card-inner.flipped {
    transform: rotateY(180deg);
}
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: var(--border-radius-lg);
    overflow: auto;
    background: var(--bg);
    box-sizing: border-box;
    will-change: transform, opacity;
}
.card-back {
    transform: rotateY(180deg);
    line-height: 1.6;
}
.card-index {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    background: rgba(254, 202, 202, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    border: none;
    z-index: 10;
}
html.dark-mode .card-index {
    background: rgba(26, 32, 44, 0.8);
}
.learned-status {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    z-index: 10;
    display: none;
}
.learned-status.learned {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    display: block;
}
.learned-status.not-learned {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    display: block;
}
.learned-status.bounce {
    animation: bounce 0.4s ease;
}
.tu_vung {
    font-size: 48px;
    color: var(--text);
    margin-bottom: 16px;
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    line-height: 1.4;
    text-align: center;
}
.meaning {
    font-size: 28px;
    color: var(--text);
    margin-bottom: 12px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
}
.example-jp {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    text-align: center;
    line-height: 1.5;
}
.example-vn {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
    font-family: 'Montserrat', sans-serif;
    text-align: center;
    line-height: 1.5;
}
.quiz .vocab-jlpt, .flashcard .vocab-jlpt, .kanji-study .vocab-jlpt {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 18px;
    color: var(--primary);
    background: rgba(200, 200, 200, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 700;
    z-index: 10;
}

/* Styles for Speak Icons on Flashcards */
.flashcard .speak-icon {
    position: absolute;
    top: 15px; /* Điều chỉnh vị trí từ trên xuống */
    font-size: 1.5em; /* Kích thước icon */
    color: #6c757d; /* Màu sắc icon */
    cursor: pointer;
    z-index: 10; /* Đảm bảo icon nằm trên các phần tử khác */
    transition: color 0.2s ease-in-out;
}

.flashcard .speak-icon:hover {
    color: #007bff; /* Màu khi hover */
}

/* Positioning for front and back speak icons */
.flashcard .card-front .speak-icon {
    right: 15px; /* Vị trí từ phải sang cho mặt trước */
}

.flashcard .card-back .speak-icon {
    right: 15px; /* Vị trí từ phải sang cho mặt sau */
}

/* Ensure click on speak icon doesn't flip the card */
.flashcard .speak-icon {
    pointer-events: auto;
}

/* Adjustments for flipped state if needed */
.flashcard .card-inner.flipped .card-front .speak-icon {
    display: none; /* Hide front icon when flipped */
}

.flashcard .card-inner:not(.flipped) .card-back .speak-icon {
    display: none; /* Hide back icon when not flipped */
}


.flashcard-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    justify-items: center;
    margin-top: 24px;
    max-width: min(90vw, 600px);
}
.learned-btn, .unmark-btn, .not-learned-btn, .auto-study-btn, .shuffle-btn, .reload-btn {
    width: 160px;
    min-height: 48px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
.learned-btn:active, .unmark-btn:active, .not-learned-btn:active, .auto-study-btn:active, .shuffle-btn:active, .reload-btn:active {
    transform: scale(0.98);
}
.btn-auto-study.btn-disabled, .btn-shuffle.btn-disabled, .btn-reload.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-auto-study.btn-disabled:hover, .btn-shuffle.btn-disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}
.vocab-container .flashcard-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    z-index: 100;
    width: 40px;
    height: 40px;
    display: flex !important;
    visibility: visible !important;
    justify-content: center;
    align-items: center;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
}
.vocab-container .flashcard-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
    background: rgba(16, 185, 129, 0.2);
}
.vocab-container .flashcard-arrow:active {
    transform: translateY(-50%) scale(0.95);
}
.vocab-container .flashcard-arrow.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed;
    pointer-events: none;
}
/* ĐIỀU CHỈNH LẠI VỊ TRÍ MŨI TÊN Ở ĐÂY */
.vocab-container .flashcard-arrow-left {
    left: -20px; /* Thử nghiệm giá trị này, có thể là -10px, -25px tùy ý */
}
.vocab-container .flashcard-arrow-right {
    right: -20px; /* Thử nghiệm giá trị này, có thể là -10px, -25px tùy ý */
}

/* Auto-mode styles */
body.auto-mode .flashcard-arrow-left,
body.auto-mode .flashcard-arrow-right,
body.auto-mode .shuffle-btn {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 40px !important; /* Đảm bảo kích thước cố định */
    height: 40px !important;
}
/* Loại bỏ hoặc điều chỉnh các dòng này nếu chúng gây ra vấn đề không mong muốn */
body.auto-mode .flashcard-arrow-left.disabled {
    left: -20px; /* Điều chỉnh tương tự mũi tên bình thường */
    right: auto;
}
body.auto-mode .flashcard-arrow-right.disabled {
    left: auto;
    right: -20px; /* Điều chỉnh tương tự mũi tên bình thường */
}
body.auto-mode .shuffle-btn {
    width: 160px !important; /* Giữ kích thước gốc */
    min-height: 48px !important;
}
body.auto-mode .learned-btn,
body.auto-mode .not-learned-btn,
body.auto-mode .unmark-btn,
body.auto-mode .auto-study-btn,
body.auto-mode .reload-btn {
    pointer-events: auto;
    opacity: 1;
    cursor: pointer;
}

/* Quiz */
.quiz {
    text-align: center;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    max-width: min(90vw, 600px);
    min-width: 350px;
    position: relative;
    background: var(--bg);
    padding: 20px;
}
.quiz-index {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    background: rgba(254, 202, 202, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    border: none;
    z-index: 10;
}
html.dark-mode .quiz-index {
    background: rgba(26, 32, 44, 0.8);
}
.quiz .jlpt {
    font-size: 16px;
    margin-bottom: 16px;
    margin-top: 24px;
}
.question-title {
    font-size: 20px;
    color: var(--purple);
    font-weight: 700;
    margin-bottom: 16px;
    margin-top: 20px;
}
.question-prefix {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 12px;
    margin-top: 12px;
    font-family: 'Montserrat', sans-serif;
}
.question {
    font-size: 26px;
    color: #229b91;
    margin-bottom: 42px;
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    text-align: center;
    line-height: 1.4;
}
.question.vietnamese {
    font-family: 'Montserrat', sans-serif;
}
.options {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.option {
    background: var(--bg);
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text);
    font-size: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}
.option.vietnamese {
    font-family: 'Montserrat', sans-serif;
}
.option:has(ruby) {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    line-height: 1.4;
}
.option .word-content {
    display: inline;
    line-height: 2;
}
.option:hover {
    transform: translateY(-1px);
    background: #F1F5F9;
}
html.dark-mode .option:hover {
    background: #2d3748;
}
.option:active {
    transform: scale(0.98);
}
.option.correct {
    background: #A7F3D0;
    border-color: var(--success);
}
.option.incorrect {
    background: #FECACA;
    border-color: var(--danger);
}
.option.shake {
    animation: shake 0.4s;
}
.result {
    margin-top: 16px;
    font-size: 16px;
}
.text-success {
    color: var(--success);
}
.text-danger {
    color: var(--danger);
}
.navigation {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}
.prev-btn, .next-btn {
    width: 100px;
    height: 44px;
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
}
.prev-btn:hover, .next-btn:hover {
    background: linear-gradient(135deg, #fefcbf 0%, #ffffff 100%);
}
html.dark-mode .prev-btn:hover, html.dark-mode .next-btn:hover {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}
.prev-btn:active, .next-btn:active {
    transform: scale(0.98);
}
.prev-btn.btn-disabled, .next-btn.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.prev-btn.btn-disabled:hover, .next-btn.btn-disabled:hover {
    background: var(--bg);
    transform: none;
}

/* Match */
.match {
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    background: var(--bg);
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    /* Bỏ viền của match content-frame fade-in */
    border: none;
}
.match-index {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    /* Đảm bảo background đủ rõ ràng, có thể tăng độ trong suốt hoặc chọn màu đậm hơn */
    background: rgba(167, 243, 208, 0.8); /* Tăng opacity từ 0.2 lên 0.8 để dễ nhìn hơn */
    padding: 4px 8px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: none;
    z-index: 10;
}
html.dark-mode .match-index {
    background: rgba(26, 32, 44, 0.8); /* Hoặc một màu khác rõ ràng hơn trong dark mode */
}
.match-columns {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    max-width: 100%;
    /* Tăng padding-top để đẩy nội dung xuống dưới match-index */
    padding: 16px 16px 0 16px;
    box-sizing: border-box;
}
.match-content, .match-result {
    flex: 1;
    min-width: 300px;
    max-width: 480px;
    padding: 16px;
    box-sizing: border-box;
}
.kanji-items, .meaning-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-top: 12px;
    padding: 0;
    box-sizing: border-box;
}
.kanji-sub-columns, .meaning-sub-columns {
    display: flex;
    flex-direction: column;
    /* Tăng khoảng cách chiều dọc giữa các thẻ */
    gap: 15px; /* Tăng gap giữa các item-wrapper*/
    /* Bỏ viền của .kanji-sub-columns và .meaning-sub-columns */
    border: none;
    border-radius: var(--border-radius);
    padding: 0;
}
.kanji-items h3, .meaning-items h3 {
    width: 100%;
    font-size: 22px !important;
    font-weight: 700 !important;
    text-align: center !important;
    margin-bottom: 12px !important;
    color: var(--primary) !important;
}
.item-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    height: auto; /* Mặc định là auto, JS sẽ thiết lập */
    justify-content: center; /* Căn giữa nội dung bên trong wrapper */
}
.item {
    background: var(--bg);
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-sm);
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text);
    font-size: clamp(18px, 3vw, 20px);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    min-height: 90px;
    /* Cố định chiều ngang của các thẻ */
    width: 100%; /* Đảm bảo item chiếm 100% chiều ngang của item-wrapper*/
    box-sizing: border-box; /* Tính padding và border vào width */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    word-wrap: break-word;
    hyphens: auto;
    overflow-y: hidden; /* Ẩn phần nội dung nếu quá dài (trên desktop) */
}
.kanji-items .item {
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    line-height: 1.6;
    padding: 14px;
}
.kanji-items .item .word-content {
    display: inline;
    line-height: 2;
}
.kanji-items .item:has(ruby) {
    padding: 12px 14px;
}
.meaning-items .item {
    font-family: 'Montserrat', sans-serif;
    line-height: 1.4;
    overflow-wrap: break-word;
    hyphens: auto;
    text-align: center;
}
.item:hover {
    transform: scale(1.03);
    background: #F1F5F9;
}
html.dark-mode .item:hover {
    background: #2d3748;
}
.item:active {
    transform: scale(0.98);
}
.item.selected, .item.dragging {
    background: #bee3f8;
    border-color: var(--primary);
}
.item.drag-over {
    background: #e6f3fa;
}
.item.matched {
    background: #A7F3D0;
    border-color: var(--success);
    animation: pulse 0.4s;
}
.item.incorrect {
    background: #FECACA;
    border-color: var(--danger);
    animation: shake 0.4s;
}
.item-index {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 36px;
    height: 36px;
    font-size: 14px;
    color: #fff;
    font-weight: 700;
    /* Đảm bảo background là gradient hoặc màu đặc để tạo hình */
    background: linear-gradient(135deg, var(--accent), #D97706); /* Màu gradient gốc */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
    z-index: 10;
}
.item:hover .item-index {
    transform: scale(1.1);
}
.item.matched .item-index {
    background: linear-gradient(135deg, var(--success), #059669);
}
.item.incorrect .item-index {
    background: linear-gradient(135deg, var(--danger), #DC2626);
}
.next-match-btn {
    margin-top: 20px;
    padding: 12px 24px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    color: var(--primary);
    width: 200px;
    margin-left: auto;
    margin-right: auto;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.next-match-btn:hover {
    background: linear-gradient(135deg, #fefcbf 0%, #ffffff 100%);
}
html.dark-mode .next-match-btn:hover {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}
.next-match-btn:active {
    transform: scale(0.98);
}
/* Styles for disabled Next Match button */
.next-match-btn.disabled {
    opacity: 0.5; /* Làm mờ */
    cursor: not-allowed; /* Thay đổi con trỏ */
    transform: none !important; /* Bỏ hiệu ứng hover/active */
    box-shadow: var(--shadow-sm) !important; /* Giữ bóng mờ */
    background: var(--bg) !important; /* Đảm bảo màu nền không thay đổi */
    /* Quan trọng: giữ kích thước cố định để không làm co giao diện */
    width: 200px; /* Giữ kích thước cố định như khi không disabled */
    height: 48px; /* Giữ chiều cao cố định */
    padding: 12px 24px; /* Giữ padding */
    box-sizing: border-box; /* Tính padding và border vào kích thước */
}
.next-match-btn.disabled:hover,
.next-match-btn.disabled:active {
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
    background: var(--bg) !important;
}

/* Kanji Study */
.kanji-study {
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    background: var(--bg);
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
}
.kanji-title {
    font-size: 28px;
    color: var(--primary);
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    font-family: 'Montserrat', sans-serif;
}
.kanji-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    width: 100%;
    padding: 16px;
}
.kanji-card {
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.kanji-card.loaded {
    opacity: 1;
}
.kanji-index {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    background: rgba(254, 202, 202, 0.2);
    padding: 4px 8px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border: none;
    z-index: 10;
}
html.dark-mode .kanji-index {
    background: rgba(26, 32, 44, 0.8);
}
.kanji-content {
    display: flex;
    width: 100%;
    gap: 16px;
}
.kanji-column {
    width: 50%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.kanji-only-wrapper {
    height: 164px;
    width: auto;
    min-width: calc(var(--kanji-font-size) + var(--kanji-padding) * 2);
    max-width: calc(var(--kanji-font-size) * 5 + var(--kanji-padding) * 2);
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    padding: 0 var(--kanji-padding);
}
.kanji-only-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 1px;
    border-top: 1px dashed var(--border);
}
.kanji-only {
    font-size: var(--kanji-font-size);
    color: var(--primary);
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.kanji-only-wrapper .vertical-line {
    position: absolute;
    top: 10%;
    bottom: 10%;
    width: 1px;
    border-left: 1px dashed var(--border);
}
.han_nom_am {
    font-size: 32px;
    color: var(--text);
    background: var(--highlight);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    margin-top: 10px;
    text-align: center;
}
.kanji-details {
    width: 50%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.detail-item {
    display: grid;
    grid-template-columns: 30px 1fr 30px;
    grid-template-rows: auto auto;
    gap: 8px;
    width: 100%;
    max-width: 600px;
    align-items: center;
    padding: 12px;
    background: rgba(255, 240, 245, 0.5);
}
.detail-icon {
    grid-column: 1;
    grid-row: 1;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
}
.han_nom_nghia .detail-icon {
    color: #6b46c1;
}
.tu_vung_tieu_bieu .detail-icon {
    color: #10B981;
}
.cach_nho_chu_han .detail-icon {
    color: #E59866;
}
.detail-item strong {
    grid-column: 2;
    grid-row: 1;
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
    text-align: center;
}
.detail-item span {
    grid-column: 1 / 4;
    grid-row: 2;
    font-size: 18px;
    color: var(--text);
    line-height: 1.6;
    max-width: 100%;
    text-align: center;
}
.han_nom_nghia span {
    color: #6b46c1;
}
.tu_vung_tieu_bieu span {
    color: var(--success);
    font-family: 'UDDigiKyokashoN-R', sans-serif;
}
.cach_nho_chu_han span {
    color: #B45309;
    font-family: 'Lora', serif;
    font-style: italic;
}
.kanji-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    width: 100%;
}
.no-kanji {
    font-size: 18px;
    color: var(--text);
    text-align: center;
    margin: 20px 0;
}

/* Result Panel */
.result-panel {
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    max-width: min(80vw, 600px);
    margin: 0 auto;
    text-align: center;
}
.result-panel.fade-in {
    animation: fadeIn 0.3s ease;
}
.result-panel h3 {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 16px;
    font-weight: 700;
}
.result-panel p {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 16px;
}
.result-panel .score {
    color: var(--success);
    font-weight: 600;
}
.result-panel .incorrect-score {
    color: var(--danger);
    font-weight: 600;
}
.result-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}
.result-action-btn {
    width: 150px;
    height: 60px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    background: var(--bg);
    padding: 10px 16px;
    margin: 0;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.result-action-btn i {
    font-size: 16px;
}
html.dark-mode .result-action-btn:hover {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}
.result-action-btn:active {
    transform: scale(0.98);
}

/* Modal */
.confirmation-modal {
    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-content {
    background: var(--bg);
    padding: 24px;
    border-radius: var(--border-radius-lg);
    max-width: 480px;
    text-align: center;
    border: 2px solid var(--danger);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease-out;
}
.modal-title {
    font-size: 22px;
    color: var(--text);
    margin-bottom: 12px;
    font-weight: 700;
}
.modal-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}
.confirm-btn, .cancel-btn {
    padding: 12px 20px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.confirm-btn {
    color: var(--primary);
}
.cancel-btn {
    color: var(--success);
}
.confirm-btn:hover, .cancel-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(229, 152, 102, 0.3);
    background: linear-gradient(135deg, #fefcbf 0%, #ffffff 100%);
}
html.dark-mode .confirm-btn:hover, html.dark-mode .cancel-btn:hover {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}
.confirm-btn:active, .cancel-btn:active {
    transform: scale(0.98);
}
.hidden {
    display: none;
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: 32px;
    right: 32px;
    padding: 16px 24px;
    border-radius: var(--border-radius-lg);
    color: #fff;
    z-index: 1000;
    display: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    box-shadow: var(--shadow-md);
    animation: pulse 0.4s;
}
.toast-notification.success {
    background: var(--success);
}
.toast-notification.danger {
    background: var(--danger);
}

/* Ruby */
ruby {
    display: ruby;
    text-align: center;
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    line-height: 1.2;
}
ruby rt {
    font-size: 0.6em;
    line-height: 1;
    color: var(--text);
    font-family: 'UDDigiKyokashoN-R', sans-serif;
    position: relative;
    top: -0.1em;
}
ruby:hover rt {
    background: var(--highlight);
}
ruby rt.no-ruby {
    display: none !important;
}

/* Error */
.error {
    color: var(--danger);
    text-align: center;
    padding: 16px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .vocab-container {
        margin: 30px 8px;
        padding: 16px;
        padding-bottom: 40px;
        width: calc(100% - 16px);
    }
    .vocab-title {
        font-size: 28px;
        padding-top: 160px;
    }
    .logo {
        width: 120px;
        height: 120px;
    }
    .logo-left {
        left: 12px;
    }
    .vocab-header .logo-right {
        right: 12px;
    }
    .vocab-controls {
        right: 12px;
        top: 100px;
    }
    .settings-btn {
        height: 48px;
        width: 140px;
        font-size: 13px;
        padding: 6px 12px;
    }
    .settings-dropdown {
        max-width: 360px;
        padding: 16px;
    }
    .dropdown-section select, .dropdown-section label, .dropdown-section button {
        font-size: 13px;
        padding: 8px;
    }
    .dropdown-section h4 {
        font-size: 15px;
    }
    .dropdown-section input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }
    .dropdown-section label {
        margin-bottom: 8px;
    }
    .vocab-progress {
        margin-top: 40px;
    }
    .quiz .vocab-jlpt, .flashcard .vocab-jlpt, .kanji-study .vocab-jlpt {
        font-size: 14px;
        padding: 2px 4px;
    }
    .tu_vung {
        font-size: 40px;
    }
    .meaning {
        font-size: 24px;
    }
    .example-jp, .example-vn {
        font-size: 18px;
    }
    .card-index, .quiz-index, .match-index, .kanji-index {
        font-size: 12px;
        padding: 3px 6px;
        z-index: 10;
    }
    .learned-status {
        font-size: 11px;
        padding: 3px 6px;
    }
    .flashcard-controls {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        justify-items: center;
        max-width: min(85vw, 550px);
    }
    .learned-btn, .unmark-btn, .not-learned-btn, .auto-study-btn, .shuffle-btn, .reload-btn {
        width: 100px;
        min-height: 40px;
        font-size: 13px;
        padding: 8px;
    }
    body.auto-mode .flashcard-arrow-left,
    body.auto-mode .flashcard-arrow-right {
        width: 36px !important;
        height: 36px !important;
        font-size: 20px;
    }
    body.auto-mode .flashcard-arrow-left.disabled {
        left: -20px;
        right: auto;
    }
    body.auto-mode .flashcard-arrow-right.disabled {
        left: auto;
        right: -20px;
    }
    body.auto-mode .shuffle-btn {
        width: 100px !important;
        min-height: 40px !important;
    }
    body.auto-mode .learned-btn,
    body.auto-mode .not-learned-btn,
    body.auto-mode .unmark-btn,
    body.auto-mode .auto-study-btn,
    body.auto-mode .reload-btn {
        pointer-events: auto;
        opacity: 1;
        cursor: pointer;
    }
    .quiz {
        padding: 16px;
        width: 90vw;
        max-width: 600px;
        min-width: 320px;
    }
    .quiz.content-frame {
        min-height: 360px;
        padding-top: 20px;
    }
    .quiz .jlpt {
        font-size: 14px;
        margin-top: 18px;
        margin-bottom: 12px;
    }
    .question-title {
        font-size: 18px;
        margin-bottom: 12px;
        margin-top: 16px;
    }
    .question-prefix {
        font-size: 16px;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    .question {
        font-size: 22px;
        margin-bottom: 42px;
        line-height: 1.4;
    }
    .options {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }
    .option {
        font-size: 18px;
        padding: 14px;
        min-height: 75px;
        max-height: 85px;
        line-height: 1.8;
    }
    .option:has(ruby) {
        padding: 12px 14px;
        line-height: 2;
    }
    /* === MATCH MODE MOBILE STYLES === */
    .match-columns {
        flex-direction: row; /* KEEP columns side-by-side */
        flex-wrap: nowrap; /* Prevent wrapping */
        gap: 4px; /* Reduced gap significantly */
        padding: 0; /* Remove horizontal padding on main columns container */
        width: 100%; /* Ensure it takes full available width */
        overflow-x: auto; /* Allow horizontal scroll if columns are too wide */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scroll-snap-type: x mandatory; /* Optional: Snap to columns when scrolling */
        justify-content: flex-start; /* Align columns to start, so they don't grow too wide */
    }
    .match-content, .match-result {
        flex: 0 0 calc(50% - 2px); /* Each column takes exactly half minus half the gap */
        max-width: calc(50% - 2px); /* Max width same as flex-basis */
        min-width: 150px; /* Set a minimum width for columns so they don't disappear */
        padding: 0; /* No padding on these containers */
        box-sizing: border-box;
        scroll-snap-align: start; /* Optional: For scroll-snap */
    }
    .kanji-items, .meaning-items {
        gap: 6px; /* Reduced gap for items */
        margin-top: 42px;
        padding: 0; /* Keep padding at 0 as requested */
        width: 100%; /* Ensure these take 100% of their parent column */
    }
    .kanji-items h3, .meaning-items h3 {
        font-size: 18px !important; /* Smaller headings */
        margin-bottom: 8px !important;
    }
    .kanji-sub-columns, .meaning-sub-columns {
        display: flex;
        flex-direction: column;
        /* Tăng khoảng cách chiều dọc giữa các thẻ */
        gap: 15px; /* Khoảng cách mới giữa các item-wrapper */
        border: none;
        border-radius: var(--border-radius);
        padding: 0;
    }
    .item-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex-grow: 1;
        height: auto;
        justify-content: center;
        /* Cố định chiều ngang của item-wrapper */
        flex-basis: 100%; /* Đảm bảo chiều ngang cố định trong Flex container của nó */
        max-width: 100%;
        min-width: 100%;
    }
    .item {
        font-size: 14px;
        min-height: 60px;
        padding: 6px;
        flex-grow: 1;
        align-self: stretch;
        max-height: 120px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;

        /* Cố định chiều ngang của thẻ, để nó không bị lệch */
        width: 100%; /* Đảm bảo item chiếm 100% chiều ngang của item-wrapper */
        box-sizing: border-box;
    }
    .kanji-items .item {
        line-height: 1.5;
        padding: 8px;
    }
    .kanji-items .item:has(ruby) {
        padding: 6px 8px;
    }
    .meaning-items .item {
        font-size: 14px;
        line-height: 1.3;
    }
    .item-index {
        top: -8px;
        left: -8px;
        width: 28px; /* Tăng nhẹ kích thước lên, ví dụ 28px */
        height: 28px; /* Tăng nhẹ kích thước lên */
        font-size: 11px; /* Tăng font-size lên 11px để chữ dễ đọc hơn */
    }
    .next-match-btn {
        width: 180px;
        font-size: 16px;
        padding: 10px 16px;
        margin-top: 16px;
    }
    /* === END MATCH MODE MOBILE STYLES === */
    .toast-notification {
        font-size: 16px;
        padding: 12px 20px;
        bottom: 24px;
        right: 24px;
    }
    /* Điều chỉnh Result Panel */
    .result-panel {
        max-width: calc(100% - 40px); /* Giới hạn chiều rộng tối đa, có khoảng cách 20px mỗi bên */
        width: auto; /* Cho phép tự động điều chỉnh chiều rộng theo nội dung */
        margin: 20px auto; /* Đảm bảo căn giữa và có khoảng cách trên/dưới */
        padding: 16px; /* Giảm padding để tiết kiệm không gian */
    }

    .result-panel h3 {
        font-size: 18px; /* Giảm kích thước tiêu đề */
        margin-bottom: 12px;
    }

    .result-panel p {
        font-size: 15px; /* Giảm kích thước chữ */
        margin-bottom: 12px;
    }

    /* Điều chỉnh các nút trong Result Panel */
    .result-buttons {
        flex-direction: column; /* Đổi thành cột để các nút không bị co lại trên màn hình nhỏ */
        gap: 10px; /* Tăng khoảng cách giữa các nút khi xếp chồng */
        width: 100%; /* Đảm bảo các nút chiếm toàn bộ chiều rộng có thể */
        align-items: center; /* Căn giữa các nút khi xếp chồng */
    }

    .result-action-btn {
        width: 100%; /* Đảm bảo nút chiếm toàn bộ chiều rộng của .result-buttons */
        max-width: 200px; /* Giới hạn chiều rộng tối đa cho nút để không quá lớn trên tablet */
        min-height: 44px; /* Điều chỉnh chiều cao tối thiểu */
        font-size: 14px; /* Điều chỉnh kích thước chữ */
        padding: 10px 12px; /* Điều chỉnh padding */
    }
    .confirmation-modal {
        padding: 8px;
    }
    .modal-content {
        max-width: 360px;
        padding: 16px;
    }
    .modal-title {
        font-size: 18px;
    }
    .modal-buttons {
        flex-direction: row;
        gap: 8px;
    }
    .confirm-btn, .cancel-btn {
        width: 120px;
        min-height: 40px;
        padding: 10px 16px;
        font-size: 13px;
    }
    .kanji-study {
        padding: 8px;
    }
    .kanji-grid {
        padding: 8px;
    }
    .kanji-card {
        padding: 14px 8px;
    }
    .kanji-content {
        flex-direction: column;
        gap: 12px;
    }
    .kanji-column, .kanji-details {
        width: 100%;
        padding: 12px;
    }
    .kanji-only-wrapper {
        height: 100px;
        min-width: calc(var(--kanji-font-size) + var(--kanji-padding) * 2);
        max-width: calc(var(--kanji-font-size) * 5 + var(--kanji-padding) * 2);
        padding: 0 var(--kanji-padding);
    }
    .kanji-only {
        font-size: var(--kanji-font-size);
    }
    .han_nom_am {
        font-size: 24px;
    }
    .kanji-details {
        padding: 10px;
    }
    .detail-item {
        grid-template-columns: 30px 1fr 30px;
        grid-template-rows: auto auto;
        gap: 4px;
        padding: 8px;
    }
    .detail-icon {
        font-size: 14px;
        width: 30px;
        height: 30px;
    }
    .detail-item strong {
        font-size: 14px;
    }
    .detail-item span {
        font-size: 12px;
    }
    .kanji-title {
        font-size: 20px;
    }
    .match {
        padding: 2px;
    }
}
.match-content,
.match-result,
.match-columns {
    overflow: visible !important;
}