:root {
  --field: #1c2318;
  --field-2: #2b3525;
  --ink: #ece8da;
  --ink-dim: #a7aa96;
  --paper: #e8e2cc;
  --contour: #8c5628;
  --blaze: #ff6a13;
  --blood: #d23a2a;
  --font: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", sans-serif;
  --font-cond: "Bahnschrift SemiCondensed", "Bahnschrift", "Roboto Condensed", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c4cfcc; color: var(--ink); font-family: var(--font); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
[hidden] { display: none !important; }

/* ---------- Меню ---------- */

#menu {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  align-items: center;
  gap: 48px;
  padding: 40px 56px;
  background: linear-gradient(90deg, rgba(22, 28, 19, 0.94) 0, rgba(22, 28, 19, 0.82) 440px, rgba(22, 28, 19, 0.2) 100%);
  overflow-y: auto;
}

.title {
  margin: 0;
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: clamp(64px, 9vw, 112px);
  line-height: 0.86;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.lede {
  margin: 18px 0 32px;
  max-width: 38ch;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.join label { display: block; font-size: 14px; color: var(--ink-dim); margin-bottom: 8px; }
.join-row { display: flex; gap: 8px; }
.join input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  font: 500 18px var(--font);
  color: var(--ink);
  background: var(--field-2);
  border: 1px solid #4a5841;
  border-radius: 3px;
}
.join input::placeholder { color: #7c8170; }
.join button {
  padding: 0 26px;
  font: 700 18px var(--font);
  color: #1a1206;
  background: var(--blaze);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.join button:hover { background: #ff8435; }
.join button:disabled { opacity: 0.55; cursor: default; }
.join input:focus-visible, .join button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.status { min-height: 1.4em; margin: 10px 0 0; font-size: 15px; color: #ffb27d; }

.roster { margin: 26px 0 28px; padding-top: 18px; border-top: 1px solid #3a4633; }
.roster h2 { margin: 0 0 6px; font-size: 14px; font-weight: 400; color: var(--ink-dim); }
.roster p { margin: 0; font-size: 17px; line-height: 1.4; }

.controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 16px;
  margin: 0;
  font-size: 14px;
  color: var(--ink-dim);
}
.controls dt { color: var(--ink); white-space: nowrap; }
.controls dd { margin: 0; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  margin-right: 2px;
  font: 600 12px var(--font);
  text-align: center;
  color: var(--ink);
  border: 1px solid #56644c;
  border-bottom-width: 2px;
  border-radius: 3px;
}

.sheet-map {
  justify-self: center;
  margin: 0;
  padding: 14px 14px 10px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(10, 14, 8, 0.45);
  transform: rotate(-1.2deg);
}
#menu-map { display: block; width: min(68vh, 560px, 100%); height: auto; aspect-ratio: 1; }
.sheet-map figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 9px;
  font-size: 13px;
  color: #4a4636;
}
#sheet { font-weight: 700; color: var(--contour); }

@media (max-width: 900px) {
  #menu { grid-template-columns: 1fr; padding: 28px 20px; gap: 28px; align-items: start; }
  .sheet-map { transform: none; justify-self: stretch; }
  #menu-map { width: 100%; }
}

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

#hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--font-cond); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }

#compass { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 480px; height: 38px; }
#grid-ref { position: absolute; top: 16px; left: 20px; font-size: 18px; white-space: pre; color: var(--ink); }

#crosshair { --gap: 8px; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: opacity 0.1s; }
#crosshair.off { opacity: 0; }
#crosshair i { position: absolute; background: rgba(240, 238, 225, 0.92); box-shadow: 0 0 2px rgba(0, 0, 0, 0.7); }
#crosshair i:nth-child(1) { width: 2px; height: 9px; left: -1px; bottom: var(--gap); }
#crosshair i:nth-child(2) { width: 2px; height: 9px; left: -1px; top: var(--gap); }
#crosshair i:nth-child(3) { width: 9px; height: 2px; top: -1px; right: var(--gap); }
#crosshair i:nth-child(4) { width: 9px; height: 2px; top: -1px; left: var(--gap); }

#hitmarker { position: absolute; left: 50%; top: 50%; opacity: 0; }
#hitmarker i { position: absolute; width: 2px; height: 10px; background: #fff; }
#hitmarker i:nth-child(1) { transform: translate(-9px, -16px) rotate(-45deg); }
#hitmarker i:nth-child(2) { transform: translate(8px, -16px) rotate(45deg); }
#hitmarker i:nth-child(3) { transform: translate(-9px, 6px) rotate(45deg); }
#hitmarker i:nth-child(4) { transform: translate(8px, 6px) rotate(-45deg); }
#hitmarker.head i { background: var(--blaze); height: 13px; }
#hitmarker.on { animation: flash 0.22s ease-out; }

#scope {
  position: absolute;
  inset: 0;
  --r: min(44vw, 47vh);
  background: radial-gradient(circle at 50% 50%, transparent 0 var(--r), #070806 calc(var(--r) + 3px));
}
#scope::before, #scope::after { content: ""; position: absolute; background: rgba(10, 10, 8, 0.85); }
#scope::before { left: 50%; top: 0; bottom: 0; width: 1.5px; transform: translateX(-50%); }
#scope::after { top: 50%; left: 0; right: 0; height: 1.5px; transform: translateY(-50%); }

#vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 30, 20, 0.55) 100%);
}
#vignette.on { animation: flash 0.9s ease-out; }

#dmg-dir {
  --angle: 0rad;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  margin: -110px 0 0 -110px;
  border-radius: 50%;
  border-top: 5px solid var(--blood);
  opacity: 0;
  transform: rotate(var(--angle));
}
#dmg-dir.on { animation: flash 1.4s ease-out; }

@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

#killfeed { position: absolute; top: 16px; right: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.feed-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 5px 10px;
  font-size: 16px;
  background: rgba(20, 25, 17, 0.6);
  border-radius: 2px;
  transition: opacity 1s;
}
.feed-row span { font-size: 13px; color: var(--ink-dim); }
.feed-row.mine { box-shadow: inset 3px 0 0 var(--blaze); }
.feed-row.gone, .chat-row.gone { opacity: 0; }

#chatlog { position: absolute; left: 20px; bottom: 130px; width: min(440px, 60vw); display: flex; flex-direction: column; gap: 3px; font-size: 16px; }
.chat-row { transition: opacity 1s; line-height: 1.3; }
.chat-row em { font-style: normal; color: var(--ink-dim); }
#chat-input {
  position: absolute;
  left: 20px;
  bottom: 94px;
  width: min(440px, 60vw);
  padding: 8px 10px;
  font: 16px var(--font);
  color: var(--ink);
  background: rgba(20, 25, 17, 0.85);
  border: 1px solid #56644c;
  border-radius: 3px;
  pointer-events: auto;
  outline: none;
}

