:root {
    --primary-orange: #FF6933;
    --primary-dark: #333333;
    --bg-light: #F8F9FA;
    --bg-white: #FFFFFF;
    --text-main: #2D3436;
    --text-muted: #636E72;
    --success-green: #2ecc71;
    --danger-red: #e74c3c;
    --gold: #f1c40f;
    --silver: #bdc3c7;
    --bronze: #e67e22;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    --border-light: 1px solid #f0f0f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Prompt', sans-serif;
}

.hidden { display: none !important; }

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
}

/* Header & Navigation */
.main-header {
    background-color: var(--bg-white);
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo .orange { color: var(--primary-orange); }

.user-stats {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-pill {
    display: flex;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid #e2e8f0;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    white-space: nowrap;
}

.stat-pill .icon {
    font-size: 1rem;
}

.stat-pill .bar-container {
    width: 60px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.stat-pill .bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.bar-fill.red { background: var(--danger-red); }
.bar-fill.orange { background: var(--primary-orange); }

.header-nav {
    display: flex;
    gap: 0.5rem;
}

.header-nav button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.header-nav button:hover {
    background: var(--bg-light);
}

/* Main Content */
#app-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 1rem;
}

#world-map, #quest-view {
    display: none;
}

#world-map.active, #quest-view.active {
    display: block;
}

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

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.world-node {
    background: var(--bg-white);
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: var(--border-light);
    position: relative;
}

.world-node:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
    border-color: rgba(255, 105, 51, 0.3);
}

.world-node.active {
    border-color: var(--primary-orange);
}

.world-node.locked {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(1);
}

.world-node.locked::after {
    content: "🔒";
    position: absolute;
    top: 10px;
    right: 10px;
}

.node-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Quest View */
.quest-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    background: var(--bg-white);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary-orange);
    font-weight: 600;
    cursor: pointer;
}

.timer {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--danger-red);
}

/* Modals */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-white);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: var(--radius);
    padding: 2rem;
    position: relative;
    overflow-y: auto;
}

.hidden { display: none !important; }

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
}

