* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #3b82f6;
  --cube-color-1: #64c8ff;
  --cube-color-2: #ff64c8;
  --cube-color-3: #64ffc8;
  --cube-glow: rgba(100, 200, 255, 0.3);
  --cube-glow-strong: rgba(100, 200, 255, 0.6);
  --dark-bg: #0a0a1a;
  --card-bg: #322f50cc;
  --text-light: rgba(255, 255, 255, 0.8);
  --success-color: #10b981;
  --error-color: #ef4444;
  --project-color: #10b981;
  --code-color: #2d4059;
  --bug-color: #c70039;
  --bug-hard-color: #b6013e;
  --boss-color: #b6013e;
  --bonus-time-color: #0077e6;
  --bonus-clean-color: #ff6e1a;

  /* Параметры компактности карточек */
  --el-pad-y: 6px;    /* вертикальные отступы блока */
  --el-pad-x: 10px;   /* правый внутренний отступ блока */
  --gap-icon-text: 8px; /* расстояние между иконкой и текстом */
  --icon-left: 8px;   /* отступ иконки слева */
}

body {
  background: linear-gradient(135deg, var(--dark-bg) 0%, #1a1c3a 100%);
  color: white;
  font-family: 'Arial', sans-serif;
  overflow: hidden;
  user-select: none;
  cursor: default;
  width: 100vw;
  height: 100vh;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  position: fixed;
  inset: 0;
}

body.cursor-locked { cursor: none; }

.game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px;
  max-width: 100vw;
  max-height: 100vh;
  touch-action: none;
}

.game-header {
  text-align: center;
  margin-bottom: 10px;
  flex-shrink: 0;
  will-change: transform;
  transform: translateZ(0);
}

