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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #87ceeb;
  font-family: "Segoe UI", Verdana, sans-serif;
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas { image-rendering: pixelated; }

/* ---------------------------------------------------------------- HUD */

#crosshair {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -52%);
  color: #fff; font-size: 26px; font-weight: bold;
  text-shadow: 0 0 4px rgba(0,0,0,.8);
  pointer-events: none; z-index: 5;
}

#topbar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 24, 30, .72);
  color: #fff; font-size: 15px;
  padding: 7px 16px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,.15);
  white-space: nowrap; pointer-events: none; z-index: 5;
}
#topbar b { color: #ffd34d; }

#plist {
  position: fixed; top: 10px; right: 10px;
  width: 210px; z-index: 5; pointer-events: none;
}
.prow {
  background: rgba(20,24,30,.72); color: #fff;
  border-radius: 6px; padding: 5px 8px; margin-bottom: 4px;
  font-size: 13px; border: 1px solid rgba(255,255,255,.12);
}
.prow.me { border-color: #ffd34d; }
.prow.dead { opacity: .55; }
.prow .pname { display: block; font-weight: 600; margin-bottom: 3px; }
.prow .pname em { font-style: normal; color: #ffd34d; font-size: 12px; }
.prow .pbar { display: block; height: 6px; background: rgba(0,0,0,.5); border-radius: 3px; overflow: hidden; }
.prow .pbar i { display: block; height: 100%; background: linear-gradient(90deg, #4dc94d, #8de24a); }
.prow.dead .pbar i { background: #777; }

#feed {
  position: fixed; top: 56px; left: 12px;
  z-index: 5; pointer-events: none; max-width: 46vw;
}
.fitem {
  background: rgba(20,24,30,.72); color: #eee;
  padding: 5px 11px; margin-bottom: 4px; border-radius: 6px;
  font-size: 14px; transition: opacity .6s;
  border-left: 3px solid #888;
}
.fitem.kill { border-left-color: #e25555; }
.fitem.wave { border-left-color: #4da9e2; color: #cfe9ff; font-weight: 600; }
.fitem.sys  { border-left-color: #ffd34d; }
.fitem.fade { opacity: 0; }

#hearts {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  font-size: 22px; letter-spacing: 2px; z-index: 5; pointer-events: none;
  text-shadow: 0 2px 3px rgba(0,0,0,.6);
}
#hearts .on  { color: #e8413c; }
#hearts .off { color: rgba(20,20,20,.45); }

#air {
  position: fixed; bottom: 116px; left: 50%; transform: translateX(-50%);
  font-size: 15px; letter-spacing: 4px; z-index: 5; pointer-events: none;
}
#air .on  { color: #6fc6ff; text-shadow: 0 0 4px rgba(0,40,120,.8); }
#air .off { color: rgba(10,30,60,.35); }

#hotbar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 5;
}
.slot {
  position: relative; width: 62px; height: 62px;
  background: rgba(30,34,40,.8);
  border: 3px solid #5a5f66; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.slot.sel { border-color: #ffd34d; box-shadow: 0 0 12px rgba(255,211,77,.5); }
.slot canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.slot .key { position: absolute; top: 1px; left: 4px; font-size: 11px; color: #bbb; }
.slot .lab {
  position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; white-space: nowrap;
}

#hint {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%);
  background: rgba(20,24,30,.65); color: #ffe9a8;
  padding: 6px 14px; border-radius: 7px; font-size: 14px;
  z-index: 5; pointer-events: none; display: none; white-space: nowrap;
}

#banner {
  position: fixed; top: 22%; left: 50%; transform: translate(-50%, -50%) scale(.9);
  font-size: 30px; font-weight: 800; color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 22px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 8; text-align: center; max-width: 90vw;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

#countdown {
  position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-size: 120px; font-weight: 900; color: #ffd34d;
  text-shadow: 0 6px 0 rgba(0,0,0,.5);
  pointer-events: none; z-index: 9;
}

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 7;
  box-shadow: inset 0 0 120px rgba(200, 0, 0, 0);
}
#vignette.hit { animation: hitflash .5s ease-out; }
@keyframes hitflash {
  0%   { box-shadow: inset 0 0 140px rgba(220, 20, 20, .85); }
  100% { box-shadow: inset 0 0 120px rgba(220, 20, 20, 0); }
}

#waterfx {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background: rgba(30, 80, 200, .25);
}

/* ---------------------------------------------------------------- сензорни контроли */
#touch {
  position: fixed; inset: 0; z-index: 8;
  pointer-events: none; /* само бутоните/джойстикът хващат допир */
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#touch .joy {
  position: absolute; left: 26px; bottom: 26px;
  width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14), rgba(20,24,30,.34));
  border: 2px solid rgba(255,255,255,.35);
  pointer-events: auto; touch-action: none;
}
#touch .joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: rgba(255,255,255,.8);
  border: 2px solid rgba(40,44,50,.5);
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
#touch .tbtns {
  position: absolute; right: 20px; bottom: 24px;
  display: grid; grid-template-columns: repeat(2, auto); gap: 12px;
  align-items: end; justify-items: center;
}
#touch .ttop {
  position: absolute; right: 18px; top: 14px;
  display: flex; gap: 10px;
}
#touch .ctl {
  pointer-events: auto; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  width: 66px; height: 66px; border-radius: 50%;
  font-size: 26px; line-height: 1; color: #fff;
  background: rgba(30,34,40,.66); border: 2px solid rgba(255,255,255,.4);
  text-shadow: 0 1px 2px #000; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#touch .ctl.big { width: 84px; height: 84px; font-size: 34px; }
