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

:root {
    --color-bg: #ffffff;
    --color-bg-secondary: #f5f4f0;
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #6b6b68;
    --color-text-tertiary: #9e9d99;
    --color-border: rgba(0, 0, 0, 0.15);
    --color-border-secondary: rgba(0, 0, 0, 0.25);
    --radius-md: 8px;
    --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1c1c1a;
        --color-bg-secondary: #252523;
        --color-text-primary: #f0ede8;
        --color-text-secondary: #9e9d99;
        --color-text-tertiary: #6b6b68;
        --color-border: rgba(255, 255, 255, 0.12);
        --color-border-secondary: rgba(255, 255, 255, 0.22);
    }
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--color-bg);
    color: var(--color-text-primary);
    min-height: 100vh;
    padding: 2rem 1rem 4rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.header p {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* Topic tabs */
.topic-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.tab {
    padding: 6px 14px;
    border-radius: 999px;
    border: 0.5px solid var(--color-border-secondary);
    background: var(--color-bg);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'DM Sans', sans-serif;
}

.tab:hover {
    background: var(--color-bg-secondary);
}

.tab.active {
    background: #3C3489;
    color: #EEEDFE;
    border-color: #3C3489;
}

/* Card area layout */
.card-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Progress bar */
.progress-bar-wrap {
    width: 100%;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--color-bg-secondary);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #534AB7;
    border-radius: 99px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--color-text-tertiary);
    min-width: 48px;
    text-align: right;
}

/* Flip card */
.scene {
    width: 100%;
    max-width: 480px;
    height: 260px;
    perspective: 1200px;
    cursor: pointer;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    border: 0.5px solid var(--color-border-secondary);
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.card-front {
    background: var(--color-bg);
}

.card-back {
    background: var(--color-bg);
    transform: rotateY(180deg);
}

/* Card content */
.card-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
    padding: 3px 10px;
    border-radius: 999px;
}

.label-q {
    background: #EEEDFE;
    color: #3C3489;
}

.label-a {
    background: #E1F5EE;
    color: #0F6E56;
}

.card-question {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--color-text-primary);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.card-hint {
    font-size: 12px;
    color: var(--color-text-tertiary);
    margin-top: 0.5rem;
}

.card-answer {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    color: var(--color-text-primary);
    line-height: 1.5;
}

.card-explanation {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 0.75rem;
    line-height: 1.6;
    max-width: 340px;
}

/* Flip hint */
.flip-hint {
    font-size: 12px;
    color: var(--color-text-tertiary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.flip-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    border: 1.5px solid var(--color-border-secondary);
    border-radius: 3px;
    transform: rotateY(30deg);
}

/* Rating controls */
.controls {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}

.btn {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--color-border-secondary);
    background: var(--color-bg);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'DM Sans', sans-serif;
}

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

.btn:active {
    transform: scale(0.97);
}

.btn-got-it {
    background: #534AB7;
    color: #EEEDFE;
    border-color: #534AB7;
}

.btn-got-it:hover {
    background: #3C3489;
    border-color: #3C3489;
}

/* Score chips */
.score-row {
    display: flex;
    gap: 16px;
}

.score-chip {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
}

.chip-got {
    background: #E1F5EE;
    color: #0F6E56;
}

.chip-miss {
    background: #FCEBEB;
    color: #A32D2D;
}

/* Completion screen */
.done-msg {
    text-align: center;
    padding: 2rem;
}

.done-msg h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.done-msg p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

/* Games button */
.games-btn {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: var(--cotext-secondary);
    background: x solid vvar(--color-bg)lor-;
    border: 0.5par(--color-border-secondary);
    border-radius: var(--radius-md);
    padding: 5px 10px;
    text-decoration: none;
    transition: all 0.15s;
    z-index: 100;
}

.games-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
}