/* ============================================
   拼音大冒险 - PinyinQuest Design System
   ============================================ */

/* --- CSS Variables --- */
:root {
    /* Primary Colors - Duolingo-inspired */
    --green-primary: #58CC02;
    --green-dark: #46A302;
    --green-light: #7ED321;
    --green-bg: #E5F9DB;

    --blue-primary: #1CB0F6;
    --blue-dark: #0995D3;
    --blue-light: #7DD8FF;

    --orange-primary: #FF9600;
    --orange-dark: #E08600;
    --orange-light: #FFB84D;

    --red-primary: #FF4B4B;
    --red-dark: #E04040;
    --red-light: #FF7B7B;

    --purple-primary: #CE82FF;
    --purple-dark: #A855F7;

    --gold-primary: #FFC800;
    --gold-dark: #E0B000;

    /* Neutral */
    --gray-50: #F7F7F7;
    --gray-100: #EEEEEE;
    --gray-200: #E2E2E2;
    --gray-300: #CCCCCC;
    --gray-400: #AFAFAF;
    --gray-500: #777777;
    --gray-600: #4B4B4B;
    --gray-700: #3C3C3C;
    --gray-800: #2B2B2B;

    --white: #FFFFFF;
    --bg-main: #131F24;
    --bg-card: #1A2E35;
    --bg-card-hover: #213940;
    --text-primary: #FFFFFF;
    --text-secondary: #AFAFAF;
    --text-muted: #777777;

    /* Layout */
    --max-width: 600px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-btn: 0 4px 0;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Font */
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Header / Top Bar --- */
.top-bar {
    width: 100%;
    max-width: var(--max-width);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-main);
}

.top-bar .back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.top-bar .back-btn:hover {
    color: var(--white);
}

/* --- Progress Bar --- */
.progress-container {
    flex: 1;
    height: 16px;
    background: var(--gray-700);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--green-primary), var(--green-light));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
    position: relative;
    min-width: 0;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 8px;
    right: 8px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
}

/* --- Hearts --- */
.hearts {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 800;
    color: var(--red-primary);
}

.hearts .heart-icon {
    font-size: 22px;
    line-height: 1;
}

/* --- Page Container --- */
.page {
    width: 100%;
    max-width: var(--max-width);
    padding: 0 20px 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeSlideIn 0.35s ease;
}

/* --- Home Page - Level Map --- */
.home-header {
    width: 100%;
    max-width: var(--max-width);
    padding: 20px 20px 0;
    text-align: center;
}

.home-header .logo {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--green-primary), var(--blue-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.home-header .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.stats-bar {
    width: 100%;
    max-width: var(--max-width);
    padding: 16px 20px;
    display: flex;
    justify-content: space-around;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}

.stat-item .stat-icon {
    font-size: 20px;
}

.stat-item .stat-value {
    color: var(--white);
}

.stat-item .stat-label {
    color: var(--text-muted);
    font-size: 12px;
}

/* Level Path */
.level-path {
    width: 100%;
    max-width: var(--max-width);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

.level-section {
    width: 100%;
    margin-bottom: 20px;
}

.level-section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    padding-left: 4px;
}

.level-nodes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
}

/* Connector line */
.level-nodes::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: var(--gray-700);
    border-radius: 2px;
    transform: translateX(-50%);
    z-index: 0;
}

.level-node {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    cursor: pointer;
    border: 4px solid transparent;
    position: relative;
    z-index: 1;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-btn) rgba(0, 0, 0, 0.3);
}

.level-node:hover {
    transform: scale(1.08);
}

.level-node:active {
    transform: scale(0.95) translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.level-node--active {
    background: var(--green-primary);
    border-color: var(--green-dark);
    color: var(--white);
    box-shadow: var(--shadow-btn) var(--green-dark), 0 0 20px rgba(88, 204, 2, 0.3);
    animation: pulse 2s infinite;
}

.level-node--completed {
    background: var(--gold-primary);
    border-color: var(--gold-dark);
    color: var(--gray-800);
    box-shadow: var(--shadow-btn) var(--gold-dark);
}

.level-node--locked {
    background: var(--gray-700);
    border-color: var(--gray-600);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.6;
}

.level-node--locked:hover {
    transform: none;
}

.level-node .node-icon {
    font-size: 28px;
    line-height: 1;
}

.level-node .node-stars {
    position: absolute;
    bottom: -8px;
    display: flex;
    gap: 2px;
    font-size: 12px;
}

/* Zigzag offset for the path */
.level-nodes .level-node:nth-child(odd) {
    margin-left: -60px;
}

.level-nodes .level-node:nth-child(even) {
    margin-right: -60px;
}

/* --- Question Page --- */
.question-area {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.question-prompt {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 24px;
    text-align: center;
}

.question-character {
    font-size: 80px;
    font-weight: 900;
    color: var(--white);
    margin-bottom: 8px;
    animation: bounceIn 0.5s ease;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.question-hint {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
    font-weight: 600;
}

/* Pinyin display with blank */
.pinyin-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 32px;
}

.pinyin-part {
    color: var(--white);
}

.pinyin-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 52px;
    border-bottom: 4px solid var(--blue-primary);
    color: var(--blue-primary);
    font-size: 36px;
    font-weight: 800;
    transition: all var(--transition-fast);
    animation: blinkCaret 1.2s infinite;
}

.pinyin-blank.filled {
    border-color: var(--green-primary);
    color: var(--green-primary);
    animation: none;
}

/* Options Grid */
.options-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.options-grid.options-3col {
    grid-template-columns: repeat(3, 1fr);
}

.options-grid.options-4col {
    grid-template-columns: repeat(4, 1fr);
}

.option-btn {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--gray-600);
    background: var(--bg-card);
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 3px 0 var(--gray-700);
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--gray-500);
    transform: translateY(-1px);
    box-shadow: 0 4px 0 var(--gray-700);
}

