:root {
    --bg-main: #FAFAFA;
    --bg-panel: rgba(255, 255, 255, 0.98);
    --text-main: #2A1A18; /* Dark brown from logo */
    --text-muted: #5D4037;
    --primary: #FFD900; /* Vibrant Hikorean Yellow */
    --primary-glow: rgba(255, 217, 0, 0.35);
    --secondary: #2A1A18; /* Match dark logo box */
    --accent: #FFD900;
    --success: #2E7D32;
    --warning: #EF6C00;
    --danger: #C62828;
    
    --font-ui: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
    --font-kr: 'Noto Sans KR', sans-serif;
    
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 15px 30px rgba(62, 39, 35, 0.1);
    --radius: 20px;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255, 217, 0, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(121, 85, 72, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

.app-container {
    width: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
}

.auth-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(28, 20, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.auth-box {
    background: var(--bg-panel);
    padding: 1.8rem 1.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    text-align: center;
    border: 2px solid var(--primary);
}

.auth-logo {
    color: var(--primary);
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-box h2 {
    color: var(--text-main);
    margin-bottom: 0.2rem;
    font-size: 1.4rem;
}

.auth-box p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
}

.form-group {
    text-align: left;
    margin-bottom: 1rem;
}

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

.form-group input[type="text"],
.form-group input[type="tel"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid rgba(121, 85, 72, 0.3);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.2s;
    background: #fff;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.auth-error {
    color: var(--danger);
    background: #FEF2F2;
    padding: 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    border: 1px solid #FECACA;
    font-weight: 500;
}

/* Home Screen Wide Layout */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.home-header {
    text-align: center;
    margin-bottom: 3rem;
}

.home-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    border: 1px solid var(--primary-glow);
}

.home-title {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.home-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 500;
}

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* Duolingo / Modern Cute Cards */
.topic-card {
    background: white;
    border-radius: 24px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 20px rgba(0,0,0,0.04);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: var(--card-bg, linear-gradient(135deg, #FFF8E1, #FFECB3));
    z-index: 0;
    border-radius: 22px 22px 0 0;
}

.topic-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 30px rgba(255, 217, 0, 0.15);
    border-color: var(--primary);
}

.topic-card:active {
    transform: translateY(-2px);
}

.topic-emoji {
    font-size: 4.5rem;
    position: relative;
    z-index: 1;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    filter: drop-shadow(0 8px 8px rgba(0,0,0,0.1));
    transition: transform 0.3s ease;
}

.topic-card:hover .topic-emoji {
    transform: scale(1.1) rotate(5deg);
}

.topic-content {
    position: relative;
    z-index: 1;
    width: 100%;
}

.topic-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.topic-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Flashcard Centered Layout */
.flashcard-wrapper {
    max-width: 650px;
    margin: 2rem auto;
    width: 100%;
    padding: 0 1rem;
}

.flashcard-main-container {
    background: var(--bg-panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 217, 0, 0.2);
    overflow: hidden;
}

/* Flashcard Header */
.app-header {
    background: linear-gradient(135deg, #FFDF73, var(--primary));
    color: var(--text-main);
    padding: 1.5rem 2rem;
    text-align: center;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.4);
    border: none;
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.back-btn:hover {
    background: rgba(255,255,255,0.8);
    transform: translateY(-50%) scale(1.05);
}

.app-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 1rem;
}

/* Progress Bar */
.progress-container {
    background: rgba(255, 255, 255, 0.5);
    padding: 1rem;
    border-radius: 16px;
    text-align: left;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--success);
    border-radius: 5px;
    transition: width 0.4s ease;
}

.progress-stats {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 0.5rem;
    text-align: right;
    font-weight: 600;
}

/* Main Content */
.flashcard-section {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

/* Flashcard Content */
.flashcard {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 2px solid rgba(255, 217, 0, 0.15);
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    align-items: center;
}

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
}

.topic-badge {
    background: #FFF8E1;
    color: #F57F17;
    border: 1px solid #FFE082;
}

.level-badge {
    background: #EFEBE9;
    color: #5D4037;
}

.bookmark-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #CBD5E1;
    cursor: pointer;
    font-size: 1.5rem;
    transition: color 0.2s;
}

.bookmark-btn:hover, .bookmark-btn.active {
    color: #F59E0B;
}

.korean-text {
    font-family: var(--font-kr);
    font-size: 2.8rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    word-break: keep-all;
    line-height: 1.4;
}

.toggle-btn {
    width: 100%;
    background: #F8FAFC;
    border: 2px dashed #CBD5E1;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: #F1F5F9;
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-btn i {
    transition: transform 0.3s;
    font-size: 1.2rem;
}

.toggle-btn.open i {
    transform: rotate(180deg);
}

.card-details {
    text-align: center;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-details.show {
    max-height: 300px;
    opacity: 1;
    margin-bottom: 2rem;
}

.romanization {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-style: italic;
    background: #F1F5F9;
    padding: 0.5rem;
    border-radius: 8px;
    display: inline-block;
}

.vietnamese {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Actions */
.card-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    border-top: 1px solid #E2E8F0;
    padding-top: 2rem;
}

.play-btn {
    background: #F3F4F6;
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.play-btn:hover {
    background: var(--primary);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 217, 0, 0.3);
}

.btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-main); 
}

.btn-primary:hover {
    background: #e6c245;
}

/* Nav Controls */
.nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.nav-btn {
    background: white;
    border: 2px solid rgba(121, 85, 72, 0.2);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #F8FAFC;
    border-color: #E2E8F0;
    box-shadow: none;
    transform: none;
}

.card-counter {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-main);
    background: white;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    border: 2px solid rgba(121, 85, 72, 0.1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

/* Responsive constraints */
@media (max-width: 768px) {
    .home-title { font-size: 2.2rem; }
    .topics-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
    .topic-emoji { font-size: 3.5rem; }
    .topic-title { font-size: 1rem; }
    .korean-text { font-size: 2rem; }
    .card-actions { flex-direction: column; }
    .nav-btn span { display: none; } /* Hide text on mobile for nav buttons */
}
