/* VVnetRU — единый стиль «Матрица» */

:root {
  --matrix-green: #00ff41;
  --matrix-green-dim: #00aa2a;
  --matrix-green-glow: rgba(0, 255, 65, 0.25);
  --bg-dark: #0a0a0f;
  --bg-card: rgba(0, 20, 0, 0.6);
  --bg-card-hover: rgba(0, 30, 0, 0.8);
  --text-light: #e0e0e0;
  --text-muted: #888;
  --border-green: rgba(0, 255, 65, 0.4);
  --header-height: 56px;
  --transition-fast: 0.15s ease;
  --transition-mid: 0.25s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  background: var(--bg-dark);
  color: var(--text-light);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Блокировка скролла */
body.no-scroll {
  overflow: hidden;
  height: 100vh;
  position: fixed;
  width: 100%;
}

/* Разрешение скролла на Plex */
body.no-scroll.allow-scroll {
  overflow: auto;
  position: static;
  height: auto;
}

/* Уменьшение motion для accessibility */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  #matrix-canvas {
    display: none;
  }
}

/* ============================
   ШАПКА
   ============================ */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-green);
}

header a {
  color: var(--matrix-green);
  text-decoration: none;
  font-weight: 600;
}

/* Состояния фокуса для доступности */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--matrix-green);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Логотип с pulse-анимацией */
.logo {
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  position: relative;
  flex-shrink: 0;
}

.logo::after {
  content: '';
  position: absolute;
  inset: -4px -8px;
  border: 1px solid transparent;
  border-radius: 2px;
  animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {

  0%,
  100% {
    border-color: transparent;
  }

  50% {
    border-color: var(--border-green);
    box-shadow: 0 0 8px var(--matrix-green-glow);
  }
}

/* Горизонтальная навигация (десктоп) */
nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

nav>a {
  font-size: 0.85rem;
  color: var(--matrix-green);
  font-weight: 600;
  transition: color var(--transition-fast);
}

nav a.active {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* Кнопка-гамбургер (скрыта на десктопе) */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border-green);
  border-radius: 4px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--matrix-green);
  border-radius: 2px;
  transition: transform var(--transition-mid), opacity var(--transition-mid);
  transform-origin: center;
}

/* Анимация гамбургера → крестик */
.menu-toggle.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.menu-toggle.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Выпадающее меню MiniGames (десктоп) */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  background: transparent;
  border: none;
  color: var(--matrix-green);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.nav-dropdown-btn::after {
  content: ' ▼';
  font-size: 0.7em;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(10, 10, 15, 0.97);
  border: 1px solid var(--border-green);
  min-width: 170px;
  padding: 0.4rem 0;
  z-index: 101;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.nav-dropdown-content a {
  display: block;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  color: var(--text-light);
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Hover-эффекты только на устройствах с мышью */
@media (hover: hover) {
  header a:hover {
    color: var(--matrix-green-dim);
  }

  .nav-dropdown-btn:hover {
    color: var(--matrix-green-dim);
  }

  .nav-dropdown:hover .nav-dropdown-content,
  .nav-dropdown-btn:focus+.nav-dropdown-content {
    display: block;
  }

  .nav-dropdown-content a:hover {
    background: rgba(0, 255, 65, 0.1);
    color: var(--matrix-green);
  }

  .minigame-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 255, 65, 0.15);
    border-color: var(--matrix-green);
    background: var(--bg-card-hover);
  }

  .btn:hover {
    background: var(--matrix-green);
    color: var(--bg-dark);
  }

  .connection-card:hover {
    border-color: var(--matrix-green);
    box-shadow: 0 4px 16px var(--matrix-green-glow);
  }
}

/* ============================
   CANVAS-ФОН
   ============================ */
#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

/* ============================
   КНОПКИ
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1.2rem;
  color: var(--matrix-green);
  border: 1px solid var(--matrix-green);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
  background: rgba(0, 255, 65, 0.15);
}

/* ============================
   ГЛАВНАЯ — HERO
   ============================ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}

.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-green);
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.08);
}

.hero h1 {
  font-size: 2rem;
  color: var(--matrix-green);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 20px rgba(0, 255, 65, 0.4);
}

.hero p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.hero-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================
   MINIGAMES СТРАНИЦА
   ============================ */
.minigames-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}

.minigames-hero h1 {
  font-size: 1.8rem;
  color: var(--matrix-green);
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.minigames-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.minigames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  max-width: 600px;
  width: 100%;
}

