/* ECHO dual — чёрно-белая минималистичная аркада.
   Только два цвета и альфа-градиенты для свечения: никаких серых заливок.
   Шрифт моноширинный, из системных — внешних запросов нет. */

@font-face {
  font-family: "Pulse Mono";
  src: local("JetBrains Mono"), local("IBM Plex Mono"), local("Cascadia Mono"), local("Consolas");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #ffffff;
  --void: #000000;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --pad: clamp(16px, 4vw, 32px);
  --mono: "Pulse Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  /* Свечение текста имитирует люминофор: тот же приём, что у кольцевых линий. */
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* --------------------------------------------------------------- сцена */

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
}

.stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Прозрачный слой, принимающий нажатия по всему полю. */
.stage__tap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ----------------------------------------------------------------- HUD */

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  padding: max(8px, env(safe-area-inset-top, 0px)) var(--pad) 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 2;
}

.hud__stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  min-height: 0;
}

.hud__stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__label {
  opacity: 0.55;
  font-size: 10px;
  letter-spacing: 0.18em;
}

.hud__value {
  font-size: clamp(14px, 3.2vw, 18px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

/* Полоса энергии: сразу под строкой счёта. */
.hud__energy {
  height: 4px;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.hud__energy-fill {
  height: 100%;
  width: 100%;
  background: var(--ink);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  transition: width 90ms linear, background-color 180ms ease, box-shadow 180ms ease;
}

/* Ниже 30%: красный остаток + лёгкий миг. */
.hud__energy-fill--low {
  background: #ff3b3b;
  box-shadow: 0 0 10px rgba(255, 59, 59, 0.75);
  animation: pulse-low 640ms ease-in-out infinite;
}

@keyframes pulse-low {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.hud__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.hud__mode {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  opacity: 0.6;
}

/* Кнопка паузы кликабельна: у всего HUD pointer-events: none. */
.hud__pause {
  appearance: none;
  pointer-events: auto;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.55);
  color: inherit;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  cursor: pointer;
}

.hud__pause:hover,
.hud__pause:focus-visible {
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

/* -------------------------------------------------------------- панели */

.panel {
  position: relative;
  z-index: 3;
  width: min(92vw, 460px);
  max-height: 92vh;
  overflow-y: auto;
  padding: var(--pad);
  text-align: center;
  /* Полупрозрачный чёрный оверлей поверх поля: кольца видны сквозь меню. */
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 60px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
}

.panel[hidden] { display: none; }

.panel--menu,
.panel--over,
.panel--pause,
.panel--scores,
.panel--rules {
  animation: panel-in 240ms var(--ease) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel__title {
  margin: 0 0 6px;
  font-size: clamp(16px, 4vw, 20px);
  letter-spacing: 0.24em;
  font-weight: 400;
}

.logo {
  margin: 0;
  font-size: clamp(34px, 11vw, 58px);
  letter-spacing: 0.16em;
  font-weight: 400;
  animation: breathe 4s var(--ease) infinite;
}

.logo__sub {
  font-size: 0.42em;
  letter-spacing: 0.2em;
  opacity: 0.75;
  vertical-align: middle;
}

.logo__tick {
  animation: blink 1.1s steps(2, end) infinite;
}

.menu-layout {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-buttons--row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

.menu-buttons--row .btn {
  flex: 1 1 auto;
  min-width: 7.5rem;
}

@keyframes breathe {
  0%, 100% { text-shadow: 0 0 16px rgba(255, 255, 255, 0.3); }
  50% { text-shadow: 0 0 34px rgba(255, 255, 255, 0.75); }
}

@keyframes blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.15; }
}

.tagline {
  margin: 6px 0 18px;
  opacity: 0.6;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.rules {
  text-align: left;
  margin: 0 auto 20px;
  font-size: 12px;
  opacity: 0.85;
}

.rules p { margin: 4px 0; }
.rules b { font-weight: 400; border-bottom: 1px solid rgba(255, 255, 255, 0.6); }

/* ------------------------------------------------------------- кнопки */

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 16px;
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.2em;
  padding: 13px 18px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  transition: background-color 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease);
}

/* Ховер — инверсия: белая плашка с чёрным текстом. */
.btn:hover,
.btn:focus-visible {
  background: var(--ink);
  color: var(--void);
  text-shadow: none;
  box-shadow: 0 0 26px rgba(255, 255, 255, 0.4);
  outline: none;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--ink);
  color: var(--void);
  text-shadow: none;
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: transparent;
  color: var(--ink);
  text-shadow: inherit;
}

.btn--ghost {
  border-color: rgba(255, 255, 255, 0.4);
  opacity: 0.85;
}

/* --------------------------------------------------------- настройки */

.settings {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0 10px;
}

.field__label {
  font-size: 10px;
  letter-spacing: 0.2em;
  opacity: 0.6;
}

.field__input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 11px 0;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
}

.field__input::placeholder { color: rgba(255, 255, 255, 0.3); }

.toggle {
  appearance: none;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.16em;
  padding: 0 12px;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--void);
  text-shadow: none;
}

.records {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.8;
}

.hint {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0.45;
}

/* ------------------------------------------------------- результат */

.result {
  margin: 14px 0;
  display: grid;
  gap: 6px;
}

.result__row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.25);
  padding-bottom: 5px;
}

.result__label {
  font-size: 11px;
  letter-spacing: 0.2em;
  opacity: 0.6;
}

