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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app-layout {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    width: 100%;
    align-items: stretch;
    justify-content: center;
}

.category-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 300px;
    height: 679px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.stats-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 400px;
    height: 679px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.stats-header {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
}

.download-stats-button {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 12px 20px !important;
    border-radius: 12px !important;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-top: 15px;
    width: 100%;
    font-family: 'Arial', sans-serif !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    outline: none;
}

.download-stats-button:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.download-stats-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

.download-stats-button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.stats-list::-webkit-scrollbar {
    width: 6px;
}

.stats-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.stats-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.stats-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.stats-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 10px;
    color: white;
    margin-bottom: 6px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
    font-size: 0.75rem;
}

.stats-table th {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 4px;
    text-align: left;
    font-weight: bold;
    font-size: 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-table td {
    padding: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: middle;
}

.stats-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.category-name {
    font-weight: bold;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-number {
    text-align: center;
    width: 25px;
    font-weight: bold;
}

.stat-number.correct {
    color: #27ae60;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
}

.stat-number.incorrect {
    color: #ff4757;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
}

.stat-number.skipped {
    color: #f39c12;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
}

.stat-number.remaining {
    color: rgba(255, 255, 255, 0.7);
}

.table-progress-bar {
    position: relative;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    width: 80px;
    display: flex;
}

.stats-category {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.stats-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 2px;
    line-height: 1.2;
}

.stats-progress {
    display: flex;
    gap: 1px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-correct {
    background: #27ae60;
}

.progress-incorrect {
    background: #e74c3c;
}

.progress-skipped {
    background: #f39c12;
}

.progress-unanswered {
    background: rgba(255, 255, 255, 0.2);
}

.category-header {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
}

.category-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-category {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.8rem;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-all {
    background: #27ae60;
    color: white;
}

.btn-all:hover {
    background: #229954;
    transform: translateY(-1px);
}

.btn-none {
    background: #e74c3c;
    color: white;
}

.btn-none:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.category-list::-webkit-scrollbar {
    width: 6px;
}

.category-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.category-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.category-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 0.9rem;
}

.category-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.category-item label {
    cursor: pointer;
    user-select: none;
}

.container {
    max-width: 600px;
    width: 100%;
    text-align: center;
    position: relative;
}

.language-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    text-align: right;
}

.header {
    color: white;
    margin-bottom: 30px;
}

.btn-language {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 60px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-language:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.btn-reset {
    background: rgba(255, 165, 0, 0.2);
    color: white;
    border: 2px solid rgba(255, 165, 0, 0.4);
    padding: 8px 16px;
    font-size: 0.9rem;
    min-width: 80px;
    margin-left: 10px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-reset:hover {
    background: rgba(255, 165, 0, 0.3);
    border-color: rgba(255, 165, 0, 0.6);
    transform: translateY(-1px);
}

/* Top-right button group - all using same base styling */
.language-button {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    min-width: 60px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.language-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.reset-button {
    background: rgba(255, 165, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 165, 0, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    min-width: 80px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.reset-button:hover {
    background: rgba(255, 165, 0, 0.2);
    border-color: rgba(255, 165, 0, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.flip-direction-button {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 10px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    min-width: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.flip-direction-button:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.card-container {
    perspective: 1000px;
    margin-bottom: 30px;
    position: relative;
}

.card-status-marker {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 4px 12px;
    background: #9b59b6;
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    z-index: 100;
    pointer-events: none;
}

.card-status-marker.to-guess {
    background: #9b59b6;
    color: white;
}

.card-status-marker.correct {
    background: #27ae60;
    color: white;
}

.card-status-marker.incorrect {
    background: #e74c3c;
    color: white;
}

.card-status-marker.skipped {
    background: #f39c12;
    color: white;
}

.card {
    background: transparent;
    border-radius: 20px;
    min-height: 300px;
    cursor: pointer;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
    position: relative;
}

.card.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: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    background: white;
    min-height: 300px;
}

.card-back {
    transform: rotateY(180deg);
    background: #f8f9fa;
}

.romaji {
    font-size: 2rem;
    color: #333;
    margin-bottom: 20px;
    font-weight: bold;
}

.hiragana {
    font-size: 3rem;
    color: #e74c3c;
    margin-bottom: 20px;
    font-weight: bold;
}

.english {
    font-size: 1.8rem;
    color: #2c3e50;
    font-weight: 600;
}

.category {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    margin: 0 auto;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 40px;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    line-height: 1.2;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-skip {
    background: #f39c12;
    color: white;
}

.btn-skip:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

/* Navigation buttons with fixed widths - only apply to main control buttons */
.controls .btn-secondary, 
.controls .btn-skip {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    font-size: 0.9rem;
    padding: 12px 20px;
}

.controls .btn-primary {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    font-size: 0.9rem;
    padding: 12px 20px;
}

/* Flip direction button specific styling */
#flipDirectionBtn {
    width: 110px;
    min-width: 110px;
    max-width: 160px;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-correct {
    background: #27ae60;
    color: white;
}

.btn-correct:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-incorrect {
    background: #e74c3c;
    color: white;
}

.btn-incorrect:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.progress {
    margin-top: 20px;
    color: white;
    font-size: 1.1rem;
}

.progress-bar {
    background: rgba(255,255,255,0.2);
    height: 8px;
    border-radius: 4px;
    margin: 10px 0;
    overflow: hidden;
}

.progress-fill {
    background: #27ae60;
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.card-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #666;
    z-index: 10;
    pointer-events: none;
}

@media (max-width: 480px) {
    .app-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .category-sidebar {
        width: 100%;
        order: 2;
        margin-top: 0;
        height: auto;
        align-self: auto;
    }
    
    .container {
        order: 1;
    }
    
    .language-toggle {
        top: 10px;
        right: 10px;
    }
    
    .btn-language {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: 50px;
    }
    
    .controls .btn-secondary, 
    .controls .btn-skip {
        width: 120px;
        min-width: 120px;
        max-width: 120px;
        font-size: 0.8rem;
        padding: 10px 15px;
    }

    .controls .btn-primary {
        width: 140px;
        min-width: 140px;
        max-width: 140px;
        font-size: 0.8rem;
        padding: 10px 15px;
    }
    
    .header h1 {
        font-size: 2rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.2;
    }
    
    .card-front, .card-back {
        padding: 30px 20px;
        min-height: 250px;
    }
    
    .romaji {
        font-size: 1.5rem;
    }
    
    .hiragana {
        font-size: 2.5rem;
    }
    
    .english {
        font-size: 1.4rem;
    }
}

/* Show All Words Button */
.show-words-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.show-words-button {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
    font-family: 'Arial', sans-serif;
}

.show-words-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Words Modal */
.words-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.words-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95));
    backdrop-filter: blur(20px);
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    animation: modalSlideIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.word-count-display {
    background: rgba(118, 75, 162, 0.2);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin: 0 auto;
}

.word-count-display span {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

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

.download-words-button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Arial', sans-serif;
}

.download-words-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.close-modal {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-weight: 300;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-body {
    flex: 1;
    overflow: hidden;
    padding: 25px 30px 30px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Table Controls */
.table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(60, 40, 80, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.filter-section,
.search-section,
.sort-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 140px;
}

.sort-section {
    flex: 1;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-width: 380px;
    overflow-x: visible;
}

.sort-section label {
    margin-right: 6px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-select,
.search-input {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    width: 100%;
    min-width: 120px;
    max-width: 140px;
}

.filter-select:focus,
.search-input:focus {
    outline: none;
    border-color: #764ba2;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 2px rgba(118, 75, 162, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.filter-select option {
    background: white;
    color: #333;
    padding: 8px;
    font-weight: 500;
}

.search-input::placeholder {
    color: rgba(100, 100, 100, 0.7);
}

.sort-btn {
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    min-width: 65px;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.sort-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sort-btn.active {
    background: #764ba2;
    border-color: #764ba2;
    color: white;
    box-shadow: 0 2px 8px rgba(118, 75, 162, 0.4);
}

.table-controls label {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-bottom: 5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    min-height: 20px;
    display: block;
}

@media (max-width: 768px) {
    .table-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .sort-section {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        overflow-x: visible;
    }
    
    .sort-btn {
        margin: 2px;
        min-width: 65px;
        font-size: 10px;
        padding: 5px 8px;
    }
}

.words-table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.4);
    border-radius: 8px 8px 0 0;
}

.words-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: transparent;
    border-spacing: 0;
    margin: 0;
}

.words-table th {
    background: #764ba2;
    color: white;
    padding: 16px 12px;
    text-align: center;
    font-weight: 700;
    position: sticky;
    top: -1px;
    z-index: 20;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    border-top: none;
    backdrop-filter: blur(10px);
}

.words-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: #374151;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    text-align: center;
}

.words-table tbody tr:hover {
    background: rgba(103, 126, 234, 0.08);
    transform: scale(1.001);
}

.words-table tbody tr:hover td {
    background: rgba(103, 126, 234, 0.08);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.words-table .romaji-col {
    font-weight: 700;
    color: #1f2937;
    font-size: 1rem;
}

.words-table .japanese-col {
    font-weight: 700;
    color: #dc2626;
    font-size: 1.2rem;
    font-family: 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

.words-table .english-col {
    color: #374151;
    font-weight: 500;
}

.words-table .spanish-col {
    color: #374151;
    font-weight: 500;
}

.words-table .category-col {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    color: #764ba2;
    font-weight: 700;
    text-transform: capitalize;
    font-size: 0.8rem;
    text-align: center;
    margin: 4px;
    padding: 6px 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

/* Custom scrollbar for the table */
.words-table-container::-webkit-scrollbar {
    width: 8px;
}

.words-table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.words-table-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.words-table-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8, #6a4190);
}

@media (max-width: 768px) {
    .show-words-container {
        bottom: 10px;
    }
    
    .show-words-button {
        padding: 10px 20px;
        font-size: 0.8rem;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 20px 20px;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-header-buttons {
        gap: 8px;
    }
    
    .download-words-button {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .modal-body {
        padding: 20px 15px 25px;
    }
    
    .words-table {
        font-size: 0.8rem;
    }
    
    .words-table th {
        padding: 10px 6px;
        font-size: 0.75rem;
    }
    
    .words-table td {
        padding: 6px 6px;
    }
    
    .words-table .japanese-col {
        font-size: 1rem;
    }
    
    .words-table .category-col {
        font-size: 0.7rem;
        padding: 6px 4px !important;
    }
    
    .close-modal {
        width: 32px;
        height: 32px;
        font-size: 1.5rem;
    }
}

/* Keyboard Controls */
.keyboard-controls {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.controls-header {
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.key-combo {
    display: flex;
    gap: 3px;
}

.key {
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    color: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 0.7rem;
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    min-width: 20px;
    text-align: center;
}

.control-desc {
    color: white;
    font-size: 0.7rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    flex: 1;
}

/* Responsive adjustments for keyboard controls */
@media (max-width: 768px) {
    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .control-item {
        padding: 3px 4px;
    }
    
    .key {
        padding: 1px 4px;
        font-size: 0.6rem;
        min-width: 18px;
    }
    
    .control-desc {
        font-size: 0.6rem;
    }
    
    .controls-header {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }
}
