u23-27gurkin il y a 2 mois
Parent
commit
e723657cc1
1 fichiers modifiés avec 259 ajouts et 232 suppressions
  1. 259 232
      docs/index.html

+ 259 - 232
docs/index.html

@@ -7,188 +7,196 @@
     <style>
         :root {
             --bg-color: #fdfaf6;
-            --panel-bg: rgba(255, 255, 255, 0.75);
+            --panel-bg: rgba(255, 255, 255, 0.85);
             --text-color: #333;
-            --border-color: rgba(204, 204, 204, 0.5);
+            --border-color: rgba(204, 204, 204, 0.6);
             --accent: #4CAF50;
             --base-wave: #2196F3;
             --btn-glow: rgba(76, 175, 80, 0.6);
-            --canvas-bg: rgba(250, 250, 250, 0.85);
+            --canvas-bg: rgba(250, 250, 250, 0.9);
         }
 
-        [data-theme="dark"] {
-            --bg-color: #121212; --panel-bg: rgba(30, 30, 30, 0.75);
-            --text-color: #eee; --border-color: rgba(68, 68, 68, 0.5); --accent: #bb86fc;
-            --base-wave: #03dac6; --btn-glow: rgba(187, 134, 252, 0.6); --canvas-bg: rgba(44, 44, 44, 0.85);
-        }
-
-        [data-theme="neon"] {
-            --bg-color: #000016; --panel-bg: rgba(10, 10, 30, 0.75);
-            --text-color: #0ff; --border-color: rgba(255, 0, 255, 0.5); --accent: #f0f;
-            --base-wave: #0ff; --btn-glow: rgba(255, 0, 255, 0.8); --canvas-bg: rgba(0, 0, 0, 0.85);
-        }
+        [data-theme="dark"] { --bg-color: #121212; --panel-bg: rgba(30, 30, 30, 0.85); --text-color: #eee; --border-color: rgba(80, 80, 80, 0.6); --accent: #bb86fc; --base-wave: #03dac6; --btn-glow: rgba(187, 134, 252, 0.6); --canvas-bg: rgba(44, 44, 44, 0.9); }
+        [data-theme="neon"] { --bg-color: #000016; --panel-bg: rgba(10, 10, 30, 0.85); --text-color: #0ff; --border-color: rgba(255, 0, 255, 0.6); --accent: #f0f; --base-wave: #0ff; --btn-glow: rgba(255, 0, 255, 0.8); --canvas-bg: rgba(0, 0, 0, 0.9); }
 
-        body, html { margin: 0; padding: 0; width: 100%; height: 100%; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; overflow-x: hidden; color: var(--text-color); }
+        /* Строгий запрет скролла. Приложение всегда 100% экрана */
+        body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: var(--text-color); }
         
-        #bg-layer {
-            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
-            background-color: var(--bg-color); background-size: cover; background-position: center;
-            z-index: -2; transition: filter 0.3s, background-image 0.5s;
-        }
+        #bg-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--bg-color); background-size: cover; background-position: center; z-index: -2; transition: filter 0.3s, background-image 0.5s ease-in-out; }
 
