* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0c08;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
}

#game {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  cursor: pointer;
  outline: none;
}

#vignette {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 100%);
  z-index: 5;
}

#dmgFlash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background: rgba(200, 30, 20, 0);
  z-index: 6;
}

.hidden {
  display: none !important;
}

/* ---------- Меню ---------- */
#menu {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60,90,40,0.25), rgba(0,0,0,0.9) 70%),
    linear-gradient(180deg, #10130c 0%, #050603 100%);
}

.menu-box {
  width: 380px;
  max-width: 90vw;
  padding: 36px 32px;
  background: rgba(15, 18, 12, 0.85);
  border: 1px solid #3b4a2f;
  border-radius: 10px;
  box-shadow: 0 0 60px rgba(90, 200, 60, 0.08), inset 0 0 30px rgba(0,0,0,0.6);
  text-align: center;
}

.menu-box h1 {
  margin: 0 0 6px 0;
  font-size: 46px;
  letter-spacing: 6px;
  color: #d7e6c9;
  text-shadow: 0 0 18px rgba(120, 220, 90, 0.55);
}

.menu-box h1 span {
  color: #7bd93f;
  text-shadow: 0 0 22px rgba(123, 217, 63, 0.9);
}

.subtitle {
  color: #8a9a7c;
  font-size: 13px;
  margin: 0 0 22px 0;
  line-height: 1.5;
}

#nickInput {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid #4a5a3c;
  background: #1a1f15;
  color: #e8f0dd;
  outline: none;
  margin-bottom: 14px;
  letter-spacing: 1px;
}
#nickInput:focus {
  border-color: #7bd93f;
  box-shadow: 0 0 12px rgba(123, 217, 63, 0.35);
}

#playBtn {
  width: 100%;
  padding: 13px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(180deg, #8fe84a, #4f9f22);
  color: #0c1406;
  cursor: pointer;
  box-shadow: 0 4px 0 #2f6011, 0 0 18px rgba(123, 217, 63, 0.4);
  transition: transform 0.08s ease;
}
#playBtn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2f6011;
}
#playBtn:disabled {
  opacity: 0.5;
  cursor: default;
}

.controls-hint {
  margin-top: 20px;
  font-size: 12px;
  color: #7c8a6e;
  line-height: 1.8;
  border-top: 1px solid #2c3524;
  padding-top: 14px;
}
.controls-hint b {
  color: #b9d99c;
}

#menuMsg {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
  color: #e05a4e;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10;
  pointer-events: none;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#crosshair::before,
#crosshair::after {
  content: '';
  position: absolute;
  background: rgba(230, 240, 220, 0.85);
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}
#crosshair::before {
  top: 50%;
  left: 2px;
  right: 2px;
  height: 2px;
  transform: translateY(-50%);
}
#crosshair::after {
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 2px;
  transform: translateX(-50%);
}

#topLeft {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 260px;
}

#hpBarWrap {
  position: relative;
  height: 26px;
  background: rgba(20, 10, 10, 0.7);
  border: 1px solid #5a2c22;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

#hpBarFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d43a2f, #ef7b3a);
  transition: width 0.15s ease;
}

#hpBarLabel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff2e8;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#scoreLine {
  margin-top: 10px;
  color: #e6dcc9;
  font-size: 15px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#scoreValue {
  color: #ffd54a;
}
#killsLine {
  margin-top: 4px;
  color: #d7e6c9;
  font-size: 13px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#killsValue {
  color: #7bd93f;
  font-weight: 700;
}

/* Шкала стамины: убывает симметрично к центру (flex-центрирование заполнения). */
#staminaWrap {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 9px;
  background: rgba(12, 14, 9, 0.55);
  border: 1px solid #3b4a2f;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
#staminaFill {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #46b0e6, #8fe3ff, #46b0e6);
  transition: width 0.08s linear;
}
#staminaFill.low {
  background: linear-gradient(90deg, #e0803a, #e0a53a, #e0803a);
}
#staminaFill.exhausted {
  background: linear-gradient(90deg, #b23a2c, #d0574a, #b23a2c);
}

#weaponName {
  margin-top: 8px;
  color: #cdd6c2;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

/* Подсказка выбора улучшения оружия (Q/E) — сверху по центру. */
#upgradePrompt {
  position: absolute;
  left: 50%;
  top: 60px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
