/* Базовые стили и неоновый / хакерский / футуристический вайб */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, #0b1220 0, #020617 40%, #020617 100%);
  color: #e5e7eb;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.2) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.2;
  mix-blend-mode: soft-light;
  z-index: -1;
}

.screen {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.background {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

#landing-screen .background::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 70% at 50% 50%,
    rgba(34, 211, 238, 0.04) 0%,
    transparent 55%
  );
  z-index: 1;
}

#landing-screen .background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 100% 100% at 50% 50%,
    transparent 50%,
    rgba(2, 6, 23, 0.35) 100%
  );
  z-index: 2;
}

.landing-parallax-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
}

.landing-parallax-layer--far {
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
  background-size: 80px 80px;
  animation: parallaxMoveFar 70s linear infinite;
}

.landing-parallax-layer--mid {
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.09) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: parallaxMoveMid 45s linear infinite;
}

.landing-parallax-layer--near {
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.11) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: parallaxMoveNear 28s linear infinite;
}

@keyframes parallaxMoveFar {
  from { background-position: 0 0; }
  to { background-position: 80px 80px; }
}

@keyframes parallaxMoveMid {
  from { background-position: 0 0; }
  to { background-position: 50px 50px; }
}

@keyframes parallaxMoveNear {
  from { background-position: 0 0; }
  to { background-position: 30px 30px; }
}

/* Панель вокруг формы — нео-футуристический хакерский стиль, мягкий для глаз */
.landing-high-score {
  margin: 1rem 0 0.5rem 0;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.1rem;
  color: rgba(34, 211, 238, 0.9);
}

@media (max-width: 380px) {
  .landing-content {
    padding: 1.5rem 1rem;
  }

  .mode-choice {
    gap: 0.5rem;
  }

  .btn-mode {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
  }
}

.leaderboard-wrap {
  margin-top: 1.5rem;
  text-align: center;
}

.leaderboard-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(34, 211, 238, 0.7);
}

.leaderboard-wrap .leaderboard-list {
  display: inline-block;
  margin: 0;
  min-width: 8rem;
}

.landing-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.5rem 3rem;
  border-radius: 1rem;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: radial-gradient(
    ellipse at center,
    rgba(15, 23, 42, 0.85) 0%,
    rgba(2, 6, 23, 0.92) 60%,
    rgba(2, 6, 23, 0.97) 100%
  );
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 30px rgba(34, 211, 238, 0.12),
    0 0 60px rgba(168, 85, 247, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  max-width: min(calc(100vw - 1rem), 420px);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.title {
  margin: 0 0 2rem 0;
  font-size: clamp(3rem, 7vw, 4.5rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e5e7eb;
  text-shadow:
    0 0 8px rgba(34, 211, 238, 0.8),
    0 0 18px rgba(14, 165, 233, 0.6),
    0 0 32px rgba(168, 85, 247, 0.5);
}

.mode-choice {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  min-width: 0;
}

.btn-mode {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.btn-mode--active {
  border-color: rgba(34, 211, 238, 0.9);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
}

.btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.7);
  border-radius: 999px;
  padding: 0.8rem 2.4rem;
  font-size: 1rem;
  text-transform: uppercase;
  background: radial-gradient(circle at top left, rgba(34, 211, 238, 0.24), rgba(15, 23, 42, 0.9));
  color: #e5e7eb;
  backdrop-filter: blur(8px);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 14px rgba(56, 189, 248, 0.4);
  transition:
    transform 0.12s ease-out,
    box-shadow 0.12s ease-out,
    border-color 0.12s ease-out,
    background 0.12s ease-out;
  /* Мобилки: не зумить при двойном тапе и не выделять текст */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: rgba(244, 244, 245, 0.9);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.8),
    0 0 22px rgba(56, 189, 248, 0.8);
  transform: translateY(-1px) scale(1.02);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 1),
    0 0 12px rgba(34, 197, 94, 0.8);
}

.btn:focus-visible,
.control-btn:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.9);
  outline-offset: 2px;
}

