*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --border: #e8eaed;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Login */
.login-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--border);
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.login-tagline {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.45;
}

.login-body {
    padding: 28px 32px 32px;
}

.login-heading {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}

.login-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-body .alert {
    margin-bottom: 16px;
}

.login-footer {
    padding: 20px 32px 24px;
    background: #fafbfc;
    border-top: 1px solid var(--border);
}

.login-legal-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
}

.login-legal-links a {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
}

.login-legal-links a:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-google {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    width: 100%;
    padding: 14px 20px;
}

.btn-google:hover { background: #f9fafb; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: #f3f4f6; }

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 16px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-icon:hover { background: #f3f4f6; color: var(--text); }

.btn-icon-sm {
    font-size: 16px;
    padding: 2px 6px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #fecaca;
}

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    text-decoration: none;
}

.brand:hover { color: var(--primary); }

.topbar-nav {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.topbar-nav-link {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.topbar-nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.topbar-nav-link.active {
    background: #eef2ff;
    color: var(--primary);
}

.user-streak {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff7ed;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

.streak-icon { font-size: 16px; }

.friends-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
}

.friend-chip {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 4px 10px 4px 4px;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 13px;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.friend-chip:hover,
.friend-chip:focus-visible {
    border-color: #c7cad1;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    outline: none;
}

.friend-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.friend-avatar.placeholder {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.friend-name {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
    margin: 0;
    transition: max-width 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}

.friend-chip:hover .friend-name,
.friend-chip:focus-visible .friend-name {
    max-width: 110px;
    opacity: 1;
    margin: 0 6px;
}

.friend-streak {
    color: #ea580c;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    line-height: 1;
    margin-left: 3px;
}

.friend-chip:hover .friend-streak,
.friend-chip:focus-visible .friend-streak {
    margin-left: 0;
}

@media (hover: none) {
    .friend-name {
        max-width: 80px;
        opacity: 1;
        margin-left: 2px;
    }
}

.friend-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.friend-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar.placeholder {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.account-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.account-btn:hover {
    border-color: #c7cad1;
    box-shadow: var(--shadow);
}

.account-btn-name {
    font-size: 13px;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.modal-open {
    overflow: hidden;
}

/* Dashboard */
.dashboard {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    width: 100%;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.section-header-compact {
    margin-bottom: 16px;
}

.section-header-compact h2 {
    margin-bottom: 0;
    display: inline;
}

.section-header-compact .badge {
    margin-left: 8px;
    vertical-align: middle;
}

.section-desc {
    color: var(--text-muted);
    font-size: 14px;
}

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

/* Daily section — semaine */
.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.week-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 12px;
}

.week-day-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.week-day-num {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
}

.week-day.completed {
    background: var(--success-bg);
    border-color: #a7f3d0;
}

.week-day.completed .week-day-num {
    color: var(--success);
}

.week-day.today {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.week-day.today .week-day-num {
    color: var(--primary);
}

.week-day.completed.today {
    background: var(--success);
    border-color: var(--success);
}

.week-day.completed.today .week-day-label,
.week-day.completed.today .week-day-num {
    color: #fff;
}

.btn-calendar-more {
    width: 100%;
    margin-bottom: 16px;
}

.calendar-widget {
    background: var(--bg);
    border-radius: 10px;
    padding: 16px;
}

.modal-calendar {
    max-width: 400px;
}

.modal-calendar h3 {
    margin-bottom: 16px;
    padding-right: 28px;
}

/* Quiz libre */
.custom-section .section-desc {
    margin-bottom: 16px;
}

.custom-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.custom-meta span {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 6px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 15px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-empty { aspect-ratio: 1; }

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid transparent;
}

.cal-day.completed {
    background: var(--success-bg);
    color: var(--success);
    border-color: #a7f3d0;
}

.cal-day.today {
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

.cal-day.completed.today {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.calendar-legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.completed { background: var(--success); }
.dot.today { background: var(--primary); }

.daily-action {
    margin-top: 4px;
}

.daily-friends-done {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 14px;
    padding: 12px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.daily-friends-done:hover {
    background: #fff;
    border-color: #d1d5db;
}

.daily-friends-done-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.daily-friends-avatars {
    display: flex;
    align-items: center;
    min-width: 0;
}

.daily-friend-av {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    margin-left: -9px;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--border);
    position: relative;
}

.daily-friends-avatars .daily-friend-av:first-child {
    margin-left: 0;
}

.daily-friend-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.daily-friend-av-init {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
}

.daily-friend-av-more {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg);
}

.daily-friends-chevron {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1;
    flex-shrink: 0;
}

.modal-daily-friends {
    max-width: 400px;
}

.daily-friends-skeleton {
    min-height: 220px;
}

.daily-friends-skel-row {
    height: 52px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.daily-friends-skel-row:last-child {
    margin-bottom: 0;
}

.daily-friends-skeleton[hidden] {
    display: none !important;
}

.daily-friends-modal-empty {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

.daily-friends-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 360px;
    overflow-y: auto;
}

.daily-friend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.daily-friend-row:last-child {
    border-bottom: none;
}

.daily-friend-row-av {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.daily-friend-row-av-init {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.daily-friend-row-info {
    flex: 1;
    min-width: 0;
}

.daily-friend-row-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.daily-friend-row-score {
    font-size: 12px;
    color: var(--text-muted);
}

.daily-friend-row-rate {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
    min-width: 44px;
    text-align: right;
}

.daily-streak-nudge {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.daily-streak-nudge-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef3c7;
    font-size: 18px;
    border-radius: 8px;
    line-height: 1;
}

.daily-streak-nudge-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.daily-streak-nudge-text strong {
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
    line-height: 1.3;
}

.daily-streak-nudge-text span {
    font-size: 12px;
    color: #b45309;
    line-height: 1.4;
}

.daily-completed-nudge {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--success-bg);
    border: 1px solid #a7f3d0;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.daily-completed-nudge-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #d1fae5;
    font-size: 18px;
    font-weight: 700;
    color: var(--success);
    border-radius: 8px;
    line-height: 1;
}

.daily-completed-nudge-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.daily-completed-nudge-text strong {
    font-size: 13px;
    font-weight: 600;
    color: #065f46;
    line-height: 1.3;
}

.daily-completed-nudge-text span {
    font-size: 12px;
    color: #047857;
    line-height: 1.4;
}

.daily-done {
    text-align: center;
}

.done-icon {
    width: 56px;
    height: 56px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
    font-weight: 700;
}

.daily-done h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.daily-done p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Custom quiz form */
.custom-form .form-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overscroll-behavior: contain;
}

.modal[hidden] { display: none; }

.modal-stacked { z-index: 210; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 16px;
    padding: 28px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    max-height: min(90vh, 720px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-friend {
    padding: 28px 28px 32px;
}

.modal-friend h3 {
    margin-bottom: 24px;
    padding-right: 32px;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    flex-wrap: wrap;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.friend-code-box label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 12px;
    flex-wrap: wrap;
}

.code-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@keyframes fp-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        #eef0f4 0%,
        #f8f9fb 40%,
        #eef0f4 80%
    );
    background-size: 200% 100%;
    animation: fp-shimmer 1.4s ease-in-out infinite;
}

[hidden] .shimmer,
.fp-shell:not(.is-loading) .shimmer {
    animation: none !important;
}

.fp-skeleton[hidden],
.fp-shell:not(.is-loading) .fp-skeleton {
    display: none !important;
}

.fp-shell.is-loading .fp-content {
    display: none !important;
}

.modal-friend-profile {
    max-width: 440px;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.fp-shell {
    min-height: 440px;
    position: relative;
}

.fp-skeleton {
    display: flex;
    flex-direction: column;
    min-height: 440px;
    padding: 24px 24px 16px;
}

.fp-skeleton-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    padding-right: 72px;
    border-bottom: 1px solid var(--border);
}

.fp-skeleton-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fp-skeleton-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fp-skeleton-line {
    height: 12px;
    border-radius: 6px;
}

.fp-skeleton-name {
    width: 60%;
    height: 18px;
}

.fp-skeleton-meta {
    width: 45%;
}

.fp-skeleton-panel {
    flex: 1;
    min-height: 240px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.fp-skeleton-tabs {
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.fp-content {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 440px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.fp-content.is-visible {
    opacity: 1;
}

.fp-topbar {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fp-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.fp-icon-btn:hover {
    background: #eef0f4;
    color: var(--text);
}

.fp-icon-btn-danger:hover {
    background: var(--error-bg);
    color: var(--error);
}

.fp-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 88px 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.fp-avatar-img,
.fp-avatar-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fp-avatar-img {
    object-fit: cover;
    display: block;
}

.fp-avatar-placeholder {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
}

.fp-identity {
    min-width: 0;
    flex: 1;
}

.fp-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.fp-since {
    font-size: 13px;
    color: var(--text-muted);
}

.fp-panels-viewport {
    flex: 1;
    overflow: hidden;
    min-height: 260px;
}

.fp-panels-track {
    display: flex;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fp-panels-track.is-rank {
    transform: translateX(-100%);
}

.fp-panel {
    flex: 0 0 100%;
    width: 100%;
    padding: 20px 24px;
    overflow-y: auto;
}

.fp-stat-list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.fp-stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
}

.fp-stat-item + .fp-stat-item {
    border-top: 1px solid var(--border);
}

.fp-stat-item dt {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

.fp-stat-item dd {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.fp-stat-item:first-child dd {
    color: #ea580c;
}

.fp-ranks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

@media (max-width: 400px) {
    .fp-ranks {
        grid-template-columns: 1fr;
    }
}

.fp-rank-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 14px;
    text-align: center;
}

.fp-rank-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.fp-rank-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
}

.fp-rank-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.fp-rank-private {
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    margin-top: 8px;
}

.fp-tabs {
    display: flex;
    gap: 0;
    margin: 0 24px 20px;
    padding: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    flex-shrink: 0;
}

.fp-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.fp-tab:hover {
    color: var(--text);
}

.fp-tab.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.fp-error {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 72px;
}

.code-display code {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary);
    background: #eef2ff;
    padding: 8px 16px;
    border-radius: 8px;
}

.hint {
    font-size: 13px;
    color: var(--text-muted);
}

.modal hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.input-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 18px;
    font-family: inherit;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
}

.form-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
}

/* Quiz UI */
.modal-quiz {
    position: relative;
    overflow: hidden;
    max-width: 600px;
}

.quiz-confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.confetti-piece {
    position: absolute;
    top: -12px;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(420px) rotate(720deg); opacity: 0; }
}

.quiz-progress-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    margin-bottom: 14px;
    max-width: 100%;
}

.quiz-progress-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.quiz-progress-bar {
    height: 5px;
    background: var(--bg);
    border-radius: 99px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 99px;
    transition: width 0.25s ease;
}

.quiz-practice-note {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.modal-quiz .quiz-practice-note,
.modal-quiz .quiz-challenge-note {
    font-size: 11px;
    padding: 5px 8px;
    margin-top: 2px;
    margin-right: 36px;
    margin-bottom: 12px;
    line-height: 1.35;
    max-width: calc(100% - 36px);
}

.quiz-question {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.quiz-option:hover {
    border-color: var(--primary);
    background: #f5f3ff;
}

.quiz-option.selected {
    border-color: var(--primary);
    background: #eef2ff;
}

.quiz-option.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.quiz-option.incorrect {
    border-color: var(--error);
    background: var(--error-bg);
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    gap: 12px;
}

.quiz-result {
    text-align: center;
    padding: 12px 0 4px;
}

.quiz-result-rate {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
}

.quiz-result-fraction {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.quiz-result-msg {
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 15px;
}

.quiz-result-streak,
.quiz-result-compare {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.quiz-result-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.quiz-review-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

.quiz-review-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 14px;
}

.quiz-review-item {
    text-align: left;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.quiz-review-item:last-child {
    border-bottom: none;
}

.quiz-review-q {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.35;
}

.quiz-review-opts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quiz-review-opt {
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    line-height: 1.35;
}

.quiz-review-opt.is-correct {
    border-color: #a7f3d0;
    background: var(--success-bg);
    color: #065f46;
    font-weight: 600;
}

.quiz-review-opt.is-wrong {
    border-color: #fecaca;
    background: var(--error-bg);
    color: #991b1b;
}

.btn-saved-quizzes,
.btn-challenges {
    margin-top: 10px;
}

.btn-challenges {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.challenges-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--text);
    color: var(--surface);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

.modal-saved-quizzes {
    max-width: 420px;
}

.saved-quizzes-skeleton {
    min-height: 140px;
}

.saved-quizzes-skel-row {
    height: 52px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.saved-quizzes-skeleton[hidden] {
    display: none !important;
}

.saved-quizzes-empty {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 24px 8px;
    line-height: 1.45;
}

.saved-quizzes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.saved-quiz-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.saved-quiz-card:hover {
    background: #fff;
    border-color: #d1d5db;
}

.saved-quiz-card-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.saved-quiz-card-meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.saved-quiz-card-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.modal-saved-quiz-menu {
    max-width: 400px;
}

.saved-quiz-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-quiz-menu-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.saved-quiz-menu-btn:hover {
    background: #fff;
    border-color: #d1d5db;
}

.saved-quiz-menu-btn-accent {
    border-color: #c7d2fe;
    background: #eef2ff;
}

.saved-quiz-menu-btn-accent:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

.saved-quiz-menu-btn-danger:hover {
    border-color: #fecaca;
    background: var(--error-bg);
}

.saved-quiz-menu-btn-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.saved-quiz-menu-btn-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.modal-saved-quiz-rename {
    max-width: 380px;
}

.modal-saved-quiz-rename .saved-quiz-rename-form {
    margin-top: 4px;
}

.modal-saved-quiz-rename .form-group {
    margin-bottom: 24px;
}

.modal-challenge-friends,
.modal-challenges {
    max-width: 420px;
}

.challenge-friends-skeleton,
.challenges-skeleton {
    min-height: 120px;
}

.challenge-friends-skel-row,
.challenges-skel-row {
    height: 48px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.challenge-friends-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 14px;
}

.challenge-friend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.challenge-friend-item:hover {
    background: #fff;
    border-color: #d1d5db;
}

.challenge-friend-item.is-selected {
    border-color: #c7d2fe;
    background: #f5f7ff;
}

.challenge-friend-checkbox {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.challenge-friend-check {
    width: 18px;
    height: 18px;
    border: 1.5px solid #d1d5db;
    border-radius: 5px;
    background: var(--surface);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.challenge-friend-item.is-selected .challenge-friend-check {
    background: var(--primary);
    border-color: var(--primary);
}

.challenge-friend-item.is-selected .challenge-friend-check::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.challenge-friend-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.challenge-friend-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.challenge-friend-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.challenge-friends-empty {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 8px;
    line-height: 1.45;
}

.challenges-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    padding: 4px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.challenges-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.challenges-tab.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.challenges-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--text);
    color: var(--surface);
    font-size: 10px;
    font-weight: 600;
}

.challenges-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
}

.challenge-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
}

.challenge-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.challenge-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.challenge-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.challenge-card-refuse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.challenge-card-refuse:hover {
    border-color: #fecaca;
    background: var(--error-bg);
    color: #991b1b;
}

.challenge-card-wait,
.challenge-card-result {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
}

.challenge-card-wait {
    background: #fef9c3;
    color: #ca8a04;
}

.challenge-card-result.is-won {
    background: #dcfce7;
    color: #15803d;
}

.challenge-card-result.is-lost {
    background: #fee2e2;
    color: #b91c1c;
}

.challenge-result-symbol {
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.challenge-card-result.is-tie {
    background: #e0e7ff;
    color: #4338ca;
}

.challenge-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.challenge-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.challenge-card-info {
    flex: 1;
    min-width: 0;
}

.challenge-card-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.challenge-card-quiz {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.challenge-card-scores {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.challenges-empty {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    padding: 24px 8px;
    line-height: 1.45;
}

.quiz-challenge-note {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.quiz-result-challenge {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
}

.quiz-result-challenge strong {
    color: var(--text);
}

.quiz-result-challenge-verdict {
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.quiz-result-challenge-verdict.is-won { color: #166534; }
.quiz-result-challenge-verdict.is-lost { color: #991b1b; }
.quiz-result-challenge-verdict.is-tie { color: #3730a3; }

.quiz-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 300;
    box-shadow: var(--shadow-lg);
}

.toast[hidden] { display: none; }

/* Account modal */
.modal-account {
    max-width: 480px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(90vh, 640px);
}

.modal-account .modal-close {
    z-index: 2;
    color: #fff;
}

.modal-account .modal-close:hover {
    color: #e5e7eb;
}

.account-header {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 28px 56px 24px 28px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #fff;
    min-width: 0;
}

.account-header > div:last-child {
    min-width: 0;
    flex: 1;
}

.account-avatar-wrap { flex-shrink: 0; }

.account-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.account-avatar.placeholder {
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
}

.account-header h3 {
    font-size: 18px;
    margin-bottom: 2px;
}

.account-email {
    font-size: 13px;
    color: #c7d2fe;
    margin-bottom: 8px;
    word-break: break-all;
}

.account-streak-badge {
    display: inline-block;
    font-size: 12px;
    background: rgba(249, 115, 22, 0.2);
    color: #fed7aa;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.account-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.account-tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.account-tab:hover {
    color: var(--text);
}

.account-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--surface);
}

.account-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    overscroll-behavior: contain;
}

.account-panel {
    padding: 24px 28px;
    display: none;
}

.account-panel.active {
    display: block;
}

.account-panel h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.account-panel .hint {
    margin-bottom: 14px;
}

.account-form input[type="url"],
.account-form input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    margin-top: 8px;
}

.account-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.account-footer {
    padding: 16px 28px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--bg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.btn-danger-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--error);
    border: 1px solid #fecaca;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.btn-danger-outline:hover {
    background: var(--error-bg);
    border-color: var(--error);
}

.modal-delete {
    max-width: 420px;
}

.modal-delete h3 {
    font-size: 20px;
    margin-bottom: 8px;
    padding-right: 28px;
}

.delete-confirm-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    text-align: center;
    letter-spacing: 1px;
    margin-top: 4px;
}

.delete-confirm-input:focus {
    outline: none;
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.privacy-toggle {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    margin-top: 8px;
}

.privacy-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.privacy-toggle-ui {
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s;
    margin-top: 2px;
}

.privacy-toggle-ui::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.privacy-toggle input:checked + .privacy-toggle-ui {
    background: var(--primary);
}

.privacy-toggle input:checked + .privacy-toggle-ui::after {
    transform: translateX(20px);
}

.privacy-toggle-text strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.privacy-toggle-text small {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.modal-custom-quiz .form-group {
    margin-bottom: 16px;
}

.custom-quiz-more-link {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-align: center;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.custom-quiz-more-link:hover {
    color: var(--primary-hover);
}

.modal-custom-quiz-more,
.modal-custom-quiz-json,
.modal-custom-quiz-builder {
    max-width: 440px;
}

.modal-custom-quiz-builder {
    max-height: min(88vh, 600px);
    display: flex;
    flex-direction: column;
}

.modal-custom-quiz-builder h3 {
    margin-bottom: 14px;
}

.modal-custom-quiz-builder .custom-form-modal {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.modal-custom-quiz-builder .form-group-compact {
    margin-bottom: 10px;
}

.custom-quiz-more-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-quiz-more-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.custom-quiz-more-btn:hover {
    background: #fff;
    border-color: #d1d5db;
}

.custom-quiz-more-btn-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.custom-quiz-more-btn-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.quiz-json-example-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 16px;
}

.quiz-json-example-link:hover {
    text-decoration: underline;
}

.quiz-json-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 108px;
    margin-bottom: 16px;
    padding: 18px 14px;
    border: 1.5px dashed #c7d2fe;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8faff 0%, #f1f5ff 100%);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.quiz-json-dropzone:hover {
    border-color: var(--primary);
    background: #eef2ff;
}

.quiz-json-dropzone.is-dragover {
    border-color: var(--primary);
    background: #e0e7ff;
    transform: scale(1.01);
}

.quiz-json-dropzone.has-file {
    border-style: solid;
    border-color: #a5b4fc;
    background: #eef2ff;
}

.quiz-json-dropzone-icon {
    display: flex;
    color: var(--primary);
    margin-bottom: 2px;
}

.quiz-json-dropzone-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.quiz-json-dropzone-hint {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-builder-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
    max-height: min(42vh, 280px);
    overflow-y: auto;
    margin-bottom: 8px;
    padding-right: 2px;
}

.quiz-builder-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 9px;
    background: var(--bg);
}

.quiz-builder-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.quiz-builder-item-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.quiz-builder-remove {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
}

.quiz-builder-remove:hover {
    border-color: #fecaca;
    background: var(--error-bg);
    color: #991b1b;
}

.quiz-builder-remove:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.quiz-builder-question-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 6px;
}

.quiz-builder-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.quiz-builder-option {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.quiz-builder-option input[type="radio"] {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.quiz-builder-option input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
}

.quiz-builder-add {
    margin-bottom: 10px;
    padding: 7px 12px;
}

.form-row-modal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

/* Leaderboard */
.lb-page {
    padding-top: 24px;
}

.lb-wrap {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lb-header h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.lb-switch {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.lb-switch-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.lb-switch-btn:hover {
    color: var(--text);
}

.lb-switch-btn.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.lb-you {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.lb-you strong {
    color: var(--text);
    font-weight: 600;
}

.lb-you-total {
    color: var(--text-muted);
}

.lb-you-muted {
    font-size: 13px;
}

.lb-context {
    font-size: 13px;
    color: var(--text-muted);
    margin: -8px 0 16px;
    line-height: 1.4;
}

.lb-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.lb-table-head,
.lb-table-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.lb-table-head {
    height: 36px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.lb-table-head span:last-child {
    text-align: right;
}

.lb-table-row {
    height: 52px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.lb-table-row:last-child {
    border-bottom: none;
}

.lb-table-row.is-you {
    background: #fafafa;
}

.lb-pos {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.lb-table-row.is-you .lb-pos {
    color: var(--text);
    font-weight: 600;
}

.lb-player {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.lb-av {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.lb-av-init {
    background: #e5e7eb;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.lb-av-unk {
    background: #f3f4f6;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.lb-player-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.lb-score-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

/* Footer */
.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 32px 24px;
}

.footer-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.footer-logo {
    font-weight: 700;
    font-size: 15px;
}

.footer-tagline {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.footer-nav a {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
}

.footer-nav a:hover {
    color: var(--text);
    text-decoration: underline;
}

.footer-copy {
    width: 100%;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Cookie banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--text);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    z-index: 400;
    font-size: 14px;
}

.cookie-banner[hidden] { display: none; }

.cookie-banner a { color: #a5b4fc; }

/* Legal pages */
.legal-page {
    flex: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 24px 64px;
    width: 100%;
}

.legal-content h1 {
    font-size: 28px;
    margin-bottom: 24px;
}

.legal-back {
    display: inline-block;
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 20px;
}

.legal-back:hover { color: var(--text); }

.legal-body h2 {
    font-size: 18px;
    margin: 28px 0 12px;
}

.legal-body p,
.legal-body li {
    font-size: 15px;
    color: #374151;
    margin-bottom: 12px;
}

.legal-body ul {
    padding-left: 20px;
    margin-bottom: 16px;
}

.legal-body a {
    color: var(--primary);
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 16px 0;
}

.legal-table th,
.legal-table td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
}

.legal-table th {
    background: var(--bg);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .friends-bar {
        order: 3;
        width: 100%;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .custom-form .form-row {
        grid-template-columns: 1fr;
    }

    .dashboard { padding: 20px 16px 48px; }
    .card { padding: 20px; }

    .account-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .account-footer .btn,
    .account-footer .btn-danger-outline {
        width: 100%;
        justify-content: center;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .account-btn-name { display: none; }

    .topbar-nav { display: none; }

    .form-row-modal {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}