#upgradePrompt.hidden {
  display: none;
}
.up-title {
  color: #ffd54a;
  font-size: 14px;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  animation: upPulse 1.1s ease-in-out infinite;
}
@keyframes upPulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
.up-cards {
  display: flex;
  gap: 14px;
  justify-content: center;
}
.up-card {
  width: 190px;
  background: rgba(12, 14, 9, 0.82);
  border: 2px solid #3b4a2f;
  border-radius: 8px;
  padding: 8px 12px 10px;
  pointer-events: auto; /* карточки кликабельны/тапабельны */
  cursor: pointer;
}
.up-skin {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: contain;
  margin: 4px 0 6px;
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0) 70%);
}
.up-key {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  margin-bottom: 5px;
  background: #e8e2d2;
  color: #1a1c14;
  border-radius: 5px;
  font-weight: 800;
  font-size: 13px;
}
.up-name {
  color: #f0f4e8;
  font-weight: 700;
  font-size: 14px;
}
.up-desc {
  color: #9fb089;
  font-size: 11px;
  margin-top: 3px;
}

#leaderboard {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 190px;
  background: rgba(12, 14, 9, 0.65);
  border: 1px solid #3b4a2f;
  border-radius: 6px;
  padding: 10px 12px;
}
.lb-title {
  font-size: 11px;
  letter-spacing: 2px;
  color: #8fae74;
  margin-bottom: 6px;
  border-bottom: 1px solid #2c3524;
  padding-bottom: 6px;
}
#lbList div {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #d7e6c9;
  padding: 2px 0;
}
#lbList div b {
  color: #7bd93f;
}

#killfeed {
  position: absolute;
  bottom: 18px;
  right: 18px;
  width: 260px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.kf-item {
  font-size: 12px;
  color: #d7e6c9;
  background: rgba(10, 12, 8, 0.55);
  padding: 4px 10px;
  border-radius: 4px;
  opacity: 1;
  transition: opacity 1.2s ease;
}
.kf-item.fade {
  opacity: 0;
}
.kf-item .kf-zombie { color: #7bd93f; }
.kf-item .kf-death { color: #e05a4e; }

#minimap {
  position: absolute;
  bottom: 18px;
  left: 18px;
  background: rgba(10, 12, 8, 0.65);
  border: 1px solid #3b4a2f;
  border-radius: 6px;
}

#connStatus {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #e0a53a;
}

#deathOverlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 4, 4, 0.35);
  pointer-events: none;
}
.death-box {
  text-align: center;
}
.death-title {
  font-size: 42px;
  letter-spacing: 6px;
  color: #e05a4e;
  text-shadow: 0 0 22px rgba(224, 90, 78, 0.7);
  margin-bottom: 10px;
}
#respawnTimer {
  font-size: 16px;
  color: #d7e6c9;
}

#resumeOverlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 3, 0.55);
  cursor: pointer;
}
.resume-box {
  padding: 16px 28px;
  border: 1px solid #3b4a2f;
  border-radius: 8px;
  background: rgba(15, 18, 12, 0.85);
  color: #d7e6c9;
  font-size: 16px;
  letter-spacing: 1px;
}

/* ==================== Тач-управление (телефон/планшет) ==================== */
#game { touch-action: none; } /* жесты обзора не скроллят/зумят страницу */
/* В тач-режиме гасим нативные жесты (pull-to-refresh, скролл, выделение, callout),
   иначе драг-обзор перехватывается браузером. */
body.touch {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#touchControls {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none; /* активны только сами элементы */
  touch-action: none;
}
#touchControls.hidden { display: none; }

#moveStick {
  position: absolute;
  left: 22px;
  bottom: 26px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(20, 24, 16, 0.35);
  border: 2px solid rgba(140, 170, 116, 0.4);
  pointer-events: auto;
}
#moveKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(190, 220, 160, 0.55);
  border: 2px solid rgba(230, 240, 220, 0.6);
}