.btn-primary {
  border-color: rgba(56, 189, 248, 0.7);
}

.btn-secondary {
  border-color: rgba(74, 222, 128, 0.7);
}

/* Текст в кнопке: центрирование, letter-spacing для стиля */
.btn-text {
  letter-spacing: 0.12em;
  margin: 0;
}

/* Игровой экран */
#game-screen {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  box-sizing: border-box;
}

#game-screen .background {
}

/* Фон игровой страницы — одна статичная сетка (как на стартовой, без анимации) */
.game-screen-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: 0 0;
}

/* Скрытое старое содержимое игровой страницы */
.game-screen-legacy {
  display: none !important;
}

/* Мелькающие звёздочки — только в пустотах, нео-футуристический стиль */
.twinkle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Звёздочка — символ ★, размер задаётся через font-size в JS */
.twinkle-star {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 1em;
  line-height: 1;
  color: rgba(34, 211, 238, 0.95);
  text-shadow: 0 0 6px rgba(34, 211, 238, 0.7), 0 0 12px rgba(34, 211, 238, 0.4);
  pointer-events: none;
  animation: twinkle-star-cycle 5s ease-in-out forwards;
}

@keyframes twinkle-star-cycle {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  12% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  28% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
  42% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  56% { opacity: 0.15; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 0.35; transform: translate(-50%, -50%) scale(1); }
  85% { opacity: 0.12; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* Главный фрейм — каркас: макс. высота, ширина = половина высоты (телефон: меню снизу) */
.main-frame {
  position: relative;
  z-index: 1;
  height: 100%;
  max-height: 100%;
  width: auto;
  aspect-ratio: 1 / 2;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: 3fr 1fr;
  grid-template-columns: 2fr 1fr;
  gap: 6px;
  padding: 0;
}

#main-frame:focus {
  outline: none;
}

/* Компьютер: menu слева (прижат к gamefield), gamefield 1:2 по центру, sidebar справа; блок не растягивается по ширине */
#game-screen.input-mode-computer .main-frame {
  aspect-ratio: auto;
  width: max-content;
  max-width: 100%;
  height: 100%;
  grid-template-rows: 1fr;
  grid-template-columns: 230px auto 148px;
}

#game-screen.input-mode-computer .frame-menu {
  grid-column: 1;
  grid-row: 1;
  height: auto;
  min-height: 0;
  max-height: none;
  align-self: center;
  width: 100%;
  min-width: 0;
  padding: 18px 16px 24px 16px;
  box-sizing: border-box;
  overflow: visible;
}

#game-screen.input-mode-computer .frame-gamefield {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  aspect-ratio: 1 / 2;
  width: auto;
  min-width: 0;
}

#game-screen.input-mode-computer .frame-sidebar {
  grid-column: 3;
  grid-row: 1;
  width: 148px;
  min-width: 148px;
  padding-left: 14px;
  padding-right: 14px;
  box-sizing: border-box;
}

/* Небольшой отступ от границ sidebar для превью с 4 клетками (горизонтальная/вертикальная палка) */
.frame-sidebar .hold-preview--main.preview-grid-4x3,
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-4x3,
.frame-sidebar .hold-preview--main.preview-grid-3x4,
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-3x4 {
  margin-left: 4px;
  margin-right: 4px;
}

/* Поле: слева сверху, 3/4 высоты, 2/3 ширины; красивое свечение от поля */
.main-frame .frame-gamefield {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.5);
  box-shadow:
    0 0 8px rgba(34, 211, 238, 0.25),
    0 0 20px rgba(34, 211, 238, 0.2),
    0 0 40px rgba(34, 211, 238, 0.15),
    0 0 64px rgba(34, 211, 238, 0.1),
    0 0 96px rgba(34, 211, 238, 0.06),
    inset 0 0 24px rgba(34, 211, 238, 0.04);
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* Обёртка доски — на весь фрейм (включая под бордер), под очками по слоям */
.frame-gamefield .gamefield-board-wrap {
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 0;
}

