/* ===== CSS Variables & Themes ===== */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #3b82f6;
    
    --accent-primary: #3b82f6;
    --accent-secondary: #6366f1;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --accent-glow: rgba(59, 130, 246, 0.15);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.1);
    
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.03);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --rating-newbie: #808080;
    --rating-pupil: #008000;
    --rating-specialist: #03a89e;
    --rating-expert: #0000ff;
    --rating-cm: #aa00aa;
    --rating-master: #ff8c00;
    --rating-gm: #ff0000;
}

[data-theme="dark"] {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-card: #111827;
    --bg-card-hover: #1a2234;
    --bg-elevated: #1a2234;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;
    
    --border-color: #1e293b;
    --border-light: #334155;
    --border-focus: #3b82f6;
    
    --accent-glow: rgba(59, 130, 246, 0.12);
    
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -2px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.6), 0 10px 10px -5px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.hidden { display: none !important; }

/* ===== Header ===== */
.header {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: var(--bg-glass);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--accent-primary) 35%, var(--accent-secondary) 65%, transparent 100%);
    opacity: 0.55;
    pointer-events: none;
    box-shadow: 0 0 20px var(--accent-glow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateX(-2px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px var(--accent-glow));
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 6px var(--accent-glow)); }
    50% { filter: drop-shadow(0 0 14px var(--accent-glow)); }
}

.logo h1 {
    font-size: 20px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #f59e0b20, #ef444420);
    border: 1px solid #f59e0b40;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    color: var(--warning);
    animation: streakPulse 2s ease-in-out infinite;
}

@keyframes streakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.streak-fire { font-size: 16px; }

.daily-goal-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
}

.daily-goal-badge.completed {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(59, 130, 246, 0.15));
    border-color: var(--success);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-status.syncing { color: var(--info); border-color: var(--info); }
.sync-status.syncing .sync-icon { animation: spin 1s linear infinite; }
.sync-status.synced { color: var(--success); border-color: var(--success); }
.sync-status.error { color: var(--warning); border-color: var(--warning); }

.sync-icon { width: 14px; height: 14px; stroke-width: 2.5; }
.sync-text { font-weight: 500; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* ===== Main ===== */
.main {
    padding: 32px 0 40px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Cards ===== */
.card {
    background: color-mix(in srgb, var(--bg-secondary) 78%, transparent);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: fadeSlideUp 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.card-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.card-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== Buttons ===== */
.btn-primary {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.45), 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-sm { padding: 6px 12px !important; font-size: 12px !important; }
.btn-large { padding: 16px 40px !important; font-size: 16px !important; }

.btn-danger {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--danger);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.4);
}

.btn-warning {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--warning);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(245, 158, 11, 0.45);
}

.btn-success {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--success);
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(16, 185, 129, 0.4);
}

.btn-mini {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary);
    color: white;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-mini:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--accent-glow);
}

.btn-mini-danger {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-mini-danger:hover {
    background: var(--danger-bg);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.3);
}

/* ===== Search Form ===== */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 0 28px rgba(59, 130, 246, 0.22);
}

/* ===== User Info ===== */
.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    animation: slideUp 0.3s ease;
}

.user-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.user-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    flex: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 700;
}

