@font-face {
  font-family: 'Fast Sans';
  src: url('../fonts/fast-font/Fast_Sans.ttf') format('truetype');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --app-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-bg: #ffffff;
  --text-main: #444;
  --text-strong: #333;
  --text-muted: #4c5669;

  --control-bg: rgba(255, 255, 255, 0.92);
  --control-bg-hover: rgba(255, 255, 255, 1);
  --control-icon: #777;
  --control-shadow: 0 3px 10px rgba(0, 0, 0, 0.10);

  --backdrop-bg: rgba(0, 0, 0, 0.12);
  --panel-bg: #f7f7f7;
  --panel-shadow: -4px 0 16px rgba(0, 0, 0, 0.18);
  --panel-divider: rgba(0, 0, 0, 0.06);

  --lang-btn-bg: #ffffff;
  --lang-btn-border: rgba(0, 0, 0, 0.08);
  --lang-btn-active-bg: #e6ecff;
  --lang-btn-active-border: #4a7bff;

  --slider-track: #ddd;
  --slider-thumb: #666;
  --hr-color: #e0e0e0;

  --switch-off-bg: #d7d7d7;
  --switch-on-bg: #4a7bff;
  --switch-thumb: #ffffff;

  --other-settings-bg: #f1f3f7;

  --quote-base: #38393b;
  --quote-fill-blue: #4f8dff;
  --quote-fill-violet: #8a59ff;
}

body.theme-dark {
  --page-bg: #10141d;
  --text-main: #d8dde8;
  --text-strong: #ecf1ff;
  --text-muted: #c4cde0;

  --control-bg: rgba(23, 30, 43, 0.88);
  --control-bg-hover: rgba(30, 39, 55, 0.96);
  --control-icon: #c8d4f4;
  --control-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);

  --backdrop-bg: rgba(0, 0, 0, 0.35);
  --panel-bg: #181f2c;
  --panel-shadow: -4px 0 16px rgba(0, 0, 0, 0.4);
  --panel-divider: rgba(255, 255, 255, 0.08);

  --lang-btn-bg: #1f2838;
  --lang-btn-border: rgba(255, 255, 255, 0.14);
  --lang-btn-active-bg: rgba(74, 123, 255, 0.2);
  --lang-btn-active-border: #82a3ff;

  --slider-track: #394862;
  --slider-thumb: #bfc9de;
  --hr-color: #2a3548;

  --switch-off-bg: #4c5d7a;
  --switch-on-bg: #82a3ff;
  --other-settings-bg: #242d3d;
  --quote-base: #d7deeb;
  --quote-fill-blue: #7ab0ff;
  --quote-fill-violet: #b38cff;
}

body.high-contrast {
  --text-main: #1c1c1c;
  --text-strong: #000000;
  --text-muted: #202020;
  --control-bg: #ffffff;
  --control-bg-hover: #ffffff;
  --control-icon: #000000;
  --panel-bg: #ffffff;
  --panel-divider: rgba(0, 0, 0, 0.26);
  --lang-btn-bg: #ffffff;
  --lang-btn-border: rgba(0, 0, 0, 0.45);
  --lang-btn-active-bg: #e6edff;
  --lang-btn-active-border: #1a43c4;
  --slider-track: #9f9f9f;
  --slider-thumb: #111111;
  --hr-color: rgba(0, 0, 0, 0.28);
  --switch-off-bg: #777777;
  --switch-on-bg: #1a43c4;
  --other-settings-bg: #f3f6ff;
  --quote-base: #111111;
  --quote-fill-blue: #0045d8;
  --quote-fill-violet: #3f1cb0;
}

body.theme-dark.high-contrast {
  --text-main: #f2f6ff;
  --text-strong: #ffffff;
  --text-muted: #f2f6ff;
  --control-bg: #0a0d13;
  --control-bg-hover: #111623;
  --control-icon: #ffffff;
  --panel-bg: #0a0d13;
  --panel-divider: rgba(255, 255, 255, 0.38);
  --lang-btn-bg: #0a0d13;
  --lang-btn-border: rgba(255, 255, 255, 0.5);
  --lang-btn-active-bg: #1a2f6f;
  --lang-btn-active-border: #8fb2ff;
  --slider-track: #7d8596;
  --slider-thumb: #ffffff;
  --hr-color: rgba(255, 255, 255, 0.35);
  --switch-off-bg: #7a7a7a;
  --switch-on-bg: #8fb2ff;
  --other-settings-bg: #16203a;
  --quote-base: #ffffff;
  --quote-fill-blue: #8fb2ff;
  --quote-fill-violet: #c3a6ff;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: var(--page-bg);
  font-family: var(--app-font-family);
  color: var(--text-strong);
}