.frame-gamefield .gamefield-board-wrap .game-board-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Доска с соотношением 1:2 — клетки остаются квадратными (10×20) */
.frame-gamefield .game-board-wrapper .game-board {
  aspect-ratio: 1 / 2;
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  width: auto;
  min-width: 0;
}

/* Очки поверх игрового поля: сверху по центру, с небольшим отступом */
.frame-gamefield .score-on-field {
  position: absolute;
  z-index: 2;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(52, 211, 153, 0.7);
  background: radial-gradient(circle at top, rgba(15, 118, 110, 0.4), rgba(2, 6, 23, 0.9));
  color: #a7f3d0;
  font-size: clamp(0.85rem, 2.2vmin, 1.05rem);
  text-shadow: 0 0 6px rgba(16, 185, 129, 0.9), 0 0 14px rgba(22, 163, 74, 0.7);
  box-shadow: 0 0 0 1px rgba(6, 78, 59, 0.9), 0 0 18px rgba(16, 185, 129, 0.4);
  white-space: nowrap;
  pointer-events: none;
}

/* Кнопка паузы на игровом поле — только для мобилок, левый верхний угол */
.frame-gamefield .gamefield-pause-btn {
  display: none;
  position: absolute;
  z-index: 2;
  top: 6px;
  left: 6px;
  padding: 0.35rem 0.6rem;
  font-size: clamp(0.65rem, 1.6vmin, 0.8rem);
}

.frame-gamefield .gamefield-pause-btn .control-icon {
  display: block;
  font-size: 1.1em;
  line-height: 1;
  color: rgba(34, 211, 238, 0.95);
}

#game-screen.input-mode-phone .frame-gamefield .gamefield-pause-btn {
  display: inline-flex;
}

#game-screen.input-mode-phone .frame-sidebar .sidebar-pause-btn {
  display: none !important;
}

/* Сайдбар: сверху справа, 3/4 высоты, 1/3 ширины; Замена и Следующие по центру по высоте */
.main-frame .frame-sidebar {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 6px 8px 6px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.5);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.12);
  min-height: 0;
}

/* Кнопка паузы в сайдбаре — сверху справа */
.frame-sidebar .sidebar-pause-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0.4rem 0.75rem;
  font-size: clamp(0.65rem, 1.6vmin, 0.8rem);
}

/* Блок в сайдбаре: фрейм в клетку */
.frame-sidebar .sidebar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.frame-sidebar .sidebar-block--hold {
  order: 1;
}

.frame-sidebar .sidebar-block--next {
  order: 2;
}

.frame-sidebar .sidebar-block-label {
  font-size: clamp(0.7rem, 1.8vmin, 0.9rem);
  color: rgba(34, 211, 238, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Замена / Следующие: размер клетки = игровое поле; сетка задаётся классом .preview-grid-3x3 / .preview-grid-4x3 / .preview-grid-3x4 */
.frame-sidebar .hold-preview--main,
.frame-sidebar .next-preview--main .next-preview-item {
  display: grid;
  border-radius: 0.35rem;
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(34, 211, 238, 0.25);
}

/* По умолчанию 3×3 (если класс сетки не задан) */
.frame-sidebar .hold-preview--main:not([class*="preview-grid-"]),
.frame-sidebar .next-preview--main .next-preview-item:not([class*="preview-grid-"]) {
  grid-template-columns: repeat(3, var(--board-cell-px, 12px));
  grid-template-rows: repeat(3, var(--board-cell-px, 12px));
  width: calc(3 * var(--board-cell-px, 12px));
  height: calc(3 * var(--board-cell-px, 12px));
}

.frame-sidebar .hold-preview--main:not([class*="preview-grid-"]) .preview-cell:nth-child(n+10),
.frame-sidebar .next-preview--main .next-preview-item:not([class*="preview-grid-"]) .preview-cell:nth-child(n+10) {
  display: none;
}

.frame-sidebar .hold-preview--main.preview-grid-3x3,
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-3x3 {
  grid-template-columns: repeat(3, var(--board-cell-px, 12px));
  grid-template-rows: repeat(3, var(--board-cell-px, 12px));
  width: calc(3 * var(--board-cell-px, 12px));
  height: calc(3 * var(--board-cell-px, 12px));
}

.frame-sidebar .hold-preview--main.preview-grid-3x3 .preview-cell:nth-child(n+10),
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-3x3 .preview-cell:nth-child(n+10) {
  display: none;
}

.frame-sidebar .hold-preview--main.preview-grid-4x3,
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-4x3 {
  grid-template-columns: repeat(4, var(--board-cell-px, 12px));
  grid-template-rows: repeat(3, var(--board-cell-px, 12px));
  width: calc(4 * var(--board-cell-px, 12px));
  height: calc(3 * var(--board-cell-px, 12px));
}

.frame-sidebar .hold-preview--main.preview-grid-3x4,
.frame-sidebar .next-preview--main .next-preview-item.preview-grid-3x4 {
  grid-template-columns: repeat(3, var(--board-cell-px, 12px));
  grid-template-rows: repeat(4, var(--board-cell-px, 12px));
  width: calc(3 * var(--board-cell-px, 12px));
  height: calc(4 * var(--board-cell-px, 12px));
}

.frame-sidebar .next-preview--main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Меню: снизу, 1/4 высоты, на всю ширину */
.main-frame .frame-menu {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.5);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.12);
  min-height: 0;
  padding: 6px;
}