#touch .ctl.sm { width: 46px; height: 46px; font-size: 18px; border-radius: 12px; }
#touch .ctl.dig   { background: rgba(120,70,30,.7); grid-column: 2; }
#touch .ctl.place { background: rgba(40,90,140,.7); }
#touch .ctl.jump  { background: rgba(40,120,70,.7); }
#touch .ctl.sprint { background: rgba(110,60,140,.7); }
#touch .ctl.on { filter: brightness(1.45); border-color: #ffd34d; }
#touch .ctl:active { filter: brightness(1.3); }

/* ---------------------------------------------------------------- наслагвания */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
}

.overlay.soft { background: none; z-index: 10; pointer-events: none; }
.overlay.soft > div {
  background: rgba(120, 10, 10, .82); color: #fff;
  font-size: 22px; font-weight: 700;
  padding: 14px 26px; border-radius: 10px;
  border: 2px solid rgba(255,255,255,.25);
}

.overlay.big { background: rgba(0,0,0,.35); z-index: 15; pointer-events: none; }
.wintext {
  font-size: 44px; font-weight: 900; color: #ffd34d; text-align: center;
  text-shadow: 0 4px 0 rgba(0,0,0,.6);
  background: rgba(20,24,30,.85);
  padding: 26px 42px; border-radius: 16px;
  border: 4px solid #ffd34d;
  animation: winpop .5s ease-out; max-width: 90vw;
}
@keyframes winpop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#loading { background: rgba(15, 20, 28, .85); color: #fff; font-size: 20px; }
.spin {
  width: 46px; height: 46px;
  border: 5px solid rgba(255,255,255,.25); border-top-color: #ffd34d;
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#pause, #disc, #advend { background: rgba(10, 14, 20, .72); z-index: 25; }
#advend { z-index: 26; }

/* ---------------------------------------------------------------- бутони */

.btn {
  display: block; width: 100%;
  font-size: 17px; font-weight: 800; letter-spacing: .5px;
  padding: 12px; margin-top: 10px; cursor: pointer;
  color: #fff; border-radius: 9px; border: 3px solid rgba(0,0,0,.35);
  transition: transform .07s, box-shadow .07s, filter .1s;
}
.btn:hover { filter: brightness(1.09); }
.btn:active { transform: translateY(3px); }
.btn.big { font-size: 23px; letter-spacing: 2px; padding: 14px; }
.btn-green { background: linear-gradient(180deg, #62b33e, #3f8f23); border-color: #2c5f1a; box-shadow: 0 5px 0 #2c5f1a; }
.btn-green:active { box-shadow: 0 2px 0 #2c5f1a; }
.btn-blue  { background: linear-gradient(180deg, #3f8fe0, #2a66b8); border-color: #1d4f93; box-shadow: 0 5px 0 #1d4f93; }
.btn-blue:active { box-shadow: 0 2px 0 #1d4f93; }
.btn-grey  { background: linear-gradient(180deg, #6b7079, #4c515a); border-color: #353941; box-shadow: 0 5px 0 #353941; }
.btn-grey:active { box-shadow: 0 2px 0 #353941; }
.btn.disabled { opacity: .45; pointer-events: none; filter: grayscale(.6); }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 10px; }

/* ---------------------------------------------------------------- меню */

#menu {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255,255,255,.25), transparent),
    linear-gradient(180deg, #6db3e8 0%, #87ceeb 45%, #79c05a 100%);
  z-index: 30;
  overflow: hidden;
}

/* Снимка от играта като фон на началния екран + ефект „движение на пикселите“ */
#menu::before {
  content: "";
  position: absolute; inset: -6%;
  background: url("../img/menu-bg.png") center / cover no-repeat;
  image-rendering: pixelated;
  z-index: -2;
  animation: menubg-drift 14s ease-in-out infinite alternate;
}
#menu::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(10, 14, 20, .45);
  z-index: -1;
}
@keyframes menubg-drift {
  0%   { transform: scale(1.06) translate(0, 0); }
  25%  { transform: scale(1.07) translate(-0.6%, 0.5%); }
  50%  { transform: scale(1.08) translate(0.6%, -0.4%); }
  75%  { transform: scale(1.07) translate(-0.4%, -0.6%); }
  100% { transform: scale(1.06) translate(0.5%, 0.6%); }
}

.panel {
  background: rgba(28, 34, 24, .93);
  border: 4px solid #54442b;
  outline: 4px solid rgba(0,0,0,.25);
  border-radius: 14px;
  padding: 26px 38px;
  text-align: center;
  color: #fff;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
  max-width: 560px; width: calc(100vw - 30px);
}
.panel.small { max-width: 420px; }
.panel.small h2 { margin-bottom: 6px; }
.panel.small p { color: #ccc; margin-bottom: 4px; }
.menu-panel { max-width: 600px; }

.panel h1 {
  font-size: 32px; letter-spacing: 1px; color: #8de24a;
  text-shadow: 0 3px 0 rgba(0,0,0,.5);
}
.panel h2 { font-size: 26px; color: #ffd34d; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.panel h3 { font-size: 19px; color: #cfe9ff; margin-bottom: 12px; }
.subtitle {
  font-size: 17px; font-weight: 800; letter-spacing: 6px; color: #ffd34d;
  margin: 2px 0 14px; text-shadow: 0 2px 0 rgba(0,0,0,.5);
}

.panel label { display: block; text-align: left; font-size: 13px; color: #b9c7ae; margin-bottom: 5px; }
.panel input[type=text] {
  width: 100%; font-size: 19px; font-weight: 700; text-align: center;
  padding: 10px; border-radius: 8px;
  border: 3px solid #54442b; background: #20261b; color: #fff;
  outline: none; margin-bottom: 12px;
}

.mode-pill {
  background: rgba(0,0,0,.3); border-radius: 20px;
  padding: 6px 14px; font-size: 14px; color: #d8e6cf; margin-bottom: 6px;
}
.mode-pill span { color: #ffd34d; font-weight: 700; }

#m-status { min-height: 20px; color: #ffb84d; font-size: 14px; margin-top: 10px; }
.points { margin-top: 8px; color: #ffd34d; font-weight: 700; font-size: 15px; }

/* карти за избор на режим */
.cards { display: flex; gap: 12px; margin-bottom: 6px; }
.card {
  flex: 1; cursor: pointer;
  background: rgba(0,0,0,.28); border: 3px solid #54442b; border-radius: 12px;
  padding: 16px 12px; transition: transform .1s, border-color .1s, background .1s;
}
.card:hover { transform: translateY(-3px); background: rgba(0,0,0,.4); }
.card.sel { border-color: #8de24a; box-shadow: 0 0 14px rgba(141,226,74,.4); }
.card-emoji { font-size: 40px; }
.card-title { font-size: 18px; font-weight: 800; color: #ffd34d; margin: 6px 0; }
.card-desc { font-size: 12.5px; color: #d2dcc8; line-height: 1.5; }

/* настройки */
.setting { text-align: left; margin-bottom: 14px; }
.setting label { color: #d8e6cf; font-size: 14px; margin-bottom: 6px; }
.setting label span { color: #ffd34d; font-weight: 700; float: right; }
.setting input[type=range] { width: 100%; accent-color: #8de24a; cursor: pointer; }
.setting-row { display: flex; align-items: center; justify-content: space-between; }
.setting-row label { margin-bottom: 0; }
.setting-row input[type=checkbox] { width: 22px; height: 22px; accent-color: #8de24a; cursor: pointer; }

.help {
  margin-top: 16px; font-size: 12.5px; line-height: 1.7; color: #c9d6bf;
  background: rgba(0,0,0,.25); border-radius: 8px; padding: 10px 12px;
}
.help b { color: #ffd34d; }
.help .muted { color: #9fb091; }

.advend-text { font-size: 18px; color: #eee; line-height: 1.6; margin: 8px 0 4px; }
