:root {
    --bg: #f1f5f9;
    --bg-elevated: #ffffff;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --text: #0f172a;
    --muted: #6b7280;
    --danger: #dc2626;
    --success: #16a34a;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.45);
    --transition-fast: 0.2s ease-out;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #e0f2fe 0%, #f9fafb 45%, #e5f0ff 100%);
    color: var(--text);
}

.app-shell {
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    padding: 12px 12px 72px;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.7);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 6px;
    z-index: 10;
}

.app-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
}

.app-logo-circle {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #f9fafb;
    background: radial-gradient(circle at top, #60a5fa, #1d4ed8);
}

.app-header-user {
    font-size: 0.8rem;
    color: var(--muted);
}

.user-name {
    max-width: 140px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 18px 4px 10px;
}

.card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    padding: 18px 18px 20px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.4);
    position: relative;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: rgba(219, 234, 254, 0.9);
    color: var(--muted);
}

.pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.card-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
}

.quiz-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.quiz-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 13px;
    border-radius: var(--radius-lg);
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.7);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

.quiz-item .quiz-name {
    text-decoration: none;
}

.quiz-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    border-color: rgba(37, 99, 235, 0.7);
}

.quiz-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quiz-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.quiz-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--muted);
}

.badge {
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 253, 0.45);
}

.badge-completed {
    background: rgba(22, 163, 74, 0.15);
    border-color: var(--success);
    color: var(--success);
    font-weight: 600;
}

.quiz-chevron {
    font-size: 1rem;
    color: var(--muted);
}

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-radius: 999px;
    border: none;
    padding: 11px 14px;
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.primary-btn {
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #f9fafb;
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.35);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 48px rgba(37, 99, 235, 0.45);
}

.secondary-btn {
    background: #ffffff;
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.9);
}

.secondary-btn:hover {
    background: #eff6ff;
    color: #1f2937;
}

.app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 480px;
    margin: 0 auto;
    padding: 6px 12px 10px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.98), transparent);
    pointer-events: none;
}

.nav-item {
    flex: 1;
    pointer-events: auto;
    text-decoration: none;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 0 7px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.9);
    font-size: 0.7rem;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.12);
}

.nav-item:hover {
    background: #eff6ff;
    color: #1f2937;
}

.nav-icon {
    font-size: 1rem;
}

.nav-item-with-badge {
    position: relative;
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    max-width: 400px;
    margin: auto;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.field-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.field-input,
.field-select,
.field-textarea {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: #ffffff;
    padding: 9px 11px;
    font-size: 0.85rem;
    color: var(--text);
    outline: none;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.field-textarea {
    resize: vertical;
    min-height: 120px;
}

.error {
    margin-top: 8px;
    padding: 6px 9px;
    border-radius: 10px;
    border: 1px solid #fecaca;
    background: #fee2e2;
    font-size: 0.78rem;
    color: #b91c1c;
}

.success {
    margin-top: 8px;
    padding: 6px 9px;
    border-radius: 10px;
    border: 1px solid #bbf7d0;
    background: #dcfce7;
    font-size: 0.78rem;
    color: #166534;
}

.quiz-question-card {
    position: relative;
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

.quiz-question-card.slide-in {
    animation: slideIn 0.25s ease-out;
}

.quiz-question-card.slide-out {
    animation: slideOut 0.2s ease-in forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 14px;
}

.option-chip {
    border-radius: 14px;
    padding: 10px 11px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.86rem;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.option-chip:hover {
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.option-prefix {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.9);
    color: var(--muted);
}

.option-chip.selected {
    border-color: var(--accent);
    background: radial-gradient(circle at top left, rgba(191, 219, 254, 0.9), rgba(219, 234, 254, 0.9));
}

.option-chip.correct {
    border-color: var(--success);
    background: rgba(22, 163, 74, 0.18);
}

.option-chip.incorrect {
    border-color: var(--danger);
    background: rgba(248, 113, 113, 0.18);
}

.quiz-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--muted);
}

.progress-bar {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: rgba(191, 219, 254, 0.9);
    overflow: hidden;
    margin-top: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transition: width 0.25s ease-out;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.8rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 8px 6px;
    text-align: left;
}

.leaderboard-table th {
    color: var(--muted);
    font-weight: 500;
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
}

.leaderboard-table tr:nth-child(odd) td {
    background: #ffffff;
}

.leaderboard-table tr:nth-child(even) td {
    background: #eff6ff;
}

.rank-pill {
    min-width: 26px;
    text-align: center;
    padding: 3px 0;
    border-radius: 999px;
    font-size: 0.76rem;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.65);
}

.rank-1 {
    background: radial-gradient(circle at top, #facc15, #f97316);
    color: #111827;
    border-color: transparent;
}

.rank-2 {
    background: radial-gradient(circle at top, #e5e7eb, #9ca3af);
    color: #111827;
    border-color: transparent;
}

.rank-3 {
    background: radial-gradient(circle at top, #fed7aa, #fb923c);
    color: #111827;
    border-color: transparent;
}

.leaderboard-podium {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-podium-item {
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
    border: 2px solid transparent;
}

.leaderboard-podium-item.rank-1 {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
    font-size: 1.1rem;
}

.leaderboard-podium-item.rank-2 {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    border-color: #9ca3af;
    font-size: 1.05rem;
}

.leaderboard-podium-item.rank-3 {
    background: linear-gradient(135deg, #ffedd5, #fed7aa);
    border-color: #fb923c;
    font-size: 1.02rem;
}

.leaderboard-podium-rank {
    min-width: 36px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.leaderboard-podium-name {
    flex: 1;
}

.leaderboard-podium-points {
    font-weight: 700;
    color: var(--accent);
}

.leaderboard-medal {
    margin-right: 4px;
}

.leaderboard-rest .leaderboard-table-small {
    font-size: 0.78rem;
}

.leaderboard-rest .leaderboard-table-small th,
.leaderboard-rest .leaderboard-table-small td {
    padding: 6px 6px;
}

.mb-2 {
    margin-bottom: 8px;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.muted {
    color: var(--muted);
}

.app-footer {
    padding: 12px 16px 16px;
    text-align: center;
}

.app-footer-copyright {
    font-size: 0.75rem;
    color: var(--muted);
}

.app-footer-copyright a {
    color: var(--accent);
    text-decoration: none;
}

.app-footer-copyright a:hover {
    text-decoration: underline;
}

@media (min-width: 768px) {
    .app-shell {
        padding-top: 26px;
    }
}

