body { background: #151515; margin: 0; overflow: hidden; color: #fff; font-family: sans-serif; user-select: none; touch-action: none; }

#mainMenu { position: absolute; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background: url('../images/floor.png') repeat; z-index: 50; }
.menu-box { background: rgba(0,0,0,0.85); padding: 40px; border-radius: 15px; border: 2px solid #333; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); width: 90%; max-width: 400px; box-sizing: border-box; }
.menu-title { font-size: 35px; margin-bottom: 30px; color: #FFD700; text-shadow: 0 2px 5px #000; }
.menu-btn { display: block; width: 100%; margin: 15px 0; padding: 15px 20px; font-size: 16px; font-weight: bold; background: #333; color: #fff; border: 2px solid #555; border-radius: 8px; cursor: pointer; transition: 0.2s; text-transform: uppercase; }
.menu-btn:hover { background: #4CAF50; border-color: #4CAF50; transform: scale(1.05); }

#gameContainer { display: none; width: 100%; height: 100%; }
#hud { position: absolute; top: 0; left: 0; width: 100%; height: 50px; background: rgba(0,0,0,0.85); display: flex; justify-content: space-between; align-items: center; padding: 0 20px; box-sizing: border-box; z-index: 10; font-weight: bold; border-bottom: 2px solid #333; }
#hudCenter { display: flex; gap: 20px; flex-grow: 1; justify-content: center; font-size: 14px; }
#exitBtnHud { background: transparent; color: #F44336; border: 1px solid #F44336; padding: 6px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; text-transform: uppercase; }
canvas { display: block; image-rendering: pixelated; }

.controls-hint { position: absolute; width: 100%; text-align: center; color: rgba(255,255,255,0.4); text-transform: uppercase; font-size: 12px; letter-spacing: 2px; z-index: 10; pointer-events: none; }

/* --- МОБИЛЬНЫЕ КНОПКИ --- */
#mobileControls {
  position: absolute; bottom: 20px; left: 0; width: 100%; display: none; justify-content: space-between; padding: 0 20px; box-sizing: border-box; z-index: 15; pointer-events: none;
}
.m-btn {
  background: rgba(255, 255, 255, 0.15); border: 2px solid rgba(255, 255, 255, 0.4); color: white; border-radius: 50%; 
  font-size: 24px; pointer-events: auto; user-select: none; touch-action: manipulation; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(4px);
}
.m-btn:active { background: rgba(255, 255, 255, 0.4); transform: scale(0.95); }
#dpad { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.dpad-row { display: flex; gap: 5px; }
#dpad .m-btn { width: 55px; height: 55px; }
#btnAttack { width: 80px; height: 80px; align-self: flex-end; margin-bottom: 10px; background: rgba(255, 50, 50, 0.25); border-color: rgba(255, 50, 50, 0.5); font-size: 30px; }
#btnAttack:active { background: rgba(255, 50, 50, 0.6); }

@media (max-width: 1024px) {
  #mobileControls { display: flex; }
  .controls-hint { display: none !important; }
}

/* ИСПРАВЛЕНИЕ ДЛЯ УЗКИХ ЭКРАНОВ: Разносим кнопку и статистику по краям */
@media (max-width: 600px) {
  #hudCenter { 
    flex-direction: column; 
    gap: 1px; 
    align-items: flex-end; /* Выравниваем текст игроков по правому краю */
  }
  #hud > div:last-child {
    display: none; /* Скрываем пустую распорку, чтобы статистика ушла в самый правый угол */
  }
}

.overlay-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 20; text-align: center; }
#gameOverTitle { font-size: 45px; margin-bottom: 10px; }
#gameOverText { font-size: 18px; color: #ccc; margin-bottom: 35px; }
.btn { padding: 16px 20px; font-size: 16px; font-weight: bold; border: none; border-radius: 12px; cursor: pointer; transition: 0.2s; text-transform: uppercase; margin: 0 5px; }
#restartBtn { background: #FFD700; color: #111; }
#quitBtn { background: #333; color: #fff; border: 1px solid #555; }
#waitText { display: none; font-size: 20px; color: #FFD700; margin-top: 20px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.7; } 50% { opacity: 1; } 100% { opacity: 0.7; } }

/* Верхняя панель */
.top-bar {
  display: flex; 
  justify-content: space-between; 
  width: 100%; 
  max-width: 600px; 
  margin-bottom: 10px;
}
.back-btn { 
  position: absolute; /* Вырываем кнопку из общего потока центрирования */
  top: 20px;          /* Прижимаем к верхнему краю экрана */
  left: 20px;         /* Прижимаем к левому краю экрана */
  background: rgba(0,0,0,0.5); 
  color: white; 
  text-decoration: none; 
  padding: 8px 15px; 
  border-radius: 8px; 
  font-weight: bold; 
  font-size: 14px; 
  border: 1px solid #fff; 
  cursor: pointer;
  z-index: 1001;
}