@font-face {
  font-family: "Pixelify Sans";
  src: url("../fonts/PixelifySans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
  font-synthesis: none;
}
@font-face {
  font-family: "Pixelify Sans";
  src: url("../fonts/PixelifySans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: block;
  font-synthesis: none;
}

:root {
  --birch: #f6e7b8;
  --oak: #4a2a12;
  --thick: #b47a3a;
  --moss: #aae26a;
  --moss-dark: #5e9e2e;
  --panel: #6a3e1e;
  --panel2: #7a4a24;
  --panel3: #5a3418;
  --accent: #ffd11e;
  --danger: #ff4a6e;
  --disabled: #c2b49a;
  --disabled-text: #8a7a5e;
  --px: 3px;
  --leaf: #5ed24a;
  --sky: #35c7f0;
  --ui-font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --pixel-font: "Pixelify Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1026;
  color: #f3e7c9;
  font-family: var(--ui-font);
  font-size: 17px;
  line-height: 1.5;
  user-select: none;
  image-rendering: pixelated;
}
#title,
#splash,
#death-title,
.panel-title,
.mode-name,
.corner {
  font-family: var(--pixel-font);
}

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

.hidden {
  display: none !important;
}

/* ---------- Кнопки: деревянные, крупные, объёмные ---------- */
.btn {
  position: relative;
  display: block;
  min-height: 50px;
  padding: 10px 22px 12px;
  background-color: var(--birch);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  background-repeat: repeat;
  color: var(--oak);
  border: 3px solid var(--oak);
  border-bottom-width: 3px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--thick), inset 0 3px 0 rgba(255, 255, 255, 0.5),
    inset 0 -3px 0 rgba(120, 70, 20, 0.18);
  transition: box-shadow 80ms linear, transform 80ms linear, color 80ms linear;
  image-rendering: pixelated;
  overflow: hidden;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  pointer-events: none;
  transition: background 80ms linear;
}
.btn:hover {
  color: #24380c;
  box-shadow: 0 7px 0 var(--moss-dark), inset 0 3px 0 rgba(255, 255, 255, 0.5),
    inset 0 -3px 0 rgba(60, 110, 20, 0.22);
}
.btn:hover::after {
  background: rgba(150, 220, 90, 0.45);
}
.btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--moss-dark), inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn.primary {
  background-color: var(--birch);
}
.btn.moss {
  background-color: var(--moss);
  box-shadow: 0 7px 0 var(--moss-dark), inset 0 3px 0 rgba(255, 255, 255, 0.5),
    inset 0 -3px 0 rgba(60, 110, 20, 0.22);
}
.btn.moss::after {
  background: rgba(150, 220, 90, 0.5);
}
.btn.moss:hover::after {
  background: rgba(180, 240, 120, 0.6);
}
.btn:disabled,
.btn.disabled {
  background-image: none;
  background: var(--disabled);
  color: var(--disabled-text);
  box-shadow: 0 7px 0 #9a8a70;
  cursor: default;
}
.btn:disabled::after,
.btn.disabled::after {
  display: none;
}
.wide-btn {
  width: 100%;
  margin-top: 10px;
}
.menu-buttons .btn {
  width: 440px;
  max-width: 88vw;
  margin: 0 auto 10px;
  min-height: 58px;
  text-align: center;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.menu-buttons .btn::before {
  content: "";
  flex: none;
  width: 30px;
  height: 30px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  image-rendering: pixelated;
}
.menu-buttons .btn[data-act="single"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='2' y='2' width='6' height='6' fill='%238fe05c'/%3E%3Crect x='8' y='2' width='6' height='6' fill='%237fd14a'/%3E%3Crect x='2' y='8' width='6' height='6' fill='%23a96b3c'/%3E%3Crect x='8' y='8' width='6' height='6' fill='%238a5530'/%3E%3Crect x='3' y='3' width='2' height='2' fill='%23ffd11e'/%3E%3C/svg%3E");
}
.menu-buttons .btn[data-act="online"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='2' y='3' width='5' height='5' fill='%23f2c08c'/%3E%3Crect x='2' y='8' width='5' height='5' fill='%2335c7f0'/%3E%3Crect x='9' y='3' width='5' height='5' fill='%23ffb08a'/%3E%3Crect x='9' y='8' width='5' height='5' fill='%23ff6a4a'/%3E%3Crect x='3' y='5' width='1' height='1' fill='%232a1a18'/%3E%3Crect x='10' y='5' width='1' height='1' fill='%232a1a18'/%3E%3C/svg%3E");
}
.menu-buttons .btn[data-act="friends"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 11' shape-rendering='crispEdges'%3E%3Crect x='1' y='1' width='4' height='3' fill='%23ff4a6e'/%3E%3Crect x='7' y='1' width='4' height='3' fill='%23ff4a6e'/%3E%3Crect x='1' y='4' width='10' height='2' fill='%23ff4a6e'/%3E%3Crect x='2' y='6' width='8' height='2' fill='%23ff4a6e'/%3E%3Crect x='4' y='8' width='4' height='2' fill='%23ff4a6e'/%3E%3C/svg%3E");
}
.menu-buttons .btn[data-act="profile"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' shape-rendering='crispEdges'%3E%3Crect x='4' y='1' width='6' height='6' fill='%23f2c08c'/%3E%3Crect x='6' y='3' width='1' height='1' fill='%232a1a18'/%3E%3Crect x='8' y='3' width='1' height='1' fill='%232a1a18'/%3E%3Crect x='3' y='8' width='8' height='5' fill='%238a5ae0'/%3E%3Crect x='6' y='8' width='2' height='5' fill='%23ffd11e'/%3E%3C/svg%3E");
}
.menu-buttons .btn[data-act="settings"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='4' height='14' fill='%239aa6be'/%3E%3Crect x='0' y='5' width='14' height='4' fill='%239aa6be'/%3E%3Crect x='2' y='2' width='10' height='10' fill='%23a8b4cc'/%3E%3Crect x='5' y='5' width='4' height='4' fill='%23ffd11e'/%3E%3C/svg%3E");
}
.menu-buttons .btn[data-act="about"]::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' shape-rendering='crispEdges'%3E%3Crect x='2' y='1' width='10' height='12' fill='%23ff6a4a'/%3E%3Crect x='4' y='3' width='6' height='1' fill='%23fff0c8'/%3E%3Crect x='4' y='6' width='6' height='1' fill='%23fff0c8'/%3E%3Crect x='4' y='9' width='6' height='1' fill='%23fff0c8'/%3E%3Crect x='6' y='0' width='2' height='14' fill='%23ffd11e'/%3E%3C/svg%3E");
}
.row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.row .btn {
  flex: 1;
}

