:root {
  --bg: #14141a;
  --panel: #26262e;
  --panel-2: #30303a;
  --line: #0b0b0f;
  --text: #e9e9ef;
  --muted: #9b9baa;
  --green: #5fa832;
  --green-dark: #3d7220;
  --gold: #f2c94c;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(95, 168, 50, 0.10), transparent 45%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 4px);
}

button { font: inherit; color: inherit; }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* ---------- шапка ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(12px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(20, 20, 26, 0.94);
  border-bottom: 3px solid var(--line);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 10px; }

.logo {
  position: relative;
  width: 30px;
  height: 30px;
  flex: none;
  background: #7a5230;
  box-shadow: inset 0 0 0 2px var(--line);
}
.logo::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 10px;
  background: #5fa832;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.logo::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.18), inset -2px -2px 0 rgba(0, 0, 0, 0.3);
}

.brand-text h1 {
  margin: 0;
  font-family: "Courier New", monospace;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #000;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.tab {
  padding: 9px 2px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
}
.tab.is-on {
  background: var(--green);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), inset 0 -3px 0 var(--green-dark);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}
.tab:active { transform: translateY(1px); }

/* ---------- общие панели ---------- */

main { padding: 12px; }

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  padding: 10px;
  margin-bottom: 12px;
}

.muted { color: var(--muted); font-size: 12.5px; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1a21;
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.5);
  padding: 0 10px;
}
.search-icon { font-size: 14px; opacity: 0.7; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
}
.search input::placeholder { color: #75758a; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  padding: 5px 11px;
  background: #1e1e25;
  border: 2px solid var(--line);
  color: #c3c3cf;
  font-size: 12px;
  cursor: pointer;
}
.chip.is-on {
  background: var(--green);
  color: #fff;
  border-color: var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

/* ---------- иконки ---------- */

.spr { image-rendering: pixelated; display: block; }

.blk {
  position: relative;
  display: block;
  flex: none;
  background: var(--c);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 3px 3px 0 rgba(255, 255, 255, 0.16),
    inset -3px -3px 0 rgba(0, 0, 0, 0.24);
}
.blk::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 4px);
}
.blk-ore::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 30% 28%, var(--o) 2px, transparent 3px),
    radial-gradient(circle at 68% 44%, var(--o) 2px, transparent 3px),
    radial-gradient(circle at 44% 72%, var(--o) 2px, transparent 3px),
    radial-gradient(circle at 74% 78%, var(--o) 1.5px, transparent 2.5px);
  z-index: 1;
}

/* ---------- рецепты ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 11px 6px 9px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.card:active { transform: translateY(1px); background: var(--panel-2); }
.card-icon { display: flex; height: 40px; align-items: center; }
.card-name {
  font-size: 11.5px;
  line-height: 1.25;
  text-align: center;
  color: #dcdce4;
}

.empty {
  grid-column: 1 / -1;
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
  border: 2px dashed #34343f;
}

/* ---------- справочник ---------- */

.guide-list { display: flex; flex-direction: column; gap: 8px; }

.gcard {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.gcard:active { transform: translateY(1px); background: var(--panel-2); }
.gcard-icon { flex: none; display: flex; width: 44px; justify-content: center; }
.gcard-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gcard-name { font-size: 14px; font-weight: 700; }
.gcard-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gold);
}
.gcard-text {
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- лист деталей ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.sheet[hidden] { display: none; }
.sheet.is-on { opacity: 1; }

.sheet-card {
  position: relative;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 14px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 3px solid var(--line);
  box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.3);
  transform: translateY(24px);
  transition: transform 0.18s ease;
}
.sheet.is-on .sheet-card { transform: none; }

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: #1e1e25;
  border: 2px solid var(--line);
  color: #c3c3cf;
  cursor: pointer;
}
.sheet-tag {
  margin: 0 0 2px;
  font-size: 10.5px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--gold);
}
.sheet-title {
  margin: 0 30px 4px 0;
  font-family: "Courier New", monospace;
  font-size: 20px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.craft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}