/* ===== Info Box ===== */
.info-box {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.info-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.info-box-header:hover { background: var(--bg-card-hover); }

.info-box-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-chevron {
    transition: transform 0.3s;
    color: var(--text-muted);
}

.info-box.collapsed .info-chevron { transform: rotate(-90deg); }
.info-box.collapsed .info-box-content { display: none; }

.info-box-content {
    padding: 0 16px 14px;
    list-style: none;
}

.info-box-content li {
    padding: 5px 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-box-content li::before {
    content: "\2192";
    color: var(--accent-primary);
    font-weight: bold;
    flex-shrink: 0;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border-color);
}

/* ===== Contest Type Cards ===== */
.contest-types {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.contest-type-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.contest-type-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

.contest-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.div4-card::before { background: var(--success); }
.div3-card::before { background: var(--info); }
.div2-card::before { background: var(--warning); }
.div1-card::before { background: var(--danger); }
.custom-card::before { background: var(--accent-gradient); }

.contest-type-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.div4-card .contest-type-icon { background: var(--success-bg); color: var(--success); }
.div3-card .contest-type-icon { background: var(--info-bg); color: var(--info); }
.div2-card .contest-type-icon { background: var(--warning-bg); color: var(--warning); }
.div1-card .contest-type-icon { background: var(--danger-bg); color: var(--danger); }
.custom-card .contest-type-icon { background: rgba(99, 102, 241, 0.15); color: var(--accent-secondary); }

.contest-type-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.contest-type-header h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.difficulty-badge {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-badge.beginner { background: var(--success-bg); color: var(--success); }
.difficulty-badge.easy { background: var(--info-bg); color: var(--info); }
.difficulty-badge.medium { background: var(--warning-bg); color: var(--warning); }
.difficulty-badge.hard { background: var(--danger-bg); color: var(--danger); }
.difficulty-badge.custom { background: rgba(99, 102, 241, 0.15); color: var(--accent-secondary); }

.contest-type-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.contest-type-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 12px;
}

.contest-type-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.contest-type-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.div4-card .contest-type-fill { background: var(--success); }
.div3-card .contest-type-fill { background: var(--info); }
.div2-card .contest-type-fill { background: var(--warning); }
.div1-card .contest-type-fill { background: var(--danger); }
.custom-fill { background: var(--accent-gradient); }

/* ===== Quick Practice ===== */
.quick-practice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ===== Config ===== */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-group.full-width { grid-column: 1 / -1; }

.config-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-group input,
.config-group select {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.config-group input:focus,
.config-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 0 26px rgba(59, 130, 246, 0.2);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    max-height: 160px;
    overflow-y: auto;
}

.tag-chip {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    color: var(--text-secondary);
}

.tag-chip:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.tag-chip.selected {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.config-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-content { text-align: center; }

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-content p {
    font-size: 15px;
    color: white;
    font-weight: 500;
}

/* ===== Contest Arena ===== */
.contest-arena {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.contest-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    gap: 20px;
}

.contest-info h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.contest-meta {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    align-items: center;
}

.contest-meta-badge {
    background: var(--accent-primary);
    color: white;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.contest-timer { text-align: right; flex-shrink: 0; }

.timer-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.timer-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    letter-spacing: 0.02em;
    line-height: 1;
    margin-bottom: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timer-display.warning { color: var(--warning); }
.timer-display.danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.timer-display.paused {
    color: var(--warning);
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.4; }
}

.timer-progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.timer-progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 1s linear, background 0.5s;
    width: 100%;
}

.timer-progress-fill.warning { background: var(--warning); }
.timer-progress-fill.danger { background: var(--danger); }

.timer-controls {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Solved Progress */
.solved-progress {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.solved-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.solved-progress-text strong { color: var(--text-primary); }

.solved-progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.solved-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #06b6d4);
    border-radius: 8px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== Problems Table ===== */
.problems-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.problems-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.problems-table thead { background: var(--bg-tertiary); }

.problems-table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.problems-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.problems-table tbody tr:last-child { border-bottom: none; }
.problems-table tbody tr:hover { background: var(--bg-tertiary); }

.problems-table tbody tr.solved-row {
    background: rgba(16, 185, 129, 0.04);
}

.problems-table td {
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text-primary);
}

.problem-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.problem-link:hover { color: var(--accent-secondary); text-decoration: underline; }

.problem-index {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-primary);
}

.problem-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.problem-tag {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.problem-tag.hidden-tag {
    filter: blur(4px);
    user-select: none;
}

.problem-tag.hidden-tag:hover { filter: blur(0); }

/* Rating Colors */
.rating-color { font-weight: 700; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.rating-newbie { color: #808080; }
.rating-pupil { color: #008000; }
.rating-specialist { color: #03a89e; }
.rating-expert { color: #0000ff; }
[data-theme="dark"] .rating-expert { color: #5b8ef5; }
.rating-cm { color: #aa00aa; }
[data-theme="dark"] .rating-cm { color: #d070d0; }
.rating-master { color: #ff8c00; }
.rating-gm { color: #ff0000; }
[data-theme="dark"] .rating-gm { color: #ff4444; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.pending { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.status-badge.attempted { background: var(--warning-bg); color: var(--warning); }
.status-badge.solved { background: var(--success-bg); color: var(--success); }
.status-badge.failed { background: var(--danger-bg); color: var(--danger); }

/* ===== Submissions Panel ===== */
.submissions-panel {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.submissions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.submissions-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.submissions-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.submissions-list {
    max-height: 240px;
    overflow-y: auto;
}

.submission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    animation: slideUp 0.2s ease;
}

.submission-item.accepted { border-left-color: var(--success); }
.submission-item.wrong { border-left-color: var(--danger); }

.submission-info { display: flex; flex-direction: column; gap: 2px; }

.submission-problem {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.submission-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
    font-size: 13px;
}

/* ===== Results ===== */
.results-header {
    text-align: center;
    margin-bottom: 28px;
}

.results-trophy {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #f59e0b20, #ef444420);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--warning);
    animation: trophyBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes trophyBounce {
    0% { transform: scale(0) rotate(-20deg); }
    60% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.performance-rating {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.performance-rating strong {
    font-size: 18px;
    font-family: 'JetBrains Mono', monospace;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.result-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card:hover { transform: translateY(-2px); }

.result-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.result-icon.success { background: var(--success-bg); color: var(--success); }
.result-icon.score { background: var(--warning-bg); color: var(--warning); }
.result-icon.time { background: var(--info-bg); color: var(--info); }
.result-icon.penalty { background: var(--danger-bg); color: var(--danger); }
.result-icon.info { background: rgba(99, 102, 241, 0.15); color: var(--accent-secondary); }

.result-info { display: flex; flex-direction: column; gap: 2px; }

.result-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.result-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.problems-results { margin-bottom: 24px; }

.problems-results h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.results-table thead { background: var(--bg-tertiary); }

.results-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.results-table td {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.results-table tbody tr:last-child td { border-bottom: none; }

.results-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* ===== Upsolve ===== */
.upsolve-section {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
}

.upsolve-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upsolve-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.upsolve-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
}

.upsolve-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.upsolve-item a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.upsolve-item a:hover { text-decoration: underline; }

/* ===== History ===== */
.history-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover { background: var(--bg-card-hover); }

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 16px;
}

.history-item:hover {
    border-color: var(--accent-primary);
    transform: translateX(3px);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.history-item-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-item-stats {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}

.history-stat { text-align: center; }

.history-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    font-family: 'JetBrains Mono', monospace;
}

.history-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.history-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.in-progress-contest { border-left: 3px solid var(--warning) !important; }

.in-progress-badge {
    padding: 2px 8px;
    background: var(--warning);
    color: white;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    animation: pulse 2s infinite;
}

/* ===== Performance Analytics ===== */
.analytics-controls {
    margin-bottom: 20px;
}

.performance-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.date-range-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.date-range-quick {
    display: flex;
    gap: 4px;
}

.range-btn {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range-inputs input[type="date"] {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.date-range-inputs input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 0 22px rgba(59, 130, 246, 0.18);
}

.date-range-sep {
    color: var(--text-muted);
    font-size: 12px;
}

.analytics-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    height: 300px;
}

.performance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* ===== Recommendation Section ===== */
.rec-tag-analysis {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.rec-tag-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rec-tag-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.rec-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.rec-tag.strong-tag {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.rec-tag.weak-tag {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.rec-problems-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rec-problem-card {
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rec-problem-card:hover {
    border-color: var(--accent-primary);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.rec-problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rec-problem-name {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color 0.15s;
}

.rec-problem-name:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.rec-problem-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.rec-problem-tag {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
}

.rec-problem-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.rec-level-up {
    text-align: center;
    padding: 40px 20px;
}

.rec-level-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--success-bg), rgba(59, 130, 246, 0.15));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    animation: trophyBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.rec-level-up h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.rec-level-up p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Division Preview ===== */
.preview-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
}

.preview-item { display: flex; flex-direction: column; gap: 2px; }

.preview-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.preview-value {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 800;
}

.division-stats-section { margin-bottom: 28px; }

.division-stats-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
}

.division-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.division-stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.stat-icon { font-size: 20px; }
.stat-info { display: flex; flex-direction: column; }

.problem-times-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.problem-time-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.problem-index-small {
    font-weight: 700;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
}

.problem-time { font-size: 13px; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }

.division-past-contests { margin-bottom: 28px; }
.division-past-contests h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

.mini-contest-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
}

.mini-contest-info { display: flex; flex-direction: column; gap: 2px; }
.mini-contest-date { font-size: 12px; color: var(--text-muted); }
.mini-contest-stats { font-size: 13px; color: var(--text-primary); font-weight: 600; }

.preview-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    margin-top: 20px;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-sep { opacity: 0.5; }

/* ===== Focus Mode ===== */
body.focus-mode .header-actions > *:not(#focusModeBtn) { display: none; }
body.focus-mode .card-header-actions { display: none; }
body.focus-mode .submissions-hint { display: none; }
body.focus-mode .hide-focus { display: none; }
body.focus-mode .footer { display: none; }
body.focus-mode #handleSection { display: none; }
body.focus-mode #contestTypeSection { display: none; }

body.focus-mode .contest-arena {
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 30px var(--accent-glow);
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeInOverlay 0.2s;
    padding: 20px;
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    animation: modalSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.stats-modal { max-width: 560px; }

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Shortcuts Modal */
.shortcuts-modal { max-width: 400px; }

.shortcut-group { margin-bottom: 18px; }
.shortcut-group:last-child { margin-bottom: 0; }

.shortcut-group h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

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

.shortcut-item:last-child { border-bottom: none; }
.shortcut-item kbd { min-width: 32px; text-align: center; }
.shortcut-item span { font-size: 13px; color: var(--text-secondary); }

/* Settings */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    gap: 16px;
}

.setting-info { flex: 1; }

.setting-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.setting-desc { font-size: 12px; color: var(--text-muted); }

.setting-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

.setting-item select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.setting-item select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 0 22px rgba(59, 130, 246, 0.18);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: all 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== Toasts ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 13px;
}

@keyframes toastSlideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.removing { animation: toastSlideOut 0.3s ease forwards; }

@keyframes toastSlideOut {
    to { transform: translateX(100px); opacity: 0; }
}

.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

.toast-icon { font-size: 18px; flex-shrink: 0; }

.toast-text { flex: 1; color: var(--text-primary); font-weight: 500; }

.toast-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s;
}

.toast-close-btn:hover { color: var(--text-primary); }

/* ===== Spinner ===== */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

/* ===== Stats Modal ===== */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card-icon { font-size: 24px; line-height: 1; }
.stat-card-info { flex: 1; }

.stat-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.stat-card-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.division-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.division-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.division-stat-row:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
}

.division-stat-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.division-stat-values {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.stats-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container { padding: 0 14px; }
    .main { padding: 20px 0 40px; }
    
    .header-left { gap: 8px; }
    .logo h1 { font-size: 16px; }
    .streak-badge { display: none; }
    .daily-goal-badge { display: none; }
    
    .card { padding: 18px; }
    .card-title { font-size: 20px; }
    .card-header-row { flex-direction: column; }
    .card-header-actions { width: 100%; }

    .contest-types { grid-template-columns: 1fr 1fr; gap: 10px; }
    .config-grid { grid-template-columns: 1fr 1fr; }
    .quick-practice-grid { grid-template-columns: 1fr 1fr; }
    .preview-info { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
    
    .contest-header { flex-direction: column; gap: 16px; }
    .contest-timer { text-align: left; width: 100%; }
    .timer-display { font-size: 28px; }
    .timer-controls { justify-content: flex-start; }

    .problems-table th,
    .problems-table td { padding: 8px 10px; font-size: 12px; }

    .hide-mobile { display: none; }
    
    .results-summary { grid-template-columns: 1fr 1fr; }
    
    .history-item { flex-direction: column; align-items: flex-start; }
    .history-item-stats { width: 100%; justify-content: space-around; }
    .history-actions { width: 100%; }
    
    .modal { margin: 10px; max-width: calc(100% - 20px); }
    
    .user-info { flex-direction: column; align-items: flex-start; }
    .user-stats { gap: 16px; }
    
    .toast-container { left: 14px; right: 14px; max-width: none; }
    
    .header-actions { gap: 4px; }
    .icon-btn { width: 34px; height: 34px; }
    .sync-status { font-size: 11px; padding: 4px 8px; }
    
    .analytics-charts-grid { grid-template-columns: 1fr; }
    .chart-container { height: 250px; }
    
    .date-range-controls { flex-direction: column; align-items: flex-start; }
    .date-range-inputs { width: 100%; }
    .date-range-inputs input[type="date"] { flex: 1; }
    
    .rec-tag-analysis { flex-direction: column; gap: 8px; }
}

@media (max-width: 480px) {
    .contest-types { grid-template-columns: 1fr; }
    .config-grid { grid-template-columns: 1fr; }
    .quick-practice-grid { grid-template-columns: 1fr; }
    .results-summary { grid-template-columns: 1fr; }
    .preview-info { grid-template-columns: 1fr; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection {
    background: var(--accent-primary);
    color: white;
}

/* ===== CF Picker Contest Banner ===== */
.picker-contest-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.12) 100%);
    border: 1.5px solid var(--accent-primary);
    animation: pickerBannerPulse 2.5s ease-in-out infinite;
}

@keyframes pickerBannerPulse {
    0%, 100% { border-color: var(--accent-primary); box-shadow: 0 0 0 0 rgba(59,130,246,0.2); }
    50% { border-color: var(--accent-secondary); box-shadow: 0 0 0 6px rgba(59,130,246,0); }
}

.picker-banner-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.picker-banner-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.picker-banner-content strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.picker-banner-content span {
    font-size: 12px;
    color: var(--text-secondary);
}
