:root {
    --primary: #ff6b6b;
    --primary-light: #ff8787;
    --secondary: #4dabf7;
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --accent-gradient: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
    --card-radius: 20px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="dark"] {
    --bg-color: #1a1b1e;
    --text-color: #e9ecef;
    --glass-bg: rgba(37, 38, 43, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Navigation */
.glass-nav {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: var(--transition);
    opacity: 0.7;
}

.nav-links a:hover,
.nav-links a.active {
    opacity: 1;
    color: var(--primary);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.theme-toggle,
.settings-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 10px;
    border-radius: 50%;
    background: var(--glass-border);
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 42px;
    height: 42px;
}

.theme-toggle:hover,
.settings-toggle:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--primary);
    color: white;
}

/* Main Content Layout */
main {
    flex: 1;
    padding: 2rem 5%;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.view {
    display: none;
    animation: fadeIn 0.5s ease;
}

.view.active {
    display: block;
}

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

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

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.accent {
    color: var(--primary);
    position: relative;
}

.accent::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    opacity: 0.3;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.8;
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-size: 1rem;
}

.btn.primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.btn.secondary {
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background: var(--glass-border);
}

/* Cards */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.daily-card {
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
}

.word-display {
    padding: 1.5rem 0;
}

.kanji {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.romaji {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.meaning {
    font-size: 1.1rem;
    opacity: 0.8;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Kana Grid */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.toggle-group,
.category-filters {
    display: flex;
    background: var(--glass-bg);
    padding: 5px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
}

.toggle-btn,
.filter-btn {
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.toggle-btn.active,
.filter-btn.active {
    background: var(--primary);
    color: white;
}

.kana-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.kana-card {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.kana-card:hover {
    transform: scale(1.05);
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.kana-char {
    font-size: 2.5rem;
    font-weight: 600;
}

.kana-romaji {
    font-size: 0.9rem;
    opacity: 0.8;
}

.kana-empty {
    visibility: hidden;
}

/* Vocab Grid */
.search-container {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-radius: 50px;
}

.search-icon {
    font-size: 1.2rem;
    opacity: 0.5;
    margin-right: 0.5rem;
}

#vocab-search {
    border: none;
    background: transparent;
    padding: 0.8rem 0;
    width: 100%;
    box-shadow: none;
}

#vocab-search:focus {
    border-color: transparent;
    box-shadow: none;
}

.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.vocab-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.vocab-card:hover {
    transform: translateY(-5px);
}

.vocab-jap {
    font-size: 1.45rem;
    font-weight: 700;
    color: #ffffff;
}

.vocab-reading {
    color: #ff6b6b;
    /* Reddish color for reading */
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.h-pron {
    color: #ffd43b;
    /* Bright Yellow */
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 0.4rem;
    margin-bottom: 0.4rem;
}

/* Quiz Area */
.quiz-container {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
}

.hidden {
    display: none;
}

.quiz-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.option-btn {
    padding: 1.5rem;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.option-btn:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-3px);
}

.option-btn.correct {
    background: #40c057;
    color: white;
}

.option-btn.wrong {
    background: #fa5252;
    color: white;
}

/* Footer */
footer {
    padding: 2rem;
    text-align: center;
    opacity: 0.9;
    font-size: 1.17rem;
    /* 0.9rem * 1.3 */
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .kana-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .nav-links {
        display: none;
        /* Mobile menu needed but skipping for now or simplify */
    }
}

@media (max-width: 480px) {
    .kana-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

/* Modal Styles */
.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: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 90%;
    max-width: 400px;
    position: relative;
    text-align: center;
    padding: 3rem 2rem;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: var(--transition);
}

.close-btn:hover {
    opacity: 1;
    color: var(--primary);
}

/* Dissertation Section Styles */
.dissertation-info {
    margin-bottom: 2rem;
    text-align: center;
}

.dissertation-info h3 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.dissertation-info .author {
    opacity: 0.8;
    font-size: 1.1rem;
}

.qa-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.qa-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
}

.qa-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.qa-item.answer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.qa-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
    /* spacing after label */
}

.qa-text.jap {
    font-size: 1.2rem;
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.5;
    margin-bottom: 0.8rem;
    /* spacing between Japanese and hiragana */
}

.qa-text.reading {
    font-size: 1rem;
    color: #ffd43b;
    /* Bright Yellow */
    font-weight: 500;
    margin-bottom: 0.8rem;
    /* spacing between hiragana and Korean pronunciation */
}

.qa-text.pronunciation {
    font-size: 1rem;
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 0.8rem;
    /* spacing between Korean pronunciation and Korean meaning */
}

.qa-text.kor {
    font-size: 1.1rem;
    opacity: 0.7;
    font-weight: 300;
    margin-bottom: 0.5rem;
    /* spacing after Korean meaning */
}

/* Dr.KO Section - Font sizes increased by 30% */
#drko .qa-label {
    font-size: 1.6rem;
    /* keeping label size as requested */
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
}

#drko .qa-text.jap {
    font-size: 1.529rem;
    /* 1.176rem * 1.3 = 1.529rem */
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.5;
    margin-bottom: 0.8rem;
    /* spacing between Japanese and hiragana */
}