body,
button,
input,
select,
textarea {
  font-family: var(--app-font-family);
}

body.bionic-font {
  --app-font-family: 'Fast Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  position: relative;
}

/* Текст над анимацией */
.breath-text {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(1200px, 90vw);
  --fill-softness: 8%;
  text-align: center;
  font-size: 24px;
  line-height: 1.5;
  --fill: 1%;
  color: var(--quote-base);
  background-image: linear-gradient(
    to right,
    var(--quote-fill-blue) 0,
    var(--quote-fill-violet) var(--fill),
    var(--quote-base) calc(var(--fill) + var(--fill-softness)),
    var(--quote-base) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 1;
  transition: opacity 1s ease;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  padding: 0;
  box-sizing: border-box;
  z-index: 5;
}

.lang-toggle:focus-visible,
.music-toggle:focus-visible,
.settings-toggle:focus-visible,
.settings-close:focus-visible,
.lang-button:focus-visible,
.other-settings summary:focus-visible,
.slider:focus-visible,
.tutorial-replay-button:focus-visible {
  outline: 3px solid var(--switch-on-bg);
  outline-offset: 3px;
}

.theme-switch:focus-within .theme-switch-slider {
  outline: 3px solid var(--switch-on-bg);
  outline-offset: 2px;
}

body.no-gradients .breath-text {
  background-image: none;
  -webkit-text-fill-color: currentColor;
}

canvas {
  display: block;
  touch-action: none;
}

/* Одинаковые кнопки (язык и настройки) */
.lang-toggle,
.music-toggle,
.settings-toggle {
  position: absolute;
  top: 20px;
  z-index: 20;

  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;

  background: var(--control-bg);
  box-shadow: var(--control-shadow);

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.lang-toggle:hover,
.music-toggle:hover,
.settings-toggle:hover {
  background: var(--control-bg-hover);
}

.lang-toggle:active,
.music-toggle:active,
.settings-toggle:active {
  transform: scale(0.94);
}

/* Светлые иконки */
.lang-toggle svg,
.music-toggle svg,
.settings-toggle svg {
  stroke: var(--control-icon);
  stroke-width: 1.6;
}

/* Позиции */
.settings-toggle {
  right: 20px;
}

.music-toggle {
  right: 92px;
}

.lang-toggle {
  right: 164px;
}

.keyboard-hint {
  position: absolute;
  top: 92px;
  right: 20px;
  z-index: 19;
  width: min(320px, 42vw);
  background: var(--control-bg);
  color: var(--text-strong);
  border: 1px solid var(--panel-divider);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--control-shadow);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 1.35s ease, transform 1.35s ease;
  pointer-events: none;
}

.keyboard-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.keyboard-hint.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.keyboard-hint p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.music-icon-on {
  display: none;
}

.music-toggle.is-on .music-icon-off {
  display: none;
}

.music-toggle.is-on .music-icon-on {
  display: block;
}

/* Бекдроп под шторками */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

.settings-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Шторки справа */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 80vw);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--panel-divider);
}

.settings-header h2 {
  font-size: 18px;
  margin: 0;
  color: var(--text-strong);
}

.settings-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  color: var(--text-main);
}

.settings-content {
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
}

/* Языковой список */
.lang-hint {
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lang-list li {
  margin-bottom: 8px;
}

.lang-button {
  width: 100%;
  text-align: left;
  border-radius: 999px;
  border: 1px solid var(--lang-btn-border);
  background: var(--lang-btn-bg);
  color: var(--text-main);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;

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

.lang-button span.code {
  font-size: 12px;
  opacity: 0.92;
}

.lang-button.active {
  border-color: var(--lang-btn-active-border);
  background: var(--lang-btn-active-bg);
  font-weight: 600;
}

/* Заголовок */
.settings-content h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
}

/* Ползунок */
.slider-label {
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-strong);
}

#speedValue {
  font-weight: 600;
}

.slider {
  width: 100%;
  margin-bottom: 10px;
  appearance: none;
  height: 6px;
  border-radius: 4px;
  background: var(--slider-track);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--slider-thumb);
  cursor: pointer;
}

