:root {
    --primary-color: #fbc02d;
    --secondary-color: #8d6e63;
    --background-color: #fffde7;
    --card-bg: #ffffff;
    --text-color: #3e2723;
    --accent-color: #f57f17;
    --gradient-bg: linear-gradient(135deg, #fff176 0%, #ffb74d 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(145, 120, 30, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

body {
    background: var(--gradient-bg);
    min-height: 100vh;
    color: var(--text-color);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.container {
    width: 100%;
    max-width: 1200px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}

header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    text-align: center;
    border-bottom: 2px solid #fff59d;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

h1 {
    font-size: 1.8rem;
    background: linear-gradient(45deg, #f57f17, #ef6c00);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0;
    font-weight: 800;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid #fbc02d;
    background: white;
    color: #f57f17;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.search-section {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
}

#searchInput {
    width: 100%;
    padding: 15px 25px;
    border-radius: 50px;
    border: 3px solid #fbc02d;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    outline: none;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 10px rgba(0, 86, 179, 0.2);
}

#searchInput:focus {
    border-color: #fdd835;
    box-shadow: 0 0 20px rgba(249, 168, 37, 0.4);
}

#searchBtn {
    padding: 15px 40px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(45deg, #fbc02d, #f57f17);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 127, 23, 0.3);
}

#searchBtn:active {
    transform: translateY(1px);
}

/* Genre Filter Styling */
.genre-filter-wrapper {
    position: relative;
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.header-download-btn {
    position: absolute;
    right: 30px;
    top: 25px;
}

/* Match action-btn styles */
.genre-filter-trigger {
    color: #f57f17;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    padding: 8px 24px;
    border-radius: 20px;
    background: white;
    border: 2px solid #fbc02d;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
}

.genre-filter-trigger:hover,
.genre-filter-trigger.active {
    background: #fffde7;
    border-color: #f57f17;
    color: #e65100;
}

.genre-dropdown {
    display: none;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #f0f0f0;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    width: max-content;
    min-width: 280px;
    padding: 8px 0;
}

.genre-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.genre-option {
    padding: 12px 20px;
    cursor: pointer;
    color: #333;
    transition: background 0.1s;
    font-size: 0.95rem;
    border-bottom: 1px solid #fcfcfc;
}

.genre-option:hover {
    background: #fff9c4;
    color: #f57f17;
}

.genre-option:last-child {
    border-bottom: none;
}

.content-area {
    padding: 30px;
    flex-grow: 1;
    overflow-y: auto;
}

#resultsGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    animation: fadeIn 0.5s ease-out;
}

.word-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #1a237e;
    position: relative;
    overflow: hidden;
}

.word-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(to bottom, #fff176, #ffb74d);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.word-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.word-card:hover::before {
    opacity: 1;
}

.word-term {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 3px;
}

.word-reading {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.word-category-badge {
    display: inline-block;
    padding: 3px 10px;
    background: #fff9c4;
    color: #e65100;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 700px;
    border-radius: 20px;
    padding: 40px;
    position: relative;
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    background: #f1f3f4;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    color: #5f6368;
}

.close-btn:hover {
    background: #e0e0e0;
}

.modal-header {
    margin-bottom: 25px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
}

.modal-term {
    font-size: 2rem;
    color: #2c3e50;
    font-weight: 800;
    margin-bottom: 5px;
}

.modal-reading {
    font-size: 1.1rem;
    color: #7f8c8d;
}

.modal-category {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 15px;
    background: linear-gradient(45deg, #11998e, #38ef7d);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-body {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #4a4a4a;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Break */
.mobile-break {
    display: none;
}

@media (max-width: 768px) {
    .mobile-break {
        display: inline;
    }

    .header-download-btn {
        display: none;
    }

    h1 {
        font-size: 1.8rem;
    }

    .search-section {
        flex-direction: column;
        align-items: center;
    }

    .search-input-wrapper {
        width: 100%;
    }

    #searchBtn {
        width: 100%;
        justify-content: center;
    }

    .genre-filter-wrapper {
        width: 100%;
    }

    .genre-dropdown {
        width: 90%;
        max-width: 320px;
    }

    .word-card {
        padding: 20px;
    }

    .modal-content {
        padding: 30px 20px;
        width: 95%;
    }

    .modal-term {
        font-size: 1.6rem;
    }
}