:root {
    /* Design System */
    --color-primary: #1CB0F6; /* Duolingo-like friendly blue */
    --color-primary-dark: #1899D6;
    --color-secondary: #FFC800; /* Friendly yellow */
    --color-background: #F7F7F7;
    --color-surface: #FFFFFF;
    --color-text-primary: #3C3C3C;
    --color-text-secondary: #777777;
    --color-border: #E5E5E5;
    
    --color-success: #58CC02;
    --color-success-bg: #D7FFB8;
    --color-error: #FF4B4B;
    --color-error-bg: #FFD8D8;
    --color-warning: #FF9600;

    --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Meiryo", sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-sm: 0 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand a {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.toggle-btn {
    background: none;
    border: 2px solid var(--color-border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: 0.2s;
}

.toggle-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary-dark);
}

/* Containers */
.container {
    max-width: 768px; /* Mobile-first but looks good on desktop */
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
}

/* Grid & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.card {
    background-color: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.level-card {
    text-align: center;
    padding: 2rem;
}

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

.exam-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.exam-card p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-block;
    background-color: var(--color-primary);
    color: white;
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--color-primary-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    width: 100%;
    transition: 0.1s;
    box-shadow: 0 4px 0 var(--color-primary-dark);
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--color-primary-dark);
}

.btn-secondary {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    border-color: var(--color-border);
    box-shadow: 0 4px 0 var(--color-border);
}

.btn-secondary:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--color-border);
}

/* Typography Helpers */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.text-muted { color: var(--color-text-secondary); }

/* Japanese Text & Furigana */
.jp-text {
    font-size: 1.25rem;
    line-height: 2; /* Important for furigana spacing */
    word-break: keep-all;
    overflow-wrap: break-word;
}

ruby {
    ruby-align: center;
}

rt {
    font-size: 0.6em;
    color: var(--color-text-secondary);
    user-select: none;
}

/* GLOBAL FURIGANA TOGGLE */
body.furigana-hidden ruby rt {
    display: none;
}

/* Reading Passage */
.passage-card {
    background-color: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.15rem;
    line-height: 2.2;
}

.passage-card details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--color-border);
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.passage-card summary {
    cursor: pointer;
    font-weight: 600;
}

/* Custom Answer Choices */
.choice-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    cursor: pointer;
    background: var(--color-surface);
    transition: 0.15s;
    font-size: 1.1rem;
}

.choice-card:hover {
    background-color: #f0f9ff;
    border-color: var(--color-primary);
}

.choice-card input[type="radio"] {
    display: none;
}

.choice-indicator {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.choice-card.selected {
    border-color: var(--color-primary);
    background-color: #f0f9ff;
}

.choice-card.selected .choice-indicator {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

.choice-card.selected .choice-indicator::after {
    content: '';
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

/* Correct / Incorrect states */
.choice-card.correct {
    border-color: var(--color-success);
    background-color: var(--color-success-bg);
}
.choice-card.correct .choice-indicator {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

.choice-card.incorrect {
    border-color: var(--color-error);
    background-color: var(--color-error-bg);
}
.choice-card.incorrect .choice-indicator {
    background-color: var(--color-error);
    border-color: var(--color-error);
}

/* Result Screen */
.result-box {
    text-align: center;
    padding: 3rem 1rem;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--color-success);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 auto 1.5rem auto;
    border: 4px solid var(--color-success-bg);
    box-shadow: var(--shadow-md);
}

/* Timer */
.sticky-timer {
    position: sticky;
    top: 60px; /* Below header */
    background: var(--color-surface);
    padding: 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    z-index: 90;
    box-shadow: var(--shadow-sm);
    color: var(--color-text-primary);
}

.sticky-timer.warning {
    color: var(--color-error);
    border-color: var(--color-error);
}

/* Skeleton loader */
.skeleton {
    background: #e2e2e2;
    background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1rem;
}
.tab-btn {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px; /* Overlap border */
    transition: 0.2s;
}
.tab-btn:hover {
    color: var(--color-text-primary);
}
.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}