/* Меню управления — телефон: 2 строки кнопок, паддинг между кнопками, чуть меньше размер */
.frame-menu .menu-controls--phone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
}

.frame-menu .menu-controls-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.frame-menu .menu-controls-row .control-btn {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.4rem;
  font-size: clamp(0.75rem, 2vmin, 0.9rem);
}

.frame-menu .menu-controls-row .control-btn--icon {
  padding: 0.4rem;
}

.frame-menu .menu-controls-row .control-btn--icon .control-icon {
  display: block;
  font-size: 1.6em;
  line-height: 1;
  font-weight: 600;
  color: rgba(34, 211, 238, 0.95);
  text-shadow: 0 0 6px rgba(34, 211, 238, 0.6);
}

.frame-menu .menu-controls-row .control-btn--rotate {
  font-size: 1.1em;
}

.frame-menu .menu-controls-row .control-btn--rotate .control-icon {
  font-size: 1.6em;
}

.frame-sidebar .sidebar-pause-btn.control-btn--icon .control-icon {
  display: block;
  font-size: 1.1em;
  line-height: 1;
  color: rgba(34, 211, 238, 0.95);
}

/* Меню управления — компьютер: подсказки по клавишам (скрыто по умолчанию) */
.frame-menu .menu-controls--computer {
  display: none !important;
}

#game-screen.input-mode-computer .frame-menu .menu-controls--phone {
  display: none !important;
}

#game-screen.input-mode-computer .frame-menu .menu-controls--computer {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

#game-screen.input-mode-computer .frame-menu .menu-controls-keys {
  font-size: clamp(0.8rem, 1.85vmin, 1rem);
}

#game-screen.input-mode-computer .frame-menu .menu-controls-keys p {
  margin: 0 0 0.8rem 0;
  white-space: nowrap;
}

#game-screen.input-mode-computer .frame-menu .menu-controls-keys p:last-child {
  margin-bottom: 0;
}

.frame-menu .menu-controls-keys {
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(0.95rem, 2.5vmin, 1.2rem);
  color: rgba(34, 211, 238, 0.9);
}

.frame-menu .menu-controls-keys p {
  margin: 0 0 0.65rem 0;
}

.frame-menu .menu-controls-keys p:last-child {
  margin-bottom: 0;
}

.frame-menu .menu-controls-keys kbd {
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: rgba(15, 23, 42, 0.9);
  font-size: 1.1em;
}

.game-frame {
}

.game-top {
}

.game-board-area {
}

.game-board-area .game-board-wrapper {
}

.game-board-area .score-display {
}

.game-board-wrapper {
  border-radius: 0.5rem;
  opacity: 0;
}