.touch-btn {
  position: absolute;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(20, 24, 16, 0.4);
  border: 2px solid rgba(140, 170, 116, 0.45);
  color: #e8f0dd;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  -webkit-user-select: none;
  user-select: none;
}
.touch-btn.on {
  background: rgba(120, 200, 90, 0.5);
  border-color: #a8e07a;
}
#fireBtn {
  right: 26px;
  bottom: 30px;
  width: 100px;
  height: 100px;
  font-size: 15px;
  background: rgba(150, 50, 40, 0.42);
  border-color: rgba(224, 90, 78, 0.6);
}
#fireBtn.on { background: rgba(210, 70, 55, 0.6); }
#aimBtn {
  right: 138px;
  bottom: 92px;
  width: 72px;
  height: 72px;
}
#jumpBtn {
  right: 140px;
  bottom: 12px;
  width: 72px;
  height: 72px;
}
#sprintBtn {
  right: 32px;
  bottom: 140px;
  width: 72px;
  height: 72px;
}

/* ==================== Адаптив под узкие экраны ==================== */
@media (max-width: 820px) {
  .menu-box {
    padding: 22px 20px;
    width: 90vw;
    max-width: 420px;
  }
  .menu-box h1 { font-size: 40px; }
  .subtitle { font-size: 13px; }
  #topLeft { width: 190px; top: 10px; left: 10px; }
  #hpBarWrap { height: 22px; }
  #hpBarLabel { font-size: 12px; }
  #scoreLine { font-size: 14px; }
  #killsLine, #weaponName { font-size: 11px; }
  #leaderboard { width: 140px; top: 10px; right: 10px; padding: 8px 10px; }
  .lb-title { font-size: 10px; }
  #lbList div { font-size: 11px; }
  /* миникарту — в правый нижний угол над кнопками, чтобы не мешала джойстику */
  #minimap { width: 110px; height: 110px; left: auto; right: 12px; bottom: auto; top: 84px; }
  #killfeed { font-size: 11px; bottom: auto; top: 150px; left: 10px; max-width: 45vw; }
  /* полоса стамины — прижата к нижней кромке экрана (ниже джойстика/кнопок) */
  #staminaWrap { width: 88vw; bottom: calc(6px + env(safe-area-inset-bottom, 0px)); height: 8px; }
  #upgradePrompt { top: 46px; width: 96vw; }
  .up-cards { gap: 8px; }
  .up-card { width: 44vw; max-width: 190px; padding: 6px 8px 8px; }
  .up-skin { height: 68px; }
  .up-name { font-size: 12px; }
  .up-desc { font-size: 10px; }
  .up-title { font-size: 12px; }
}

/* На телефоне скрываем клавиатурную подсказку и показываем тач-подсказку. */
.touch-hint { display: none; }
body.touch .controls-hint:not(.touch-hint) { display: none; }
body.touch .touch-hint { display: block; }

/* ==================== Записка в избе ==================== */
#readPrompt {
  position: absolute;
  left: 50%;
  bottom: 20%;
  transform: translateX(-50%);
  z-index: 25;
  padding: 10px 20px;
  background: rgba(12, 14, 9, 0.8);
  border: 1px solid #b89a5a;
  border-radius: 8px;
  color: #f0e6c8;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  pointer-events: auto;
  animation: upPulse 1.3s ease-in-out infinite;
}
#readPrompt.hidden { display: none; }
body:not(.touch) #readPrompt::before { content: 'F — '; color: #ffd54a; }

#noteOverlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 1, 0, 0.9);
  cursor: pointer;
}
#noteOverlay.hidden { display: none; }
.note-paper {
  width: min(78vw, 460px);
  min-height: 300px;
  padding: 48px 40px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
  /* Старая пожелтевшая бумага с пятнами и затемнёнными краями */
  background:
    radial-gradient(ellipse at 22% 28%, rgba(50,32,14,0.4), rgba(0,0,0,0) 42%),
    radial-gradient(ellipse at 80% 74%, rgba(40,24,10,0.45), rgba(0,0,0,0) 46%),
    radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(20,12,4,0.5)),
    linear-gradient(160deg, #ad9868, #85704a);
  border: 1px solid #6e5a34;
  border-radius: 4px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.8), inset 0 0 70px rgba(30, 18, 6, 0.55);
  transform: rotate(-1.4deg);
  filter: contrast(1.05) saturate(0.9);
}
.note-body {
  color: #201408;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 26px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 1px 0 rgba(210, 190, 150, 0.25);
}
.note-hint {
  color: #6b5836;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.5px;
}