.option-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--gray-700);
}

.option-btn.selected {
    border-color: var(--blue-primary);
    background: rgba(28, 176, 246, 0.15);
    box-shadow: 0 3px 0 var(--blue-dark);
}

.option-btn.correct {
    border-color: var(--green-primary);
    background: rgba(88, 204, 2, 0.2);
    color: var(--green-primary);
    box-shadow: 0 3px 0 var(--green-dark);
    animation: correctPop 0.4s ease;
}

.option-btn.incorrect {
    border-color: var(--red-primary);
    background: rgba(255, 75, 75, 0.2);
    color: var(--red-primary);
    box-shadow: 0 3px 0 var(--red-dark);
    animation: shake 0.5s ease;
}

.option-btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Tone options */
.tone-option {
    font-size: 28px;
    padding: 16px;
}

/* --- Input Type Question --- */
.pinyin-input-area {
    width: 100%;
    max-width: 320px;
    margin-bottom: 20px;
}

.pinyin-input {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    border: 3px solid var(--gray-600);
    background: var(--bg-card);
    color: var(--white);
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-family);
    text-align: center;
    outline: none;
    transition: border-color var(--transition-fast);
}

.pinyin-input:focus {
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 4px rgba(28, 176, 246, 0.2);
}

.pinyin-input.correct {
    border-color: var(--green-primary);
    box-shadow: 0 0 0 4px rgba(88, 204, 2, 0.2);
}

.pinyin-input.incorrect {
    border-color: var(--red-primary);
    box-shadow: 0 0 0 4px rgba(255, 75, 75, 0.2);
    animation: shake 0.5s ease;
}

/* --- Matching Question --- */
.matching-area {
    width: 100%;
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.matching-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    max-width: 160px;
}

.match-item {
    padding: 14px;
    border-radius: var(--radius-md);
    border: 2px solid var(--gray-600);
    background: var(--bg-card);
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.match-item:hover {
    border-color: var(--gray-400);
}

.match-item.selected {
    border-color: var(--blue-primary);
    background: rgba(28, 176, 246, 0.15);
}

.match-item.matched {
    border-color: var(--green-primary);
    background: rgba(88, 204, 2, 0.15);
    color: var(--green-primary);
    pointer-events: none;
    opacity: 0.7;
}

.match-item.wrong {
    animation: shake 0.4s ease;
    border-color: var(--red-primary);
}

/* --- Check / Continue Button --- */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    background: linear-gradient(to top, var(--bg-main) 80%, transparent);
}

.check-btn {
    width: 100%;
    max-width: var(--max-width);
    padding: 16px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-family);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.check-btn--default {
    background: var(--green-primary);
    color: var(--white);
    box-shadow: 0 4px 0 var(--green-dark);
}

.check-btn--default:hover {
    background: var(--green-light);
    transform: translateY(-1px);
    box-shadow: 0 5px 0 var(--green-dark);
}

.check-btn--default:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--green-dark);
}

.check-btn--disabled {
    background: var(--gray-600);
    color: var(--gray-400);
    box-shadow: 0 4px 0 var(--gray-700);
    cursor: not-allowed;
}

.check-btn--continue {
    background: var(--blue-primary);
    color: var(--white);
    box-shadow: 0 4px 0 var(--blue-dark);
}

.check-btn--continue:hover {
    background: var(--blue-light);
}

.check-btn--continue:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--blue-dark);
}

/* --- Feedback Banner --- */
.feedback-banner {
    width: 100%;
    max-width: var(--max-width);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideUp 0.3s ease;
}