.frame-gamefield .game-board-wrapper {
  opacity: 1;
}

.game-board-wrapper--visible {
  opacity: 1;
}

.game-board {
  position: relative;
  --board-cell-px: 12px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(20, 1fr);
  background: radial-gradient(circle at top, #020617, #020617 40%, #000 100%);
  border-radius: 0.4rem;
  box-shadow:
    0 0 0 1px rgba(30, 64, 175, 0.6),
    0 0 10px rgba(37, 99, 235, 0.4),
    0 0 20px rgba(59, 130, 246, 0.25);
}


.board-piece-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(20, 1fr);
  border-radius: inherit;
  pointer-events: none;
}

.piece-layer-cell {
  background: transparent;
  border-radius: 3px;
}

.piece-layer-cell--filled {
  background-color: var(--cell-color);
  box-shadow:
    0 0 8px var(--cell-color),
    0 0 14px var(--cell-color);
}

.game-sidebar {
}

.score-display {
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(52, 211, 153, 0.7);
  background: radial-gradient(circle at top, rgba(15, 118, 110, 0.4), rgba(2, 6, 23, 0.9));
  color: #a7f3d0;
  font-size: clamp(0.7rem, 1.8vmin, 0.9rem);
  text-shadow:
    0 0 6px rgba(16, 185, 129, 0.9),
    0 0 14px rgba(22, 163, 74, 0.7);
  box-shadow:
    0 0 0 1px rgba(6, 78, 59, 0.9),
    0 0 18px rgba(16, 185, 129, 0.4);
}

.sidebar-frame {
  border-radius: 0.5rem;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(15, 23, 42, 0.9);
}

.sidebar-frame--hold {
}

.sidebar-frame--next {
}

.sidebar-frame-label {
  font-size: clamp(0.6rem, 1.6vmin, 0.75rem);
  color: rgba(34, 211, 238, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ПК: 4×3 (4 по длине, 3 по высоте); клетки = поле или меньше, не вылезать за родителя */
.hold-preview {
  border-radius: 3px;
  background: rgba(2, 6, 23, 0.8);
}

.next-preview {
}

/* ПК: 4×3; клетки = поле или меньше, не вылезать за родителя */
.next-preview-item {
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 0.4rem;
  background: rgba(2, 6, 23, 0.6);
}

.game-controls {
  border-top: 1px solid rgba(34, 211, 238, 0.2);
}

.game-controls .controls--phone {
}

.game-controls .controls--computer {
}

.controls-keys {
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(0.9rem, 2.2vmin, 1.1rem);
  color: rgba(34, 211, 238, 0.9);
}

.controls-keys p {
  margin: 0;
}

.controls-keys kbd {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: rgba(15, 23, 42, 0.9);
  font-size: 1em;
}

.cell {
  --cell-color: #22c55e;
  background-color: rgba(15, 23, 42, 0.9);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 1);
}

.cell--filled {
  background-color: var(--cell-color);
  box-shadow:
    0 0 8px var(--cell-color),
    0 0 14px var(--cell-color);
}

.cell--shadow {
  background-color: var(--cell-color);
  opacity: 0.35;
  box-shadow: none;
}

.cell--current {
}

.board--glow .cell--filled,
.board--pulse .cell--filled {
  animation: boardGlow 0.5s ease-out;
}

/* На мобильных — упрощённое свечение без анимации, чтобы не лагало */
@media (max-width: 600px), (max-height: 700px) {
  .cell--filled {
    box-shadow: 0 0 4px var(--cell-color);
  }

  .board--glow .cell--filled,
  .board--pulse .cell--filled {
    animation: none;
    box-shadow: 0 0 4px var(--cell-color);
  }
}

@keyframes boardGlow {
  0%, 100% {
    box-shadow: 0 0 8px var(--cell-color), 0 0 14px var(--cell-color);
  }
  50% {
    box-shadow: 0 0 9px var(--cell-color), 0 0 15px var(--cell-color);
  }
}

.cell--clearing {
  animation: lineClear 0.2s ease-out forwards;
}

@keyframes lineClear {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.4;
  }
  100% {
    transform: scale(0.9);
    opacity: 0;
  }
}

