/* ---------------------------------------------------------------------------
   BlockCraft 2D - retro UI
--------------------------------------------------------------------------- */

:root {
  --hud-bg: rgba(12, 14, 20, 0.62);
  --accent: #7cd468;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0c12;
}

body {
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

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

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

.panel {
  position: absolute;
  background: var(--hud-bg);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 2px 2px 0 rgba(0, 0, 0, 0.35);
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.5;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

#stats {
  top: 12px;
  left: 12px;
}

#daybox {
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#clock {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

/* ----- hotbar ----- */

#hotbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--hud-bg);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 2px 2px 0 rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.slot {
  position: relative;
  width: 48px;
  height: 48px;
  background: rgba(28, 30, 38, 0.85);
  border: 2px solid #101216;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.slot canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.slot-num {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 1px 1px 0 #000;
}

.slot.selected {
  border-color: #fff;
  box-shadow: inset 0 0 0 1px #fff, 0 0 8px rgba(255, 255, 255, 0.35);
  transform: translateY(-3px);
  background: rgba(48, 52, 64, 0.9);
}

.slot-count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 11px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

#blockname {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
  opacity: 0;
  transition: opacity 0.35s ease;
  white-space: nowrap;
}

#blockname.show {
  opacity: 1;
}

/* ----- inventory / crafting screen ----- */

#toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 14, 20, 0.85);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 2px 2px 0 rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 40;
}

#toast.show {
  opacity: 1;
}

#screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 12, 0.5);
  z-index: 30;
}

#screen.hidden {
  display: none;
}

#screen-panel {
  background: rgba(24, 26, 33, 0.96);
  border: 3px solid #000;
  box-shadow: 0 0 0 2px #454a56, 10px 10px 0 rgba(0, 0, 0, 0.45);
  padding: 20px 26px 16px;
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  text-align: center;
}

#screen-title {
  font-size: 22px;
  letter-spacing: 5px;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 16px;
}

#screen-body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

#inv-main {
  display: grid;
  grid-template-columns: repeat(9, 44px);
  gap: 3px;
}

#inv-craft {
  display: flex;
  align-items: center;
  gap: 6px;
}

#craft-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 3px;
}

#craft-arrow {
  font-size: 24px;
  color: #ffd75e;
  text-shadow: 2px 2px 0 #000;
  margin: 0 4px;
}

.slot-output {
  box-shadow: inset 0 0 0 1px rgba(255, 215, 94, 0.35);
}

#inv-hint {
  width: 200px;
  font-size: 11px;
  line-height: 1.9;
  color: #9aa3b8;
  text-align: left;
  text-shadow: 1px 1px 0 #000;
}

#inv-hint b {
  color: #ffd75e;
  font-size: 12px;
}

.inv-slot {
  width: 44px;
  height: 44px;
}

.inv-slot canvas {
  width: 30px;
  height: 30px;
}

.slot.disabled {
  opacity: 0.3;
  pointer-events: none;
}

#inv-hotbar {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid #3a3d44;
}

#screen-tip {
  margin-top: 10px;
  font-size: 11px;
  color: #7f8798;
  text-shadow: 1px 1px 0 #000;
}

#cursor-item {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#cursor-item.hidden {
  display: none;
}

#cursor-item canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

#cursor-count {
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 12px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  font-weight: 700;
}

/* ----- overlay / menu ----- */

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 12, 0.55);
}

#overlay.hidden {
  display: none;
}

#menu {
  background: rgba(20, 23, 31, 0.94);
  border: 3px solid #000;
  box-shadow: 0 0 0 2px #454a56, 10px 10px 0 rgba(0, 0, 0, 0.45);
  padding: 30px 40px 24px;
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  text-align: center;
}

#logo {
  font-size: 44px;
  letter-spacing: 8px;
  text-shadow: 4px 4px 0 #000;
}

#logo span {
  color: var(--accent);
}

#swatches {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

#swatches i {
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

#swatches i:nth-child(1) { background: #67a832; }
#swatches i:nth-child(2) { background: #8a5a2f; }
#swatches i:nth-child(3) { background: #8f8f8f; }
#swatches i:nth-child(4) { background: #6d4c2a; }
#swatches i:nth-child(5) { background: #b08a4f; }
#swatches i:nth-child(6) { background: #4aedd9; }
#swatches i:nth-child(7) { background: #d9c77e; }

#tagline {
  margin-top: 14px;
  font-size: 13px;
  color: #aeb6c8;
  text-shadow: 1px 1px 0 #000;
}

#menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px auto 0;
  width: 280px;
}

.mcbtn {
  font: inherit;
  font-size: 16px;
  color: #fff;
  text-shadow: 2px 2px 0 #3a3a3a;
  padding: 10px 12px;
  background: linear-gradient(#9a9a9a, #777 45%, #6a6a6a);
  border: 2px solid #000;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.35), 2px 2px 0 rgba(0, 0, 0, 0.4);
  cursor: pointer;
  letter-spacing: 1px;
}

.mcbtn:hover {
  background: linear-gradient(#b0b0b0, #8a8a8a 45%, #7c7c7c);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.35), 0 0 0 2px #ffd75e, 2px 2px 0 rgba(0, 0, 0, 0.4);
}

.mcbtn:active {
  transform: translateY(1px);
}

#controls {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
  font-size: 13px;
  color: #cfd6e4;
  text-align: left;
}

#controls b {
  color: #ffd75e;
  font-weight: 700;
}

#seedline {
  margin-top: 20px;
  font-size: 12px;
  color: #8b93a7;
  text-shadow: 1px 1px 0 #000;
}

/* ----- small screens ----- */

@media (max-width: 640px) {
  #logo {
    font-size: 30px;
    letter-spacing: 4px;
  }

  #menu {
    padding: 22px 18px 18px;
  }

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

  .slot canvas {
    width: 26px;
    height: 26px;
  }

  .panel {
    font-size: 11px;
    padding: 4px 8px;
  }

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

  .inv-slot canvas {
    width: 26px;
    height: 26px;
  }

  #inv-main {
    grid-template-columns: repeat(9, 38px);
  }

  #craft-grid {
    grid-template-columns: repeat(3, 38px);
  }

  #inv-hint {
    display: none;
  }

  #screen-panel {
    padding: 14px 12px 12px;
  }
}