.minigame-card {
  background: var(--bg-card);
  border: 1px solid var(--border-green);
  padding: 1.5rem;
  text-decoration: none;
  transition: transform var(--transition-mid), box-shadow var(--transition-mid), border-color var(--transition-mid), background var(--transition-mid);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.minigame-card:active {
  transform: scale(0.97);
  background: var(--bg-card-hover);
}

.minigame-icon {
  width: 60px;
  height: 60px;
  margin-bottom: 1rem;
}

.minigame-icon svg {
  width: 100%;
  height: 100%;
}

.minigame-card h2 {
  color: var(--matrix-green);
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.minigame-card p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================
   КОНТЕНТ-СТРАНИЦЫ (PUBG, PLEX)
   ============================ */
main {
  padding: 5rem 1.5rem 3rem;
  max-width: 700px;
  margin: 0 auto;
}

.page-title {
  font-size: 1.5rem;
  color: var(--matrix-green);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

.page-description {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.instruction-block {
  background: var(--bg-card);
  border: 1px solid var(--border-green);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.instruction-title {
  font-size: 1rem;
  color: var(--matrix-green);
  margin-bottom: 1rem;
}

.instruction-steps {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.8;
  padding-left: 1.25rem;
}

.instruction-steps li {
  margin-bottom: 0.5rem;
}

/* Карточки подключений */
.connections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.connection-card {
  background: var(--bg-card);
  border: 1px solid var(--border-green);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: border-color var(--transition-mid), box-shadow var(--transition-mid);
}

.connection-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: var(--matrix-green);
}

.connection-card h3 {
  font-size: 1rem;
  color: var(--matrix-green);
  margin-bottom: 0.25rem;
}

.connection-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.connection-card a {
  color: var(--matrix-green);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-green);
  transition: border-color var(--transition-fast);
}

@media (hover: hover) {
  .connection-card a:hover {
    border-color: var(--matrix-green);
  }
}

/* ============================
   TETRIS
   ============================ */
.tetris-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  min-height: calc(100vh - var(--header-height));
}

#tetris-canvas {
  border: 1px solid var(--border-green);
  background: var(--bg-card);
  display: block;
  width: 300px;
  height: 600px;
  max-width: 100%;
  object-fit: contain;
}

.tetris-panel {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.tetris-panel span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.tetris-panel span strong {
  color: var(--matrix-green);
}

.tetris-stats {
  width: 100%;
  max-width: 320px;
}

.tetris-controls {
  width: 100%;
  max-width: 320px;
}

#tetris-next {
  border: 1px solid var(--border-green);
  background: var(--bg-card);
  display: inline-block;
  width: 60px;
  height: 40px;
  vertical-align: middle;
}

.page-title .tetris-highscore {
  font-size: 0.7rem;
  color: var(--matrix-green);
  font-weight: normal;
  margin-left: 0.5rem;
  border: 1px solid var(--matrix-green);
  padding: 0.15rem 0.4rem;
  display: inline-block;
}

/* ============================
   КРЕСТИКИ-НОЛИКИ
   ============================ */
.game-area {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: flex-start;
}

.game-panel {
  min-width: 130px;
}

.game-mode {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.game-mode label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  touch-action: manipulation;
  min-height: 44px;
}

.game-mode input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--matrix-green);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.game-mode input[type="radio"]:checked {
  background: var(--matrix-green);
}

.game-mode input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--bg-dark);
  border-radius: 50%;
}

.game-mode input[type="radio"]:focus-visible {
  outline: 2px solid var(--matrix-green);
  outline-offset: 4px;
}

#tictactoe-canvas {
  border: 1px solid var(--border-green);
  background: var(--bg-card);
  display: block;
  cursor: pointer;
  max-width: 100%;
  height: auto;
}

/* ============================
   MATRIX RUNNER
   ============================ */
#gameCanvas {
  border: 1px solid var(--border-green);
  background: var(--bg-card);
  display: block;
  max-width: 100%;
  height: auto;
  width: 400px;
  height: 300px;
}

/* ============================
   МОБИЛЬНЫЕ КНОПКИ ТЕТРИС
   ============================ */