.score-popup {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.5rem;
  font-weight: bold;
  color: #a7f3d0;
  text-shadow:
    0 0 8px rgba(16, 185, 129, 0.9),
    0 0 16px rgba(22, 163, 74, 0.7);
  animation: scorePopup 1s ease-out forwards;
  pointer-events: none;
  z-index: 3;
}

@keyframes scorePopup {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  85% {
    transform: translate(-50%, -50%) translateY(-30px);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translateY(-50px);
    opacity: 0;
  }
}

.spark {
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.8);
  animation: sparkOut 0.8s ease-out forwards;
}

@keyframes sparkOut {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--spark-dx), var(--spark-dy)) scale(0.5);
    opacity: 0;
  }
}

.hold-preview .preview-cell,
.next-preview-item .preview-cell {
  --cell-color: #22c55e;
  background-color: rgba(15, 23, 42, 0.95);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 1);
}

.hold-preview .preview-cell--filled,
.next-preview-item .preview-cell--filled {
  background-color: var(--cell-color);
  box-shadow: 0 0 4px var(--cell-color), 0 0 8px var(--cell-color);
}

.controls-row {
}

.controls .control-btn {
  font-size: clamp(0.7rem, 2vmin, 0.875rem);
}


.control-btn--rotate {
  font-size: 1.2rem;
}

.controls-pause-wrap {
}

.control-btn--pause {
  font-size: clamp(0.7rem, 1.8vmin, 0.85rem);
}

.control-btn {
}

.controls-row--1 .control-btn,
.controls-row--2 .control-btn,
.controls-row--3 .control-btn {
}

#game-screen.input-mode-computer .controls--phone {
  display: none !important;
}

#game-screen.input-mode-computer .controls--computer {
  display: flex !important;
}

#game-screen.input-mode-phone .controls--computer {
  display: none !important;
}

/* Оверлей «Игра окончена» — поверх всего экрана */
.game-over-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.95) 0%, rgba(0, 0, 0, 0.97) 100%);
  backdrop-filter: blur(8px);
}

.game-over-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-radius: 1rem;
  border: 1px solid rgba(252, 165, 165, 0.5);
  background: radial-gradient(ellipse at top, rgba(248, 113, 113, 0.12), rgba(15, 23, 42, 0.98));
  box-shadow:
    0 0 0 1px rgba(127, 29, 29, 0.8),
    0 0 24px rgba(248, 113, 113, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  max-width: min(320px, 100%);
  text-align: center;
}

.game-over-text {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fecaca;
  text-shadow: 0 0 10px rgba(248, 113, 113, 0.8);
}

.game-over-score {
  margin: 0;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.15rem;
  color: #bbf7d0;
  text-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
}

.game-over-high-score {
  margin: 0;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.05rem;
  color: rgba(34, 211, 238, 0.9);
}

.leaderboard-list {
  list-style: none;
  font-family: "Share Tech Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.05rem;
  color: #a7f3d0;
}

.leaderboard-list--compact {
  font-size: 0.95rem;
  margin: 0;
  padding-left: 1.25rem;
  text-align: left;
}

.leaderboard-item {
}

.leaderboard-item--compact {
}

/* Оверлей паузы — поверх всего экрана */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.92) 0%, rgba(0, 0, 0, 0.95) 100%);
  backdrop-filter: blur(6px);
}

.pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.75rem 2.25rem;
  border-radius: 1rem;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: radial-gradient(ellipse at top, rgba(34, 211, 238, 0.06), rgba(15, 23, 42, 0.98));
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 0 28px rgba(34, 211, 238, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
}

.pause-text {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(34, 211, 238, 0.95);
  text-shadow:
    0 0 10px rgba(34, 211, 238, 0.7),
    0 0 20px rgba(34, 211, 238, 0.4);
}

/* Универсальное скрытие экранов и оверлеев */
.screen--hidden {
  display: none !important;
}