#vitals { position: absolute; left: 20px; bottom: 20px; }
.hp { display: flex; align-items: center; gap: 12px; }
#hp-num { font-size: 44px; font-weight: 700; line-height: 1; min-width: 2.1ch; }
.bar { width: 170px; height: 8px; background: rgba(20, 25, 17, 0.65); border-radius: 1px; overflow: hidden; }
#hp-bar { height: 100%; background: var(--ink); transition: width 0.15s; }
#hp-bar.low { background: var(--blood); }
#stance { margin-top: 6px; font-size: 16px; color: var(--ink-dim); }

#arms { position: absolute; right: 22px; bottom: 20px; text-align: right; }
#arms .count { line-height: 1; }
#ammo { font-size: 44px; font-weight: 700; }
#reserve { margin-left: 6px; font-size: 20px; color: var(--ink-dim); }
#weapon-name { margin-top: 6px; font-size: 16px; color: var(--ink-dim); }
#arms-note { min-height: 1.2em; margin-top: 2px; font-size: 16px; color: var(--blaze); }

#map-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 19, 13, 0.55); }
#map-big { width: min(86vh, 720px, 92vw); height: auto; aspect-ratio: 1; border: 10px solid var(--paper); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }

#scoreboard { position: absolute; inset: 0; display: grid; place-items: center; }
#scoreboard table {
  min-width: 420px;
  border-collapse: collapse;
  background: rgba(20, 25, 17, 0.88);
  font-size: 18px;
  text-shadow: none;
}
#scoreboard th { padding: 12px 18px 8px; font-size: 14px; font-weight: 400; color: var(--ink-dim); text-align: right; }
#scoreboard th:first-child, #scoreboard td:first-child { text-align: left; }
#scoreboard td { padding: 8px 18px; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid #333f2d; }
#scoreboard td i { display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 50%; }
#scoreboard tr.me td { background: rgba(255, 106, 19, 0.14); }

#death { position: absolute; left: 0; right: 0; top: 58%; text-align: center; }
#death-text { margin: 0; font-size: 30px; font-weight: 700; }
#death-timer { margin: 6px 0 0; font-size: 18px; color: var(--ink-dim); }

#pause {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 19, 13, 0.5);
  pointer-events: auto;
  cursor: pointer;
}
#pause p { margin: 0; padding: 14px 22px; font-size: 22px; background: rgba(20, 25, 17, 0.85); border-left: 4px solid var(--blaze); }

@media (prefers-reduced-motion: reduce) {
  #hitmarker.on, #vignette.on, #dmg-dir.on { animation-duration: 0.01s; }
}
