:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #818cf8;
    --neon-cyan: #22d3ee;
    --neon-pink: #f472b6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --gold: #fbbf24;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    overflow: hidden;
    user-select: none; 
    transition: background 0.5s ease;
    /* MOBILE FIX: Prevent horizontal scroll */
    width: 100vw;
}

/* --- ROOM THEMES --- */
body.room-default { background: radial-gradient(circle at 10% 20%, #1e1b4b 0%, #0f172a 90%); }
body.room-library { background: linear-gradient(#271c19, #0f0a0a); }
body.room-cyber { background: repeating-linear-gradient(90deg, #0f172a 0px, #0f172a 50px, #1e293b 51px); }
body.room-rain { background: linear-gradient(to bottom, #334155, #0f172a); }

/* Backgrounds */
.bg-gradient {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 60%);
    z-index: -2;
    pointer-events: none;
}
#particles { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

/* Layout */
.app-container { display: flex; height: 100vh; }
.glass {
    background: var(--glass-bg); backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border); border-radius: 16px;
}

/* Sidebar */
.sidebar { width: 260px; padding: 2rem; display: flex; flex-direction: column; margin: 1rem; gap: 1rem; flex-shrink: 0; }
.logo { display: flex; gap: 10px; font-family: 'Space Grotesk'; font-weight: 700; font-size: 1.2rem; align-items: center; margin-bottom: 20px; }
.logo-icon { width: 35px; height: 35px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; }

.nav-links li {
    list-style: none; padding: 1rem; margin-bottom: 5px; border-radius: 12px;
    cursor: pointer; color: var(--text-muted); transition: 0.2s; display: flex; gap: 10px; align-items: center;
}
.nav-links li:hover, .nav-links li.active { background: rgba(255,255,255,0.1); color: white; transform: translateX(5px); }

/* Main Content */
.main-content { flex: 1; padding: 2rem; overflow: hidden; display: flex; flex-direction: column; position: relative; width: 100%; }
header { display: flex; justify-content: space-between; margin-bottom: 2rem; align-items: center; flex-shrink: 0; }
.stat-badge { background: rgba(255, 100, 100, 0.2); padding: 0.5rem 1rem; border-radius: 20px; color: #ff8888; font-weight: bold; }

/* Dashboard & Common */
.dashboard-grid { display: flex; gap: 20px; margin-bottom: 20px; }
.stats-overview { flex: 1; display: flex; justify-content: space-around; padding: 1rem; align-items: center; }
.stat-item span { font-size: 1.5rem; font-weight: 700; display: block; }

.add-task-bar { flex: 2; padding: 1rem; display: flex; gap: 10px; }
input, select { background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); color: white; padding: 0.8rem; border-radius: 8px; flex: 1; outline: none; }
.glow-btn { background: var(--primary); border: none; color: white; padding: 0.8rem 1.5rem; border-radius: 8px; cursor: pointer; transition: 0.2s; box-shadow: 0 0 10px rgba(129, 140, 248, 0.3); }
.glow-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px var(--primary); }
.glass-btn { background: transparent; border: 1px solid var(--glass-border); color: white; padding: 0.8rem 1.5rem; border-radius: 8px; cursor: pointer; transition: 0.2s; }
.glass-btn:hover { background: rgba(255,255,255,0.1); }

/* Tasks Container */
.tasks-container { flex: 1; overflow-y: auto; padding-right: 10px; -webkit-overflow-scrolling: touch; }
.task-card {
    background: rgba(255,255,255,0.03); padding: 1rem; margin-bottom: 10px; border-radius: 12px;
    display: flex; justify-content: space-between; align-items: center; border-left: 4px solid var(--text-muted); transition: 0.2s;
}
.task-card:hover { background: rgba(255,255,255,0.08); }
.task-card.completed { opacity: 0.5; text-decoration: line-through; }

/* Syllabus */
.syllabus-header { display: flex; gap: 10px; padding: 1rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }
.tab-btn { background: transparent; border: 1px solid var(--glass-border); color: var(--text-muted); padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; transition: 0.2s; }
.tab-btn.active { background: var(--primary); color: white; }
.syllabus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; overflow-y: auto; height: 60vh; padding-right: 10px; -webkit-overflow-scrolling: touch; }
.subject-group { padding: 1.5rem; }
.chapter-row { display: flex; gap: 10px; margin: 10px 0; font-size: 0.95rem; color: #ccc; align-items: center; }
.chapter-row input { flex: 0; width: 18px; height: 18px; cursor: pointer; }

/* FOCUS CORE */
#focus { 
    height: 100%; 
    overflow-y: auto; 
    overflow-x: hidden;
    padding-bottom: 2rem;
    -webkit-overflow-scrolling: touch;
}

.focus-layout { 
    display: flex; 
    gap: 40px; 
    min-height: 100%; 
    align-items: center; 
    justify-content: center; 
    flex-wrap: wrap; 
    perspective: 1200px; 
    padding: 20px;
}

.timer-visual { 
    position: relative; 
    width: 350px; 
    height: 350px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
    border: 1px solid rgba(34, 211, 238, 0.2);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.timer-visual .glow-effect {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 16px;
    background: radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.05), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

#timer-canvas { 
    position: absolute; 
    top:0; left:0; 
    transform: translateZ(20px);
    filter: drop-shadow(0 10px 15px rgba(34, 211, 238, 0.2));
}

.timer-overlay { 
    position: relative; 
    z-index: 2; 
    text-align: center; 
    transform: translateZ(40px);
    text-shadow: 0 5px 10px rgba(0,0,0,0.5);
}

#timer-display { font-size: 4rem; font-weight: 800; font-family: 'Space Grotesk'; letter-spacing: -2px; }
#timer-status { letter-spacing: 4px; font-size: 0.8rem; color: var(--neon-cyan); margin-top: 10px; }

.timer-config { display: flex; flex-direction: column; gap: 20px; width: 300px; transform: translateZ(10px); }
.panel-p { padding: 1.5rem; }
.panel-p h3 { margin-bottom: 15px; font-size: 1rem; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.large-btn { width: 100%; padding: 1rem; font-weight: 800; letter-spacing: 1px; }

.timer-buttons { display: flex; flex-direction: column; gap: 10px; }
.avatar-selector { display: flex; gap: 10px; justify-content: center; }
.av-btn { width: 50px; height: 50px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.3); color: white; cursor: pointer; font-size: 1.2rem; transition: 0.3s; }
.av-btn.active, .av-btn:hover { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 15px var(--primary); transform: translateY(-3px); }

/* Settings Toggles */
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 10px 0; }
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.2); transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--neon-cyan); }
input:checked + .slider:before { transform: translateX(24px); }