/* Quest Gameplay Specifics */
.game-container {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.drag-area {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem;
    border: 2px dashed #ddd;
    border-radius: var(--radius);
    min-height: 100px;
}

.drop-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.drop-zone {
    background: var(--bg-light);
    border: 2px solid #eee;
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 150px;
    text-align: center;
}

.drop-zone h4 { margin-bottom: 1rem; }

.btn-primary {
    background-color: var(--primary-orange);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.rank-badge, .vocab-total {
    margin-left: 15px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.vocab-total { color: #2c3e50; }

.pos-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-right: 10px;
    vertical-align: middle;
    border: 1px solid #bbdefb;
}

.btn-primary:hover {
    background-color: #e55a2b;
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Result Modal Styling */
.result-content {
    text-align: center;
}

.result-content h2 {
    font-size: 2rem;
    color: var(--primary-orange);
    margin-bottom: 1rem;
}

.rewards {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.reward-item {
    font-size: 1.25rem;
    font-weight: 700;
}

#reward-xp { color: var(--primary-orange); }
#reward-gold { color: var(--gold); }

/* Card Styling */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.vocab-card {
    background: white;
    border: 2px solid #eee;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    transition: box-shadow 0.2s;
}

.vocab-card.bronze { border-color: var(--bronze); }
.vocab-card.silver { border-color: var(--silver); }
.vocab-card.gold { border-color: var(--gold); }

.vocab-card .word {
    font-weight: 700;
    display: block;
    font-size: 1.1rem;
}

.vocab-card .meaning {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Sentence Builder Specifcs */
.sentence-quest {
    text-align: center;
}

.sentence-area {
    font-size: 1.5rem;
    margin: 2rem 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.blank {
    width: 120px;
    height: 40px;
    border-bottom: 3px solid var(--primary-orange);
    display: inline-block;
    vertical-align: middle;
}

.options-pool {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}
/* Mobile Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    .user-stats {
        width: 100%;
        justify-content: space-around;
        flex-wrap: wrap;
    }
}

/* Dark Mode Variables */
:root[data-theme="dark"] {
    --bg-light: #121212;
    --bg-white: #1e1e1e;
    --text-main: #f0f0f0;
    --text-muted: #aaaaaa;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --primary-dark: #f0f0f0;
}

:root[data-theme="dark"] .logo .dark { color: #f0f0f0; }
:root[data-theme="dark"] .main-header { border-bottom: 1px solid #333; }
:root[data-theme="dark"] .world-node, 
:root[data-theme="dark"] .quest-header,
:root[data-theme="dark"] .game-container,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .vocab-card,
:root[data-theme="dark"] .btn-option {
    background-color: var(--bg-white);
    color: var(--text-main);
}

:root[data-theme="dark"] .btn-option:hover {
    background-color: #2a2a2a;
}

/* Daily Quests Panel */
#daily-quests-container {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 1rem;
}

.daily-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

#daily-quests-list {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0 1.5rem 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#daily-quests-list::-webkit-scrollbar { display: none; }

.quest-item {
    background: var(--bg-white);
    padding: 1rem 1.25rem;
    border-radius: 14px;
    min-width: 260px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid #eeeeee;
    transition: all 0.3s ease;
    position: relative;
}

.quest-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    border-color: rgba(255, 105, 51, 0.2);
}

.quest-icon {
    font-size: 1.6rem;
    background: #fdfdfd;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid #f5f5f5;
}

.quest-content-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quest-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.quest-title-row .title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.quest-title-row .progress-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.quest-progress {
    height: 4px; /* Slim and elegant */
    background: #f2f2f2;
    border-radius: 2px;
}

.quest-progress-bar {
    height: 100%;
    background: var(--primary-orange); 
    border-radius: 2px;
}

.quest-footer-row {
    display: flex;
    justify-content: flex-start;
    margin-top: 2px;
}

.rewards-inline {
    display: flex;
    gap: 0.6rem;
}

.reward {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.reward.xp { background: #fef1ec; color: #ff6a34; }
.reward.gold { background: #fff8e1; color: #b78a00; }

.quest-item.completed {
    background: #fafafa;
    border-color: #e0e0e0;
}

.quest-item.completed .quest-icon {
    opacity: 0.5;
    filter: grayscale(1);
}

.quest-item.completed .title {
    color: var(--text-muted);
    text-decoration: line-through;
}

.quest-item.completed::after {
    content: "Done";
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--success-green);
    text-transform: uppercase;
}

/* Dashboard Tabs */
.dashboard-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--primary-orange);
    border-bottom-color: var(--primary-orange);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Leaderboard */
#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 8px;
}

.rank-item.top3 {
    background: rgba(255, 105, 51, 0.1);
    border: 1px solid var(--primary-orange);
}

/* World 3: Vocab Dungeon Styles */
.vocab-battle {
    text-align: center;
}

.monster-area {
    font-size: 5rem;
    margin: 1rem 0;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.flashcard {
    background: var(--bg-light);
    border: 3px solid var(--primary-orange);
    padding: 2rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.flashcard .question-word {
    font-size: 2.5rem;
    font-weight: 700;
}

.mcq-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn-option {
    background: white;
    border: 2px solid #eee;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-option:hover {
    border-color: var(--primary-orange);
    background: var(--bg-light);
}

/* Rank Highlights */
.rank-badge-container {
    padding: 2px 10px;
    border-radius: 20px;
    background: rgba(255, 105, 51, 0.1);
    border: 1px solid var(--primary-orange);
    text-align: center;
}

#user-rank { font-weight: 700; color: var(--primary-orange); }
.rank-beginner { color: #888 !important; }
.rank-intermediate { color: #5dade2 !important; }
.rank-advanced { color: #f1c40f !important; font-weight: 700; }

/* Word Detail View - Premium Redesign */
#word-detail-view {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 2rem;
}

#word-detail-view.active { display: flex; }

.word-card {
    background: var(--bg-white);
    width: 100%;
    max-width: 600px;
    padding: 4rem 3rem;
    border-radius: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.04);
    text-align: center;
    position: relative;
    border: var(--border-light);
}

.word-card .btn-back {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    color: #ff8c66;
    font-size: 1.1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.word-header h1 {
    font-size: clamp(3.5rem, 15vw, 5.5rem); 
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main); /* Darker for luxury */
    letter-spacing: -2px;
    word-break: break-word;
}

.sub-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.pos-badge-blue {
    background: #e1f5fe;
    color: #0288d1;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
}

.thai-reading {
    font-size: 1.4rem;
    color: #666;
    font-weight: 400;
}

.main-speaker-container {
    margin: 1.5rem 0 2.5rem 0;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.btn-speaker-large {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 3.5rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-speaker-large:hover {
    transform: scale(1.15);
}

.section-label {
    color: var(--primary-orange);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.meaning-text {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    font-weight: 700;
    color: #333;
    margin-bottom: 2.5rem;
    text-align: left;
}

.example-container {
    text-align: left;
}

.btn-speak-mini {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
}

.en-text {
    font-size: 1.2rem;
    font-weight: 500;
    font-style: italic;
    color: #333;
    margin-bottom: 0.5rem;
}

.th-text {
    font-size: 1.1rem;
    color: #888;
}

.btn-next-word {
    background: var(--primary-orange);
    color: white;
    width: 100%;
    border: none;
    padding: 1.25rem;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 2rem;
    transition: all 0.2s;
    box-shadow: 0 10px 20px rgba(255, 105, 51, 0.2);
}

.btn-next-word:hover {
    background: #ff521a;
    transform: translateY(-3px);
    box-shadow: 0 14px 28px rgba(255, 105, 51, 0.3);
}

.btn-next-word:active {
    transform: translateY(-1px);
}

/* ========================================= */
/*       Mobile Responsive Design (768px)    */
/* ========================================= */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: space-between;
        padding-top: 0.5rem;
    }
    
    .logo {
        width: auto;
        text-align: left;
        margin-bottom: 0;
        font-size: 1.2rem;
    }
    
    .header-nav {
        position: static;
        order: 2;
    }

    .word-card {
        padding: 2.5rem 1.25rem;
    }

    .btn-speaker-large {
        font-size: 2.5rem;
    }

    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .user-stats {
        width: 100%;
        order: 3;
        justify-content: center;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    #app-container {
        margin: 1rem auto;
        padding: 0.5rem;
    }
    
    .map-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .world-node {
        padding: 1.5rem;
    }
    
    /* Word Detail View adjustments */
    #word-detail-view {
        padding: 1rem;
    }
    
    .word-card {
        padding: 2rem 1.5rem;
    }
    
    .word-header h1 {
        font-size: 2.2rem;
    }
    
    .meaning-section p {
        font-size: 1.2rem;
        margin-bottom: 1.5rem;
    }
    
    .example-section .en-text {
        font-size: 1rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        padding: 1.25rem;
        margin: 2vh auto;
    }
    
    .stats-grid, .settings-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .word-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Mastered States (Global) */
.level-card.mastered {
    border: 2px solid var(--success-green);
    background: rgba(40, 167, 69, 0.05);
}

.level-card.mastered .level-status {
    color: var(--success-green);
    font-weight: 700;
}

.mastered-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--success-green);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.level-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-review-small, .btn-test-small {
    padding: 0.4rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-review-small {
    background: #fff0eb;
    color: var(--primary-orange);
}

.btn-test-small {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-review-small:hover { background: #ffe0d6; }
.btn-test-small:hover { background: #c8e6c9; }

/* Level Grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.level-card {
    background: white;
    padding: 2rem 1rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.level-card.unlocked {
    border-color: #ffe0d6;
}

.level-card.unlocked:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(255, 105, 51, 0.15);
    border-color: var(--primary-orange);
}

.level-card.locked {
    opacity: 0.5;
    background: #f0f0f0;
    cursor: not-allowed;
}

.level-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-orange);
    margin-bottom: 0.5rem;
}

.level-status {
    font-size: 0.85rem;
    color: #888;
    font-weight: 600;
}

/* Test Mode UI */
.test-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
}

.test-word-box {
    margin-bottom: 3rem;
}

.test-word-box h1 {
    font-size: 4rem;
    color: var(--primary-orange);
    margin-top: 1rem;
}

.test-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.btn-test-option {
    background: white;
    border: 2px solid #eee;
    padding: 1.25rem;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-test-option:hover {
    border-color: var(--primary-orange);
    background: #fffafa;
    transform: translateX(5px);
}

.btn-test-option:active {
    transform: translateX(2px);
}

/* Auth View CSS */
#auth-view {
    display: none;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #fff5f2 0%, #fff 100%);
    padding: 1.5rem;
}

#auth-view.active { display: flex; }

.auth-card {
    background: var(--bg-white);
    width: 100%;
    max-width: 450px;
    padding: 3rem 2.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(255, 105, 51, 0.1);
    text-align: center;
}

.auth-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-orange);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.input-group input {
    padding: 1rem;
    border: 2px solid #eee;
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-orange);
}

.auth-footer {
    margin-top: 2rem;
    font-size: 0.95rem;
}

.auth-footer a {
    color: var(--primary-orange);
    font-weight: 700;
    text-decoration: none;
}

/* Mobile Responsive Refinements (Simple & Elegant) */
@media (max-width: 480px) {
    .main-header { padding: 0.5rem; }
    
    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 0.6rem;
    }
    
    .logo { font-size: 1.1rem; }
    
    .user-stats {
        width: 100%;
        display: flex;
        justify-content: center;
        overflow-x: auto;
        padding-bottom: 0.4rem;
        gap: 0.4rem;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .user-stats::-webkit-scrollbar { display: none; }
    
    .stat-pill {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        gap: 0.3rem;
        min-width: fit-content;
    }
    
    .stat-pill .bar-container { width: 40px; }
    
    .header-nav {
        width: 100%;
        justify-content: center;
        gap: 1rem;
        border-top: 1px solid #f5f5f5;
        padding-top: 0.5rem;
    }

    #app-container { margin: 1rem auto; padding: 0 1rem; }
    
    .map-grid { grid-template-columns: 1fr; gap: 1rem; }
    
    .world-node { padding: 2rem 1rem; }
    
    .word-card {
        padding: 2.5rem 1.25rem;
        border-radius: 24px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    }
    
    .word-header h1 {
        font-size: 2.8rem;
        letter-spacing: -1px;
    }
    
    .thai-reading { font-size: 1.1rem; }
    
    .meaning-text {
        font-size: 1.6rem;
        margin-bottom: 2rem;
    }
    
    .en-text { font-size: 1.1rem; }
    
    .btn-speaker-large { font-size: 2.5rem; }
    
    .btn-next-word {
        padding: 1rem;
        font-size: 1.25rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
    
    .auth-card {
        padding: 2rem 1.5rem;
    }
}

/* Touch targets for visual excellence */
button, input, .btn-test-option, .level-card {
    min-height: 44px;
    touch-action: manipulation;
}

#user-welcome {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 120px;
}

/* --- Industrial Polishing: Status & Toasts --- */
#server-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-online { background: #00c853; box-shadow: 0 0 8px #00c853; animation: pulse 2s infinite; }
.status-offline { background: #ff5252; box-shadow: 0 0 8px #ff5252; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 24px;
    background: #323232;
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    animation: slideInRight 0.3s ease forwards, fadeOut 0.3s ease forwards 2.7s;
}

.settings-select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-top: 5px;
    font-size: 0.9rem;
}
.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 4px; bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary-orange); }
input:checked + .slider:before { transform: translateX(26px); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Status Indicator Pill */
.status-indicator {
    position: fixed;
    top: 85px; /* Safely below header */
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.95);
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(0,0,0,0.05);
    backdrop-filter: blur(5px);
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

/* --- Professional Mobile & iPhone Optimization --- */
@media (max-width: 600px) {
    /* 1. Global Scaling */
    :root { --font-main: 14px; }
    
    /* 2. Word Detail View Fixing */
    #detail-word {
        font-size: 2.2rem !important;
        margin-top: 10px !important;
    }
    #btn-speak {
        width: 60px !important;
        height: auto !important;
        margin: 15px auto !important;
    }

    /* 3. Status Indicator (Mobile adjustment) */
    .status-indicator {
        top: 80px !important;
        right: 10px !important;
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
    }

    /* 4. Controls */
    .btn-primary[onclick*="showNextWord"] {
        width: 90% !important;
        margin: 0 auto 20px auto !important;
        display: block;
    }

    /* 5. Voice List (iPhone Picker) */
    .settings-select {
        font-size: 16px !important; /* Prevents iOS auto-zoom on select */
    }
}