-        .gradient-text {
-            background: linear-gradient(45deg, #ff00cc, #3333ff, #00ffcc, #ff00cc);
-            background-size: 300% 300%; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
-            animation: gradientFlow 5s ease infinite; font-weight: bold;
-        }
+        .gradient-text { background: linear-gradient(45deg, #ff00cc, #3333ff, #00ffcc, #ff00cc); background-size: 300% 300%; -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: gradientFlow 5s ease infinite; font-weight: bold; }
         @keyframes gradientFlow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
 
-        #welcome-screen {
-            position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center;
-            background: var(--bg-color); z-index: 1000; transition: opacity 0.5s;
-        }
+        #welcome-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--bg-color); z-index: 1000; transition: opacity 0.5s; }
         .logo { font-size: 80px; margin-bottom: 20px; text-shadow: 0 0 30px rgba(0, 212, 255, 0.5); }
         .app-title { font-size: 56px; margin: 0; }
         .app-subtitle { font-size: 20px; color: var(--text-color); margin-bottom: 40px; opacity: 0.8; }
         
-        /* Анимации кнопок и инпутов */
-        .btn, .settings-group select, .settings-group input[type="file"] {
-            transition: all 0.2s ease; cursor: pointer;
-        }
-        .btn:active, .settings-group select:active, .settings-group input[type="file"]:active {
-            transform: scale(0.92) !important;
-        }
-
-        .btn-enter {
-            padding: 15px 40px; font-size: 22px; font-weight: bold; color: #fff;
-            background: linear-gradient(45deg, #ff00cc, #3333ff); border: none; border-radius: 30px;
-            box-shadow: 0 0 20px rgba(51, 51, 255, 0.6);
+        .btn, .quiz-option, .tab, .sidebar-link { transition: all 0.2s ease; cursor: pointer; }
+        .btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 4px 12px var(--btn-glow); filter: brightness(1.1); }
+        .btn:active { transform: scale(0.95); box-shadow: none; }
+        .btn-enter { padding: 15px 40px; font-size: 22px; font-weight: bold; color: #fff; background: linear-gradient(45deg, #ff00cc, #3333ff); border: none; border-radius: 30px; box-shadow: 0 0 20px rgba(51, 51, 255, 0.6); }
+
+        #main-app { display: none; padding: 15px; box-sizing: border-box; height: 100%; flex-direction: column; }
+
+        /* --- БОКОВАЯ ПАНЕЛЬ И НАВИГАЦИЯ --- */
+        .top-bar { display: flex; align-items: center; gap: 15px; padding: 5px 10px; margin-bottom: 10px; flex-shrink: 0; }
+        .menu-btn { font-size: 28px; background: var(--panel-bg); border: 1px solid var(--border-color); color: var(--text-color); cursor: pointer; transition: 0.3s; padding: 5px 15px; border-radius: 8px; backdrop-filter: blur(10px); }
+        .menu-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
+        .nav-logo { font-size: 28px; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 5px 15px; background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: 8px; backdrop-filter: blur(10px); }
+        
+        #sidebar {
+            position: fixed; left: -320px; top: 0; width: 300px; height: 100%; background: var(--panel-bg);
+            box-shadow: 5px 0 20px rgba(0,0,0,0.3); backdrop-filter: blur(15px); z-index: 2000;
+            transition: left 0.3s ease; padding: 20px; box-sizing: border-box; overflow-y: auto; display: flex; flex-direction: column;
         }
-        .btn-enter:hover { transform: scale(1.05); }
+        #sidebar.open { left: 0; }
+        .sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
+        .close-sidebar { font-size: 30px; cursor: pointer; color: var(--text-color); transition: 0.2s; }
+        .close-sidebar:hover { color: #f44336; transform: scale(1.1); }
+        
+        .sidebar-section { margin-bottom: 25px; }
+        .sidebar-title { font-size: 14px; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; letter-spacing: 1px; }
+        .sidebar-link { padding: 10px; border-radius: 6px; margin-bottom: 5px; font-weight: bold; background: var(--canvas-bg); border: 1px solid var(--border-color); }
+        .sidebar-link:hover { background: var(--accent); color: white; transform: translateX(5px); }
 
-        #main-app { display: none; padding: 20px; box-sizing: border-box; height: 100%; display: flex; flex-direction: column; }
-
-        .top-bar {
-            display: flex; justify-content: space-between; align-items: center; background: var(--panel-bg); padding: 10px 20px; border-radius: 8px;
-            border: 1px solid var(--border-color); margin-bottom: 15px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); backdrop-filter: blur(10px);
-        }
-        .nav-logo { font-size: 28px; cursor: pointer; display: flex; align-items: center; gap: 10px;}
-        .settings-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
-        .settings-group select, .settings-group input[type="file"] {
-            background: var(--canvas-bg); color: var(--text-color); border: 1px solid var(--border-color); padding: 5px; border-radius: 4px;
-        }
+        .setting-block { margin-bottom: 15px; }
+        .setting-block label { display: block; margin-bottom: 8px; font-weight: bold; font-size: 14px; }
+        .setting-block select, .setting-block input[type="file"] { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--border-color); background: var(--canvas-bg); color: var(--text-color); cursor: pointer; }
+        #sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1999; backdrop-filter: blur(3px); }
 
+        /* --- ИДЕАЛЬНАЯ АДАПТИВНАЯ СЕТКА ГРАФИКОВ --- */
         .grid-container { 
-            display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
-            gap: 15px; flex-grow: 1; min-height: 0;
+            display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 15px; 
+            flex-grow: 1; min-height: 0; /* min-height: 0 позволяет сетке сжиматься */
         }
         .panel { 
             background: var(--panel-bg); border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; 
-            display: flex; flex-direction: column; backdrop-filter: blur(10px);
+            display: flex; flex-direction: column; backdrop-filter: blur(10px); min-height: 0; 
         }
-        .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
+        .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-shrink: 0; }
         
-        .canvas-wrapper { 
-            flex-grow: 1; resize: both; overflow: hidden; width: 100%; min-height: 150px; min-width: 250px; 
-            background: var(--canvas-bg); border: 1px solid var(--border-color); border-radius: 4px; position: relative; 
-        }
-        canvas { display: block; width: 100%; height: 100%; }
+        /* Враппер подстраивается под оставшееся место, а canvas занимает 100% абсолютно */
+        .canvas-wrapper { flex-grow: 1; position: relative; width: 100%; min-height: 0; background: var(--canvas-bg); border: 1px solid var(--border-color); border-radius: 4px; overflow: hidden; }
+        canvas { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
         
-        .tabs { display: flex; gap: 5px; margin: 10px 0; }
-        .tab { padding: 8px 15px; cursor: pointer; background: transparent; border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-color); transition: 0.2s; }
+        .tabs { display: flex; gap: 5px; margin: 10px 0; flex-shrink: 0; }
+        .tab { padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-color); background: var(--canvas-bg); }
+        .tab:hover { background: rgba(128,128,128,0.1); }
         .tab.active { background: var(--accent); color: #fff; font-weight: bold; border-color: var(--accent); }
-        .control-row { margin-bottom: 10px; display: flex; align-items: center; }
-        label { display: inline-block; width: 140px; font-weight: bold; }
+        .control-row { margin-bottom: 8px; display: flex; align-items: center; flex-shrink: 0; }
+        .control-row label { display: inline-block; width: 120px; font-weight: bold; font-size: 14px; }
         input[type=range] { flex-grow: 1; margin-right: 15px; cursor: pointer; }
         
-        .btn { padding: 8px 15px; border: none; border-radius: 4px; font-weight: bold; color: white; margin-right: 5px; margin-bottom: 5px; }
-        .btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
-        .btn-audio { background: #2196F3; } .btn-dist { background: #9C27B0; } .btn-reset { background: #607D8B; } .btn-test { background: #FF9800; } .btn-icon { background: transparent; border: 1px solid var(--border-color); color: var(--text-color); }
-        .btn-audio.active { background: #f44336; box-shadow: 0 0 15px rgba(244, 67, 54, 0.6); }
-        .btn-dist.active { background: #d32f2f; box-shadow: 0 0 15px rgba(211, 47, 47, 0.6); }
-
-        /* --- Тестирование --- */
-        .modal-overlay {
-            display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
-            background: rgba(0,0,0,0.7); z-index: 2000; justify-content: center; align-items: center; backdrop-filter: blur(8px);
-        }
-        .modal-content {
-            background: var(--bg-color); padding: 30px; border-radius: 12px; width: 600px; max-width: 90%;
-            max-height: 85vh; overflow-y: auto; border: 2px solid var(--accent); position: relative;
-        }
-        .close-btn { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: var(--text-color); transition: 0.2s; }
-        .close-btn:hover { color: #f44336; transform: scale(1.1); }
+        .btn { padding: 8px 15px; border: none; border-radius: 4px; font-weight: bold; color: white; margin-right: 5px; margin-bottom: 5px; flex-shrink: 0; }
+        .btn-audio { background: #2196F3; } .btn-dist { background: #9C27B0; } .btn-reset { background: #607D8B; } .btn-test { background: #FF9800; } .btn-icon { background: transparent; border: 1px solid var(--border-color); color: var(--text-color); padding: 5px 10px; font-size: 12px; }
+        .btn-audio.active { background: #f44336; } .btn-dist.active { background: #d32f2f; }
+
+        /* Подвал */
+        .app-footer { text-align: center; font-size: 12px; opacity: 0.6; padding-top: 10px; flex-shrink: 0; font-weight: bold; }
+
+        /* --- ТЕСТИРОВАНИЕ --- */
+        .modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; justify-content: center; align-items: center; backdrop-filter: blur(8px); }
+        .modal-content { background: var(--bg-color); padding: 30px; border-radius: 12px; width: 700px; max-width: 95%; max-height: 85vh; overflow-y: auto; border: 2px solid var(--accent); position: relative; }
+        
+        .test-modes { display: flex; gap: 15px; justify-content: center; margin-top: 30px; }
+        .test-modes .btn { font-size: 18px; padding: 15px 25px; flex: 1; }
+        .btn-easy { background: #4CAF50; } .btn-medium { background: #FF9800; } .btn-hard { background: #f44336; }
+        
         .question { margin-bottom: 20px; background: var(--panel-bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); }
         .question p { font-weight: bold; margin-top: 0; margin-bottom: 15px; font-size: 16px; }
         
-        .quiz-option { 
-            display: block; padding: 10px; margin-bottom: 8px; border-radius: 6px; cursor: pointer;
-            border: 1px solid var(--border-color); transition: all 0.2s ease; background: var(--canvas-bg);
-        }
-        .quiz-option:hover { background: rgba(128,128,128,0.1); transform: translateX(5px); }
-        .quiz-option input { margin-right: 10px; transform: scale(1.2); cursor: pointer; }
-        .quiz-option.correct { background-color: rgba(76, 175, 80, 0.3); border-color: #4CAF50; color: #fff; box-shadow: 0 0 10px rgba(76, 175, 80, 0.4); }
-        .quiz-option.wrong { background-color: rgba(244, 67, 54, 0.3); border-color: #f44336; color: #fff; box-shadow: 0 0 10px rgba(244, 67, 54, 0.4); }
+        .quiz-option { display: block; padding: 12px; margin-bottom: 8px; border-radius: 6px; border: 1px solid var(--border-color); background: var(--canvas-bg); }
+        .quiz-option:hover { transform: translateX(8px); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
+        .quiz-option input { margin-right: 10px; transform: scale(1.2); }
+        .quiz-option.correct { background-color: rgba(76, 175, 80, 0.4); border-color: #4CAF50; color: #fff; box-shadow: 0 0 12px rgba(76, 175, 80, 0.5); }
+        .quiz-option.wrong { background-color: rgba(244, 67, 54, 0.4); border-color: #f44336; color: #fff; box-shadow: 0 0 12px rgba(244, 67, 54, 0.5); }
 
         #test-result { margin-top: 20px; font-size: 22px; font-weight: bold; text-align: center; opacity: 0; transition: opacity 0.5s; }
+        .test-controls { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
     </style>
 </head>
 <body onload="document.getElementById('main-app').style.display='none';">
     <div id="bg-layer"></div>
+    <div id="sidebar-overlay" onclick="toggleSidebar()"></div>
 
+    <!-- ВХОД -->
     <div id="welcome-screen">
         <div class="logo">🌊</div>
         <h1 class="app-title gradient-text">HarmoniX</h1>
-        <h2 class="app-subtitle">Волновой Спектр / Механические волны и Фурье</h2>
-        <button class="btn-enter" onclick="startApp()">Войти в приложение</button>
+        <h2 class="app-subtitle">Механические волны и Спектр Фурье</h2>
+        <button class="btn-enter" onclick="startApp()">Начать работу</button>
     </div>
 
-    <div id="main-app">
-        <nav class="top-bar">
-            <div class="nav-logo gradient-text" onclick="location.reload()"><span>🌊</span> HarmoniX</div>
-            <div class="settings-group">
-                <label>🎨 Тема:</label>
+    <!-- БОКОВАЯ ПАНЕЛЬ -->
+    <div id="sidebar">
+        <div class="sidebar-header">
+            <h2 class="gradient-text" style="margin:0;">Настройки</h2>
+            <div class="close-sidebar" onclick="toggleSidebar()">&times;</div>
+        </div>
+        
+        <div class="sidebar-section">
+            <h3 class="sidebar-title">📌 Навигация сайта</h3>
+            <div class="sidebar-link" onclick="toggleSidebar()">🏠 Главная панель</div>
+            <div class="sidebar-link" onclick="openTestMenu(); toggleSidebar()">📝 Итоговое Тестирование</div>
+            <div class="sidebar-link" onclick="alert('Справочник формул: \ny = A*cos(wt+θ)\nT = 1/V\nw = 2πV'); playUISound('click')">📚 Справочник формул</div>
+            <div class="sidebar-link" onclick="alert('HarmoniX Версия 2.6\nИнтерактивное образовательное PWA приложение.'); playUISound('click')">ℹ️ О проекте</div>
+        </div>
+
+        <div class="sidebar-section">
+            <h3 class="sidebar-title">🎨 Внешний вид</h3>
+            <div class="setting-block">
+                <label>Тема интерфейса:</label>
                 <select onchange="changeTheme(this.value)">
-                    <option value="default">Светлая</option><option value="dark">Темная</option><option value="neon">Неон</option>
-                </select>
-                
-                <label>🖼️ Обои:</label>
-                <!-- Исправлены ссылки на картинки (без кавычек внутри url) для корректной работы -->
-                <select onchange="changePresetBg(this.value)">
-                    <option value="none">Без фона</option>
-                    <option value="url(https://images.unsplash.com/photo-1462331940025-496dfbfc7564?auto=format&fit=crop&w=1920&q=80)">Космос</option>
-                    <option value="url(https://images.unsplash.com/photo-1505118380757-91f5f5632de0?auto=format&fit=crop&w=1920&q=80)">Морские волны</option>
-                    <option value="url(https://images.unsplash.com/photo-1518770660439-4636190af475?auto=format&fit=crop&w=1920&q=80)">Абстракция</option>
+                    <option value="default">Светлая (Базовая)</option>
+                    <option value="dark">Темная (Ночная)</option>
+                    <option value="neon">Неон (Киберпанк)</option>
                 </select>
-                <input type="file" accept="image/*" onchange="uploadBackground(event)" title="Загрузить свое фото">
-                
-                <label>✨ Фильтр:</label>
+            </div>
+            <div class="setting-block">
+                <label>Загрузить свои обои:</label>
+                <input type="file" accept="image/*" id="bgUpload" onchange="uploadBackground(event)">
+                <button class="btn btn-reset" style="width: 100%; margin-top: 8px; padding: 10px;" onclick="clearBackground()">🗑 Удалить обои</button>
+            </div>
+            <div class="setting-block">
+                <label>Фильтры фона:</label>
                 <select onchange="changeFilter(this.value)">
-                    <option value="none">Нет</option>
+                    <option value="none">Без фильтра</option>
                     <option value="blur(8px)">Размытие</option>
-                    <option value="grayscale(100%)">Ч/Б</option>
-                    <option value="hue-rotate(90deg)">Инверсия</option>
+                    <option value="grayscale(100%)">Чёрно-белый</option>
+                    <option value="sepia(80%)">Сепия</option>
+                    <option value="hue-rotate(90deg)">Инверсия оттенков</option>
                 </select>
-                <button class="btn btn-icon" style="margin-bottom:0;" onclick="toggleFullscreen()">🔲 На весь экран</button>
             </div>
-        </nav>
+        </div>
+        <div style="flex-grow: 1;"></div>
+        <div style="text-align: center; font-size: 12px; opacity: 0.5;">v2.6 Dashboard App</div>
+    </div>
+
+    <!-- ОСНОВНОЙ ИНТЕРФЕЙС -->
+    <div id="main-app">
+        <div class="top-bar">
+            <button class="menu-btn" onclick="toggleSidebar()">☰ Меню</button>
+            <div class="nav-logo gradient-text"><span>🌊</span> HarmoniX</div>
+            <button class="menu-btn" id="btnFullscreen" onclick="toggleFullscreen()">🔲 На весь экран</button>
+        </div>
 
         <div class="grid-container">
             <div class="panel">
-                <div class="panel-header"><h3 style="margin:0;">1. Базовое колебание</h3><span style="font-size:10px; opacity:0.5;">Потяните за правый нижний угол ↘</span></div>
+                <div class="panel-header"><h3 style="margin:0;">1. Базовое колебание</h3></div>
                 <div class="canvas-wrapper"><canvas id="canvas-single"></canvas></div>
             </div>
 
             <div class="panel">
                 <div class="panel-header">
                     <h3 style="margin:0;">3. Теорема Фурье</h3>
-                    <button class="btn btn-icon" style="padding: 4px 8px; font-size:12px; margin-bottom:0;" onclick="downloadGraph('canvas-sum')">💾 Скачать график</button>
+                    <button class="btn btn-icon" onclick="downloadGraph('canvas-sum')">💾 Скачать график</button>
                 </div>
                 <div class="canvas-wrapper"><canvas id="canvas-sum"></canvas></div>
             </div>
 
             <div class="panel">
-                <h3 style="margin:0">2. Управление</h3>
+                <h3 style="margin:0">2. Панель Управления</h3>
                 <div class="tabs">
                     <div class="tab active" onclick="switchTab(0)">V1</div><div class="tab" onclick="switchTab(1)">V2</div><div class="tab" onclick="switchTab(2)">V3</div>
                 </div>
@@ -207,49 +215,87 @@
                     <input type="range" id="amp" min="0" max="100" value="80" oninput="updateWave(); playSliderSound(this.value, 100, 0, 'low')">
                     <div style="width: 60px; text-align:right"><span id="valA">80</span>%</div>
                 </div>
-                <div>
+                <div style="margin-top: auto;">
                     <button class="btn btn-audio" onclick="toggleAudio(); playUISound('action')" id="btnAudio">🔊 Динамик</button>
-                    <!-- Кнопка искажения переименована, чтобы занимать меньше места -->
-                    <button class="btn btn-dist" onclick="toggleClip(); playUISound('action')" id="btnClip">⚡ Нелин. преобр. (искаж.)</button>
+                    <button class="btn btn-dist" onclick="toggleClip(); playUISound('action')" id="btnClip">⚡ Нелин. преобр. (Искажение)</button>
                     <button class="btn btn-reset" onclick="resetAll(); playUISound('error')">🔄 Сброс</button>
-                    <button class="btn btn-test" onclick="openTest(); playUISound('action')">📝 Тестирование</button>
                 </div>
             </div>
 
             <div class="panel">
-                <h3 style="margin:0; margin-bottom: 10px;">4. Спектр</h3>
+                <h3 style="margin:0; margin-bottom: 10px;">4. Спектрограмма</h3>
                 <div class="canvas-wrapper"><canvas id="canvas-spectrum"></canvas></div>
             </div>
         </div>
+        <div class="app-footer">HarmoniX v2.6 | Разработано для интерактивного изучения физики © 2026</div>
     </div>
 
-    <!-- Модальное окно тестирования -->
+    <!-- ТЕСТИРОВАНИЕ -->
     <div id="test-overlay" class="modal-overlay">
         <div class="modal-content">
             <span class="close-btn" onclick="closeTest()">&times;</span>
-            <h2 class="gradient-text" style="text-align: center; margin-top: 0;">Итоговое тестирование</h2>
+            <h2 class="gradient-text" style="text-align: center; margin-top: 0; font-size: 32px;">Итоговое тестирование</h2>
             
-            <div id="quiz-container">
-                <!-- Вопросы генерируются через JS -->
+            <div id="test-start-menu">
+                <p style="text-align:center; font-size: 18px;">Выберите режим тестирования:</p>
+                <div class="test-modes">
+                    <button class="btn btn-easy" onclick="startQuiz(5)">Легкий<br><small>5 вопросов</small></button>
+                    <button class="btn btn-medium" onclick="startQuiz(15)">Средний<br><small>15 вопросов</small></button>
+                    <button class="btn btn-hard" onclick="startQuiz(30)">Сложный<br><small>30 вопросов</small></button>
+                </div>
+                <div style="text-align: center; margin-top: 30px;">
+                    <button class="btn btn-reset" onclick="closeTest()" style="padding: 10px 30px;">🚪 Выйти</button>
+                </div>
             </div>
-            
-            <div style="text-align: center; margin-top: 20px;">
-                <button class="btn btn-test" id="checkBtn" style="font-size: 18px; padding: 10px 30px;" onclick="checkTest()">Проверить ответы</button>
-                <!-- Добавлена кнопка "Начать сначала" -->
-                <button class="btn btn-reset" id="restartTestBtn" style="font-size: 18px; padding: 10px 30px; display: none;" onclick="openTest()">🔄 Начать сначала</button>
+
+            <div id="quiz-process" style="display: none;">
+                <div id="quiz-container"></div>
+                <div class="test-controls" id="quiz-buttons">
+                    <button class="btn btn-test" id="checkBtn" style="font-size: 18px; padding: 10px 30px;" onclick="checkTest()">✅ Проверить ответы</button>
+                    <button class="btn btn-reset" onclick="closeTest()" style="font-size: 18px; padding: 10px 30px;">🚪 Выйти</button>
+                </div>
+                <div id="test-result"></div>
+                <div class="test-controls" id="post-quiz-buttons" style="display: none;">
+                    <button class="btn btn-audio" onclick="openTestMenu()" style="font-size: 18px; padding: 10px 30px;">🔄 Начать сначала</button>
+                    <button class="btn btn-reset" onclick="closeTest()" style="font-size: 18px; padding: 10px 30px;">🚪 Выйти</button>
+                </div>
             </div>
-            <div id="test-result"></div>
         </div>
     </div>
 
     <script>
-        // --- ДАННЫЕ ДЛЯ ТЕСТА ---
-        const quizData = [
+        // --- БАЗА ИЗ 30 ВОПРОСОВ ---
+        const masterQuizData = [
             { q: "Что утверждает теорема Фурье?", opts: [{t:"Любое сложное колебание есть сумма простых гармонических.", c:true}, {t:"Энергия системы всегда постоянна.", c:false}, {t:"Частота обратно пропорциональна амплитуде.", c:false}] },
             { q: "Формула циклической частоты (w)?", opts: [{t:"w = 2πV", c:true}, {t:"w = V / T", c:false}, {t:"w = 2π / V", c:false}] },
-            { q: "Единицы измерения частоты (V)?", opts: [{t:"Герцы (Гц)", c:true}, {t:"Радианы (рад)", c:false}, {t:"Децибелы (дБ)", c:false}] },
+            { q: "В каких единицах измеряется частота (V)?", opts: [{t:"В Герцах (Гц)", c:true}, {t:"В Радианах (рад)", c:false}, {t:"В Децибелах (дБ)", c:false}] },
             { q: "Что показывает амплитудно-частотный спектр?", opts: [{t:"Зависимость амплитуды гармоник от их частоты.", c:true}, {t:"Изменение формы волны во времени.", c:false}, {t:"Скорость распространения звука.", c:false}] },
-            { q: "К чему приводит клиппинг?", opts: [{t:"К обрезке пиков и появлению паразитных гармоник.", c:true}, {t:"К сдвигу фазы на 180 градусов.", c:false}, {t:"К плавному затуханию сигнала.", c:false}] }
+            { q: "К чему визуально приводит нелинейное преобразование (клиппинг)?", opts: [{t:"К обрезке амплитудных пиков и появлению паразитных гармоник.", c:true}, {t:"К сдвигу фазы на 180 градусов.", c:false}, {t:"К плавному затуханию сигнала.", c:false}] },
+            { q: "Единица измерения периода колебаний (T)?", opts: [{t:"Секунды (с)", c:true}, {t:"Метры (м)", c:false}, {t:"Герцы (Гц)", c:false}] },
+            { q: "Как математически связаны период (T) и частота (V)?", opts: [{t:"Они обратно пропорциональны (V = 1/T)", c:true}, {t:"Они прямо пропорциональны", c:false}, {t:"Связь определяется логарифмом", c:false}] },
+            { q: "Какую частоту имеет нота 'Ля' первой октавы (стандарт)?", opts: [{t:"440 Гц", c:true}, {t:"220 Гц", c:false}, {t:"1000 Гц", c:false}] },
+            { q: "Что такое амплитуда колебания?", opts: [{t:"Максимальное отклонение от положения равновесия", c:true}, {t:"Число колебаний в секунду", c:false}, {t:"Скорость волны", c:false}] },
+            { q: "Что происходит с графиком волны при изменении фазы (θ)?", opts: [{t:"График сдвигается вдоль оси времени", c:true}, {t:"Изменяется высота пиков", c:false}, {t:"График сжимается по горизонтали", c:false}] },
+            { q: "Если период T = 0.1 с, то чему равна частота V?", opts: [{t:"10 Гц", c:true}, {t:"100 Гц", c:false}, {t:"1 Гц", c:false}] },
+            { q: "Как выглядит амплитудный спектр идеального синусоидального сигнала?", opts: [{t:"Один единственный пик на графике спектра", c:true}, {t:"Сплошная линия (белый шум)", c:false}, {t:"Множество убывающих пиков", c:false}] },
+            { q: "Какие гармоники появляются при симметричном ограничении (клиппинге)?", opts: [{t:"Преимущественно нечетные (3, 5, 7...)", c:true}, {t:"Только четные", c:false}, {t:"Никакие", c:false}] },
+            { q: "Что означает 'w' в уравнении y = A cos(wt)?", opts: [{t:"Скорость изменения фазы (циклическая частота)", c:true}, {t:"Длину волны", c:false}, {t:"Мощность сигнала", c:false}] },
+            { q: "Что мы услышим при сложении волн 440 Гц и 442 Гц?", opts: [{t:"Биения (пульсацию громкости)", c:true}, {t:"Белый шум", c:false}, {t:"Чистый аккорд", c:false}] },
+            { q: "Какой формы станет синусоида при экстремально сильном клиппинге?", opts: [{t:"Почти прямоугольной (меандр)", c:true}, {t:"Треугольной", c:false}, {t:"Пилообразной", c:false}] },
+            { q: "Влияет ли фаза (θ) одной гармоники на восприятие высоты ее тона ухом?", opts: [{t:"Нет, ухо не чувствительно к абсолютной фазе", c:true}, {t:"Да, тон становится выше", c:false}, {t:"Да, тон становится ниже", c:false}] },
+            { q: "Если частота звука увеличивается в 2 раза, то на слух это звучит как:", opts: [{t:"Повышение на одну октаву", c:true}, {t:"Увеличение громкости в 2 раза", c:false}, {t:"Появление эха", c:false}] },
+            { q: "Какой сигнал содержит только нечетные гармоники с амплитудами 1/n?", opts: [{t:"Прямоугольный (меандр)", c:true}, {t:"Пилообразный", c:false}, {t:"Треугольный", c:false}] },
+            { q: "Согласно теореме Котельникова, какой должна быть частота дискретизации для сигнала 20 кГц?", opts: [{t:"Не менее 40 кГц (удвоенная)", c:true}, {t:"Не менее 10 кГц", c:false}, {t:"Точно 20 кГц", c:false}] },
+            { q: "От чего зависит полная энергия гармонического осциллятора?", opts: [{t:"Пропорциональна квадрату амплитуды", c:true}, {t:"Обратно пропорциональна частоте", c:false}, {t:"Пропорциональна корню амплитуды", c:false}] },
+            { q: "Если на спектре есть пики на 100, 200 и 300 Гц, какова основная (фундаментальная) частота?", opts: [{t:"100 Гц", c:true}, {t:"300 Гц", c:false}, {t:"200 Гц", c:false}] },
+            { q: "Чем отличается спектр шума от спектра гармонического сигнала?", opts: [{t:"У шума сплошной спектр, у гармонического - линейчатый", c:true}, {t:"У шума спектр линейный, у гармонического - сплошной", c:false}, {t:"Разницы нет", c:false}] },
+            { q: "Как изменится циклическая частота (w), если период уменьшить в 4 раза?", opts: [{t:"Увеличится в 4 раза", c:true}, {t:"Уменьшится в 4 раза", c:false}, {t:"Останется прежней", c:false}] },
+            { q: "Что такое резонанс?", opts: [{t:"Резкое возрастание амплитуды при совпадении частот", c:true}, {t:"Затухание волны в среде", c:false}, {t:"Отражение волны от препятствия", c:false}] },
+            { q: "В уравнении колебаний аргумент косинуса (wt + θ) называется:", opts: [{t:"Фазой колебания", c:true}, {t:"Спектром колебания", c:false}, {t:"Декрементом", c:false}] },
+            { q: "Влияет ли нелинейное искажение на тембр звука?", opts: [{t:"Да, так как меняется спектр (добавляются обертоны)", c:true}, {t:"Нет, меняется только громкость", c:false}, {t:"Нет, меняется только основная частота", c:false}] },
+            { q: "Сколько гармоник необходимо для идеального воссоздания прямоугольного импульса?", opts: [{t:"Бесконечно много", c:true}, {t:"Ровно три", c:false}, {t:"Десять", c:false}] },
+            { q: "Почему столбцы спектра при клиппинге в приложении рисуются красным?", opts: [{t:"Потому что это паразитные (искажающие) частоты", c:true}, {t:"Это ошибка рендера Canvas", c:false}, {t:"Это основные тона", c:false}] },
+            { q: "При сложении двух волн в противофазе (сдвиг 180°) с одинаковыми амплитудами:", opts: [{t:"Волны полностью гасят друг друга (сумма равна 0)", c:true}, {t:"Амплитуда удваивается", c:false}, {t:"Частота удваивается", c:false}] }
         ];
 
         let uiAudioCtx = null, audioCtx = null, oscillators = [];
@@ -257,13 +303,30 @@
         let currentWave = 0, freqStep = 100, time = 0, isClipped = false, isAudioOn = false;
         let animationFrameId = null;
 
+        // --- Умный Resize Observer для идеальной сетки (всегда вписывается в контейнер) ---
         const resizeObserver = new ResizeObserver(entries => {
             for (let entry of entries) {
                 const canvas = entry.target.querySelector('canvas');
-                if (canvas) { canvas.width = entry.target.clientWidth; canvas.height = entry.target.clientHeight; }
+                if (canvas) {
+                    canvas.width = entry.contentRect.width;
+                    canvas.height = entry.contentRect.height;
+                }
             }
         });
 
+        // --- ЛОГИКА ПОЛНОЭКРАННОГО РЕЖИМА И КНОПКИ ---
+        function toggleFullscreen() {
+            if (!document.fullscreenElement) { document.documentElement.requestFullscreen().catch(err=>{}); }
+            else { if (document.exitFullscreen) document.exitFullscreen(); }
+        }
+        
+        document.addEventListener('fullscreenchange', () => {
+            const btn = document.getElementById('btnFullscreen');
+            if (document.fullscreenElement) { btn.innerHTML = '✖ Выйти из полноэкранного'; } 
+            else { btn.innerHTML = '🔲 На весь экран'; }
+            playUISound('action');
+        });
+
         function startApp() {
             document.getElementById('welcome-screen').style.opacity = '0';
             setTimeout(() => {
@@ -276,155 +339,120 @@
             }, 500);
         }
 
-        // --- ЛОГИКА ТЕСТА С АНИМАЦИЯМИ И ЗВУКАМИ ---
+        function toggleSidebar() {
+            const sidebar = document.getElementById('sidebar'); const overlay = document.getElementById('sidebar-overlay');
+            if (sidebar.classList.contains('open')) { sidebar.classList.remove('open'); overlay.style.display = 'none'; playUISound('click'); } 
+            else { sidebar.classList.add('open'); overlay.style.display = 'block'; playUISound('action'); }
+        }
+
+        // --- ЛОГИКА ТЕСТА ---
         function shuffle(array) { return array.sort(() => Math.random() - 0.5); }
-        
-        function openTest() {
+        function openTestMenu() {
             document.getElementById('test-overlay').style.display = 'flex';
+            document.getElementById('test-start-menu').style.display = 'block';
+            document.getElementById('quiz-process').style.display = 'none';
+            playUISound('click');
+        }
+
+        function startQuiz(numQuestions) {
+            document.getElementById('test-start-menu').style.display = 'none';
+            document.getElementById('quiz-process').style.display = 'block';
             document.getElementById('test-result').style.opacity = '0';
-            document.getElementById('checkBtn').style.display = 'inline-block';
-            document.getElementById('restartTestBtn').style.display = 'none'; // Скрываем кнопку рестарта
-            
-            const container = document.getElementById('quiz-container');
-            container.innerHTML = '';
+            document.getElementById('quiz-buttons').style.display = 'flex';
+            document.getElementById('post-quiz-buttons').style.display = 'none';
             
-            let shuffledQuestions = shuffle([...quizData]);
+            const container = document.getElementById('quiz-container'); container.innerHTML = '';
+            let shuffledQuestions = shuffle([...masterQuizData]).slice(0, numQuestions);
             shuffledQuestions.forEach((item, qIndex) => {
                 let qDiv = document.createElement('div'); qDiv.className = 'question';
                 qDiv.innerHTML = `<p>${qIndex + 1}. ${item.q}</p>`;
-                
                 let shuffledOpts = shuffle([...item.opts]);
-                shuffledOpts.forEach((opt, oIndex) => {
+                shuffledOpts.forEach((opt) => {
                     let lbl = document.createElement('label'); lbl.className = 'quiz-option';
                     lbl.innerHTML = `<input type="radio" name="q${qIndex}" value="${opt.c ? '1' : '0'}" onclick="playUISound('click')"> ${opt.t}`;
                     qDiv.appendChild(lbl);
                 });
                 container.appendChild(qDiv);
             });
-            playUISound('click');
+            playUISound('action');
         }
 
         function closeTest() { document.getElementById('test-overlay').style.display = 'none'; playUISound('click'); }
         
         async function checkTest() {
-            document.getElementById('checkBtn').style.display = 'none';
-            let score = 0;
-            const questions = document.querySelectorAll('.question');
+            document.getElementById('quiz-buttons').style.display = 'none';
+            let score = 0; const questions = document.querySelectorAll('.question'); let total = questions.length;
             
-            // Проверяем вопросы по очереди с задержкой и индивидуальным звуком
             for (let q of questions) {
-                let selected = q.querySelector('input:checked');
-                let lbl = selected ? selected.parentElement : null;
-                
+                let selected = q.querySelector('input:checked'); let lbl = selected ? selected.parentElement : null;
                 if (selected && selected.value === '1') {
-                    score++;
-                    if(lbl) lbl.classList.add('correct');
-                    playQuizSound('ding');
+                    score++; if(lbl) lbl.classList.add('correct'); playQuizSound('ding');
                 } else {
                     if(lbl) lbl.classList.add('wrong');
                     let correctInput = q.querySelector('input[value="1"]');
                     if(correctInput) correctInput.parentElement.classList.add('correct');
                     playQuizSound('buzz');
                 }
-                await new Promise(r => setTimeout(r, 400));
+                await new Promise(r => setTimeout(r, 200)); // Ускорено для 30 вопросов
             }
             
-            // Итоговый вывод
+            let percent = Math.round((score / total) * 100);
             let resDiv = document.getElementById('test-result');
-            resDiv.innerHTML = `Правильных ответов: ${score} из 5<br>`;
+            resDiv.innerHTML = `Правильных ответов: ${score} из ${total} (${percent}%)<br><br>`;
             
-            if(score === 5) {
-                resDiv.style.color = "var(--accent)"; resDiv.innerHTML += "🎉 Великолепно! Ты настоящий мастер волн! 🎉";
-                playQuizSound('win');
-            } else if (score >= 3) {
-                resDiv.style.color = "#FF9800"; resDiv.innerHTML += "👍 Хороший результат! Так держать!";
-                playQuizSound('win');
-            } else {
-                resDiv.style.color = "#f44336"; resDiv.innerHTML += "😅 Упс! Стоит еще раз изучить конспект.";
-                playQuizSound('lose');
-            }
-            resDiv.style.opacity = '1';
-            document.getElementById('restartTestBtn').style.display = 'inline-block'; // Показываем кнопку "Начать сначала"
+            if(percent >= 90) { resDiv.style.color = "var(--accent)"; resDiv.innerHTML += "🎉 Великолепно! Вы настоящий гений физики! 🎉"; playQuizSound('win'); } 
+            else if (percent >= 60) { resDiv.style.color = "#FF9800"; resDiv.innerHTML += "👍 Хороший результат! Но есть куда расти."; playQuizSound('win'); } 
+            else { resDiv.style.color = "#f44336"; resDiv.innerHTML += "😅 Упс... Нужно серьезно повторить конспект."; playQuizSound('lose'); }
+            resDiv.style.opacity = '1'; document.getElementById('post-quiz-buttons').style.display = 'flex';
         }
 
-        // --- UI ЗВУКИ И ФОНЫ ---
-        function changePresetBg(val) { document.getElementById('bg-layer').style.backgroundImage = val; playUISound('action'); }
+        // --- ФОНЫ, ТЕМЫ И ЗВУКИ ---
+        function clearBackground() { document.getElementById('bg-layer').style.backgroundImage = 'none'; document.getElementById('bgUpload').value = ''; playUISound('error'); }
         function uploadBackground(event) {
             if (event.target.files[0]) {
                 const reader = new FileReader();
                 reader.onload = e => { document.getElementById('bg-layer').style.backgroundImage = `url('${e.target.result}')`; playUISound('action'); };
                 reader.readAsDataURL(event.target.files[0]);
             }
-            event.target.value = ''; 
+        }
+        function changeTheme(themeName) { document.documentElement.setAttribute('data-theme', themeName); playUISound('action'); }
+        function changeFilter(filterValue) { document.getElementById('bg-layer').style.filter = filterValue; playUISound('click'); }
+        
+        function downloadGraph(canvasId) {
+            const canvas = document.getElementById(canvasId); const link = document.createElement('a'); link.download = 'HarmoniX_Graph.png';
+            const tempCanvas = document.createElement('canvas'); tempCanvas.width = canvas.width; tempCanvas.height = canvas.height;
+            const tCtx = tempCanvas.getContext('2d'); tCtx.fillStyle = '#ffffff'; tCtx.fillRect(0,0, tempCanvas.width, tempCanvas.height); tCtx.drawImage(canvas, 0, 0);
+            link.href = tempCanvas.toDataURL(); link.click(); playUISound('action');
         }
 
         function playUISound(type) {
             if (!uiAudioCtx) return;
             const osc = uiAudioCtx.createOscillator(), gain = uiAudioCtx.createGain();
             osc.connect(gain); gain.connect(uiAudioCtx.destination); let now = uiAudioCtx.currentTime;
-            if (type === 'click' || type === 'hover') {
-                osc.type = 'sine'; osc.frequency.setValueAtTime(800, now);
-                gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.1);
-                osc.start(now); osc.stop(now + 0.1);
-            } else if (type === 'action') {
-                osc.type = 'triangle'; osc.frequency.setValueAtTime(400, now); osc.frequency.exponentialRampToValueAtTime(800, now + 0.15);
-                gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.01, now + 0.15);
-                osc.start(now); osc.stop(now + 0.15);
-            } else if (type === 'error') {
-                osc.type = 'sawtooth'; osc.frequency.setValueAtTime(150, now);
-                gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2);
-                osc.start(now); osc.stop(now + 0.2);
-            }
+            if (type === 'click' || type === 'hover') { osc.type = 'sine'; osc.frequency.setValueAtTime(800, now); gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.1); osc.start(now); osc.stop(now + 0.1); } 
+            else if (type === 'action') { osc.type = 'triangle'; osc.frequency.setValueAtTime(400, now); osc.frequency.exponentialRampToValueAtTime(800, now + 0.15); gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.01, now + 0.15); osc.start(now); osc.stop(now + 0.15); } 
+            else if (type === 'error') { osc.type = 'sawtooth'; osc.frequency.setValueAtTime(150, now); gain.gain.setValueAtTime(0.1, now); gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2); osc.start(now); osc.stop(now + 0.2); }
         }
-        
         function playQuizSound(type) {
             if (!uiAudioCtx) return;
             const osc = uiAudioCtx.createOscillator(), gain = uiAudioCtx.createGain();
             osc.connect(gain); gain.connect(uiAudioCtx.destination); let now = uiAudioCtx.currentTime;
-            
-            if (type === 'ding') {
-                osc.type = 'sine'; osc.frequency.setValueAtTime(600, now); osc.frequency.setValueAtTime(900, now + 0.1);
-                gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3);
-                osc.start(now); osc.stop(now + 0.3);
-            } else if (type === 'buzz') {
-                osc.type = 'sawtooth'; osc.frequency.setValueAtTime(200, now); osc.frequency.setValueAtTime(150, now + 0.1);
-                gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3);
-                osc.start(now); osc.stop(now + 0.3);
-            } else if (type === 'win') {
-                osc.type = 'triangle';
-                [440, 554, 659, 880].forEach((f, i) => osc.frequency.setValueAtTime(f, now + i*0.1));
-                gain.gain.setValueAtTime(0.1, now); gain.gain.linearRampToValueAtTime(0, now + 0.5);
-                osc.start(now); osc.stop(now + 0.5);
-            } else if (type === 'lose') {
-                osc.type = 'sawtooth';
-                [300, 280, 260, 200].forEach((f, i) => osc.frequency.setValueAtTime(f, now + i*0.2));
-                gain.gain.setValueAtTime(0.1, now); gain.gain.linearRampToValueAtTime(0, now + 0.8);
-                osc.start(now); osc.stop(now + 0.8);
-            }
+            if (type === 'ding') { osc.type = 'sine'; osc.frequency.setValueAtTime(600, now); osc.frequency.setValueAtTime(900, now + 0.1); gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3); osc.start(now); osc.stop(now + 0.3); } 
+            else if (type === 'buzz') { osc.type = 'sawtooth'; osc.frequency.setValueAtTime(200, now); osc.frequency.setValueAtTime(150, now + 0.1); gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.3); osc.start(now); osc.stop(now + 0.3); } 
+            else if (type === 'win') { osc.type = 'triangle'; [440, 554, 659, 880].forEach((f, i) => osc.frequency.setValueAtTime(f, now + i*0.1)); gain.gain.setValueAtTime(0.1, now); gain.gain.linearRampToValueAtTime(0, now + 0.5); osc.start(now); osc.stop(now + 0.5); } 
+            else if (type === 'lose') { osc.type = 'sawtooth'; [300, 280, 260, 200].forEach((f, i) => osc.frequency.setValueAtTime(f, now + i*0.2)); gain.gain.setValueAtTime(0.1, now); gain.gain.linearRampToValueAtTime(0, now + 0.8); osc.start(now); osc.stop(now + 0.8); }
         }
-
         function playSliderSound(value, max, min = 0, type = 'high') {
             if (!uiAudioCtx) return;
             const osc = uiAudioCtx.createOscillator(), gain = uiAudioCtx.createGain();
             osc.connect(gain); gain.connect(uiAudioCtx.destination);
             let freq = type === 'high' ? 300 + ((value - min) / (max - min)) * 1000 : 150 + ((value - min) / (max - min)) * 300;
             osc.type = 'sine'; let now = uiAudioCtx.currentTime;
-            osc.frequency.setValueAtTime(freq, now);
-            gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.05);
+            osc.frequency.setValueAtTime(freq, now); gain.gain.setValueAtTime(0.05, now); gain.gain.exponentialRampToValueAtTime(0.001, now + 0.05);
             osc.start(now); osc.stop(now + 0.05);
         }
 
-        function changeTheme(themeName) { document.documentElement.setAttribute('data-theme', themeName); playUISound('action'); }
-        function changeFilter(filterValue) { document.getElementById('bg-layer').style.filter = filterValue; playUISound('click'); }
-        function toggleFullscreen() { if (!document.fullscreenElement) document.documentElement.requestFullscreen(); else if (document.exitFullscreen) document.exitFullscreen(); }
-        
-        function downloadGraph(canvasId) {
-            const canvas = document.getElementById(canvasId); const link = document.createElement('a'); link.download = 'HarmoniX_Graph.png';
-            const tempCanvas = document.createElement('canvas'); tempCanvas.width = canvas.width; tempCanvas.height = canvas.height;
-            const tCtx = tempCanvas.getContext('2d'); tCtx.fillStyle = '#ffffff'; tCtx.fillRect(0,0, tempCanvas.width, tempCanvas.height); tCtx.drawImage(canvas, 0, 0);
-            link.href = tempCanvas.toDataURL(); link.click(); playUISound('action');
-        }
-
+        // --- УПРАВЛЕНИЕ ВОЛНАМИ ---
         function switchTab(index) {
             currentWave = index; document.querySelectorAll('.tab').forEach((el, i) => el.classList.toggle('active', i === index));
             document.getElementById('freq').value = waves[index].f; document.getElementById('amp').value = waves[index].a;
@@ -437,14 +465,13 @@
         function toggleClip() {
             isClipped = !isClipped; let btn = document.getElementById('btnClip');
             if (isClipped) { btn.classList.add('active'); btn.innerText = "⚡ Убрать искажение"; }
-            else { btn.classList.remove('active'); btn.innerText = "⚡ Нелин. преобр. (искаж.)"; }
+            else { btn.classList.remove('active'); btn.innerText = "⚡ Нелин. преобр. (Искажение)"; }
             updateAudio();
         }
 
         function resetAll() {
-            waves = [{ f: 440, a: 80 }, { f: 880, a: 0 }, { f: 1320, a: 0 }]; isClipped = false;
-            let btnClip = document.getElementById('btnClip'); btnClip.classList.remove('active'); btnClip.innerText = "⚡ Нелин. преобр. (искаж.)";
-            document.getElementById('bg-layer').style.backgroundImage = 'none';
+            waves = [{ f: 440, a: 80 }, { f: 880, a: 0 }, { f: 1320, a: 0 }]; isClipped = false; clearBackground();
+            let btnClip = document.getElementById('btnClip'); btnClip.classList.remove('active'); btnClip.innerText = "⚡ Нелин. преобр. (Искажение)";
             switchTab(0); updateAudio();
         }
 
@@ -516,7 +543,7 @@
             ctx3.fillText("10кГц", (10000 / 20000) * c3.width, c3.height - 2);
             ctx3.fillText("15кГц", (15000 / 20000) * c3.width, c3.height - 2);
 
-            ctx3.fillStyle = "#4CAF50"; // Возвращен зеленый цвет спектра
+            ctx3.fillStyle = "#4CAF50";
             for (let i = 0; i < 3; i++) {
                 if (waves[i].a > 0) {
                     let xPos = (waves[i].f / 20000) * c3.width; let h = (waves[i].a / 100) * (c3.height - 30);