/* Views */
.view { display: none; animation: fadeIn 0.3s ease; height: 100%; flex-direction: column; }
.active-view { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* History Section */
#timeline { display: none; height: 100%; flex-direction: column; }
#timeline.active-view { display: flex; }
.report-header { flex-shrink: 0; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.timeline-container { flex: 1; overflow-y: auto; padding-right: 15px; position: relative; -webkit-overflow-scrolling: touch; }
.timeline-item { margin-bottom: 15px; border-left: 2px solid var(--primary); padding-left: 15px; opacity: 0; animation: slideInLeft 0.5s forwards; }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
.time-stamp { font-size: 0.8rem; color: var(--text-muted); }
.mb-20 { margin-bottom: 20px; }

/* ANALYTICS UI IMPROVEMENT: Styles for improved graphs */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; width: 100%; height: 100%; overflow-y: auto; padding-right: 10px; }
.chart-helper { text-align: center; margin-top: 10px; font-size: 0.9rem; color: var(--text-muted); font-style: italic; }
.text-neon { color: var(--neon-cyan); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); border-radius: 4px; }
::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.15); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.3); }

/* Avatar System */
.mentor-container { position: fixed; bottom: 30px; right: 30px; display: flex; flex-direction: column; align-items: flex-end; z-index: 100; pointer-events: none; }
.speech-bubble { background: white; color: black; padding: 10px 20px; border-radius: 20px 20px 0 20px; margin-bottom: 15px; opacity: 0; transition: 0.3s; font-weight: 600; box-shadow: 0 0 20px rgba(255,255,255,0.3); width: max-content; max-width: 250px; }
.avatar-wrapper { display: none; width: 80px; height: 80px; position: relative; pointer-events: auto; cursor: pointer; }
.avatar-wrapper.active { display: block; animation: float 3s ease-in-out infinite; }