.slider-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 20px;
  line-height: 1.4;
}

.settings-content hr {
  border: 0;
  height: 1px;
  background: var(--hr-color);
  margin: 20px 0;
}

.other-settings {
  border: 1px solid var(--panel-divider);
  border-radius: 12px;
  background: var(--other-settings-bg);
  padding: 0 12px 8px;
  margin-bottom: 10px;
}

.other-settings summary {
  list-style: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  padding: 12px 0;
}

.other-settings summary::-webkit-details-marker {
  display: none;
}

.other-settings summary::after {
  content: '▾';
  float: right;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.other-settings[open] summary::after {
  transform: rotate(180deg);
}

.other-settings-content {
  padding-bottom: 4px;
}

.other-settings-content h3 {
  margin-top: 8px;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 2px;
  margin-bottom: 8px;
  color: var(--text-strong);
  font-size: 14px;
}

.tutorial-replay-button {
  border: 1px solid var(--lang-btn-border);
  background: var(--lang-btn-bg);
  color: var(--text-main);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.tutorial-replay-button:hover {
  background: var(--lang-btn-active-bg);
  border-color: var(--lang-btn-active-border);
}

.theme-switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-block;
}

.theme-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.theme-switch-slider {
  position: absolute;
  inset: 0;
  background: var(--switch-off-bg);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.theme-switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: var(--switch-thumb);
  transition: transform 0.2s ease;
}

.theme-switch input:checked + .theme-switch-slider {
  background: var(--switch-on-bg);
}

.theme-switch input:checked + .theme-switch-slider::before {
  transform: translateX(20px);
}

.theme-switch input:focus-visible + .theme-switch-slider {
  outline: 2px solid var(--switch-on-bg);
  outline-offset: 2px;
}

/* Нижний блок */
.description {
  margin-top: 100vh;
  padding: 40px 16px 80px;
  max-width: 700px;
  box-sizing: border-box;
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.6;
}

.description h1 {
  font-size: 28px;
  margin-bottom: 16px;
}

.description p {
  margin: 0 0 12px;
}

.app-footer {
  margin: 0;
  padding: 10px 16px 22px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  opacity: 0.82;
}

.app-footer a {
  color: inherit;
  text-decoration-color: currentColor;
}

.app-footer a:hover,
.app-footer a:focus-visible {
  opacity: 1;
}

body.large-text .settings-header h2 {
  font-size: 20px;
}

body.large-text .settings-content {
  font-size: 16px;
  line-height: 1.6;
}

body.large-text .settings-content h3 {
  font-size: 18px;
}

body.large-text .slider-label,
body.large-text .lang-button {
  font-size: 16px;
}

body.large-text .tutorial-replay-button {
  font-size: 14px;
}

body.large-text .slider-hint,
body.large-text .lang-hint,
body.large-text .lang-button span.code {
  font-size: 14px;
}

body.large-text .breath-text {
  font-size: clamp(22px, 2.7vw, 30px);
  width: min(1200px, 92vw);
  line-height: 1.55;
}

body.large-text .description {
  font-size: 18px;
  line-height: 1.7;
}

body.large-text .description h1 {
  font-size: 32px;
  line-height: 1.25;
}

/* Адаптивность */
@media (max-width: 480px) {
  .breath-text {
    font-size: 20px;
    width: 90vw;
    bottom: 20px;
  }

  .lang-toggle,
  .music-toggle,
  .settings-toggle {
    width: 52px;
    height: 52px;
    top: 16px;
  }

  .settings-toggle {
    right: 16px;
  }

  .music-toggle {
    right: 84px;
  }

  .lang-toggle {
    right: 152px;
  }

  .keyboard-hint {
    top: 80px;
    right: 16px;
    width: min(250px, 44vw);
    padding: 9px 10px;
  }

  .keyboard-hint p {
    font-size: 12px;
  }

  .description {
    padding: 32px 16px 64px;
  }

  .app-footer {
    font-size: 11px;
  }

  body.large-text .settings-panel {
    width: min(360px, 92vw);
  }

  body.large-text .breath-text {
    font-size: clamp(20px, 5vw, 24px);
    width: 92vw;
    bottom: 18px;
  }

  body.large-text .description {
    font-size: 17px;
  }

  body.large-text .description h1 {
    font-size: 30px;
  }
}
