/* ═══════════════════════════════════════════════════════════
   ГЕНЗАЩИТА · ДИЗАЙН-СИСТЕМА (кибер / AI dark)
═══════════════════════════════════════════════════════════ */
:root {
  --bg:       #07070f;
  --surface:  #0d0d1f;
  --surface2: #13132b;
  --text:     #e2e2f0;
  --muted:    #6b6b8f;

  --cyan:  #00e5ff;
  --red:   #ff3d71;
  --gold:  #ffc300;
  --green: #00e096;

  --border: rgba(0, 229, 255, 0.2);
  --radius: 16px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html { height: -webkit-fill-available; }

body {
  font-family: "Outfit", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  line-height: 1.55;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  position: relative;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* фоновая сетка */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* мягкое свечение */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60% 45% at 50% -5%, rgba(0, 229, 255, 0.10), transparent 70%),
    radial-gradient(45% 40% at 100% 100%, rgba(255, 61, 113, 0.06), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* ── Утилиты цвета ── */
.text-cyan  { color: var(--cyan); }
.text-red   { color: var(--red); }
.text-gold  { color: var(--gold); }
.text-green { color: var(--green); }
.hidden     { visibility: hidden; }

/* ═══════════════ HEADER ═══════════════ */
.header {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 12px auto 0;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13, 13, 31, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header__logo {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header__logo span { color: var(--cyan); }
.header__logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 0 7px rgba(0, 229, 255, 0.35));
  /* защита: не выделяется, не перетаскивается, не цель правого клика */
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}
.header__logo-text { cursor: pointer; }
.header__action { padding: 0 18px; min-height: 40px; }

/* кнопка «Назад» — появляется только во время игры */
.header__back {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 20px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  touch-action: manipulation;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
@media (hover: hover) {
  .header__back:hover { border-color: var(--cyan); background: rgba(0, 229, 255, 0.14); transform: translateY(-1px); }
}
.header__back:active { transform: scale(0.96); }

/* ═══════════════ КНОПКИ ═══════════════ */
.button {
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  font-size: 16px;
  min-height: 48px;
  padding: 0 28px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  -webkit-appearance: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button--primary {
  color: #07070f;
  background: var(--cyan);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.22);
}
.button--ghost {
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border);
}

@media (hover: hover) {
  .button--primary:hover { transform: translateY(-2px); box-shadow: 0 0 34px rgba(0, 229, 255, 0.4); }
  .button--ghost:hover   { transform: translateY(-2px); border-color: var(--cyan); background: rgba(0, 229, 255, 0.14); }
}
.button:active { transform: scale(0.97); }

/* ═══════════════ КАРТОЧКИ ═══════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.08);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card__label {
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ═══════════════ ЭКРАНЫ ═══════════════ */
.screen { display: none; animation: fadeIn 0.35s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════ HERO ═══════════════ */
.hero {
  text-align: center;
  padding: 32px 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.tag {
  font-family: "Outfit", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan);
  border: 1px solid var(--border);
  background: rgba(0, 229, 255, 0.06);
  padding: 6px 16px;
  border-radius: 999px;
}

.hero__title {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 9vw, 84px);
  line-height: 0.95;
  letter-spacing: -0.05em;
  background: linear-gradient(180deg, #ffffff, #9ddfff 60%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__desc {
  font-size: clamp(15px, 3.5vw, 18px);
  color: var(--muted);
  max-width: 460px;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

/* ═══════════════ LAYOUT (start screen) ═══════════════ */
.layout { display: grid; gap: 18px; }
.stack  { display: grid; gap: 18px; }

@media (min-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .summary-panel { position: sticky; top: 96px; }
}

/* ── Steps / Tips ── */
.steps { display: flex; flex-direction: column; gap: 16px; }
.step  { display: flex; align-items: flex-start; gap: 12px; }
.step__icon { font-size: 22px; line-height: 1; flex-shrink: 0; width: 30px; text-align: center; }
.step__text { font-size: 14px; color: var(--muted); }
.step__text strong { color: var(--text); font-weight: 600; }

.tips { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.tips li {
  font-size: 14px;
  color: var(--muted);
  padding-left: 22px;
  position: relative;
}
.tips li::before { content: "→"; position: absolute; left: 0; color: var(--cyan); font-weight: 700; }

/* ── Metrics (summary) ── */
.metric { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.metric:last-child { border-bottom: none; }
.metric__value { font-family: "Bebas Neue", sans-serif; font-size: 38px; line-height: 1; letter-spacing: 1px; }
.metric__label { font-size: 12px; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════
   GAME-SPECIFIC · ЗРИТЕЛЬНАЯ ПАМЯТЬ
═══════════════════════════════════════════════════════════ */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 600px;
  margin: 12px auto 0;
}

.game__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
}
.game__stat { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; }
.game__stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.game__stat-value { font-family: "Bebas Neue", sans-serif; font-size: 30px; line-height: 1; color: var(--text); }

.phase-badge {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 3.5vw, 17px);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--cyan);
  color: #07070f;
  letter-spacing: 0.3px;
  white-space: nowrap;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}
.phase-badge.recall {
  background: var(--gold);
  color: #07070f;
  box-shadow: 0 0 20px rgba(255, 195, 0, 0.35);
}

/* прогресс-бар обратного отсчёта */
.countdown {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.countdown__fill {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

/* сетка */
#grid-wrap { width: 100%; display: flex; justify-content: center; padding: 4px 0; }
#grid { display: grid; gap: 8px; }

.cell {
  background: var(--surface2);
  border: 1px solid rgba(0, 229, 255, 0.1);
  border-radius: 10px;
  cursor: default;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  aspect-ratio: 1;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.cell.active {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.35);
  transform: scale(1.0);
}
.cell.selected {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 195, 0, 0.5);
  transform: scale(0.96);
}
.cell.correct {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0, 224, 150, 0.5);
}
.cell.wrong {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 16px rgba(255, 61, 113, 0.55);
  animation: shake 0.4s ease;
}
#grid.recall .cell { cursor: pointer; }

@media (hover: hover) {
  #grid.recall .cell:not(.selected):hover {
    background: #1c1c3d;
    border-color: var(--border);
    transform: scale(1.04);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes levelUp {
  0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); }
}
#grid.level-up { animation: levelUp 0.35s ease; }

.game-counter {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: 999px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.game-counter span { color: var(--cyan); font-weight: 600; }

/* ═══════════════ РЕЗУЛЬТАТ ═══════════════ */
.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  max-width: 460px;
  margin: 24px auto 0;
}
.result__icon  { font-size: clamp(52px, 13vw, 72px); line-height: 1; }
.result__title { font-family: "Syne", sans-serif; font-weight: 800; font-size: clamp(24px, 6vw, 32px); }
.result__card  { width: 100%; text-align: center; border-color: var(--cyan); box-shadow: 0 0 50px rgba(0, 229, 255, 0.15); }
.result__big   { font-family: "Bebas Neue", sans-serif; font-size: clamp(44px, 12vw, 64px); line-height: 1; color: var(--cyan); letter-spacing: 1px; }
.result__sub   { font-size: 16px; color: var(--muted); margin-top: 4px; }
.result__message { font-size: 15px; color: var(--muted); max-width: 340px; }
.result__actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }

/* ═══════════════ ВЫБОР СЛОЖНОСТИ ═══════════════ */
.diff-select {
  display: flex;
  gap: 8px;
  width: 100%;
}

.diff-opt {
  position: relative;
  flex: 1;
}

.diff-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.diff-opt span {
  display: block;
  text-align: center;
  padding: 11px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

@media (hover: hover) {
  .diff-opt--easy:hover span   { border-color: var(--green); }
  .diff-opt--medium:hover span { border-color: var(--gold); }
  .diff-opt--hard:hover span   { border-color: var(--red); }
}

.diff-opt--easy   input:checked + span {
  border-color: var(--green);
  background: rgba(0, 224, 150, 0.12);
  color: var(--green);
  box-shadow: 0 0 14px rgba(0, 224, 150, 0.2);
}
.diff-opt--medium input:checked + span {
  border-color: var(--gold);
  background: rgba(255, 195, 0, 0.12);
  color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 195, 0, 0.2);
}
.diff-opt--hard   input:checked + span {
  border-color: var(--red);
  background: rgba(255, 61, 113, 0.12);
  color: var(--red);
  box-shadow: 0 0 14px rgba(255, 61, 113, 0.2);
}

/* Бейдж сложности в игровой панели */
.diff-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: 999px;
  white-space: nowrap;
}
.diff-badge--easy   { color: #07070f; background: var(--green); box-shadow: 0 0 10px rgba(0,224,150,0.35); }
.diff-badge--medium { color: #07070f; background: var(--gold);  box-shadow: 0 0 10px rgba(255,195,0,0.35); }
.diff-badge--hard   { color: #ffffff; background: var(--red);   box-shadow: 0 0 10px rgba(255,61,113,0.4); }

/* ═══════════════ БУСТ-КАРТОЧКА ═══════════════ */
.result__boost {
  width: 100%;
  text-align: left;
  border-color: rgba(0, 224, 150, 0.35);
  box-shadow: 0 0 40px rgba(0, 224, 150, 0.1);
}

.boost-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.boost-row:last-child { border-bottom: none; padding-bottom: 0; }
.boost-row:first-of-type { padding-top: 0; }

.boost-icon {
  font-size: 22px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.boost-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.boost-value {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(28px, 7vw, 36px);
  line-height: 1;
  letter-spacing: 1px;
}

.boost-label {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

/* ═══════════════ ПРОГРЕСС-КАРТОЧКА ═══════════════ */
.result__progress {
  width: 100%;
  text-align: left;
}

.progress-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.45;
}
.progress-item:first-of-type { padding-top: 8px; }
.progress-item:last-child { border-bottom: none; padding-bottom: 0; }

.progress-item__icon {
  font-size: 17px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  line-height: 1.45;
}

.progress-item__text { color: var(--muted); }
.progress-item__text strong { color: var(--text); font-weight: 600; }
.hi-green  { color: var(--green); font-weight: 600; }
.hi-red    { color: var(--red);   font-weight: 600; }
.hi-cyan   { color: var(--cyan);  font-weight: 600; }
.hi-gold   { color: var(--gold);  font-weight: 600; }

.boost-benefit-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(0, 229, 255, 0.04);
  border: 1px solid var(--border);
  width: 100%;
}

/* ═══════════════ АДАПТИВ ═══════════════ */
@media (max-width: 600px) {
  .header { top: 8px; margin-top: 8px; }
  .header__action { display: none; }
  .button { width: 100%; }
  .hero__actions, .result__actions { max-width: 100%; }
  .hero { padding: 24px 0 20px; }
}

@media (max-width: 380px) {
  .app { padding: 12px 10px 40px; }
  #grid { gap: 6px; }
  .cell { border-radius: 8px; }
  .game__bar { padding: 12px 14px; }
}

/* sticky отключаем на узких экранах */
@media (max-width: 859px) {
  .summary-panel { position: static; }
}
