/* Phonics 5 Steps Web App - Mobile-First Stylesheet */
:root {
    --primary: #4F46E5;
    --primary-light: #EEF2FF;
    --step1-color: #EF4444;
    --step2-color: #F59E0B;
    --step3-color: #10B981;
    --step4-color: #06B6D4;
    --step5-color: #8B5CF6;
    --bg-main: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --radius-lg: 1.25rem;
    --radius-md: 0.75rem;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Prompt', 'Mali', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Mobile Container */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    min-height: 100vh;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.06);
    position: relative;
}

/* Top App Header */
.app-header {
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    color: white;
    padding: 1rem 1.25rem;
    border-bottom-left-radius: 1.5rem;
    border-bottom-right-radius: 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.school-tag {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.25);
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 500;
}

.passport-badge {
    background: #FEF08A;
    color: #854D0E;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.25rem 0.7rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
}

.app-subtitle {
    font-size: 0.8rem;
    opacity: 0.92;
}

/* Progress Step Indicator Bar */
.step-nav {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #F1F5F9;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.step-nav::-webkit-scrollbar {
    display: none;
}

.step-tab {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 0.4rem 0.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.step-tab .tab-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #CBD5E1;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.step-tab.active {
    color: var(--primary);
    background: #EEF2FF;
}

.step-tab.active .tab-icon {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

.step-tab.completed .tab-icon {
    background: #10B981;
}

/* Main Content Area */
.app-content {
    flex: 1;
    padding: 1.25rem;
    padding-bottom: 5rem;
    overflow-y: auto;
}

/* Card Styles */
.quest-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 2px solid #E2E8F0;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.quest-card.highlight {
    border-color: #6366F1;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}

.step-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed #CBD5E1;
}

.step-number-tag {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
}

/* Step Colors */
.bg-s1 { background: var(--step1-color); }
.bg-s2 { background: var(--step2-color); }
.bg-s3 { background: var(--step3-color); }
.bg-s4 { background: var(--step4-color); }
.bg-s5 { background: var(--step5-color); }

.border-s1 { border-color: var(--step1-color); }
.border-s2 { border-color: var(--step2-color); }
.border-s3 { border-color: var(--step3-color); }
.border-s4 { border-color: var(--step4-color); }
.border-s5 { border-color: var(--step5-color); }

/* Interactive Flashcards Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.letter-card {
    background: #FFFBEB;
    border: 2px solid #FDE68A;
    border-radius: 1rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    user-select: none;
}

.letter-card:active {
    transform: scale(0.95);
    background: #FEF08A;
}

.letter-big {
    font-size: 1.6rem;
    font-weight: 800;
    color: #D97706;
}

.letter-sound {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4B5563;
    background: rgba(0,0,0,0.05);
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    margin: 0.2rem 0;
}

.letter-word {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1F2937;
}

.letter-thai {
    font-size: 0.75rem;
    color: #6B7280;
}

/* Sound Button */
.btn-sound {
    background: #EEF2FF;
    color: #4F46E5;
    border: 1.5px solid #C7D2FE;
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sound:active {
    background: #C7D2FE;
    transform: scale(0.96);
}

/* Primary Action Buttons */
.btn-primary {
    background: linear-gradient(135deg, #4F46E5, #6366F1);
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #F1F5F9;
    color: #334155;
    border: 1px solid #CBD5E1;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* Option Choices in Quiz */
.option-btn {
    width: 100%;
    background: #F8FAFC;
    border: 2px solid #E2E8F0;
    border-radius: 0.85rem;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #1E293B;
    text-align: left;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-btn:active {
    background: #EEF2FF;
    border-color: #6366F1;
}

.option-btn.correct {
    background: #ECFDF5 !important;
    border-color: #10B981 !important;
    color: #065F46 !important;
}

.option-btn.wrong {
    background: #FEF2F2 !important;
    border-color: #EF4444 !important;
    color: #991B1B !important;
}

/* Word Blending Interactive Area */
.blending-box {
    background: #FEF3C7;
    border: 2px dashed #F59E0B;
    border-radius: 1rem;
    padding: 1.2rem;
    text-align: center;
    margin: 1rem 0;
}

.phoneme-tiles {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.phoneme-tile {
    width: 44px;
    height: 52px;
    background: white;
    border: 2px solid #F59E0B;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #B45309;
    box-shadow: 0 3px 0 #D97706;
}

.blend-operator {
    font-size: 1.2rem;
    font-weight: bold;
    color: #D97706;
}

/* Word Tile Clickable for Sentence Building */
.tile-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
    min-height: 48px;
    padding: 0.5rem;
    background: #F8FAFC;
    border: 2px dashed #CBD5E1;
    border-radius: 0.75rem;
}

.word-tile {
    background: white;
    border: 1.5px solid #6366F1;
    color: #4338CA;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 0 #4F46E5;
    user-select: none;
    transition: transform 0.1s;
}

.word-tile:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Canvas Tracing / Drawing Area */
.canvas-wrapper {
    position: relative;
    width: 100%;
    background: #FFFFFF;
    border: 2px solid #CBD5E1;
    border-radius: 1rem;
    overflow: hidden;
    touch-action: none;
    margin: 0.75rem 0;
}

canvas {
    display: block;
    width: 100%;
    height: 180px;
    background: transparent;
    cursor: crosshair;
}

.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: #F1F5F9;
    border-top: 1px solid #E2E8F0;
}

.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

.color-dot.active {
    transform: scale(1.2);
    border-color: #1E293B;
}

/* Voice Recorder Component */
.recorder-box {
    background: #F5F3FF;
    border: 2px solid #DDD6FE;
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    margin: 0.75rem 0;
}

.record-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #EF4444;
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.record-btn.recording {
    animation: pulse 1s infinite;
    background: #DC2626;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.08); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Certificate & Summary Result Sheet */
.certificate-card {
    background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
    border: 4px double #D97706;
    border-radius: 1.25rem;
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.cert-stamp {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 64px;
    height: 64px;
    border: 3px dashed #B45309;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.7rem;
    color: #B45309;
    transform: rotate(15deg);
}

.score-badge-big {
    font-size: 2.5rem;
    font-weight: 900;
    color: #4F46E5;
    margin: 0.5rem 0;
}

.score-table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.score-table th, .score-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #E2E8F0;
}

.score-table th {
    background: rgba(0,0,0,0.03);
    color: #475569;
}

/* Bottom Navigation */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: 100%;
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    z-index: 50;
}

/* Print Styling */
@media print {
    body { background: white; }
    .app-container { max-width: 100%; box-shadow: none; }
    .step-nav, .bottom-bar, .btn-sound, .btn-primary, .app-header { display: none !important; }
    .certificate-card { border: 2px solid #000; box-shadow: none; }
}