.feedback-banner--correct {
    background: rgba(88, 204, 2, 0.15);
    border: 2px solid var(--green-primary);
}

.feedback-banner--correct .feedback-icon {
    color: var(--green-primary);
    font-size: 28px;
}

.feedback-banner--correct .feedback-text {
    color: var(--green-primary);
    font-weight: 800;
    font-size: 18px;
}

.feedback-banner--incorrect {
    background: rgba(255, 75, 75, 0.15);
    border: 2px solid var(--red-primary);
}

.feedback-banner--incorrect .feedback-icon {
    color: var(--red-primary);
    font-size: 28px;
}

.feedback-banner--incorrect .feedback-text {
    color: var(--red-primary);
    font-weight: 800;
    font-size: 16px;
}

.feedback-banner .feedback-detail {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Result Page --- */
.result-page {
    width: 100%;
    max-width: var(--max-width);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeSlideIn 0.5s ease;
}

.result-icon {
    font-size: 80px;
    margin-bottom: 16px;
    animation: bounceIn 0.6s ease;
}

.result-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 32px;
}

.result-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.result-stat {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.result-stat .stat-number {
    font-size: 28px;
    font-weight: 900;
}

.result-stat .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

.result-stat--xp .stat-number {
    color: var(--gold-primary);
}

.result-stat--accuracy .stat-number {
    color: var(--green-primary);
}

.result-stat--combo .stat-number {
    color: var(--orange-primary);
}

.result-stat--time .stat-number {
    color: var(--blue-primary);
}

/* --- Timer Display --- */
.timer-display {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    min-width: 48px;
    text-align: center;
    letter-spacing: 0.5px;
}

/* --- Best Time Badge on Level Nodes --- */
.best-time-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--blue-primary);
    background: rgba(28, 176, 246, 0.12);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-top: -4px;
    z-index: 1;
    text-align: center;
}

/* --- Word Spell Hint --- */
.word-spell-hint {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
    opacity: 0.8;
}

/* --- New Record Badge --- */
.new-record-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.2));
    border: 2px solid var(--gold-primary);
    color: var(--gold-primary);
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 20px;
    animation: bounceIn 0.6s ease, pulse 2s infinite 0.6s;
}

/* XP Bar animation */
.xp-gain-bar {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 32px;
}

.xp-gain-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.xp-gain-label .xp-amount {
    color: var(--gold-primary);
}

.xp-track {
    height: 12px;
    background: var(--gray-700);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-primary), var(--orange-primary));
    border-radius: var(--radius-full);
    transition: width 1.5s cubic-bezier(0.22, 1, 0.36, 1);
    width: 0;
}

.result-btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-family);
    text-transform: uppercase;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all var(--transition-fast);
}

.result-btn--primary {
    background: var(--green-primary);
    color: var(--white);
    box-shadow: 0 4px 0 var(--green-dark);
}

.result-btn--primary:hover {
    background: var(--green-light);
}

.result-btn--secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    box-shadow: 0 4px 0 var(--gray-700);
    border: 2px solid var(--gray-600);
}

/* --- Profile Page --- */
.profile-page {
    width: 100%;
    max-width: var(--max-width);
    padding: 20px;
}

.profile-header {
    text-align: center;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-primary), var(--blue-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 16px rgba(88, 204, 2, 0.3);
}

.profile-name {
    font-size: 22px;
    font-weight: 800;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.profile-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-stat-card .card-icon {
    font-size: 28px;
}

.profile-stat-card .card-info {
    display: flex;
    flex-direction: column;
}

.profile-stat-card .card-value {
    font-size: 20px;
    font-weight: 800;
}

.profile-stat-card .card-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.profile-notebook-card {
    background: var(--bg-card);
    border: 2px solid var(--gray-600);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.profile-notebook-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 8px;
}

.profile-notebook-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.profile-notebook-actions .result-btn {
    margin-bottom: 10px;
}

.profile-notebook-next {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.notebook-filters {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.notebook-filter {
    border: 2px solid var(--gray-600);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.notebook-filter.active {
    border-color: var(--blue-primary);
    color: var(--blue-primary);
    background: rgba(28, 176, 246, 0.1);
}

.notebook-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.notebook-item {
    background: var(--bg-card);
    border: 2px solid var(--gray-600);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.notebook-item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.notebook-item-char {
    font-size: 28px;
    font-weight: 900;
    color: var(--white);
}

.notebook-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
}

.notebook-item-sub {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.notebook-empty {
    background: var(--bg-card);
    border: 2px dashed var(--gray-600);
    border-radius: var(--radius-lg);
    padding: 20px 12px;
    text-align: center;
}

/* --- Tab Navigation --- */
.tab-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 2px solid var(--gray-700);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 200;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 16px;
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font-family);
    transition: color var(--transition-fast);
    color: var(--text-muted);
}

.tab-item:hover {
    color: var(--text-secondary);
}

.tab-item.active {
    color: var(--blue-primary);
}

.tab-item .tab-icon {
    font-size: 24px;
    line-height: 1;
}

.tab-item .tab-label {
    font-size: 11px;
    font-weight: 700;
}

/* --- Confetti --- */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 12px;
    height: 12px;
    top: -20px;
    animation: confettiFall linear forwards;
}

/* --- Combo Indicator --- */
.combo-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, var(--orange-primary), var(--red-primary));
    color: var(--white);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 800;
    z-index: 100;
    animation: comboPop 0.4s ease;
    box-shadow: 0 4px 16px rgba(255, 150, 0, 0.4);
}