.craft-grid {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 3px;
  padding: 4px;
  background: #1a1a21;
  border: 2px solid var(--line);
}
.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #23232b;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.craft-arrow { font-size: 22px; color: var(--muted); }
.craft-out {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px;
  background: #1f2a1a;
  border: 2px solid #3d7220;
}
.craft-out span { font-size: 11px; color: #b8dca4; }

.need {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.need li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #1e1e25;
  border: 2px solid var(--line);
  font-size: 13px;
}
.need li b { margin-left: auto; color: var(--gold); }
.need-icon { display: flex; width: 22px; justify-content: center; }

.note {
  margin: 0 0 14px;
  padding: 9px 10px;
  font-size: 12.5px;
  color: #c9c9d6;
  background: #1e1e25;
  border-left: 3px solid var(--green);
}

.guide-hero {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}
.guide-text { font-size: 14px; color: #d6d6e0; margin: 0 0 16px; }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 2px solid var(--line);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn:active { transform: translateY(2px); }
.btn-wide { width: 100%; }
.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), inset 0 -4px 0 var(--green-dark);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}
.btn-stone {
  background: var(--panel-2);
  color: #d6d6e0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), inset 0 -4px 0 #1b1b22;
}
.btn + .btn { margin-top: 8px; }
.btn[hidden] { display: none; }

/* ---------- викторина ---------- */

.quiz-intro { text-align: center; }
.hero {
  display: flex;
  justify-content: center;
  padding: 14px 0 6px;
}
.quiz-intro h2 {
  margin: 4px 0 6px;
  font-family: "Courier New", monospace;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.quiz-intro .muted { margin: 0 0 12px; }

.best-row {
  display: inline-block;
  margin-bottom: 14px;
  padding: 7px 14px;
  background: #1e1e25;
  border: 2px solid var(--line);
  font-size: 13px;
}
.best-row b { color: var(--gold); }

.quiz-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.bar {
  height: 8px;
  background: #0e0e12;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.2s ease;
}
.question {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.35;
}

.answers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.answer {
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.07), inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  font-size: 14px;
  cursor: pointer;
}
.answer:active { transform: translateY(1px); }
.answer.is-right {
  background: #2f6a2a;
  border-color: #4b9b3f;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2), inset 0 -3px 0 #1f4a1b;
}
.answer.is-wrong {
  background: #6a2424;
  border-color: #a33c3c;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15), inset 0 -3px 0 #451515;
}
.answer[disabled] { cursor: default; }

.quiz-result { text-align: center; }
.score-big {
  margin: 10px 0 6px;
  font-family: "Courier New", monospace;
  font-size: 42px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}
.quiz-result p { margin: 0 0 10px; }
.quiz-result .btn { margin-top: 10px; }

.top-list {
  margin: 16px 0 6px;
  padding: 10px;
  background: #1e1e25;
  border: 2px solid var(--line);
  text-align: left;
}
.top-list h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
}
.top-list ol { list-style: none; margin: 0; padding: 0; }
.top-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid #2c2c36;
}
.top-list li:last-child { border-bottom: 0; }
.top-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list li b { color: var(--gold); }

/* ---------- уведомление ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 88vw;
  padding: 10px 16px;
  background: #2f6a2a;
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2);
  font-size: 13px;
  text-align: center;
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 3D-мир ---------- */

body.playing { overflow: hidden; }
body.playing .top {
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-bottom: 8px;
}
body.playing .brand-text p { display: none; }
body.playing .brand-text h1 { font-size: 16px; }
body.playing .logo { width: 24px; height: 24px; }
body.playing .logo::before { height: 8px; }
body.playing .tabs { margin-top: 8px; }

