:root {
    --bg-main: #0a0e27; --bg-panel: #141b2d; --bg-editor: #0d1117;
    --text-main: #ffffff; --text-muted: #8b92a8; --border: #1f2937;
    --primary: #58cc02; --primary-hover: #46a302; --danger: #ff4b4b;
    --accent: #1cb0f6; --gold: #ffc800; --terminal: #000;
    --hint-bg: #1a1f36; --success: #58cc02;
}

body.light-mode {
    --bg-main: #f7f8fa; --bg-panel: #ffffff; --bg-editor: #fafbfc;
    --text-main: #1f1f1f; --text-muted: #6b7280; --border: #e5e7eb;
    --terminal: #f4f4f4; --hint-bg: #f0f2f5;
}

* { box-sizing: border-box; }
body { font-family: 'Rubik', sans-serif; margin: 0; background-color: var(--bg-main); color: var(--text-main); height: 100vh; overflow: hidden; transition: background 0.3s, color 0.3s; }
html[dir="rtl"] { direction: rtl; } 
html[dir="ltr"] { direction: ltr; }

.hidden { display: none !important; }
.main-layout { display: flex; height: 100vh; }

/* === LOGIN === */
#login-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #1a1f2e; z-index: 100; display: flex; justify-content: center; align-items: center; }
.login-box { background: #252d3d; padding: 60px 50px; border-radius: 32px; text-align: center; border: 2px solid #2d3748; width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }

.logo-container { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 48px; }
.logo-icon { font-size: 5rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.logo-text { font-size: 4rem; font-weight: 900; background: linear-gradient(135deg, #58cc02, #3fa602); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: -2px; }

.login-box input { width: 100%; padding: 20px 24px; margin: 0 0 24px; background: #1a1f2e; color: var(--text-main); border: 2px solid #2d3748; border-radius: 16px; text-align: center; font-size: 18px; transition: all 0.3s; font-weight: 500; }
.login-box input::placeholder { color: #6b7280; opacity: 0.7; }
.login-box input:focus { outline: none; border-color: var(--primary); background: #1f2533; box-shadow: 0 0 0 4px rgba(88, 204, 2, 0.1); }

.login-primary-btn { width: 100%; background: linear-gradient(135deg, #58cc02, #46a302); color: white; border: none; padding: 20px 32px; border-radius: 16px; cursor: pointer; font-weight: 800; font-size: 20px; transition: all 0.3s; box-shadow: 0 8px 24px rgba(88, 204, 2, 0.3); text-transform: none; letter-spacing: 0; }
.login-primary-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(88, 204, 2, 0.5); background: linear-gradient(135deg, #5edc02, #4cb302); }
.login-primary-btn:active { transform: translateY(-1px); }

/* === SIDEBAR === */
.sidebar { width: 260px; background: var(--bg-panel); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 24px 16px; gap: 4px; }
.logo { font-size: 1.8rem; font-weight: 900; color: var(--primary); margin-bottom: 20px; text-align: center; letter-spacing: 0.5px; }
.controls { display: flex; gap: 8px; justify-content: center; margin-bottom: 24px; }
.ctrl-btn { background: var(--bg-main); border: 1px solid var(--border); color: var(--text-muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: 0.2s; font-weight: 500; }
.ctrl-btn:hover { border-color: var(--accent); color: var(--text-main); background: rgba(28, 176, 246, 0.1); }

.nav-item { padding: 14px 18px; border-radius: 12px; cursor: pointer; color: var(--text-muted); font-weight: 500; font-size: 15px; transition: all 0.2s ease; position: relative; display: flex; align-items: center; gap: 12px; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.nav-item.active { background: linear-gradient(90deg, rgba(88, 204, 2, 0.15), transparent); color: var(--primary); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; top: 8px; bottom: 8px; width: 4px; background: var(--primary); border-radius: 0 4px 4px 0; box-shadow: 0 0 12px var(--primary); }
html[dir="rtl"] .nav-item.active::before { right: 0; border-radius: 4px 0 0 4px; }
html[dir="ltr"] .nav-item.active::before { left: 0; }
.nav-item.logout { margin-top: auto; color: var(--danger); }
.nav-item.logout:hover { background: rgba(255, 75, 75, 0.1); }

.nav-divider { height: 1px; background: var(--border); margin: 16px 0; }
.nav-section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); font-weight: 700; padding: 8px 18px; opacity: 0.6; }

.nav-item.disabled { opacity: 0.4; cursor: not-allowed; position: relative; display: flex; justify-content: space-between; }
.nav-item.disabled:hover { background: transparent; color: var(--text-muted); }
.coming-soon-badge { background: linear-gradient(135deg, #ffc800, #ffaa00); color: #000; padding: 2px 8px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.5px; }

/* === HEADER === */
.content-area { flex-grow: 1; display: flex; flex-direction: column; }
.top-header { height: 70px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 32px; background: var(--bg-panel); }
.user-info { font-size: 16px; font-weight: 600; }
.stats-area { display: flex; gap: 16px; }
.stat-box { background: var(--bg-main); padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 14px; border: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }

/* === MAP SCREEN === */
#map-screen { overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.map-header { padding: 32px; text-align: center; border-bottom: 1px solid var(--border); background: var(--bg-panel); }
.map-header h1 { margin: 0 0 8px; font-size: 2.2rem; font-weight: 800; }
.map-header p { margin: 0; color: var(--text-muted); font-size: 1.1rem; }

.map-scroll-area { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding: 40px 20px 100px; background: var(--bg-main); }
.map-scroll-area::-webkit-scrollbar { width: 8px; }
.map-scroll-area::-webkit-scrollbar-track { background: var(--bg-main); }
.map-scroll-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#levels-container { max-width: 600px; margin: 0 auto; }

.section-header { text-align: center; margin: 60px 0 30px; }
.section-header:first-child { margin-top: 20px; }
.section-number { display: inline-block; background: linear-gradient(135deg, var(--accent), #0ea5e9); color: white; padding: 6px 20px; border-radius: 20px; font-size: 13px; font-weight: 700; letter-spacing: 1px; margin-bottom: 12px; }
.section-title { font-size: 1.8rem; font-weight: 800; margin: 0; color: var(--text-main); }

.section-path { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 20px 0; }

.level-wrap { display: flex; justify-content: center; width: 100%; transition: transform 0.3s; }
.level-wrap:hover { transform: translateY(-4px); }
.level-wrap.offset-right { padding-inline-start: 80px; }

.level-node-new { width: 140px; padding: 20px; background: var(--bg-panel); border: 3px solid var(--border); border-radius: 20px; cursor: pointer; transition: all 0.3s; text-align: center; position: relative; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.level-node-new:hover { transform: scale(1.05); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

.level-icon { font-size: 2.5rem; margin-bottom: 8px; }
.level-label { font-size: 14px; font-weight: 600; color: var(--text-muted); }

.level-node-new.completed { background: linear-gradient(135deg, #46a302, #58cc02); border-color: #58cc02; box-shadow: 0 4px 20px rgba(88, 204, 2, 0.4); }
.level-node-new.completed .level-label { color: white; }

.level-node-new.current { border-color: var(--accent); border-width: 4px; background: linear-gradient(135deg, rgba(28, 176, 246, 0.2), rgba(28, 176, 246, 0.05)); box-shadow: 0 0 30px rgba(28, 176, 246, 0.6); animation: pulse 2s infinite; }
.level-node-new.current .level-label { color: var(--accent); font-weight: 700; }

.level-node-new.locked { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); }
.level-node-new.locked:hover { transform: none; }

.level-node-new.exam { background: linear-gradient(135deg, #ffc800, #ffaa00); border-color: var(--gold); }
.level-node-new.exam .level-label { color: #000; font-weight: 700; }
.level-node-new.exam .level-icon { font-size: 3rem; }

.level-node-new.intro { border-color: #8b5cf6; background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.05)); }

.level-connector { width: 4px; height: 20px; background: var(--border); margin: 0 auto; }
.level-connector.completed { background: var(--primary); box-shadow: 0 0 10px var(--primary); }

@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* === LEARNING SCREEN === */
.learning-layout { display: flex; height: calc(100vh - 70px); }

.instruction-pane { width: 35%; min-width: 380px; max-width: 500px; padding: 32px; background: var(--bg-panel); border-inline-end: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.instruction-pane::-webkit-scrollbar { width: 6px; }
.instruction-pane::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.editor-pane { flex-grow: 1; display: flex; flex-direction: column; background: var(--bg-editor); }

.lesson-header-row { display: flex; justify-content: space-between; align-items: center; }
.exit-btn { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: 500; transition: 0.2s; display: flex; align-items: center; gap: 6px; }
.exit-btn:hover { color: var(--text-main); border-color: var(--accent); background: rgba(28, 176, 246, 0.1); }

.lesson-progress-bar { height: 6px; background: var(--bg-main); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #46a302); transition: width 0.5s; border-radius: 10px; }

.lesson-badge { display: flex; gap: 8px; margin-bottom: 4px; }
.badge-difficulty { background: rgba(88, 204, 2, 0.15); color: var(--primary); padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.badge-type { background: rgba(28, 176, 246, 0.15); color: var(--accent); padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 700; }

.task-title { font-size: 2rem; font-weight: 900; color: var(--text-main); margin: 8px 0 12px; line-height: 1.2; }
.task-desc { font-size: 1.05rem; line-height: 1.7; color: var(--text-muted); }

/* Goal and Expected Output Boxes - NEW! */
.goal-box { background: linear-gradient(135deg, rgba(88, 204, 2, 0.15), rgba(88, 204, 2, 0.05)); padding: 20px; border-radius: 12px; border: 2px solid var(--primary); border-left: 6px solid var(--primary); margin-bottom: 16px; }
.goal-box h3 { margin: 0 0 10px; font-size: 0.95rem; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.goal-statement { font-size: 1.1rem; font-weight: 600; color: var(--text-main); line-height: 1.5; }

.what-to-do-box { background: var(--hint-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
.what-to-do-box h3 { margin: 0 0 12px; font-size: 0.95rem; color: var(--accent); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; }
.steps-list { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps-list li { position: relative; padding-inline-start: 40px; margin-bottom: 14px; line-height: 1.6; color: var(--text-main); font-size: 0.95rem; }
.steps-list li::before { counter-increment: step; content: counter(step); position: absolute; top: 0; width: 26px; height: 26px; background: var(--bg-panel); border: 2px solid var(--accent); border-radius: 50%; text-align: center; line-height: 22px; font-size: 13px; color: var(--accent); font-weight: 700; }
html[dir="rtl"] .steps-list li::before { right: 0; }
html[dir="ltr"] .steps-list li::before { left: 0; }

/* AI Assistant */
.ai-assistant { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; gap: 12px; }

.hint-section { display: flex; flex-direction: column; gap: 8px; }
.hint-action-btn { width: 100%; padding: 12px; border: 2px solid var(--accent); background: rgba(28, 176, 246, 0.1); color: var(--accent); border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 15px; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.hint-action-btn:hover { background: rgba(28, 176, 246, 0.2); transform: translateY(-2px); }
.hint-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hints-list { display: flex; flex-direction: column; gap: 8px; }
.hint-bubble { background: var(--hint-bg); padding: 14px; border-radius: 10px; border-inline-start: 4px solid var(--accent); font-size: 0.9rem; line-height: 1.5; animation: slideIn 0.3s; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.solution-accordion { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-main); }
.solution-accordion summary { padding: 12px 16px; background: var(--bg-panel); cursor: pointer; font-weight: 700; font-size: 0.9rem; color: var(--text-muted); transition: 0.2s; user-select: none; }
.solution-accordion summary:hover { color: var(--text-main); background: var(--hint-bg); }
.solution-code { padding: 16px; background: var(--bg-editor); color: var(--primary); font-family: 'Fira Code', monospace; border-top: 1px solid var(--border); direction: ltr; white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

/* Editor & Terminal */
.editor-header { padding: 12px 24px; background: var(--bg-panel); border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 16px; font-family: 'Fira Code', monospace; }
.lang-tag { background: rgba(88, 204, 2, 0.15); color: var(--primary); padding: 4px 10px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.file-name { color: var(--text-muted); font-size: 13px; }

.code-wrapper { position: relative; flex-grow: 1; font-family: 'Fira Code', monospace; background: var(--bg-editor); min-height: 350px; }
#editing, #highlighting { margin: 0; padding: 24px; width: 100%; height: 100%; border: 0; position: absolute; top: 0; left: 0; background: transparent; white-space: pre-wrap; word-wrap: break-word; font-size: 18px; line-height: 1.8; direction: ltr; text-align: left; font-family: 'Fira Code', monospace; }
#editing { z-index: 2; color: transparent; caret-color: var(--text-main); outline: none; resize: none; }
#editing::placeholder { color: var(--text-muted); opacity: 0.5; font-size: 16px; }
#highlighting { z-index: 1; pointer-events: none; color: var(--text-main); }

.terminal { height: 220px; background: var(--terminal); border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.terminal-tabs { padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--bg-panel); display: flex; gap: 20px; }
.tab { font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; padding-bottom: 8px; border-bottom: 2px solid transparent; transition: 0.2s; }
.tab.active-tab { color: var(--primary); border-bottom-color: var(--primary); }
.terminal-content { padding: 16px; font-family: 'Fira Code', monospace; font-size: 14px; overflow-y: auto; color: #aaa; direction: ltr; text-align: left; flex-grow: 1; line-height: 1.6; }
.terminal-content::-webkit-scrollbar { width: 6px; }
.terminal-content::-webkit-scrollbar-thumb { background: var(--border); }

.action-area { padding: 16px 24px; background: var(--bg-panel); border-top: 1px solid var(--border); display: flex; gap: 12px; }
html[dir="ltr"] .action-area { justify-content: flex-end; }
html[dir="rtl"] .action-area { justify-content: flex-start; }

.primary-btn { background: var(--primary); color: white; border: none; padding: 12px 28px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 15px; transition: 0.2s; box-shadow: 0 4px 12px rgba(88, 204, 2, 0.3); }
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(88, 204, 2, 0.4); }

.submit-btn { background: transparent; color: var(--accent); border: 2px solid var(--accent); padding: 12px 28px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 15px; transition: 0.2s; }
.submit-btn:hover { background: rgba(28, 176, 246, 0.1); }

/* === PROFILE SCREEN === */
#profile-screen { padding: 40px; overflow-y: auto; }
.profile-container { max-width: 1100px; margin: 0 auto; }

.profile-header-card { background: var(--bg-panel); border-radius: 24px; border: 1px solid var(--border); padding: 0; margin-bottom: 32px; text-align: center; position: relative; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.profile-banner { height: 140px; background: linear-gradient(135deg, #1cb0f6, #0ea5e9, #7c3aed); position: relative; }
.profile-banner::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 50%; background: linear-gradient(to bottom, transparent, var(--bg-panel)); }
.profile-avatar-large { width: 130px; height: 130px; border-radius: 50%; background: linear-gradient(135deg, var(--bg-main), var(--bg-panel)); border: 6px solid var(--bg-panel); margin: -65px auto 20px; font-size: 4.5rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 30px rgba(0,0,0,0.4); position: relative; z-index: 2; transition: transform 0.3s; }
.profile-avatar-large:hover { transform: scale(1.05) rotate(5deg); }
.profile-username { font-size: 2.2rem; font-weight: 900; margin: 0 0 8px; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.profile-bio { color: var(--text-muted); margin: 0 0 28px; font-size: 1.05rem; font-weight: 500; }

.profile-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 40px; }
.profile-stat-card { background: var(--bg-panel); border: 2px solid var(--border); border-radius: 20px; padding: 28px; text-align: center; transition: all 0.3s; position: relative; overflow: hidden; }
.profile-stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); opacity: 0; transition: opacity 0.3s; }
.profile-stat-card:hover { transform: translateY(-6px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(28, 176, 246, 0.2); }
.profile-stat-card:hover::before { opacity: 1; }

.stat-icon { font-size: 2.5rem; margin-bottom: 12px; }
.stat-number { font-size: 3rem; font-weight: 900; margin-bottom: 8px; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: 0.95rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

.stat-xp .stat-number { background: linear-gradient(135deg, #ffd700, #ffaa00); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-streak .stat-number { background: linear-gradient(135deg, #ff6b6b, #ff4444); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-levels .stat-number { background: linear-gradient(135deg, #58cc02, #46a302); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.progress-overview { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px; padding: 32px; margin-bottom: 32px; }
.progress-overview h2 { margin: 0 0 24px; font-size: 1.6rem; font-weight: 800; }
.overall-progress { }
.progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; }
.progress-label span:first-child { color: var(--text-main); font-size: 1.05rem; }
.progress-label span:last-child { color: var(--primary); font-size: 1.3rem; font-weight: 800; }
.progress-bar-large { height: 20px; background: var(--bg-main); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.progress-fill-large { height: 100%; background: linear-gradient(90deg, var(--primary), #46a302); transition: width 1s ease; border-radius: 12px; box-shadow: 0 0 10px var(--primary); position: relative; }
.progress-fill-large::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.badges-section { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px; padding: 36px; margin-bottom: 32px; }
.badges-section h2 { margin: 0 0 28px; font-size: 1.8rem; font-weight: 900; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.badge-card { background: var(--bg-main); border: 2px solid var(--border); border-radius: 16px; padding: 22px; display: flex; gap: 18px; align-items: center; transition: all 0.3s; opacity: 0.5; position: relative; overflow: hidden; }
.badge-card::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); transition: left 0.5s; }
.badge-card:hover::before { left: 100%; }
.badge-card.unlocked { opacity: 1; border-color: var(--primary); background: linear-gradient(135deg, rgba(88, 204, 2, 0.15), rgba(88, 204, 2, 0.05)); box-shadow: 0 4px 16px rgba(88, 204, 2, 0.2); }
.badge-card:hover { transform: translateY(-4px); }

.badge-icon { font-size: 3.5rem; min-width: 70px; text-align: center; filter: grayscale(1); transition: filter 0.3s; }
.badge-card.unlocked .badge-icon { filter: none; animation: badgePop 0.6s; }
@keyframes badgePop { 0% { transform: scale(0); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

.badge-info { flex-grow: 1; }
.badge-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: var(--text-main); }
.badge-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.badge-progress { display: flex; align-items: center; gap: 8px; }
.progress-bar { flex-grow: 1; height: 6px; background: var(--bg-panel); border-radius: 10px; overflow: hidden; }
.progress-bar .progress-fill { height: 100%; background: var(--primary); transition: width 0.5s; }
.progress-text { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); min-width: 40px; text-align: right; }

.danger-btn { background: transparent; border: 2px solid var(--danger); color: var(--danger); padding: 12px 28px; border-radius: 10px; cursor: pointer; font-weight: 700; transition: 0.2s; display: block; margin: 0 auto; }
.danger-btn:hover { background: rgba(255, 75, 75, 0.1); }

/* === LEADERBOARD === */
#leaderboard-screen { padding: 40px; }
.screen-header { text-align: center; margin-bottom: 32px; }
.screen-header h1 { font-size: 2.5rem; font-weight: 900; margin: 0; }

.table-wrapper { max-width: 800px; margin: 0 auto; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th { background: var(--bg-main); padding: 16px; text-align: center; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.leaderboard-table td { padding: 18px; text-align: center; border-bottom: 1px solid var(--border); }
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr.my-rank { background: rgba(88, 204, 2, 0.1); font-weight: 700; color: var(--primary); }
.leaderboard-table tr:hover { background: rgba(255,255,255,0.03); }

/* === MODAL === */
#modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 200; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(8px); animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box { background: var(--bg-panel); padding: 48px 40px; border-radius: 28px; text-align: center; border: 1px solid var(--border); width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: slideUp 0.4s; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-icon { font-size: 5rem; margin-bottom: 16px; animation: bounce 0.6s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

.modal-box h2 { font-size: 2rem; font-weight: 900; margin: 0 0 20px; color: var(--primary); }

.rewards-display { margin: 20px 0; }
.xp-reward { background: linear-gradient(135deg, var(--primary), #46a302); color: white; padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 1.2rem; margin-bottom: 12px; }
.badge-unlock { background: rgba(255, 200, 0, 0.2); color: var(--gold); padding: 10px 16px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; margin-top: 8px; border: 1px solid var(--gold); }
/* ============================================ */
/* === דף אתגרים - עיצוב עדין ונעים === */
/* ============================================ */

#challenges-screen {
    padding: 2.5rem;
    background: linear-gradient(180deg, 
        rgba(102, 126, 234, 0.03) 0%, 
        rgba(118, 75, 162, 0.05) 100%);
    min-height: 100vh;
    overflow-y: auto;
}

.challenges-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.challenges-header h1 {
    font-size: 2.8rem;
    margin-bottom: 0.8rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.challenges-header p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    opacity: 0.85;
    font-weight: 400;
}

#challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.8rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.challenge-card {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 1.8rem;
    border: 2px solid transparent;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.challenge-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.challenge-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(102, 126, 234, 0.05), transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.challenge-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.18);
    border-color: rgba(102, 126, 234, 0.3);
}

.challenge-card:hover::before {
    transform: scaleX(1);
}

.challenge-card:hover::after {
    opacity: 1;
}

.challenge-card.solved {
    border-color: rgba(88, 204, 2, 0.4);
    background: linear-gradient(135deg, 
        rgba(88, 204, 2, 0.03) 0%, 
        rgba(88, 204, 2, 0.08) 100%);
}

.challenge-card.solved::before {
    background: linear-gradient(90deg, #58cc02, #4caf50);
    transform: scaleX(1);
}

.challenge-card.solved:hover {
    border-color: rgba(88, 204, 2, 0.6);
    box-shadow: 0 12px 32px rgba(88, 204, 2, 0.2);
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.2rem;
    position: relative;
    z-index: 1;
}

.challenge-header h3 {
    font-size: 1.35rem;
    color: var(--text-main);
    margin: 0;
    flex: 1;
    font-weight: 700;
    line-height: 1.4;
}

.difficulty-badge {
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.challenge-card:hover .difficulty-badge {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.challenge-desc {
    color: var(--text-muted);
    line-height: 1.7;
    margin: 1.2rem 0;
    font-size: 0.98rem;
    position: relative;
    z-index: 1;
}

.challenge-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.8rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.xp-reward {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    color: var(--primary);
    font-size: 1.15rem;
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.08);
    transition: all 0.3s ease;
}

.challenge-card:hover .xp-reward {
    background: rgba(102, 126, 234, 0.15);
    transform: scale(1.05);
}

.xp-reward::before {
    content: '⭐';
    font-size: 1.3rem;
    animation: sparkle 2s ease-in-out infinite;
}

.status-badge {
    padding: 0.45rem 0.9rem;
    border-radius: 14px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.challenge-card.solved .status-badge {
    background: linear-gradient(135deg, #58cc02, #4caf50);
    color: white;
    box-shadow: 0 4px 12px rgba(88, 204, 2, 0.3);
}

/* אנימציות */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-25px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(15deg); }
}

/* רספונסיבי */
@media (max-width: 768px) {
    #challenges-screen {
        padding: 1.5rem 1rem;
    }
    
    #challenges-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .challenges-header h1 {
        font-size: 2.2rem;
    }
    
    .challenge-card {
        padding: 1.5rem;
    }
}

/* אפקט עדין לכרטיסים - כניסה מדורגת */
.challenge-card {
    animation: fadeInUp 0.5s ease-out backwards;
}

.challenge-card:nth-child(1) { animation-delay: 0.05s; }
.challenge-card:nth-child(2) { animation-delay: 0.1s; }
.challenge-card:nth-child(3) { animation-delay: 0.15s; }
.challenge-card:nth-child(4) { animation-delay: 0.2s; }
.challenge-card:nth-child(5) { animation-delay: 0.25s; }
.challenge-card:nth-child(6) { animation-delay: 0.3s; }
.challenge-card:nth-child(7) { animation-delay: 0.35s; }
.challenge-card:nth-child(8) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* תיקון Cursor Alignment - Code Editor */
#editing, #highlighting, #highlighting-content {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    letter-spacing: 0 !important;
    white-space: pre !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    tab-size: 4;
    -moz-tab-size: 4;
}

#editing {
    resize: none;
}

/* שיפור כפתור המודאל */
#modal-btn {
    transition: all 0.3s ease;
}

#modal-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(88, 204, 2, 0.4);
}