/* ---------- Панели ---------- */
.panel {
  background-color: var(--panel);
  background-image: url("../assets/ui/wood_panel.png");
  background-size: 64px 64px;
  background-repeat: repeat;
  border: 4px solid var(--oak);
  border-radius: 14px;
  box-shadow: 0 6px 0 #2a1809, inset 0 0 0 2px #6b4526;
  padding: 18px;
  width: 480px;
  max-width: 94vw;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.panel.wide {
  width: 720px;
}
.panel-title {
  font-size: 26px;
  font-weight: 700;
  color: #f3e7c9;
  text-shadow: 3px 3px 0 var(--oak);
  text-align: center;
  margin: 2px 0 14px;
}
.settings-body {
  background: #2f1d10;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-height: 260px;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 12px;
}

/* ---------- Главное меню ---------- */
#main-menu {
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 4vh;
}
.menu-bg-tint {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.1) 30%, rgba(40, 20, 5, 0.55) 100%);
  pointer-events: none;
}
.menu-wrap {
  position: relative;
  text-align: center;
  z-index: 2;
  width: 100%;
}
#title {
  font-size: 68px;
  font-weight: 700;
  color: #f3e7c9;
  margin: 0;
  letter-spacing: 2px;
  text-shadow: 4px 4px 0 var(--oak);
  line-height: 1;
}
#splash {
  display: inline-block;
  transform: rotate(-15deg);
  color: #ffe84a;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 2px 2px 0 #3f3a00;
  margin: 6px 0 30px;
  animation: splashPulse 0.8s ease-in-out infinite alternate;
}
@keyframes splashPulse {
  from { transform: rotate(-15deg) scale(1); }
  to { transform: rotate(-15deg) scale(1.06); }
}
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.corner {
  position: absolute;
  bottom: 8px;
  font-size: 15px;
  color: #f3e7c9;
  text-shadow: 2px 2px 0 var(--oak);
  z-index: 3;
}
.corner.left { left: 10px; }
.corner.right { right: 10px; }

