:root {
  color-scheme: dark;
  font-family: "Courier New", "Lucida Console", monospace;
  --sky-top: #6ec5ff;
  --sky-bottom: #dff3ff;
  --panel-dark: #1f3a2f;
  --panel-mid: #40684f;
  --panel-light: #88b06c;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgb(255 255 255 / 55%), transparent 30%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
}

canvas {
  display: block;
}

#welcome-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
  background:
    linear-gradient(180deg, #72b8ff 0%, #8fd0ff 24%, #d8efff 58%, #f4e0ba 100%);
}

#welcome-screen.hidden {
  display: none;
}

.welcome-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.welcome-sun {
  position: absolute;
  left: 9%;
  top: 12%;
  width: 110px;
  height: 110px;
  background:
    radial-gradient(circle, rgb(255 255 255 / 96%) 0 34%, rgb(255 238 163 / 96%) 35% 60%, rgb(255 228 132 / 0%) 61%);
  filter: drop-shadow(0 0 42px rgb(255 240 176 / 0.7));
}

.welcome-cloud {
  position: absolute;
  height: 22px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.92) 0 60%, rgb(212 232 255 / 0.92) 60% 100%);
  box-shadow:
    24px 0 0 0 rgb(255 255 255 / 0.92),
    48px 0 0 0 rgb(255 255 255 / 0.92),
    12px 22px 0 0 rgb(230 240 255 / 0.92),
    36px 22px 0 0 rgb(230 240 255 / 0.92);
  opacity: 0.72;
}

.welcome-cloud--a {
  top: 14%;
  left: 58%;
  width: 72px;
}

.welcome-cloud--b {
  top: 22%;
  left: 20%;
  width: 64px;
  transform: scale(0.85);
}

.welcome-cloud--c {
  top: 18%;
  left: 74%;
  width: 58px;
  transform: scale(0.75);
}

.welcome-ground {
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: -2%;
  height: 28%;
  background:
    linear-gradient(180deg, #56b55a 0 10%, #4d8f48 10% 24%, #715643 24% 100%);
  clip-path: polygon(0 34%, 10% 28%, 20% 36%, 32% 24%, 47% 30%, 60% 18%, 75% 26%, 100% 12%, 100% 100%, 0 100%);
  box-shadow: inset 0 10px 0 rgb(118 219 112 / 0.42);
}

.welcome-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgb(255 255 255 / 0) 0 3px,
    rgb(0 0 0 / 0.045) 3px 4px
  );
  mix-blend-mode: multiply;
}

.floating-block {
  position: absolute;
  width: 62px;
  height: 62px;
  border: 4px solid rgb(0 0 0 / 0.2);
  image-rendering: pixelated;
  box-shadow:
    inset -10px -10px 0 rgb(0 0 0 / 0.18),
    0 18px 30px rgb(0 0 0 / 0.18);
  animation: float-block 5.2s steps(6) infinite;
}