/* --- XP Popup --- */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--gold-primary);
    color: var(--gray-800);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 20px;
    font-weight: 900;
    z-index: 9999;
    animation: xpFly 1s ease forwards;
    box-shadow: 0 4px 24px rgba(255, 200, 0, 0.5);
}

/* --- Tooltip (for locked levels) --- */
.tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-700);
    color: var(--white);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 10;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--gray-700);
}

.level-node--locked:hover .tooltip {
    opacity: 1;
}

/* --- Streak Day Indicator --- */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--orange-primary), var(--red-primary));
    color: var(--white);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 800;
}

/* --- Animations --- */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    70% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(-8px);
    }

    30% {
        transform: translateX(8px);
    }

    45% {
        transform: translateX(-6px);
    }

    60% {
        transform: translateX(6px);
    }

    75% {
        transform: translateX(-3px);
    }

    90% {
        transform: translateX(3px);
    }
}

@keyframes correctPop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: var(--shadow-btn) var(--green-dark), 0 0 20px rgba(88, 204, 2, 0.3);
    }

    50% {
        box-shadow: var(--shadow-btn) var(--green-dark), 0 0 30px rgba(88, 204, 2, 0.5);
    }
}

@keyframes blinkCaret {

    0%,
    100% {
        border-color: var(--blue-primary);
    }

    50% {
        border-color: transparent;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes confettiFall {
    0% {
        top: -10%;
        transform: rotate(0deg) translateX(0);
        opacity: 1;
    }

    100% {
        top: 110%;
        transform: rotate(720deg) translateX(var(--drift));
        opacity: 0;
    }
}

@keyframes comboPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes xpFly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    60% {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1.3);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(0.8);
    }
}

@keyframes starBurst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.3) rotate(180deg);
    }

    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .question-character {
        font-size: 60px;
    }

    .pinyin-display {
        font-size: 28px;
    }

    .pinyin-blank {
        min-width: 36px;
        height: 42px;
        font-size: 28px;
    }

    .option-btn {
        padding: 12px;
        font-size: 18px;
    }

    .level-node {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }

    .level-nodes .level-node:nth-child(odd) {
        margin-left: -40px;
    }

    .level-nodes .level-node:nth-child(even) {
        margin-right: -40px;
    }

    .result-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .result-stat {
        padding: 12px 8px;
    }

    .result-stat .stat-number {
        font-size: 22px;
    }

    .matching-column {
        max-width: 140px;
    }

    .match-item {
        padding: 10px;
        font-size: 17px;
    }
}

@media (min-width: 769px) {
    .page {
        padding-bottom: 120px;
    }

    .level-node {
        width: 80px;
        height: 80px;
        font-size: 24px;
    }

    .level-nodes .level-node:nth-child(odd) {
        margin-left: -80px;
    }

    .level-nodes .level-node:nth-child(even) {
        margin-right: -80px;
    }

    .option-btn {
        padding: 16px 20px;
        font-size: 22px;
    }

    .question-character {
        font-size: 96px;
    }
}

/* --- Auth --- */
.auth-page {
    justify-content: center;
    min-height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-card);
    border: 1px solid var(--gray-700);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px 20px;
}

.auth-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.auth-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--text-secondary);
}

.auth-input {
    width: 100%;
    border: 2px solid var(--gray-700);
    background: #14252b;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 16px;
    outline: none;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.auth-input:focus {
    border-color: var(--blue-primary);
    transform: translateY(-1px);
}

.auth-hint {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-error {
    min-height: 22px;
    margin-top: 10px;
    font-size: 14px;
    color: var(--red-light);
    font-weight: 700;
}

.auth-submit,
.auth-switch {
    width: 100%;
    margin-top: 10px;
}

.auth-submit:disabled,
.auth-switch:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.profile-phone {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

.text-green {
    color: var(--green-primary);
}

.text-red {
    color: var(--red-primary);
}

.text-gold {
    color: var(--gold-primary);
}

.text-blue {
    color: var(--blue-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 3px;
}