.game {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 6;
  overflow: hidden;
  background: #8ec9ff;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.game[hidden] { display: none; }
.game canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
.crosshair::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}
.crosshair::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
}

.game-hint {
  position: absolute;
  left: 50%;
  top: 66px;
  transform: translateX(-50%);
  max-width: 94%;
  padding: 7px 12px;
  background: rgba(20, 20, 26, 0.62);
  border: 2px solid rgba(0, 0, 0, 0.5);
  font-size: 11.5px;
  line-height: 1.35;
  color: #e9e9ef;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.game-hint.is-off { opacity: 0; }

.stick {
  position: absolute;
  left: 16px;
  bottom: calc(58px + env(safe-area-inset-bottom));
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: rgba(20, 20, 26, 0.32);
  border: 2px solid rgba(255, 255, 255, 0.28);
  touch-action: none;
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(233, 233, 239, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.game-actions {
  position: absolute;
  right: 14px;
  bottom: calc(58px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gbtn {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(38, 38, 46, 0.78);
  border: 2px solid rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 21px;
  cursor: pointer;
  touch-action: manipulation;
}
.gbtn:active {
  background: rgba(95, 168, 50, 0.9);
  transform: scale(0.95);
}
.gbtn-jump { font-size: 25px; }
.gbtn-down { font-size: 22px; background: rgba(38, 38, 46, 0.62); }
.gbtn[hidden] { display: none; }

.hotbar {
  position: absolute;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 20, 26, 0.55);
  border: 2px solid rgba(0, 0, 0, 0.55);
}
.hot {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #1b1b22;
  border: 2px solid rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.hot canvas {
  display: block;
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}
.hot.is-on {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--green);
}

.game-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- игровые экраны ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(8, 8, 12, 0.72);
  overflow-y: auto;
  touch-action: pan-y;
}
.overlay[hidden] { display: none; }

.menu-card {
  width: min(100%, 360px);
  max-height: 100%;
  overflow-y: auto;
  margin: auto;
  padding: 16px;
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.08), 0 12px 32px rgba(0, 0, 0, 0.55);
  touch-action: pan-y;
}
.menu-small { width: min(100%, 300px); }

.menu-kicker {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold);
}
.menu-title {
  margin: 0 0 6px;
  font-family: "Courier New", monospace;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #000;
}
.menu-sub {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.menu-foot {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.menu-row { display: flex; gap: 8px; margin-top: 10px; }
.menu-row .btn { flex: 1; margin-top: 0; padding: 10px 8px; font-size: 12.5px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: var(--muted);
}
.field input[type="text"] {
  padding: 10px;
  background: #1a1a21;
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.5);
  color: var(--text);
  font: inherit;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.field input[type="text"]::placeholder { color: #6c6c80; }
.field input[type="range"] { width: 100%; accent-color: var(--green); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 2px;
  font-size: 13px;
}
.check input { width: 18px; height: 18px; accent-color: var(--green); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.xbtn {
  flex: none;
  width: 32px;
  height: 32px;
  background: #1e1e25;
  border: 2px solid var(--line);
  color: #c3c3cf;
  cursor: pointer;
}

.help-list {
  list-style: none;
  margin: 10px 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.help-list li {
  padding: 8px 10px;
  background: #1e1e25;
  border-left: 3px solid var(--green);
  font-size: 12.5px;
  color: #c9c9d6;
}
.help-list b {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--gold);
}

.death-card { text-align: center; }
.death-card .menu-title { color: #e0483f; }
.death-card .muted { margin: 0 0 14px; }

/* ---------- инвентарь ---------- */

.inv-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
  margin-top: 12px;
  touch-action: pan-y;
}
.inv-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #1b1b22;
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.inv-slot:active { background: var(--panel-2); }
.inv-slot canvas {
  display: block;
  width: 30px;
  height: 30px;
  image-rendering: pixelated;
}
.inv-slot b {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.inv-slot small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  font-size: 8px;
  letter-spacing: 0.3px;
  color: #b8dca4;
}
.inv-emoji { font-size: 22px; line-height: 1; }
.inv-hint {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}
.inv-hot {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 10px;
}
.inv-hot .hot { width: 38px; height: 38px; }
.inv-hot .hot canvas { width: 28px; height: 28px; }

.craft-title {
  margin: 14px 0 6px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}
.craft-title[hidden] { display: none; }
.craft-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 28vh;
  overflow-y: auto;
  touch-action: pan-y;
}
.craft-list[hidden] { display: none; }
.craft-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  background: #1b1b22;
  border: 2px solid var(--line);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.craft-item:active { background: var(--panel-2); }
.craft-item.is-off { opacity: 0.45; }
.craft-icon { flex: none; display: flex; }
.craft-icon canvas {
  display: block;
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}
.craft-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.craft-body b { font-size: 12px; font-weight: 700; }
.craft-body small {
  overflow: hidden;
  font-size: 10px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.craft-count { flex: none; font-size: 11px; color: #b8dca4; }

.hot-count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}
.hot-count.is-zero { color: #e07b1f; }
.hot-empty { width: 6px; height: 6px; background: #3a3a44; }

/* ---------- здоровье, голод, воздух ---------- */

.hud[hidden],
.hunger[hidden],
.air[hidden],
.game-top[hidden],
.hotbar[hidden],
.break-bar[hidden],
.crosshair[hidden],
.game-hint[hidden] { display: none; }

.hud {
  position: absolute;
  left: 10px;
  top: 8px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  padding: 4px 6px;
  background: rgba(20, 20, 26, 0.42);
  border: 2px solid rgba(0, 0, 0, 0.45);
}
.hearts, .hunger, .air { display: flex; gap: 2px; }
.heart::before {
  content: "❤";
  font-size: 15px;
  line-height: 14px;
  color: #e0483f;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
}
.heart.half::before {
  background: linear-gradient(90deg, #e0483f 50%, #4a2a2a 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.heart.empty::before { color: #4a2a2a; }
.hunger .food {
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6));
}
.hunger .food.empty { opacity: 0.28; filter: grayscale(1); }
.bubble {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7fd7ff;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3), 1px 1px 0 rgba(0, 0, 0, 0.5);
}
.bubble.empty { background: rgba(20, 20, 26, 0.6); }

.game-top {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 6px;
}
.clock {
  padding: 5px 9px;
  background: rgba(20, 20, 26, 0.62);
  border: 2px solid rgba(0, 0, 0, 0.5);
  font-size: 11.5px;
  white-space: nowrap;
  color: #e9e9ef;
}
.icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(38, 38, 46, 0.78);
  border: 2px solid rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2);
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:active { background: rgba(95, 168, 50, 0.9); }

.break-bar {
  position: absolute;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 112px;
  height: 8px;
  background: rgba(10, 10, 14, 0.65);
  border: 2px solid rgba(0, 0, 0, 0.6);
}
.break-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.water-tint {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: rgba(40, 110, 190, 0.35);
}
.water-tint[hidden] { display: none; }

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(circle, transparent 38%, rgba(180, 20, 20, 0.55));
  opacity: 0;
  transition: opacity 0.12s ease;
}
.damage-flash.is-on { opacity: 1; }

.game-toast {
  position: absolute;
  left: 50%;
  bottom: calc(132px + env(safe-area-inset-bottom));
  z-index: 9;
  max-width: 86%;
  padding: 9px 15px;
  background: rgba(47, 106, 42, 0.94);
  border: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.2);
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.game-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (pointer: fine) {
  .stick, .game-actions { display: none; }
  .game-hint { font-size: 12px; }
  .game { cursor: crosshair; }
}

@media (max-height: 560px) {
  .overlay { align-items: flex-start; }
  .inv-grid { max-height: 34vh; }
  .menu-title { font-size: 20px; }
}