.floating-block--grass {
  top: 18%;
  right: 19%;
  background:
    linear-gradient(180deg, #6ddf73 0 18%, #6cb052 18% 20%, #7b5b43 20% 100%);
}

.floating-block--stone {
  top: 52%;
  right: 9%;
  width: 54px;
  height: 54px;
  background:
    linear-gradient(135deg, #9ca4b0 0 36%, #7b8798 36% 100%);
  animation-delay: -1.2s;
}

.floating-block--sand {
  top: 26%;
  left: 14%;
  width: 52px;
  height: 52px;
  background:
    linear-gradient(135deg, #ecd086 0 42%, #c9ab5f 42% 100%);
  animation-delay: -2.4s;
}

.floating-block--wood {
  top: 60%;
  left: 10%;
  width: 58px;
  height: 58px;
  background:
    linear-gradient(90deg, #8d6238 0 18%, #a97a46 18% 34%, #87572d 34% 52%, #aa7b46 52% 68%, #8a5b31 68% 100%);
  animation-delay: -3.2s;
}

.welcome-panel {
  position: relative;
  width: min(92vw, 820px);
  padding: 30px;
  border: 4px solid #111a10;
  box-shadow:
    inset 0 0 0 4px #7d9c62,
    inset 0 0 0 8px #2c3f22,
    0 28px 70px rgb(0 0 0 / 28%);
  background:
    linear-gradient(180deg, rgb(46 65 29 / 0.95) 0%, rgb(28 42 20 / 0.97) 100%);
  color: #eef7ea;
}

.welcome-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgb(214 255 184 / 0.1);
  pointer-events: none;
}

.welcome-kicker {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 10px;
  border: 2px solid #203019;
  background: linear-gradient(180deg, #a0d776 0%, #7bb44f 100%);
  color: #12200b;
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 rgb(0 0 0 / 18%);
}

.welcome-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.welcome-title {
  margin: 0;
  font-size: clamp(44px, 8vw, 94px);
  line-height: 0.88;
  color: #f7ffe9;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 #253615,
    6px 6px 0 rgb(0 0 0 / 18%);
}

.welcome-copy {
  max-width: 60ch;
  margin: 18px 0 22px;
  color: #d5e8d0;
  font-size: 15px;
  line-height: 1.6;
}

.welcome-copy a {
  color: #f5ffb7;
  text-decoration: none;
}

.welcome-copy a:hover {
  text-decoration: underline;
}

.welcome-brand {
  margin: 0 0 6px;
}

.welcome-brand-logo {
  display: block;
  width: min(78px, 16vw);
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 6px 14px rgb(0 0 0 / 18%));
}

.welcome-copy--small {
  margin-top: -8px;
  font-size: 13px;
  color: #c9e4c9;
}

.welcome-copy--small a {
  color: #f5ffb7;
  text-decoration: none;
}

.welcome-copy--small a:hover {
  text-decoration: underline;
}

.welcome-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.welcome-button {
  border: 3px solid #17220e;
  box-shadow:
    inset 0 0 0 3px #b7ef79,
    0 6px 0 #294717;
  background: linear-gradient(180deg, #89df5f 0%, #5ca735 100%);
  color: #13210d;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transform: translateY(0);
}

.welcome-button:hover:enabled {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.welcome-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.welcome-status {
  min-width: 160px;
  padding: 10px 12px;
  border: 2px solid rgb(199 232 172 / 0.16);
  background: rgb(255 255 255 / 0.06);
  color: #e2f4d7;
  font-size: 13px;
}

.welcome-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.welcome-loading.hidden {
  display: none;
}

.welcome-loading-bar {
  position: relative;
  width: min(300px, 52vw);
  height: 14px;
  border: 2px solid #17220e;
  box-shadow: inset 0 0 0 2px #41632e;
  background:
    linear-gradient(180deg, rgb(10 20 7 / 80%) 0%, rgb(25 45 16 / 88%) 100%);
  overflow: hidden;
}

.welcome-loading-fill {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      #9ae66f 0 16px,
      #7bcb51 16px 32px
    );
  transform: translateX(-72%);
  animation: welcome-loading-scan 1.35s linear infinite;
  box-shadow:
    0 0 16px rgb(154 230 111 / 30%),
    inset 0 0 0 2px rgb(220 255 182 / 0.18);
}

.welcome-loading-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.welcome-loading-dots span {
  width: 8px;
  height: 8px;
  background: #dff7c6;
  box-shadow:
    0 0 0 2px #28411b,
    0 0 10px rgb(212 255 180 / 0.35);
  animation: welcome-dot-bounce 1s steps(2) infinite;
}

.welcome-loading-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.welcome-loading-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

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

#hud.hidden {
  display: none;
}

#underwater-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 35%, rgb(122 184 255 / 0.2) 0%, rgb(74 130 214 / 0.22) 28%, rgb(39 88 170 / 0.44) 100%),
    linear-gradient(180deg, rgb(55 108 198 / 0.22) 0%, rgb(26 67 145 / 0.52) 100%);
  opacity: 0;
  transition: opacity 120ms ease-out;
}

#underwater-overlay.hidden {
  opacity: 0;
}

#underwater-overlay.is-active {
  opacity: 1;
}

#tips {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 2px solid #1d1d1d;
  border-radius: 2px;
  color: #f3f3f3;
  background: rgb(38 38 38 / 88%);
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 0.4px;
}

#status {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 0;
  border: 0;
  color: #ffffff;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
}

#crosshair.hidden {
  display: none;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgb(255 255 255 / 90%);
}

#crosshair::before {
  left: 7px;
  top: 0;
  width: 2px;
  height: 16px;
}

#crosshair::after {
  left: 0;
  top: 7px;
  width: 16px;
  height: 2px;
}

#hotbar-hud {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
}

#hotbar-label {
  min-height: 18px;
  color: #fff9c9;
  font-size: 14px;
  text-shadow:
    0 2px 0 #000,
    0 0 8px rgb(0 0 0 / 45%);
  letter-spacing: 0.4px;
}

#vitals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.vital-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.vital-row:last-child {
  justify-content: flex-end;
}

.vital-icon {
  width: 15px;
  height: 15px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / 55%));
}

.heart {
  background-image: url("./assets/minecraft/textures/gui/sprites/hud/heart/container.png");
}

.heart.is-filled {
  background-image: url("./assets/minecraft/textures/gui/sprites/hud/heart/full.png");
}

.hunger {
  background-image: url("./assets/minecraft/textures/gui/sprites/hud/food_empty.png");
}