#drko .qa-text.reading {
    font-size: 1.274rem;
    /* 0.98rem * 1.3 = 1.274rem */
    color: #ffd43b;
    /* Bright Yellow */
    font-weight: 500;
    margin-bottom: 0.8rem;
    /* spacing between hiragana and Korean pronunciation */
}

#drko .qa-text.pronunciation {
    font-size: 1.274rem;
    /* 0.98rem * 1.3 = 1.274rem */
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 0.8rem;
    /* spacing between Korean pronunciation and Korean meaning */
}

#drko .qa-text.kor {
    font-size: 1.401rem;
    /* 1.078rem * 1.3 = 1.401rem */
    opacity: 0.7;
    font-weight: 300;
    margin-bottom: 0.5rem;
}

/* Presentation Section Styles */
.presentation-container {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.slide-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--glass-bg);
    border-radius: var(--card-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

.slide-title {
    font-size: 1.5rem;
    color: var(--primary);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    width: fit-content;
}

.modal.hidden {
    display: none !important;
}

/* Sound Buttons */
.sound-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.sound-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    color: var(--text-color);
}

.sound-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.sound-btn.small {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    width: auto;
    height: auto;
    font-size: 0.8rem;
    font-weight: 600;
}

.sound-btn.small.slow {
    background: rgba(255, 212, 59, 0.1);
    border-color: #ffd43b;
    color: #ffd43b;
}

.sound-btn.small.slow:hover {
    background: #ffd43b;
    color: #1a1a2e;
    transform: scale(1.1);
}

/* Layout helpers */
.vocab-header,
.qa-header,
.kanji-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.border-top {
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.kanji-container {
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Mastery Styles */
.kana-card.mastered {
    border-color: #40c057;
    background: rgba(64, 192, 87, 0.1);
}

.mastery-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #40c057;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.vocab-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.mastery-btn {
    padding: 4px 12px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-color);
    opacity: 0.6;
}

.mastery-btn:hover {
    opacity: 1;
    background: var(--glass-border);
}

.mastery-btn.active {
    background: #40c057;
    color: white;
    border-color: #40c057;
    opacity: 1;
}

.vocab-card.mastered {
    border-left: 4px solid #40c057;
}


#quiz-question .sound-btn {
    margin-top: 1rem;
}

/* Writing Practice Styles */
.writing-container {
    display: flex;
    gap: 2rem;
    align-items: stretch;
    margin-top: 1rem;
}

.char-guide-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.guide-char {
    font-size: 10rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary);
}

.guide-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.canvas-box {
    flex: 2;
    padding: 0;
    overflow: hidden;
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    /* Explicit background for drawing */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    cursor: crosshair;
    position: relative;
}

.canvas-box::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    border-top: 1px dashed #ddd;
    pointer-events: none;
}

.canvas-box::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    border-left: 1px dashed #ddd;
    pointer-events: none;
}

#writing-canvas {
    width: 100%;
    height: 400px;
    touch-action: none;
}

.writing-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.glass-select {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    outline: none;
}

.btn.small {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .writing-container {
        flex-direction: column;
    }

    .char-guide-box {
        min-height: 200px;
        padding: 1rem;
    }

    .guide-char {
        font-size: 6rem;
    }

    .canvas-box {
        width: 100%;
        min-height: 300px;
    }

    #writing-canvas {
        height: 300px;
    }
}

/* Settings Modal Specifics */
.settings-modal-content {
    max-width: 500px !important;
    text-align: left !important;
}

.settings-modal-content h2 {
    margin-bottom: 2rem;
    font-weight: 700;
    text-align: center;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--primary);
}

.settings-hint {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.settings-hint.small {
    font-size: 0.75rem;
}

.glass-input,
.glass-select {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.glass-input:focus,
.glass-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2);
}

.settings-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.close-settings-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: var(--transition);
}

.close-settings-btn:hover {
    opacity: 1;
    color: var(--primary);
}

.hidden {
    display: none !important;
}