.mobile-controls {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.mobile-controls-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.mobile-btn {
  width: 70px;
  height: 70px;
  font-size: 1.6rem;
  font-family: inherit;
  background: var(--bg-card);
  border: 2px solid var(--matrix-green);
  color: var(--matrix-green);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.mobile-btn:active {
  background: var(--matrix-green);
  color: var(--bg-dark);
  transform: scale(0.93);
}

.mobile-btn-drop {
  width: min(200px, 60vw);
}

/* Подсказка для мобильных */
.mobile-hint {
  display: none;
}

@media (max-width: 768px) {
  .mobile-hint {
    display: inline;
  }
}

/* ============================
   МОБИЛЬНАЯ ВЕРСИЯ (≤ 768px)
   ============================ */
@media (max-width: 768px) {

  /* Шапка */
  header {
    padding: 0 1rem;
  }

  /* Гамбургер-кнопка */
  .menu-toggle {
    display: flex;
  }

  /* Навигация скрыта по умолчанию на мобиле */
  nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 99;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: rgba(10, 10, 15, 0.97);
    border-bottom: 1px solid var(--border-green);
    padding: 0.5rem 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: nav-slide-down 0.2s ease forwards;
  }

  @keyframes nav-slide-down {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Открытое меню */
  nav.nav-open {
    display: flex;
  }

  nav>a {
    font-size: 1rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(0, 255, 65, 0.1);
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Дропдаун MiniGames — встраивается в мобильное меню */
  .nav-dropdown {
    position: static;
  }

  .nav-dropdown-btn {
    font-size: 1rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(0, 255, 65, 0.1);
    width: 100%;
    text-align: left;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .nav-dropdown-btn::after {
    content: ' ▼';
    font-size: 0.7em;
    margin-left: auto;
    transition: transform var(--transition-fast);
  }

  .nav-dropdown-btn.is-open::after {
    transform: rotate(180deg);
  }

  .nav-dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid rgba(0, 255, 65, 0.1);
    background: rgba(0, 20, 0, 0.4);
    padding: 0;
    min-width: unset;
  }

  .nav-dropdown-content a {
    font-size: 0.95rem;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid rgba(0, 255, 65, 0.07);
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Блокировка скролла */
  body.no-scroll {
    overflow: hidden;
    height: 100%;
    position: fixed;
    width: 100%;
    touch-action: none;
  }

  /* main */
  main {
    padding: 4rem 0.75rem 0.75rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
  }

  .page-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    text-align: center;
    flex-shrink: 0;
  }

  /* Главная */
  .hero {
    padding: 1.5rem 1rem;
  }

  .hero-card {
    padding: 1.75rem 1.25rem;
    max-width: 100%;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero-buttons {
    flex-direction: column;
    gap: 0.6rem;
  }

  .hero-buttons .btn {
    width: 100%;
    font-size: 0.95rem;
  }

  /* MiniGames — горизонтальные карточки */
  .minigames-hero {
    padding: 0.75rem 1rem;
    justify-content: center;
  }

  .minigames-hero h1 {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
  }

  .minigames-subtitle {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .minigames-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    max-width: 100%;
  }

  .minigame-card {
    flex-direction: row;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 1.25rem;
    text-align: left;
  }

  .minigame-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    margin-bottom: 0;
  }

  .minigame-card h2 {
    font-size: 1rem;
    margin-bottom: 0.15rem;
  }

  /* Tetris */
  .tetris-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    width: 100%;
    max-width: 100%;
    padding: 0;
  }

  .tetris-stats,
  .tetris-controls {
    width: 100%;
    max-width: 300px;
    gap: 0.25rem;
    padding: 0.2rem 0.25rem;
  }

  .tetris-stats span,
  .tetris-controls span {
    font-size: 0.7rem;
    padding: 0.15rem 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-green);
    border-radius: 3px;
  }

  #tetris-canvas {
    width: 100% !important;
    max-width: 240px !important;
    height: auto !important;
    aspect-ratio: 10 / 20;
    flex-shrink: 0;
  }

  #tetris-next {
    width: 50px !important;
    height: 35px !important;
  }

  .mobile-controls {
    display: flex;
    width: 100%;
    max-width: 320px;
    margin-top: 0.25rem;
    padding: 0.5rem;
  }

  /* Крестики-нолики */
  .game-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .game-mode {
    gap: 1rem;
    margin-bottom: 0.75rem;
  }

  #tictactoe-canvas {
    width: 100% !important;
    max-width: 300px !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }

  .game-panel {
    width: 100%;
    max-width: 300px;
    text-align: center;
  }

  /* Matrix Runner */
  #gameCanvas {
    width: 100% !important;
    max-width: 300px !important;
    height: auto !important;
    aspect-ratio: 4 / 3;
  }
}

/* ============================
   СТИЛИ ДЛЯ ПЕЧАТИ
   ============================ */
@media print {
  #matrix-canvas {
    display: none !important;
  }

  header {
    position: static;
    background: white;
    border-bottom: 1px solid #000;
    color: black;
  }

  header a {
    color: black;
  }

  body {
    background: white;
    color: black;
  }

  .hero-card,
  .connection-card,
  .instruction-block {
    border: 1px solid #ccc;
    background: white;
    color: black;
  }

  .btn {
    border: 1px solid black;
    color: black;
  }

  main {
    padding: 1rem;
    max-width: 100%;
  }

  .menu-toggle {
    display: none;
  }
}