.hunger.is-filled {
  background-image: url("./assets/minecraft/textures/gui/sprites/hud/food_full.png");
}

#hotbar-xp {
  width: 100%;
  height: 8px;
  border: 2px solid #0d1117;
  background: rgb(6 19 11 / 85%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 10%),
    0 2px 0 rgb(0 0 0 / 35%);
}

#hotbar-xp-fill {
  height: 100%;
  width: 8%;
  background: linear-gradient(180deg, #85ff63 0%, #2cc62f 100%);
  box-shadow: 0 0 8px rgb(95 255 103 / 35%);
}

#hotbar {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
  width: 364px;
  height: 44px;
  padding: 2px 3px;
  background: url("./assets/minecraft/textures/gui/sprites/hud/hotbar.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 4px 8px rgb(0 0 0 / 30%));
  image-rendering: pixelated;
}

.hotbar-slot {
  position: relative;
  width: 40px;
  height: 40px;
}

.hotbar-slot.is-selected {
  background: url("./assets/minecraft/textures/gui/sprites/hud/hotbar_selection.png") center / 100% 100% no-repeat;
}

.hotbar-slot.is-empty {
  opacity: 0.7;
}

.hotbar-icon {
  position: absolute;
  inset: 6px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  display: grid;
  place-items: center;
  color: #eef8ff;
  font-size: 10px;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000;
}

.hotbar-count {
  position: absolute;
  right: 4px;
  bottom: 1px;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000;
}

#toolbox {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  --toolbox-w: min(68vw, 460px);
  --u: calc(var(--toolbox-w) / 176);
  width: var(--toolbox-w);
  aspect-ratio: 176 / 166;
  pointer-events: auto;
  image-rendering: pixelated;
  color: #202020;
}

#toolbox.hidden {
  display: none;
}

.inventory-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url("./assets/minecraft/textures/gui/container/inventory.png");
  background-repeat: no-repeat;
  background-position: top left;
  background-size: calc(100% * 256 / 176) calc(100% * 256 / 166);
  filter: drop-shadow(0 16px 40px rgb(0 0 0 / 55%));
}

.inventory-slot {
  width: calc(var(--u) * 16);
  height: calc(var(--u) * 16);
  background: url("./assets/minecraft/textures/gui/sprites/container/slot.png") center / 100% 100% no-repeat;
}

.inventory-slot--armor,
.inventory-slot--offhand {
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 1;
  filter: none;
}

.inventory-slot--armor {
  width: calc(var(--u) * 14);
  height: calc(var(--u) * 14);
  position: relative;
  z-index: 5;
}

.inventory-slot--offhand {
  position: absolute;
  width: calc(var(--u) * 14);
  height: calc(var(--u) * 14);
  z-index: 5;
}

.inventory-slot--helmet {
  background-image: url("./assets/minecraft/textures/gui/sprites/container/slot/helmet.png");
}

.inventory-slot--chestplate {
  background-image: url("./assets/minecraft/textures/gui/sprites/container/slot/chestplate.png");
}

.inventory-slot--leggings {
  background-image: url("./assets/minecraft/textures/gui/sprites/container/slot/leggings.png");
}

.inventory-slot--boots {
  background-image: url("./assets/minecraft/textures/gui/sprites/container/slot/boots.png");
}

.inventory-armor-slot {
  position: absolute;
}

.inventory-armor-slot--helmet {
  left: 5.1%;
  top: 5.7%;
}

.inventory-armor-slot--chestplate {
  left: 5.1%;
  top: 16.543%;
}

.inventory-armor-slot--leggings {
  left: 5.1%;
  top: 27.387%;
}

.inventory-armor-slot--boots {
  left: 5.1%;
  top: 38.23%;
}

.inventory-slot--shield {
  background-image: url("./assets/minecraft/textures/gui/sprites/container/slot/shield.png");
}

.inventory-player {
  position: absolute;
  left: calc(var(--u) * 28);
  top: calc(var(--u) * 11);
  width: calc(var(--u) * 40);
  height: calc(var(--u) * 63);
}

.inventory-player-preview {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.04));
  image-rendering: pixelated;
}

#inventory-player-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.inventory-slot--offhand {
  left: 44.3%;
  top: 38.2%;
}

.inventory-crafting {
  position: absolute;
  left: calc(var(--u) * 96);
  top: calc(var(--u) * 7);
  width: calc(var(--u) * 76);
  height: calc(var(--u) * 54);
}

.inventory-crafting-title {
  position: absolute;
  left: calc(var(--u) * 13);
  top: calc(var(--u) * 2);
  color: #3c3c3c;
  font-size: calc(var(--u) * 6);
  line-height: 1;
}

