:root {
    --primary: #818cf8;
    --primary-glow: rgba(129, 140, 241, 0.3);
    --secondary: #f472b6;
    --accent: #fbbf24;
    --bg-deep: #020617;
    --surface: rgba(30, 41, 59, 0.5);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --radius: 20px;
    --transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Noto Sans KR', sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: radial-gradient(circle at top left, #1e1b4b, #020617);
    display: flex;
    flex-direction: column;
}

/* HEADER - FIXED COMPACT */
header {
    padding: 25px 20px 10px;
    flex-shrink: 0;
}

.title-container {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -1px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.highlight {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.premium-badge {
    font-size: 0.55rem;
    font-weight: 900;
    background: var(--accent);
    color: #000;
    padding: 2px 8px;
    border-radius: 6px;
}

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
}

#user-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

#username-display {
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--primary);
}

.divider {
    width: 1px;
    height: 14px;
    background: var(--glass-border);
}

.study-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

select {
    background: none;
    color: #fff;
    border: none;
    font-size: 0.8rem;
    font-weight: 800;
    outline: none;
    cursor: pointer;
}

/* REUSABLE BUTTONS */
button {
    border: none;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.glass-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.primary-btn {
    background: var(--primary);
    color: #020617;
    padding: 6px 14px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.75rem;
}

/* MODES */
.mode-tabs {
    display: flex;
    padding: 10px 20px 15px;
    gap: 8px;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 700;
}

.tab-btn.active {
    background: var(--primary);
    color: #020617;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* MAIN CONTENT */
#content-area {
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding: 0 20px;
    scrollbar-width: none;
}

#content-area::-webkit-scrollbar {
    display: none;
}

/* WORD LIST */
.word-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 20px;
}

.word-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 20px 24px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

.word-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.word-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.phonetic {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.8;
    font-weight: 400;
}

.play-btn {
    background: var(--primary-glow);
    border: 1px solid rgba(129, 140, 241, 0.2);
    color: var(--primary);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.play-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.play-btn:hover {
    background: var(--primary);
    color: #020617;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.play-btn:active {
    transform: scale(0.95);
}

.eng {
    text-transform: lowercase;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

.kor {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.kor-small {
    font-size: 0.75rem;
    color: var(--primary);
    opacity: 0.8;
    margin-top: 4px;
    font-weight: 700;
}

/* FLASHCARD - FIXED STYLING */
.flash-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 50px;
}

.flashcard {
    width: 100%;
    height: 350px;
    perspective: 1200px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.card-face.front {
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

.card-face.back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #020617;
}

.card-face h2 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    text-transform: lowercase;
}

/* QUIZ - FIXED STYLING */
.quiz-card {
    padding-top: 40px;
    padding-bottom: 60px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100%;
}

.quiz-card h2 {
    font-size: 2.6rem;
    margin-bottom: 40px;
    text-align: center;
    text-transform: lowercase;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.option-btn {
    display: block;
    width: 100%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 18px 20px;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.3) !important;
    color: #fff !important;
    border-color: #10b981 !important;
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.3) !important;
    color: #fff !important;
    border-color: #ef4444 !important;
}

/* MODALS */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(25px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal {
    background: #0f172a;
    padding: 40px 30px;
    border-radius: 40px;
    width: 90%;
    max-width: 360px;
    border: 1px solid var(--glass-border);
    position: relative;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    color: white;
    font-size: 1.5rem;
}

.auth-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
    border-radius: 14px;
    margin-bottom: 25px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    color: var(--text-muted);
    font-weight: 800;
    border-radius: 10px;
}

.auth-tab.active {
    background: var(--glass);
    color: var(--primary);
}

.modal input {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: #fff;
    margin-bottom: 12px;
    font-size: 1rem;
}

.modal .primary-btn {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border-radius: 16px;
    margin-top: 10px;
}

/* RANKING */
.rank-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 8px;
    border: 1px solid transparent;
}

.rank-item:first-child {
    background: linear-gradient(to right, rgba(251, 191, 36, 0.1), transparent);
    border-color: rgba(251, 191, 36, 0.3);
}

.rank-num {
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 35px;
}

.rank-item:first-child .rank-num {
    color: var(--accent);
}

.rank-user {
    font-weight: 700;
    flex: 1;
}

.rank-score {
    font-weight: 900;
    color: var(--primary);
}

/* FOOTER */
footer {
    padding: 10px 25px 30px;
    flex-shrink: 0;
}

.progress-info {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 10px;
    opacity: 0.5;
}

.progress-bar-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ctrl-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #020617;
    font-size: 1.5rem;
    font-weight: 900;
    box-shadow: 0 10px 25px var(--primary-glow);
}

.ctrl-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    box-shadow: none;
    opacity: 0.2;
}

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

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

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

.hidden {
    display: none !important;
}