* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0f1720;
  color: #f7f1dc;
  font-family: "Trebuchet MS", "Lucida Grande", Verdana, sans-serif;
  user-select: none;
}

button,
input {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #0c1117;
}

.world-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgb(255 255 255 / 0.08), transparent 18%, transparent 72%, rgb(0 0 0 / 0.24)),
    radial-gradient(circle at center, transparent 48%, rgb(0 0 0 / 0.28));
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: difference;
}

.crosshair span {
  position: absolute;
  background: #ffffff;
  box-shadow: 0 0 0 1px #111;
}

.crosshair span:first-child {
  left: 13px;
  top: 3px;
  width: 2px;
  height: 22px;
}

.crosshair span:last-child {
  left: 3px;
  top: 13px;
  width: 22px;
  height: 2px;
}

.hotbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(9, 56px);
  gap: 4px;
  transform: translateX(-50%);
  padding: 6px;
  background: rgb(14 14 14 / 0.68);
  border: 3px solid rgb(255 255 255 / 0.28);
  box-shadow: 0 10px 32px rgb(0 0 0 / 0.45);
}

.slot {
  position: relative;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: rgb(55 55 55 / 0.84);
  border: 3px solid #171717;
  box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.16), inset -2px -2px 0 rgb(0 0 0 / 0.45);
}

.slot.active {
  border-color: #f4f0d4;
  background: rgb(88 88 88 / 0.94);
  transform: translateY(-4px);
}

.slot-index {
  position: absolute;
  left: 5px;
  top: 2px;
  font-size: 10px;
  color: rgb(255 255 255 / 0.6);
}

.slot-count {
  position: absolute;
  right: 5px;
  bottom: 2px;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 2px 2px #000;
}

.block-chip,
.item-chip,
.sword-chip {
  width: 31px;
  height: 31px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.24), transparent 35%),
    linear-gradient(315deg, rgb(0 0 0 / 0.28), transparent 42%),
    var(--block-color);
  border: 2px solid rgb(0 0 0 / 0.42);
  image-rendering: pixelated;
  box-shadow: 4px 5px 0 rgb(0 0 0 / 0.18);
}

.item-chip {
  width: 28px;
  height: 22px;
  border-radius: 2px;
  transform: rotate(-12deg);
}

.sword-chip {
  width: 8px;
  height: 34px;
  position: relative;
  transform: rotate(42deg);
  background: linear-gradient(#f2cf82 0 68%, #6b4424 68% 78%, #3b2414 78%);
  border: 1px solid rgb(0 0 0 / 0.45);
}

.sword-chip::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 23px;
  width: 26px;
  height: 5px;
  background: #6b4424;
  border: 1px solid rgb(0 0 0 / 0.45);
}

.survival-hud {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  justify-items: center;
  text-shadow: 2px 2px #000;
}

.meter-row {
  display: flex;
  gap: 5px;
}

.heart,
.hunger {
  width: 18px;
  height: 18px;
  clip-path: polygon(50% 90%, 8% 50%, 10% 18%, 36% 8%, 50% 25%, 64% 8%, 90% 18%, 92% 50%);
  background: #332221;
  border: 1px solid rgb(0 0 0 / 0.4);
}

.heart.full {
  background: #e34a3e;
}

.hunger {
  clip-path: polygon(15% 15%, 72% 10%, 90% 32%, 80% 72%, 55% 90%, 22% 78%, 8% 45%);
}

.hunger.full {
  background: #d99a33;
}

.selected-label {
  min-width: 180px;
  text-align: center;
  font-size: 14px;
  color: #fff6c9;
}

.debug-panel {
  position: fixed;
  left: 16px;
  top: 16px;
  max-width: 320px;
  padding: 10px 12px;
  background: rgb(0 0 0 / 0.34);
  color: #f8f8f8;
  font-size: 13px;
  line-height: 1.45;
  text-shadow: 1px 1px #000;
  border: 1px solid rgb(255 255 255 / 0.16);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.pause-overlay {
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgb(0 0 0 / 0.48), rgb(0 0 0 / 0.72)),
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.035) 0 3px, transparent 3px 10px);
}

.pause-panel,
.inventory-panel,
.settings-panel,
.chest-panel {
  width: min(760px, calc(100vw - 32px));
  padding: 28px;
  background: #2f3135;
  border: 4px solid #0d0d0d;
  box-shadow: inset 3px 3px 0 rgb(255 255 255 / 0.18), inset -4px -4px 0 rgb(0 0 0 / 0.42), 0 28px 80px rgb(0 0 0 / 0.55);
}

.pause-panel h1,
.inventory-panel h2,
.settings-panel h2 {
  margin: 0;
  color: #fff4be;
  font-size: clamp(26px, 5vw, 48px);
  letter-spacing: 0;
  text-align: center;
  text-shadow: 3px 3px #000;
}

.pause-panel p {
  min-height: 24px;
  margin: 14px auto 22px;
  color: #e6dfc4;
  text-align: center;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin: 0 auto 22px;
}

.menu-grid button,
.recipe-row,
.toggle {
  min-height: 46px;
  color: #f6f1dc;
  background: #6b6d70;
  border: 3px solid #111;
  box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.24), inset -3px -3px 0 rgb(0 0 0 / 0.35);
  cursor: pointer;
}

.menu-grid button:hover,
.recipe-row:hover:not(:disabled),
.toggle:hover {
  background: #7c7f82;
}

.menu-grid button:last-child {
  grid-column: 1 / -1;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: #cfc7a5;
  font-size: 13px;
}

.controls-grid span {
  min-height: 30px;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.22);
  border: 1px solid rgb(255 255 255 / 0.1);
}

.sheet-overlay {
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.58);
}

.inventory-panel,
.settings-panel,
.chest-panel {
  width: min(860px, calc(100vw - 32px));
}

.inventory-panel header,
.settings-panel header,
.chest-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.inventory-panel h2,
.settings-panel h2,
.chest-panel h2 {
  text-align: left;
  font-size: 30px;
}

.icon-button {
  width: 40px;
  height: 40px;
  color: #fff;
  background: #4f5154;
  border: 3px solid #111;
  cursor: pointer;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(9, 56px);
  gap: 5px;
  justify-content: center;
  padding: 12px;
  background: rgb(0 0 0 / 0.22);
}

.chest-panel h3 {
  margin: 16px 0 8px;
  color: #fff4be;
}

.chest-grid {
  grid-template-columns: repeat(9, 56px);
}

.slot-button {
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.slot-button:hover .slot {
  border-color: #fff4be;
}

.crafting-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.crafting-list h3 {
  margin: 0 0 4px;
  color: #fff4be;
}

.recipe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  text-align: left;
}

.recipe-row:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.recipe-row small {
  color: #d7ccb0;
}

.settings-panel {
  max-width: 520px;
}

.settings-panel label {
  display: grid;
  grid-template-columns: 170px 1fr;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
}

.settings-panel input[type="range"] {
  width: 100%;
}

.toggle {
  width: 100%;
  margin-top: 10px;
}

.toggle.on {
  background: #4f7b54;
}

@media (max-width: 720px) {
  .hotbar {
    grid-template-columns: repeat(9, 38px);
    bottom: 14px;
  }

  .slot {
    width: 38px;
    height: 38px;
  }

  .block-chip {
    width: 22px;
    height: 22px;
  }

  .inventory-grid {
    grid-template-columns: repeat(6, 46px);
  }

  .controls-grid,
  .menu-grid {
    grid-template-columns: 1fr;
  }
}