.recipe-book-toggle {
  position: absolute;
  left: calc(var(--u) * 106);
  top: calc(var(--u) * 61);
  width: calc(var(--u) * 17);
  height: calc(var(--u) * 18);
  border: 0;
  background: url("./assets/minecraft/textures/gui/sprites/recipe_book/button.png") center / 100% 100% no-repeat;
  cursor: pointer;
  image-rendering: pixelated;
  padding: 0;
}

.recipe-book-toggle:hover {
  background-image: url("./assets/minecraft/textures/gui/sprites/recipe_book/button_highlighted.png");
}

.inventory-storage {
  position: absolute;
  left: calc(var(--u) * 8);
  right: calc(var(--u) * 8);
  top: calc(var(--u) * 85);
  height: calc(var(--u) * 68);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 4);
}

.inventory-slot-grid {
  display: grid;
  grid-template-columns: repeat(9, calc(var(--u) * 16));
  grid-auto-rows: calc(var(--u) * 16);
  gap: 0;
  align-content: start;
}

#inventory-list {
  flex: 0 0 calc(var(--u) * 48);
  grid-template-rows: repeat(3, calc(var(--u) * 16));
}

.inventory-slot-grid--hotbar {
  flex: 0 0 calc(var(--u) * 16);
  grid-template-rows: calc(var(--u) * 16);
}

.inventory-item-slot {
  position: relative;
  width: calc(var(--u) * 16);
  height: calc(var(--u) * 16);
}

.inventory-item-icon {
  position: absolute;
  inset: calc(var(--u) * 2.5);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
}

.inventory-item-count {
  position: absolute;
  right: calc(var(--u) * 1.5);
  bottom: calc(var(--u) * 1);
  color: #ffffff;
  font-size: calc(var(--u) * 7);
  line-height: 1;
  text-shadow:
    1px 1px 0 #000,
    -1px 1px 0 #000,
    1px -1px 0 #000,
    -1px -1px 0 #000;
}

.inventory-empty-slot {
  width: calc(var(--u) * 16);
  height: calc(var(--u) * 16);
}

.recipe-panel {
  position: absolute;
  right: -18px;
  top: 44px;
  width: 248px;
  max-height: 468px;
  padding: 14px 14px 12px;
  border: 4px solid #161616;
  box-shadow:
    inset 0 0 0 4px #8f8f8f,
    0 10px 24px rgb(0 0 0 / 28%);
  background: linear-gradient(180deg, #c6c6c6 0%, #a5a5a5 100%);
}

.recipe-panel.hidden {
  display: none;
}

.recipe-panel-title {
  margin-bottom: 10px;
  font-size: 18px;
  color: #222222;
}

.recipe-panel-list {
  display: grid;
  gap: 8px;
  max-height: 416px;
  overflow: auto;
  padding-right: 4px;
}

.recipe-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px;
  border: 3px solid #535353;
  box-shadow: inset 0 0 0 2px #d2d2d2;
  background: linear-gradient(180deg, #bdbdbd 0%, #9f9f9f 100%);
}

.recipe-left {
  min-width: 0;
}

.recipe-name {
  font-size: 14px;
  font-weight: 700;
  color: #161616;
}

.recipe-need {
  margin-top: 3px;
  font-size: 12px;
  color: #303030;
}

.recipe-item button {
  align-self: center;
  border: 2px solid #2c2c2c;
  box-shadow: inset 0 0 0 2px #d0d0d0;
  background: linear-gradient(180deg, #d8d8d8 0%, #b4b4b4 100%);
  color: #121212;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

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

@media (max-width: 760px) {
  .welcome-panel {
    width: min(94vw, 820px);
    padding: 22px;
  }

  .welcome-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .welcome-title {
    font-size: clamp(42px, 13vw, 74px);
  }

  .welcome-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .floating-block {
    display: none;
  }

  #status {
    font-size: 14px;
  }

  #hotbar {
    width: 274px;
    height: 33px;
    padding: 1px 2px;
  }

  .hotbar-slot {
    width: 30px;
    height: 30px;
  }

  .hotbar-icon {
    inset: 4px;
  }

  .hotbar-count {
    font-size: 12px;
  }

  #hotbar-xp {
    width: 100%;
  }

  #vitals {
    width: 100%;
  }

  .vital-icon {
    width: 14px;
    height: 14px;
  }

  #toolbox {
    --toolbox-w: min(90vw, 460px);
    width: var(--toolbox-w);
    height: auto;
  }

  .inventory-screen {
    aspect-ratio: 704 / 664;
  }

  .recipe-panel {
    right: 10px;
    top: 10px;
    width: min(42vw, 220px);
    max-height: min(54vh, 360px);
  }
}

@keyframes float-block {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes welcome-loading-scan {
  0% {
    transform: translateX(-72%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes welcome-dot-bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