.drone-body { width: 60px; height: 60px; background: #000; border: 2px solid var(--neon-cyan); border-radius: 50%; position: absolute; top: 10px; left: 10px; box-shadow: 0 0 15px var(--neon-cyan); }
.drone-eye { width: 20px; height: 6px; background: var(--neon-cyan); position: absolute; top: 45%; left: 50%; transform: translateX(-50%); animation: blink 4s infinite; }
.orb-core { width: 60px; height: 60px; background: radial-gradient(circle, var(--neon-pink), transparent); border-radius: 50%; position: absolute; top: 10px; left: 10px; box-shadow: 0 0 30px var(--neon-pink); }
.orb-ring { position: absolute; border: 1px solid var(--neon-pink); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.ring1 { width: 70px; height: 70px; animation: spin 4s linear infinite; border-bottom: transparent; }
.ring2 { width: 80px; height: 80px; animation: spin 6s linear infinite reverse; border-top: transparent; }
.owl-head { width: 60px; height: 60px; background: #1e293b; border: 2px solid #fbbf24; border-radius: 40% 40% 50% 50%; position: absolute; top: 10px; left: 10px; box-shadow: 0 0 15px #fbbf24; }
.owl-eye { width: 18px; height: 18px; background: #fff; border-radius: 50%; position: absolute; top: 15px; }
.owl-eye.left { left: 8px; } .owl-eye.right { right: 8px; }
.owl-eye::after { content:''; width: 8px; height: 8px; background: #000; border-radius: 50%; position: absolute; top: 5px; left: 5px; }
.owl-beak { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid #fbbf24; position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes blink { 0%, 95%, 100% { height: 6px; } 98% { height: 1px; } }
@keyframes spin { 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* Gamification & Shop */
.text-gold { color: var(--gold); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; overflow-y: auto; height: 60vh; padding-right: 10px; -webkit-overflow-scrolling: touch; }
.shop-card { background: rgba(0,0,0,0.2); border: 1px solid var(--glass-border); border-radius: 12px; padding: 15px; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: 0.2s; position: relative; }
.shop-card:hover { transform: translateY(-5px); background: rgba(255,255,255,0.05); }
.shop-icon { font-size: 2rem; margin-bottom: 10px; color: var(--neon-cyan); }
.shop-price { font-weight: bold; color: var(--gold); }
.shop-btn { padding: 5px 15px; border-radius: 20px; border: none; cursor: pointer; font-weight: bold; }
.btn-buy { background: var(--gold); color: #000; }
.btn-equip { background: var(--primary); color: #fff; }
.btn-equipped { background: rgba(255,255,255,0.1); color: #aaa; cursor: default; }

/* Missions */
.mission-grid { display: flex; flex-direction: column; gap: 10px; }
.mission-card { display: flex; justify-content: space-between; align-items: center; padding: 15px; background: rgba(255,255,255,0.02); border-left: 3px solid var(--text-muted); border-radius: 8px; }
.mission-card.completed { border-color: #4ade80; opacity: 0.6; }
.mission-reward { background: rgba(251, 191, 36, 0.2); color: var(--gold); padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; }

/* Settings Tabs */
.settings-tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.set-tab { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 10px; font-weight: 600; flex-shrink: 0; }
.set-tab.active { color: var(--neon-cyan); border-bottom: 2px solid var(--neon-cyan); }
.set-content { display: none; animation: fadeIn 0.3s ease; }
.set-content.active { display: block; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { width: 90%; max-width: 500px; padding: 2rem; display: flex; flex-direction: column; gap: 15px; }
.mood-selector { background: rgba(255,255,255,0.05); padding: 15px; border-radius: 12px; }
.mood-btns { display: flex; gap: 10px; margin-top: 10px; }
.mood-btn { flex: 1; padding: 10px; background: transparent; border: 1px solid var(--glass-border); color: #fff; border-radius: 8px; cursor: pointer; }
.mood-btn.active { background: var(--primary); border-color: var(--primary); }
.glass-inset { background: rgba(0,0,0,0.3); padding: 10px; border-radius: 8px; border: 1px solid var(--glass-border); }
.full-width { width: 100%; }

.breathing-circle { width: 100px; height: 100px; background: var(--neon-cyan); border-radius: 50%; margin: 30px auto; box-shadow: 0 0 40px var(--neon-cyan); animation: breathe 8s infinite ease-in-out; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(2); opacity: 1; } }

/* ========================================================================== */
/* MOBILE FIX: RESPONSIVE MEDIA QUERIES & TOUCH OPTIMIZATION                  */
/* ========================================================================== */
@media (max-width: 768px) {
    /* MOBILE FIX: Change Layout to Column */
    .app-container { flex-direction: column; }
    
    /* MOBILE FIX: Sidebar becomes top navigation */
    .sidebar { width: 100%; padding: 1rem; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin: 0; border-radius: 0; border: none; border-bottom: 1px solid var(--glass-border); }
    .logo { margin-bottom: 0; font-size: 1rem; }
    
    /* MOBILE FIX: Scrollable Navigation Links */
    .nav-links { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 5px; flex: 1; margin: 0 10px; -webkit-overflow-scrolling: touch; }
    .nav-links::-webkit-scrollbar { display: none; } /* Hide scrollbar for cleaner look */
    .nav-links li { padding: 0.5rem 0.8rem; margin: 0; white-space: nowrap; font-size: 0.9rem; }
    
    /* MOBILE FIX: Compact Profile */
    .user-profile { display: none; } /* Hidden to save space on mobile */
    
    /* MOBILE FIX: Main Content padding */
    .main-content { padding: 1rem; height: calc(100vh - 80px); /* Adjust for header height */ }
    
    /* MOBILE FIX: Dashboard Stack */
    .dashboard-grid { flex-direction: column; gap: 15px; }
    .add-task-bar { flex-direction: column; }
    .stats-overview { gap: 10px; }
    
    /* MOBILE FIX: Focus Core Scaling */
    .timer-visual { width: 280px; height: 280px; }
    #timer-canvas { width: 280px; height: 280px; } /* Ensure canvas fits */
    #timer-display { font-size: 3rem; }
    .timer-config { width: 100%; max-width: 350px; }
    .focus-layout { gap: 20px; padding-bottom: 50px; }
    
    /* MOBILE FIX: Shop Grid */
    .shop-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); height: auto; max-height: 60vh; }
    
    /* MOBILE FIX: Mentor Avatar Position */
    .mentor-container { bottom: 10px; right: 10px; scale: 0.8; transform-origin: bottom right; }
    
    /* MOBILE FIX: Touch Targets */
    button, select, input { min-height: 44px; } /* Touch friendly size */
    
    /* MOBILE FIX: Modal Responsive */
    .modal { width: 95%; padding: 1.5rem; }
    .mood-btns { flex-wrap: wrap; }
}