/* ---------- Создание мира ---------- */
.create-body {
  display: flex;
  gap: 16px;
}
.create-left { flex: 1.4; min-width: 0; }
.create-right { flex: 1; min-width: 0; }
.mode-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.mode-card {
  width: 260px;
  max-width: 46%;
  min-height: 200px;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 3px solid var(--oak);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 80ms linear, border-color 80ms linear;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card.selected {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 6px 0 #2a1809;
}
.mode-icon {
  width: 72px;
  height: 72px;
  margin: 6px auto 10px;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.gold-cube {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='3' y='1' width='10' height='1' fill='%23fff6b0'/%3E%3Crect x='2' y='2' width='12' height='4' fill='%23ffe24a'/%3E%3Crect x='1' y='6' width='7' height='8' fill='%23e8b820'/%3E%3Crect x='8' y='6' width='7' height='8' fill='%23c99a10'/%3E%3Crect x='1' y='6' width='14' height='1' fill='%23b8860b'/%3E%3Crect x='1' y='13' width='14' height='1' fill='%23a9790a'/%3E%3Crect x='0' y='1' width='1' height='14' fill='%238a5a00'/%3E%3Crect x='15' y='1' width='1' height='14' fill='%238a5a00'/%3E%3Crect x='3' y='3' width='3' height='2' fill='%23fff8b0'/%3E%3Crect x='9' y='8' width='2' height='2' fill='%23e8c840'/%3E%3C/svg%3E");
}
.iron-pick {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect x='0' y='2' width='4' height='1' fill='%23c8ccd6'/%3E%3Crect x='1' y='1' width='4' height='2' fill='%23eef1f6'/%3E%3Crect x='5' y='1' width='6' height='2' fill='%23f6f8fc'/%3E%3Crect x='11' y='1' width='4' height='2' fill='%23eef1f6'/%3E%3Crect x='12' y='2' width='4' height='1' fill='%23c8ccd6'/%3E%3Crect x='5' y='3' width='6' height='1' fill='%23a8aebc'/%3E%3Crect x='7' y='4' width='2' height='1' fill='%237a5228'/%3E%3Crect x='7' y='5' width='2' height='1' fill='%238a5a2e'/%3E%3Crect x='6' y='6' width='2' height='1' fill='%238a5a2e'/%3E%3Crect x='6' y='7' width='2' height='1' fill='%237a5228'/%3E%3Crect x='5' y='8' width='2' height='1' fill='%238a5a2e'/%3E%3Crect x='5' y='9' width='2' height='1' fill='%237a5228'/%3E%3Crect x='4' y='10' width='2' height='1' fill='%238a5a2e'/%3E%3Crect x='4' y='11' width='2' height='1' fill='%237a5228'/%3E%3Crect x='10' y='10' width='2' height='2' fill='%23c8372d'/%3E%3Crect x='13' y='10' width='2' height='2' fill='%23c8372d'/%3E%3Crect x='10' y='12' width='5' height='2' fill='%23c8372d'/%3E%3Crect x='11' y='14' width='3' height='1' fill='%23c8372d'/%3E%3C/svg%3E");
}
.mode-name { font-size: 20px; font-weight: 700; color: #6b3f00; }
.mode-desc { font-size: 15px; color: #4a2f1b; margin-top: 6px; }
.field-label { display: block; margin: 8px 0 4px; font-size: 16px; color: #e0d3b4; }
.field {
  width: 100%;
  background: #1a1410;
  border: 2px solid var(--thick);
  border-radius: var(--radius-sm);
  color: #f3e7c9;
  font-family: inherit;
  font-size: 17px;
  padding: 8px 10px;
  outline: none;
  caret-color: var(--accent);
}
.field:focus { border-color: var(--accent); }
.saved-title { font-size: 18px; color: var(--accent); margin-bottom: 8px; }
.saved-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.saved-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
}
.saved-row:hover { border-color: var(--accent); }
.saved-row .s-thumb {
  width: 48px; height: 32px;
  flex: none;
  border: 2px solid var(--oak);
  image-rendering: pixelated;
}
.saved-row .s-name {
  font-weight: 700;
  color: #3b2414;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-row .s-meta {
  font-size: 14px; color: #5a3a1e;
  flex: none;
  text-align: right;
  white-space: nowrap;
  line-height: 1.25;
}
.saved-mode {
  width: 20px; height: 20px; image-rendering: pixelated; flex: none;
}
.saved-mode.creative { background: var(--accent); box-shadow: inset -4px -4px 0 #c9a800; }
.saved-mode.survival { background: #d8d8d8; box-shadow: inset -4px -4px 0 #9a9a9a; }
.saved-actions { display: flex; gap: 4px; flex: none; align-items: center; }
.saved-actions .btn.mini {
  min-height: 30px;
  padding: 2px 8px;
  font-size: 13px;
}
.s-rename {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 6px;
  font-size: 15px;
  background: #1a1410;
  border: 2px solid var(--accent);
  color: #f3e7c9;
  font-family: inherit;
  outline: none;
}

/* ---------- Сетевая игра: выбор приватности ---------- */
.privacy-cards {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.privacy-card {
  flex: 1;
  min-width: 0;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 3px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 80ms linear, border-color 80ms linear;
}
.privacy-card:hover { border-color: var(--accent); }
.privacy-card.selected {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 5px 0 #2a1809;
}
.privacy-name { font-size: 18px; font-weight: 700; color: #6b3f00; }
.privacy-desc { font-size: 14px; color: #4a2f1b; margin-top: 4px; }

/* ---------- Сетевая игра: список онлайн миров ---------- */
.online-block { margin: 4px 0 12px; }
.online-block .saved-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.btn.mini {
  min-height: 30px;
  padding: 2px 12px;
  font-size: 14px;
  flex: none;
}
.online-list { max-height: 180px; overflow-y: auto; }
.online-row { cursor: pointer; }
.online-row-main { flex: 1 1 auto; min-width: 0; }
.online-row-name {
  font-weight: 700;
  color: #3b2414;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-row-sub { font-size: 14px; color: #5a3a1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-empty { color: #c6b894; font-size: 14px; padding: 6px 2px; }
@media (max-height: 620px) {
  .privacy-card { padding: 7px 9px; }
  .privacy-name { font-size: 16px; }
  .privacy-desc { font-size: 12px; margin-top: 2px; }
}

/* ---------- Загрузка ---------- */
.loading-wrap { text-align: center; }
.loading-text { font-size: 24px; margin-bottom: 14px; text-shadow: 3px 3px 0 var(--oak); }
.loading-bar { display: flex; gap: 2px; justify-content: center; }
.loading-bar .cell {
  width: 14px; height: 18px; background: #3a2a18;
  box-shadow: inset 0 0 0 1px var(--oak);
}
.loading-bar .cell.filled {
  background: #6baa3c;
  box-shadow: inset 0 -4px 0 #3e7a22, inset 0 0 0 1px #2f5f18;
}

/* ---------- Вкладки настроек ---------- */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: -2px;
  padding: 0 2px;
}
.tab {
  flex: 1;
  padding: 8px 6px;
  background: var(--panel3);
  color: #d8c8a8;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: none;
  font-family: inherit;
  font-size: 17px;
  cursor: pointer;
  transform: translateY(2px);
  transition: transform 80ms linear, background 80ms linear;
}
.tab.active {
  background: var(--birch);
  color: var(--oak);
  font-weight: 700;
  transform: translateY(0);
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px dashed #5a3a20;
}
.setting-row > span:first-child { flex: 1; }
.setting-row .val { width: 62px; text-align: right; color: var(--accent); }
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px;
}
.ctrl-row > span { flex: 1; }
.key-btn {
  min-width: 120px;
  min-height: 34px;
  padding: 4px 10px;
  background-color: var(--birch);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  color: var(--oak);
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--thick);
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}
.key-btn.waiting { color: var(--accent); background: #3a2a14; }
.key-btn:hover { background: var(--moss); box-shadow: 0 3px 0 var(--moss-dark); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  width: 180px;
  background: transparent;
  flex: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--oak);
  border: 2px solid #241408;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  background: #6baa3c;
  border: 2px solid #2f5f18;
  box-shadow: inset 0 -4px 0 #3e7a22, inset 0 0 0 2px #79b84a;
}
input[type="range"]::-moz-range-track { height: 8px; background: var(--oak); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 0; border: 2px solid #2f5f18; background: #6baa3c;
}
.btn.toggle, .btn.choice {
  min-width: 110px;
  min-height: 38px;
  font-size: 16px;
  padding: 4px 10px;
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair span { position: absolute; background: #fff; }
#crosshair span:nth-child(1) { left: 8px; top: 0; width: 2px; height: 18px; }
#crosshair span:nth-child(2) { top: 8px; left: 0; height: 2px; width: 18px; }

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  background: rgba(62, 40, 23, 0.72);
  padding: 3px;
  border: 2px solid #7a5a34;
}
.slot {
  width: 44px; height: 44px;
  margin: 1px;
  background: rgba(233, 221, 191, 0.14);
  border: 2px solid #7a5a34;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  image-rendering: pixelated;
}
.slot.active {
  border: 3px solid #ffd24a;
  background: rgba(255, 210, 74, 0.28);
  box-shadow: 0 0 0 1px #3b2414;
}
.slot img { width: 36px; height: 36px; image-rendering: pixelated; }
.slot .count {
  position: absolute;
  right: 1px; bottom: -1px;
  font-size: 12px;
  line-height: 1.05;
  font-weight: 700;
  color: #fff2c0;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
#heldname {
  position: absolute;
  left: 50%; bottom: 70px;
  transform: translateX(-50%);
  font-size: 17px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  opacity: 0;
  transition: opacity 300ms;
}
#heldname.show { opacity: 1; }

#survival-bars {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  width: 388px;
  max-width: 92vw;
}
#hearts, #food {
  display: flex;
  gap: 1px;
  height: 18px;
}
#hearts { float: left; }
#food { float: right; }
.heart, .food-icon, .heart-half, .food-half {
  width: 18px; height: 18px;
  image-rendering: pixelated;
  background-size: 18px 18px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
#xpbar {
  clear: both;
  height: 8px;
  margin-top: 4px;
  background: #1a1410;
  border: 2px solid #2a2018;
}
#xpfill { height: 100%; width: 0%; background: #7fd13b; transition: width 200ms; }
#xpbar.hidden { display: none; }

#debug {
  position: absolute;
  left: 6px; top: 6px;
  font-size: 13px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  white-space: pre;
  opacity: 0.85;
  display: none;
}
#debug.show { display: block; }
.toast {
  position: absolute;
  left: 50%; top: 20%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  padding: 6px 14px;
  font-size: 17px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 300ms;
}
.toast.show { opacity: 1; }

/* ---------- Лобби сетевой игры ---------- */
.lobby-body {
  min-height: 120px;
  background: #2f1d10;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  font-size: 16px;
  color: #eadfc0;
}
.lobby-body .lobby-seat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.lobby-body .dot { width: 12px; height: 12px; background: #6baa3c; box-shadow: 0 0 0 2px #2f5f18; }
.lobby-body .dot.off { background: #7a6a4a; box-shadow: 0 0 0 2px #3a2a14; }
.lobby-link { display: flex; gap: 8px; margin-bottom: 8px; }
.lobby-link .field { flex: 1; }
.lobby-link .btn { flex: none; min-height: 40px; }

/* ---------- Смерть / пауза ---------- */
.death-tint { background: rgba(200, 55, 45, 0.4); }
.death-wrap { text-align: center; }
#death-title {
  font-size: 54px;
  font-weight: 700;
  color: #f3e7c9;
  text-shadow: 4px 4px 0 #3b2414;
  margin-bottom: 22px;
}
.death-wrap .btn { width: 320px; max-width: 80vw; margin: 0 auto 8px; }

/* ---------- Инвентарь ---------- */
.inv-panel { width: 620px; }
.inv-content {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
.inv-grid {
  display: grid;
  gap: 2px;
  background: #7a7a7a;
  padding: 3px;
  border: 2px solid var(--oak);
}
.inv-grid .slot {
  background: #8b8b8b;
  border: 2px solid #6a6a6a;
  box-shadow: inset 2px 2px 0 #5a5a5a, inset -2px -2px 0 #ababab;
}
.inv-grid .slot:hover { background: #a0a0a0; }
.inv-side { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.player-silhouette { width: 90px; height: 130px; background: #8b8b8b; border: 2px solid #6a6a6a; }
.arrow { font-size: 28px; color: #2a2a2a; }
.craft-out { display: grid; place-items: center; }
.creative-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.ctab {
  padding: 6px 10px; background: var(--panel3); color: #d8c8a8;
  border: 2px solid var(--oak); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px; cursor: pointer;
}
.ctab.active { background: var(--birch); color: var(--oak); font-weight: 700; }
#inv-creative-search { margin-bottom: 10px; }
.inv-hint { font-size: 15px; color: #d8c9a6; text-align: center; margin-top: 12px; }

/* ---------- Мобильное управление ---------- */
#touch-controls { position: absolute; inset: 0; pointer-events: none; }
#touch-controls.hidden { display: none; }
#joy {
  position: absolute; left: 14px; bottom: 74px;
  width: 112px; height: 112px;
  border-radius: 50%;
  background: rgba(20,16,12,0.28);
  border: 2px solid rgba(255,255,255,0.30);
  pointer-events: auto;
  touch-action: none;
}
#joy .knob {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255,255,255,0.42);
  border: 2px solid rgba(255,255,255,0.55);
}
#tbuttons { position: absolute; right: 12px; bottom: 118px; display: flex; flex-direction: row; gap: 6px; pointer-events: auto; }
.tb {
  height: 44px; min-width: 54px; padding: 0 10px;
  font-size: 13px; font-weight: 700; line-height: 1.05; white-space: nowrap;
  font-family: inherit; border-radius: 10px;
  background-color: rgba(20, 16, 12, 0.5);
  color: #f3e7c9;
  border: 2px solid rgba(255,255,255,0.32); pointer-events: auto; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.tb:active, .tb.on { background-color: rgba(110, 143, 62, 0.72); }
.tb.big { height: 50px; min-width: 80px; font-size: 14px; }
#btn-break { position: absolute; right: 104px; bottom: 62px; }
#btn-place { position: absolute; right: 14px; bottom: 62px; }
#btn-inv { position: absolute; left: 14px; top: 10px; }
#btn-friends { position: absolute; left: 14px; top: 62px; }

.hud-profile {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.42);
  border: 2px solid #1a1410;
  padding: 2px 10px 2px 4px;
  font-size: 15px;
  color: #f3e7c9;
  text-shadow: 2px 2px 0 #000;
}
.hud-profile img { width: 16px; height: 32px; image-rendering: pixelated; }

#mobile-warn { display: none; }

@media (max-width: 640px) {
  html, body { font-size: 15px; }
  #debug { display: none; }
  #title { font-size: 46px; }
  #splash { font-size: 17px; }
  .menu-buttons .btn { font-size: 18px; }
  .panel-title { font-size: 21px; }
  .create-body { flex-direction: column; }
  .mode-card { min-height: 150px; max-width: 48%; }
  .slot { width: 38px; height: 38px; }
  .slot img { width: 30px; height: 30px; }
  .saved-row .s-meta { display: none; }
  .saved-actions .btn.mini { padding: 2px 6px; font-size: 12px; }
  #hotbar { bottom: 8px; }
  #hearts, #food { height: 15px; }
  .heart, .food-icon { width: 15px; height: 15px; background-size: 15px 15px; }
}

/* Тесные по высоте экраны (телефон в альбомной ориентации, ноутбук) */
/* ---------- Профиль, друзья, чат ---------- */
.friends-status {
  font-size: 15px;
  color: #c6b894;
  margin-bottom: 10px;
  text-align: center;
}
.friends-status.warn { color: var(--accent); }
.skin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.skin-card {
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: transform 80ms linear, border-color 80ms linear;
}
.skin-card:hover { border-color: var(--accent); }
.skin-card.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  transform: translateY(-3px);
}
.skin-card img { width: 48px; height: 96px; image-rendering: pixelated; }
.skin-name { font-size: 13px; color: #4a2f1b; }

.add-friend { margin-bottom: 10px; }
.seg-group { display: flex; margin-bottom: 8px; }
.seg {
  flex: 1;
  padding: 8px 6px;
  background: var(--panel3);
  color: #d8c8a8;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}
.seg.active { background: var(--birch); color: var(--oak); font-weight: 700; }

.friends-subhead { font-size: 16px; color: var(--accent); margin: 12px 0 6px; }
.friends-list { min-height: 40px; }
.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-bottom: 6px;
}
.fr-avatar {
  width: 32px; height: 64px;
  flex: none;
  image-rendering: pixelated;
  background: #2f1d10;
}
.fr-main { flex: 1 1 auto; min-width: 0; }
.fr-nick { font-weight: 700; color: #3b2414; display: flex; align-items: center; gap: 6px; }
.fr-sub { font-size: 13px; color: #5a3a1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-row .dot { width: 10px; height: 10px; background: #6baa3c; box-shadow: 0 0 0 2px #2f5f18; flex: none; }
.friend-row .dot.off { background: #7a6a4a; box-shadow: 0 0 0 2px #3a2a14; }
.friend-row.guide { border-color: var(--accent); }
.fr-nick .badge {
  font-size: 11px;
  padding: 1px 5px;
  background: var(--accent);
  color: var(--oak);
  border: 1px solid var(--oak);
  font-weight: 700;
}
.btn.mini.danger { background: #e2b4a8; }
.btn.mini.danger:hover { background: #f0cabe; box-shadow: 0 3px 0 #8a4a3a; }

.chat-messages {
  height: 300px;
  max-height: 46vh;
  overflow-y: auto;
  background: #2f1d10;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.chat-msg {
  max-width: 78%;
  padding: 6px 10px;
  background: var(--panel2);
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  color: #eadfc0;
  font-size: 16px;
  word-break: break-word;
  align-self: flex-start;
}
.chat-msg.mine { align-self: flex-end; background: var(--moss); color: var(--oak); border-color: var(--moss-dark); }
.chat-empty { color: #c6b894; font-size: 14px; text-align: center; }

/* Короткие экраны: меню с шестью кнопками должно помещаться */
@media (max-height: 620px) {
  .panel { padding: 12px; }
  .panel-title { font-size: 22px; margin: 0 0 10px; }
  .mode-card { min-height: 118px; padding: 8px; }
  .mode-icon { width: 44px; height: 44px; margin: 2px auto 6px; }
  .mode-name { font-size: 17px; }
  .mode-desc { font-size: 13px; margin-top: 3px; }
  .field-label { margin: 5px 0 3px; }
  .field { padding: 6px 8px; font-size: 15px; }
  .settings-body { min-height: 0; }
  .setting-row { padding: 4px 0; }
  .inv-panel { width: 94vw; }
  .inv-panel .panel-title { font-size: 20px; margin: 0 0 6px; }
  .creative-tabs { gap: 3px; margin-bottom: 6px; }
  .ctab { padding: 4px 8px; font-size: 13px; }
  #inv-creative-search { margin-bottom: 6px; }
  .inv-grid .slot { width: 34px; height: 34px; }
  .inv-grid .slot img { width: 28px; height: 28px; }
  .inv-hint { margin-top: 6px; font-size: 12px; }
  #main-menu { padding-top: 1vh; }
  #title { font-size: 42px; }
  #splash { font-size: 15px; margin: 2px 0 8px; }
  .menu-buttons { gap: 4px; }
  .menu-buttons .btn { min-height: 30px; font-size: 16px; margin-bottom: 3px; padding: 2px 12px 4px; }
  .menu-buttons .btn::before { width: 22px; height: 22px; }
  .chat-messages { height: 180px; max-height: 40vh; }
  .skin-card img { width: 38px; height: 76px; }
}
@media (max-height: 520px) {
  #title { font-size: 34px; }
  #splash { font-size: 13px; margin: 1px 0 6px; }
  .menu-buttons .btn { min-height: 26px; font-size: 14px; margin-bottom: 2px; padding: 1px 10px 3px; }
  .menu-buttons .btn::before { width: 18px; height: 18px; }
}
@media (max-height: 460px) {
  #title { font-size: 28px; }
  .menu-buttons .btn { min-height: 22px; font-size: 13px; padding: 0 8px 2px; }
  .menu-buttons .btn::before { width: 16px; height: 16px; }
}

/* ---------- Достижения ---------- */
.ach-list { display: flex; flex-direction: column; gap: 6px; }
.ach-sum { text-align: center; color: var(--accent); font-size: 16px; margin-bottom: 6px; }
.ach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  opacity: 0.72;
}
.ach-row.done { opacity: 1; border-color: var(--accent); }
.ach-icon { width: 36px; height: 36px; image-rendering: pixelated; flex: none; }
.ach-main { flex: 1 1 auto; min-width: 0; }
.ach-name { font-weight: 700; color: #3b2414; }
.ach-desc { font-size: 14px; color: #5a3a1e; }
.ach-state { flex: none; font-size: 14px; font-weight: 700; color: #8a5a1e; }
.ach-row.done .ach-state { color: #2f6b18; }

/* ---------- Игроки и карты ---------- */
#main-menu { overflow-y: auto; }
.players-list { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
}
.player-row:hover { border-color: var(--accent); }
.pl-avatar { width: 32px; height: 64px; flex: none; image-rendering: pixelated; background: #2f1d10; border-radius: 4px; }
.pl-main { flex: 1 1 auto; min-width: 0; }
.pl-nick { font-weight: 700; color: #3b2414; display: flex; align-items: center; gap: 6px; }
.pl-sub { font-size: 13px; color: #5a3a1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-row .dot { width: 10px; height: 10px; background: #6baa3c; box-shadow: 0 0 0 2px #2f5f18; flex: none; }
.player-row .dot.off { background: #7a6a4a; box-shadow: 0 0 0 2px #3a2a14; }
.pl-nick .badge { font-size: 11px; padding: 1px 5px; background: var(--accent); color: var(--oak); border: 1px solid var(--oak); font-weight: 700; }

.pcard-body { min-height: 80px; }
.pcard-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pcard-avatar { width: 72px; height: 144px; image-rendering: pixelated; background: #2f1d10; border: 2px solid var(--oak); border-radius: 6px; }
.pcard-nick { font-size: 22px; font-weight: 700; color: var(--accent); text-shadow: 2px 2px 0 var(--oak); }
.pcard-sub { font-size: 14px; color: #d0c19c; }
.map-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.map-card {
  background-color: var(--panel2);
  background-image: url("../assets/ui/wood_button.png");
  background-size: 64px 64px;
  border: 2px solid var(--oak);
  border-radius: var(--radius-sm);
  padding: 6px;
  text-align: center;
}
.map-thumb { width: 100%; height: auto; image-rendering: pixelated; border: 2px solid var(--oak); border-radius: 4px; display: block; }
.map-name { font-weight: 700; color: #3b2414; font-size: 14px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-meta { font-size: 12px; color: #5a3a1e; }
@media (max-width: 640px) { .map-grid { grid-template-columns: 1fr; } }
