:root {
  --bg: #12141a;
  --panel: #1a1d26;
  --panel-2: #222634;
  --line: #2e3342;
  --text: #e6e8ef;
  --muted: #8b91a5;
  --accent: #5aa9e6;
  --ok: #57c98a;
  --off: #6c7285;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
}

#map {
  position: absolute;
  inset: 0 320px 0 0;
  background: #0c0e13;
}

#panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: 320px;
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#panel h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

#panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
}
.status--on { color: var(--ok); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 40%, transparent); }
.status--off { color: var(--off); }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field span {
  font-size: 12px;
  color: var(--muted);
}
.field select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
}

.group { border-top: 1px solid var(--line); padding-top: 14px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 13px;
}
.list li.empty {
  background: none;
  color: var(--muted);
  font-style: italic;
  padding-left: 0;
}
.list li b { font-weight: 600; }
.list li .meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  white-space: nowrap;
}
.list li[data-clickable] { cursor: pointer; }
.list li[data-clickable]:hover { background: #2b3145; }

#panel footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* Маркеры на карте */
.player-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.player-marker .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0c0e13;
  box-shadow: 0 0 0 1px var(--accent);
}
.player-marker .tag {
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(12, 14, 19, 0.82);
  font-size: 11px;
  white-space: nowrap;
}

.waypoint-marker {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #0c0e13;
  border: 1px solid rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------------------
   Экран входа
   --------------------------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

/* Собственный display перебивает браузерное [hidden] { display: none },
   поэтому скрытие приходится объявлять явно. */
.gate[hidden] {
  display: none;
}

.gate__card {
  width: min(380px, 100%);
  padding: 26px 24px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gate__card h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
}
.gate__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.gate__hint code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--text);
}

.gate__input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-size: 19px;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}
.gate__input:focus {
  outline: none;
  border-color: var(--accent);
}

.gate__submit {
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0b1017;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.gate__submit:hover { filter: brightness(1.08); }
.gate__submit:disabled { opacity: 0.55; cursor: default; }

.gate__error {
  margin: 0;
  font-size: 13px;
  color: #ff8a8a;
}

/* ---------------------------------------------------------------------------
   Профиль игрока и майнкрафтовые шкалы
   --------------------------------------------------------------------------- */

.profile {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 340px;
  max-height: calc(100% - 32px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(20, 23, 31, 0.97);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

/* Та же история, что и с экраном входа: display: flex сильнее [hidden]. */
.profile[hidden] {
  display: none;
}

.profile__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.profile__head h2 {
  margin: 0;
  font-size: 15px;
}
.profile__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.profile__close:hover { color: var(--text); }

.profile__tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
}
.tab {
  flex: 1;
  padding: 7px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tab--active { color: var(--text); background: #2b3145; }

.profile__body {
  padding: 12px 14px 16px;
  overflow-y: auto;
}

/* Шкалы: сердца, броня, голод — по половинке на единицу, как в игре. */
.vitals { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.bar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.bar .icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}
.bar .value {
  margin-left: 6px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.icon--empty { opacity: 0.22; }
.icon--half { clip-path: inset(0 50% 0 0); }
.icon--half-bg { position: relative; }

.effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.effect {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #34305a;
  color: #cfc8ff;
}

/* Сетка инвентаря повторяет раскладку игры: броня и рюкзак сверху, хотбар снизу. */
.inv-group { margin-bottom: 12px; }
.inv-group h3 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
}
.inv-grid--narrow { grid-template-columns: repeat(5, 1fr); }

.slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  background: #14171f;
  border: 1px solid #2b3040;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.slot--filled { background: #232838; border-color: #3a4358; }
.slot .abbr {
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
  color: #b9c0d4;
  padding: 1px;
  word-break: break-all;
}

/* Картинка предмета перекрывает подпись; если её нет, остаётся подпись. */
.icon-item {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  object-fit: contain;
  /* Анимированные текстуры приходят вертикальной лентой кадров — показываем верхний. */
  object-position: top;
  image-rendering: pixelated;
  background: inherit;
}
.slot:has(.icon-item) .abbr { display: none; }
.slot .count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}
.slot .durability {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 2px;
  border-radius: 1px;
  background: #000;
}
.slot .durability i {
  display: block;
  height: 100%;
  border-radius: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.stat-row span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Подсказка над игроком */
.player-tip .bar { margin-top: 2px; }
.player-tip .gear {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.player-tip .gear span {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #2b3145;
  color: #c8cee0;
}
.leaflet-tooltip.player-tip {
  background: rgba(12, 14, 19, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
}
.leaflet-tooltip.player-tip::before { border-top-color: var(--line); }

.player-marker .dot { cursor: pointer; }

/* Карта пиксельная: сглаживание при увеличении превращает блоки в кашу. */
.atlas-tiles {
  image-rendering: pixelated;
}

/* Тёмная подложка карты глушит тонкие рамки схем — добавляем свечение,
   чтобы они читались и поверх воды, и поверх суши. */
.placement-rect {
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9));
}

.leaflet-container {
  background: #0c0e13;
  font: inherit;
}

@media (max-width: 900px) {
  #map { inset: 0 0 45% 0; }
  #panel { inset: 55% 0 0 0; width: auto; border-left: none; border-top: 1px solid var(--line); }
}