.game-header h1 {
  font-size: clamp(1.5rem, 4vw, 1.6rem);
  margin-bottom: 8px;
  text-shadow: 0 0 20px var(--cube-glow-strong);
  background: linear-gradient(90deg, var(--cube-color-1), var(--cube-color-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2vw, 15px);
  flex-wrap: wrap;
}

.stat {
  background: var(--card-bg);
  padding: clamp(5px, 1.5vw, 8px) clamp(10px, 2vw, 15px);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(0.7rem, 2vw, 0.9rem);
}

.stat-icon {
  width: clamp(14px, 3vw, 18px);
  height: clamp(14px, 3vw, 18px);
}

.stat-label { color: var(--text-light); }

.game-area {
  flex: 1;
  background: rgba(16, 18, 40, 0.6);
  border: 2px solid var(--cube-color-1);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 0 30px var(--cube-glow);
  touch-action: none;
  width: 100%;
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  contain: layout style paint;
}

.game-area.cursor-locked { cursor: none; }

.project-zone {
  position: absolute;
  bottom: 0; left: 0; width: 100%;
  height: 0%;
  background: #2d4059;
  transition: height 0.3s ease;
  z-index: 1;
  opacity: 0.3;
  border-top: 2px solid #2d4059;
  will-change: height;
}

.project-zone.full { animation: projectComplete 1s ease-in-out; }
@keyframes projectComplete {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; box-shadow: 0 0 30px #2d4059; }
}

.project-zone.damage { animation: projectDamage 0.3s ease-in-out; }
@keyframes projectDamage {
  0%, 100% { background: linear-gradient(to top, var(--project-color), #2d4059); }
  50% { background: linear-gradient(to top, #ef4444, #f87171); }
}

.player-cursor {
  position: absolute;
  width: 40px; height: 40px;
  cursor: none;
  z-index: 100;
  transition: transform 0.05s linear;
  pointer-events: none;
  display: none;
  align-items: center;
  justify-content: center;
  will-change: transform;
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
}

.player-cursor.active { display: flex; }

.sight-circle {
  width: 30px; height: 30px;
  border: 2px solid #64c8ff;
  border-radius: 50%;
  position: absolute;
  box-shadow: 0 0 15px rgba(100, 200, 255, 0.6);
  animation: pulse 2s infinite;
  backface-visibility: hidden;
}
.sight-crosshair { position: absolute; width: 30px; height: 30px; backface-visibility: hidden; }
.sight-crosshair::before,
.sight-crosshair::after {
  content: '';
  position: absolute;
  background: #64c8ff;
  box-shadow: 0 0 8px rgba(100, 200, 255, 0.8);
  backface-visibility: hidden;
}
.sight-crosshair::before { width: 2px; height: 22px; left: 50%; top: 4px; transform: translateX(-50%); }
.sight-crosshair::after { width: 22px; height: 2px; top: 50%; left: 4px; transform: translateY(-50%); }
.sight-dot {
  width: 6px; height: 6px; background: #64c8ff;
  border-radius: 50%; position: absolute;
  box-shadow: 0 0 12px rgba(100, 200, 255, 1);
  z-index: 2; backface-visibility: hidden;
}
@keyframes pulse { 0%,100%{opacity:.8} 50%{opacity:1} }

.game-controls {
  display: flex; justify-content: center; gap: 12px;
  margin-bottom: 10px; flex-shrink: 0;
}

/* Кнопки/модалки оставляем без изменений визуально */
.game-button {
  background: var(--card-bg);
  color: white;
  border: 2px solid var(--cube-color-1);
  padding: 10px 25px;
  border-radius: 8px;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  font-weight: bold;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  text-shadow: 0 0 5px var(--cube-glow);
  touch-action: manipulation;
  min-width: 80px;
  user-select: none;
  -webkit-user-select: none;
}
.game-button:hover:not(:disabled) {
  background: rgba(100,200,255,0.2);
  box-shadow: 0 0 20px var(--cube-glow);
  transform: translateY(-2px);
}
.game-button:disabled { opacity:.6; cursor:not-allowed; }
.help-button { padding: 10px 15px; min-width: 50px; font-size: 1.2rem; font-weight: bold; }

.help-content { text-align:left; margin-bottom:20px; max-height:60vh; overflow-y:auto; }
.help-section { margin-bottom:20px; }
.help-section h3 { color:var(--cube-color-1); margin-bottom:8px; font-size:1.1rem; }
.help-section p { margin-bottom:8px; line-height:1.4; }
.help-section ul { list-style:none; padding-left:15px; }
.help-section li { margin-bottom:4px; position:relative; padding-left:15px; }
.help-section li::before { content:"•"; color:var(--cube-color-1); position:absolute; left:0; }

.element-info { display:flex; align-items:center; margin-bottom:8px; gap:10px; }
.element-example {
  padding: 6px 12px 6px 35px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.8rem;
  min-width: 120px;
  position: relative;
  font-family: 'Courier New', monospace;
}
.element-example::before {
  content: '';
  position: absolute;
  left: 8px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; background: currentColor; border-radius: 2px; opacity: .7;
}

/* ===== ПАДАЮЩИЕ БЛОКИ: авто-ширина, авто-высота от иконки ===== */
.falling-element {
  position: absolute;
  display: inline-flex;            /* авто-ширина по содержимому */
  align-items: center;             /* высота берётся из контента (иконки + паддинги) */
  justify-content: flex-start;
  gap: var(--gap-icon-text);
  padding: 4px; 
  border-radius: 8px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  z-index: 10;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  will-change: transform, opacity;
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
  pointer-events: auto;
  /* никаких фиксированных min-height — высота от иконки */
}

/* Контентный wrapper (оставлен для совместимости) */
.element-content {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  height: auto;
  width: 100%;
}

/* Иконка: по умолчанию 20x20; можно менять размеры в HTML/CSS, блок подстроится */
.element-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  object-fit: contain;
  margin: 2px;
  pointer-events: none;
  backface-visibility: hidden;
}

/* Текст: влево, компактный, без ограничения высоты */
.element-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  pointer-events: none;
  /* правый отступ уже задан паддингом блока */
}

/* ===== Цвета и визуальные вариации ===== */
.element-code {
  background: var(--code-color);
  border: 2px solid #35455c;
  color: #eeeeee;
  box-shadow: 0 4px 12px rgba(45, 64, 89, 0.4);
}
.element-bug {
  background: var(--bug-color);
  border: 2px solid #cf1827;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(199, 0, 57, 0.5);
}
.element-bug-hard {
  background: var(--bug-hard-color);
  border: 2px solid #970228;
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(182, 1, 62, 0.6);
}
.element-boss-zigzag {
  background: var(--boss-color);
  border: 3px solid #970228;
  color: #ffffff;
  font-size: 0.9rem;
  box-shadow: 0 6px 25px rgba(182, 1, 62, 0.7);
}
.element-super-boss {
  background: var(--boss-color);
  border: 3px solid #970228;
  color: #ffffff;
  font-size: 0.95rem;
  box-shadow: 0 8px 30px rgba(182, 1, 62, 0.8);
}
.element-super-boss.mimic-green {
  background: var(--code-color);
  border: 3px solid #35455c;
  box-shadow: 0 8px 30px rgba(45, 64, 89, 0.6);
}
.element-timefix {
  background: var(--bonus-time-color);
  border: 2px solid #3971d8;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 119, 230, 0.5);
}
.element-systemwipe {
  background: var(--bonus-clean-color);
  border: 2px solid #ec6e25;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(255, 110, 26, 0.5);
}

/* ===== Анимации без transform, чтобы не было «скачков» ===== */
.falling-element.caught {
  animation: catchFade 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes catchFade {
  0% { opacity: 1; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* Модалки */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  cursor: default;
}
.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 12px;
  border: 2px solid var(--cube-color-1);
  text-align: center;
  max-width: 90%;
  width: 500px;
  max-height: 90vh;
  box-shadow: 0 0 40px var(--cube-glow-strong);
  backdrop-filter: blur(10px);
  cursor: default;
  overflow-y: auto;
}
.modal-content h2 {
  color: var(--cube-color-1);
  margin-bottom: 20px;
  text-shadow: 0 0 10px var(--cube-glow);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
}
.modal-stats { margin-bottom: 20px; }
.modal-stat {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding: 8px 12px;
  background: rgba(255,255,255,0.1); border-radius: 6px;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
}
.modal-stat strong { color: var(--cube-color-1); font-size: clamp(0.9rem, 3vw, 1.2rem); }

/* Частицы */
.particle {
  position: absolute; pointer-events: none; border-radius: 50%;
  z-index: 1000; will-change: transform, opacity; transform: translateZ(0);
}

/* Адаптация */
@media (max-width: 768px) {
  body { cursor: default; }
  .player-cursor { display: none !important; }
  .game-controls { flex-direction: row; justify-content: center; gap: 10px; }
  .game-button { padding: 12px 20px; font-size: 1rem; min-width: 90px; }
  .help-button { padding: 12px 15px; min-width: 55px; }
  .modal-content { padding: 20px; margin: 10px; width: 95%; }
  .element-text { max-width: 90px; }
}

@media (max-width: 480px) {
  .game-stats { flex-direction: row; flex-wrap: nowrap; gap: 3px; }
  .stat { flex: 1; justify-content: center; padding: 5px 8px; font-size: 0.7rem; }
  .stat-icon { display: none; }
  .game-button { padding: 10px 15px; font-size: 0.9rem; min-width: 70px; }
  .help-button { padding: 10px 12px; min-width: 50px; }
  .element-text { max-width: 80px; }
}

/* Tap feedback без transform */
@keyframes tapFeedback {
  0% { box-shadow: 0 0 0 rgba(255,255,255,0); }
  50% { box-shadow: 0 0 10px rgba(255,255,255,0.7); }
  100% { box-shadow: 0 0 0 rgba(255,255,255,0); }
}
.tap-feedback { animation: tapFeedback 0.2s ease; }
