:root {
    --bg-color: #f9fafb;
    --text-color: #1f2937;
    --card-bg: #ffffff;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #e5e7eb;
    --rating-know: #10b981;
    --rating-soso: #f59e0b;
    --rating-unknown: #ef4444;
}

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

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

.top-bar {
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    stroke-width: 2.5;
}

.topic-select {
    padding: 6px 10px;
}

.top-progress-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #4b5563;
    width: 100%;
}

.progress-bar {
    width: 150px;
    height: 10px;
    background: var(--secondary-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--rating-know);
    transition: width 0.3s ease-out;
}

select, button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--secondary-color);
    background: var(--card-bg);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

button.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 20px;
    transition: background 0.2s;
}

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

.main-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.flashcard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    perspective: 1000px;
    min-height: 0;
}

.flashcard {
    width: 100%;
    max-width: 350px;
    flex: 1;
    max-height: 400px;
    min-height: 150px;
    position: relative;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-color: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    text-align: center;
    overflow: hidden;
}

.flashcard-back {
    transform: rotateY(180deg);
}

.card-image {
    margin-bottom: 10px;
    max-height: 45%;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-image svg, .card-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply; /* Makes white background of raster image transparent on white card */
}

.card-text {
    font-size: min(1.8rem, 6vh);
    font-weight: 600;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.card-sentence {
    font-size: min(1rem, 4vh);
    font-weight: 300;
    color: #4b5563;
    font-style: italic;
    margin-top: 10px;
    overflow-y: auto;
}

.card-category {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 2;
}

.hidden {
    display: none !important;
}

.actions {
    margin-top: 15px;
    text-align: center;
    min-height: 50px;
    flex-shrink: 0;
}

.rating-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-rate {
    border: none;
    padding: 10px 15px;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.btn-unknown { background-color: var(--rating-unknown); }
.btn-soso { background-color: var(--rating-soso); }
.btn-know { background-color: var(--rating-know); }

.bottom-bar {
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--secondary-color);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    color: #9ca3af;
    gap: 3px;
    cursor: pointer;
    transition: color 0.2s;
    font-family: inherit;
    padding: 5px 15px;
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-btn.active .nav-icon {
    transform: scale(1.1);
}

.nav-icon {
    font-size: 1.4rem;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-text {
    font-size: 0.75rem;
    font-weight: 600;
}

.stats-page, .settings-page {
    padding: 15px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

.stats-page h2, .settings-page h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
    text-align: center;
}

.box-style {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.no-padding-bottom {
    padding-bottom: 0;
}

.stat-block h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #374151;
}

.stat-block .progress-bar {
    width: 90%;
    margin: 10px auto;
}

.streak-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 600;
    margin: 10px auto;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.4);
}

.category-stats-list {
    list-style: none;
    padding: 0;
    margin: 0 -15px;
}

.category-stats-list li {
    padding: 12px 15px;
    border-bottom: 1px solid var(--secondary-color);
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.category-stats-list li:last-child {
    border-bottom: none;
}

.mb-10 { margin-bottom: 10px; }
.small-text { font-size: 0.8rem; color: #6b7280; }

.setting-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #4b5563;
}

.setting-group select {
    width: 100%;
}

.ad-placeholder {
    padding: 10px;
    font-size: 0.8rem;
    color: #9ca3af;
    background: #e5e7eb;
    margin: 10px;
    border-radius: 8px;
    text-align: center;
}

/* Desktop adaptations */
@media(min-width: 768px) {
    .flashcard {
        height: 450px;
        flex: none;
        max-height: none;
        max-width: 400px;
    }
    .bottom-nav {
        justify-content: center;
        gap: 30px;
    }
}