.result__value {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.grid {
  margin: 14px 0;
  font-size: clamp(18px, 5.5vw, 26px);
  letter-spacing: 0.12em;
  white-space: pre-wrap;
  word-break: break-all;
  text-shadow: none;
}

.record-badge {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.26em;
  animation: blink 1s steps(2, end) infinite;
}

/* ------------------------------------------------------------ рекорды */

.scores {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  text-align: left;
}

.scores li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.2);
  font-size: 13px;
}

.scores__place { opacity: 0.5; }
.scores__score { font-variant-numeric: tabular-nums; }

.scores__empty {
  margin: 12px 0;
  font-size: 12px;
  opacity: 0.5;
}

/* ---------------------------------------------------- стартовая подсказка */

.tap-hint {
  position: absolute;
  bottom: clamp(24px, 8vh, 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.24em;
  opacity: 0.75;
  pointer-events: none;
  animation: breathe 2.4s var(--ease) infinite;
}

.tap-hint[hidden] { display: none; }

.tap-hint__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.8);
}

/* --------------------------------------------------------------- тост */

.toast {
  position: absolute;
  bottom: clamp(18px, 5vh, 40px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 9px 16px;
  font-size: 11px;
  letter-spacing: 0.18em;
  background: var(--ink);
  color: var(--void);
  text-shadow: none;
  animation: panel-in 200ms var(--ease) both;
}

.toast[hidden] { display: none; }

/* -------------------------------------------------------- вход на сайт */

.site-gate {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: var(--void);
}

.site-gate[hidden] { display: none; }

.site-gate__frame {
  width: min(92vw, 320px);
  padding: 28px 24px 24px;
  border: 1px solid var(--ink);
  background: var(--void);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.08);
}

.site-gate__title {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: 0.28em;
}

.site-gate__label {
  font-size: 10px;
  letter-spacing: 0.22em;
  opacity: 0.55;
}

.site-gate__input {
  appearance: none;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  outline: none;
}

.site-gate__input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
}

.site-gate__error {
  margin: 0;
  min-height: 1.2em;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #ff3b3b;
}

.site-gate__error[hidden] { display: none; }

.site-gate__submit {
  margin-top: 4px;
}

/* ----------------------------------------------- ориентация: ландшафт */

.rotate-gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--pad);
  background: rgba(0, 0, 0, 0.92);
  pointer-events: auto;
}

.rotate-gate[hidden] { display: none; }

.rotate-gate__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  max-width: 280px;
}

.rotate-gate__phone {
  width: 26px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.35);
  animation: rotate-hint 1.6s var(--ease) infinite;
}

.rotate-gate__phone::after {
  content: "";
  display: block;
  width: 8px;
  height: 2px;
  margin: 5px auto 0;
  background: var(--ink);
  opacity: 0.7;
}

.rotate-gate__title {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.28em;
}

.rotate-gate__text {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.65;
  line-height: 1.5;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(90deg); }
  70% { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-gate__phone { animation: none; transform: rotate(90deg); }
}

/* ---------------------------------------------------------- доступность */

/* Отключаем пульсации и переходы, когда пользователь просит меньше движения. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 420px) {
  .hud__label { font-size: 9px; }
  .rules { font-size: 11px; }
}

/* ------------------------------------ компактный UI в ландшафте */

@media (orientation: landscape) and (max-height: 520px) {
  .panel {
    width: min(94vw, 740px);
    max-height: 92vh;
    padding: 10px 16px;
  }

  .panel--menu .menu-layout {
    display: grid;
    grid-template-columns: minmax(140px, 0.9fr) minmax(200px, 1.2fr);
    gap: 8px 20px;
    align-items: center;
    text-align: left;
  }

  .panel--menu .menu-brand {
    text-align: left;
  }

  .panel--menu .logo {
    font-size: clamp(26px, 9vh, 40px);
    letter-spacing: 0.12em;
  }

  .panel--menu .tagline {
    margin: 4px 0 0;
    font-size: 10px;
  }

  .panel--menu .menu-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
  }

  .panel--menu .menu-buttons .btn--primary {
    grid-column: 1 / -1;
  }

  .btn {
    padding: 8px 12px;
    font-size: 11px;
  }

  .settings {
    margin-bottom: 6px;
    gap: 6px;
  }

  .field__input {
    padding: 7px 0;
    font-size: 12px;
  }

  .toggle {
    font-size: 10px;
    padding: 0 8px;
  }

  .records {
    font-size: 10px;
    margin: 0;
  }

  .hint {
    font-size: 9px;
    margin-top: 2px;
  }

  .panel__title {
    margin-bottom: 4px;
    font-size: 14px;
  }

  .panel--pause .tagline {
    margin: 2px 0 10px;
    font-size: 11px;
  }

  .panel--pause .menu-buttons,
  .panel--over .menu-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
  }

  .result {
    margin: 6px 0;
    grid-template-columns: 1fr 1fr;
    gap: 2px 16px;
  }

  .result__value {
    font-size: 16px;
  }

  .grid {
    margin: 4px 0;
    font-size: 11px;
  }

  .record-badge {
    margin: 4px 0;
    font-size: 10px;
  }

  .panel--rules .rules {
    margin-bottom: 10px;
    font-size: 11px;
    columns: 2;
    column-gap: 16px;
  }

  .panel--rules .rules p {
    break-inside: avoid;
  }

  .scores {
    max-height: 42vh;
    overflow: auto;
    margin: 6px 0;
  }
}

/* На широких экранах панель центрируется, поле остаётся круглым. */
@media (min-width: 900px) {
  .panel { width: min(60vw, 460px); }
}

@media (orientation: landscape) and (max-height: 520px) and (min-width: 900px) {
  .panel { width: min(70vw, 740px); }
}