:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.view {
    display: none;
    padding: 24px;
    height: 100%;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* Dashboard */
.app-header {
    margin-bottom: 40px;
    text-align: center;
    padding-top: 20px;
}

.app-header h1 {
    font-size: 24px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress-summary {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.stat-card {
    background: var(--background);
    padding: 16px 24px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    /* Changed from center to allow scrolling */
    justify-content: center;
    margin-bottom: 24px;
    overflow-y: auto;
    /* Allow container scrolling */
    height: 0;
    /* Force flex child to respect height */
}

/* Dashboard Grid */
.day-list-container {
    flex: 1;
    overflow-y: auto;
}

.day-list-container h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 18px;
    color: var(--text-muted);
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
    padding-bottom: 24px;
}

.day-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    height: 80px;
}

.day-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.day-card.completed {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: var(--success);
}

.day-num {
    font-weight: 600;
    font-size: 14px;
}

.status-icon {
    font-weight: bold;
}

/* Detailed Word Card */
.word-card {
    width: 100%;
    background: var(--background);
    border-radius: 20px;
    padding: 32px;
    /* Remove min-height to allow content flow */
    /* min-height: 400px; */
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.card-header {
    text-align: center;
    margin-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 16px;
}

.word-title {
    font-size: 36px;
    margin-bottom: 8px;
    color: var(--primary);
}

.phonetics-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    color: var(--text-muted);
    font-family: monospace;
    font-size: 14px;
}

.pron .region {
    background: #e0e7ff;
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: sans-serif;
    margin-right: 4px;
    font-weight: 600;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.section-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.meaning-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.detail-list {
    list-style: none;
}

.detail-list li {
    margin-bottom: 12px;
    line-height: 1.5;
    border-bottom: 1px dashed #f1f5f9;
    padding-bottom: 8px;
}

.detail-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.en-text {
    color: var(--text-main);
    font-weight: 500;
    font-size: 15px;
}

.cn-text {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.word-ref {
    color: var(--primary);
    font-weight: 600;
}

.cn-ref {
    color: var(--text-muted);
    font-size: 13px;
    margin-left: 4px;
}

.empty-section {
    color: #cbd5e1;
    font-size: 13px;
    font-style: italic;
}

.study-controls {
    display: flex;
    gap: 12px;
}

.study-controls button {
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Test View */
.test-card {
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s;
    justify-content: center;
}

.test-card .hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 16px;
}

.answer-actions {
    display: flex;
    gap: 16px;
    width: 100%;
}

.action-btn {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.action-btn.forgot {
    background: #fef2f2;
    color: var(--danger);
}

.action-btn.remembered {
    background: #f0fdf4;
    color: var(--success);
}

.action-btn .icon {
    font-size: 24px;
}

/* Completion View */
.completion-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.stats {
    margin: 32px 0;
    padding: 24px;
    background: var(--background);
    border-radius: 16px;
    width: 100%;
}
/* Buttons */
button {
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    transform: scale(0.98);
}

.primary-btn {
    background: var(--primary);
    color: white;
    padding: 16px;
    width: 100%;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 16px;
    border: 1px solid #e2e8f0;
}

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

.back-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
    font-size: 14px;
}

/* View Header */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-top: env(safe-area-inset-top, 0);
}

/* Test Container */
.test-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 24px;
    overflow-y: auto;
}

.test-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== MOBILE RESPONSIVE STYLES ========== */

/* Safe Area for iOS notch */
html {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    -webkit-overflow-scrolling: touch;
}

#app {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Touch improvements */
* {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Prevent text selection on buttons */
button, .day-card {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile-specific adjustments */
@media screen and (max-width: 480px) {
    .view {
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top, 0));
    }
    
    .app-header {
        margin-bottom: 24px;
        padding-top: 10px;
    }
    
    .app-header h1 {
        font-size: 22px;
        margin-bottom: 16px;
    }
    
    .stat-card {
        padding: 12px 16px;
        min-width: 80px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .days-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
    }
    
    .day-card {
        padding: 14px 8px;
        height: 65px;
    }
    
    .day-num {
        font-size: 13px;
    }
    
    .word-card {
        padding: 20px;
        border-radius: 16px;
    }
    
    .word-title {
        font-size: 28px;
    }
    
    .phonetics-container {
        flex-direction: column;
        gap: 6px;
        font-size: 13px;
    }
    
    .meaning-text {
        font-size: 16px;
    }
    
    .section {
        padding: 12px;
        border-radius: 10px;
    }
    
    .section-label {
        font-size: 11px;
    }
    
    .en-text {
        font-size: 14px;
    }
    
    .cn-text {
        font-size: 12px;
    }
    
    .study-controls {
        gap: 8px;
    }
    
    .primary-btn, .secondary-btn {
        padding: 14px;
        font-size: 15px;
    }
    
    .action-btn {
        padding: 14px;
    }
    
    .action-btn .icon {
        font-size: 20px;
    }
    
    .answer-actions {
        gap: 10px;
    }
    
    .success-icon {
        font-size: 48px;
    }
    
    .completion-content h2 {
        font-size: 20px;
    }
    
    .stats {
        margin: 24px 0;
        padding: 16px;
    }
}

/* Very small phones */
@media screen and (max-width: 360px) {
    .days-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .day-card {
        padding: 12px 6px;
        height: 60px;
    }
    
    .day-num {
        font-size: 12px;
    }
    
    .word-title {
        font-size: 24px;
    }
    
    .phonetics-container {
        font-size: 12px;
    }
}

/* Landscape orientation */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .app-header {
        margin-bottom: 16px;
        padding-top: 8px;
    }
    
    .app-header h1 {
        margin-bottom: 12px;
    }
    
    .day-list-container h2 {
        margin-bottom: 12px;
    }
    
    .days-grid {
        gap: 8px;
    }
    
    .day-card {
        height: 50px;
        padding: 10px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
    }
    
    .stat-card {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .day-card {
        background: var(--surface);
        border-color: #334155;
    }
    
    .day-card.completed {
        background: rgba(34, 197, 94, 0.1);
        border-color: rgba(34, 197, 94, 0.3);
    }
    
    .word-card {
        background: var(--surface);
    }
    
    .section {
        background: rgba(255, 255, 255, 0.03);
    }
    
    .card-header {
        border-bottom-color: #334155;
    }
    
    .detail-list li {
        border-bottom-color: #334155;
    }
    
    .pron .region {
        background: rgba(99, 102, 241, 0.2);
    }
    
    .secondary-btn {
        border-color: #334155;
    }
    
    .action-btn.forgot {
        background: rgba(239, 68, 68, 0.1);
    }
    
    .action-btn.remembered {
        background: rgba(34, 197, 94, 0.1);
    }
}
