@font-face {
  font-family: "Monocraft";
  src: url("../assets/fonts/Monocraft.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Monocraft";
  src: url("../assets/fonts/Monocraft-Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --yellow: #ffff55;
  --shadow: #3f3f3f;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: #1b1410;
  color: #fff;
  font-family: "Monocraft", ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

a, button { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ---------- background ---------- */
.bg {
  position: fixed;
  inset: -128px;
  z-index: -1;
  background-color: #3b2a1d;
  background-image: linear-gradient(rgba(0, 0, 0, .62), rgba(0, 0, 0, .62)), var(--tex-dirt, none);
  background-size: auto, 64px 64px;
  image-rendering: pixelated;
  animation: pan 60s linear infinite;
  will-change: transform;
}
@keyframes pan { to { transform: translate(64px, 64px); } }

/* ---------- layout & routing ---------- */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 56px;
}

.screen {
  display: none;
  width: min(100%, 640px);
  flex-direction: column;
  align-items: center;
  gap: 16px;
  scroll-margin-top: 24px;
}
.screen--menu, .screen:target { display: flex; }
.stage:has(.screen:not(.screen--menu):target) .screen--menu { display: none; }

.screen__title {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  text-shadow: 2px 2px 0 var(--shadow);
}

/* ---------- title ---------- */
.title { position: relative; display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; }
.title__logo {
  width: clamp(120px, 22vw, 200px);
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .35));
}
.title__text {
  margin: 4px 0 0;
  font-size: clamp(32px, 8vw, 72px);
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  color: transparent;
  background-color: #8b8b8b;
  background-image: var(--tex-stone, none);
  background-size: 48px 48px;
  -webkit-background-clip: text;
  background-clip: text;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 0 #4a4a4a) drop-shadow(0 3px 0 #2b2b2b) drop-shadow(0 6px 4px rgba(0, 0, 0, .5));
}
.title__splash {
  position: absolute;
  left: 84%;
  bottom: clamp(36px, 6vw, 64px);
  z-index: 2;
  margin: 0;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #3f3f00;
  font-size: clamp(12px, 2.4vw, 20px);
  white-space: nowrap;
  pointer-events: none;
  animation: splash .45s ease-in-out infinite alternate;
}
@keyframes splash {
  from { transform: translateX(-50%) rotate(-20deg) scale(1); }
  to { transform: translateX(-50%) rotate(-20deg) scale(1.1); }
}
@media (max-width: 520px) {
  .title__splash { left: 72%; }
  .foot { font-size: 11px; white-space: nowrap; }
}

/* ---------- MC button ---------- */
.menu { display: flex; flex-direction: column; gap: 8px; width: min(100%, 400px); }
.menu__row, .dialog__row { display: flex; gap: 8px; }

.mc-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  appearance: none;
  font: inherit;
  color: #e0e0e0;
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--shadow);
  background-color: #6f6f6f;
  background-image: linear-gradient(rgba(255, 255, 255, .08), rgba(0, 0, 0, .12)), var(--tex-stone, none);
  background-size: auto, 32px 32px;
  image-rendering: pixelated;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .35), inset -2px -4px 0 rgba(0, 0, 0, .4);
  cursor: pointer;
}
.mc-btn--half { flex: 1; }
.mc-btn--done { width: min(100%, 400px); }
.mc-btn:hover, .mc-btn:focus-visible {
  outline: none;
  color: var(--yellow);
  border-color: #fff;
  background-color: #7f86c9;
  background-image: linear-gradient(rgba(110, 120, 255, .35), rgba(60, 70, 200, .35)), var(--tex-stone, none);
}
.mc-btn[aria-disabled="true"],
.mc-btn[aria-disabled="true"]:hover {
  color: #a0a0a0;
  border-color: #000;
  box-shadow: none;
  background-color: #3c3c3c;
  background-image: linear-gradient(rgba(0, 0, 0, .45), rgba(0, 0, 0, .45)), var(--tex-stone, none);
}
.mc-btn[aria-disabled="true"]:focus-visible { border-color: #fff; }

.sound {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: auto;
  min-height: 32px;
  font-size: 14px;
}
html:not(.js) .sound, html:not(.js) #copy-email { display: none; }

/* ---------- hit (MC hurt) animation ---------- */
.is-hit { z-index: 1; animation: hit 250ms steps(6, end); }
.is-hit::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: rgba(255, 40, 40, .55);
  pointer-events: none;
  animation: hit-flash 250ms steps(2, end) forwards;
}
@keyframes hit {
  0% { transform: translate(var(--kx, 0px), var(--ky, 0px)); }
  60% { transform: translate(calc(var(--kx, 0px) * .4), calc(var(--ky, 0px) * .4)); }
  100% { transform: none; }
}
@keyframes hit-flash {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- projects ("select world") ---------- */
.worlds {
  list-style: none;
  margin: 0;
  padding: 8px;
  width: 100%;
  max-height: min(60vh, 440px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, .55);
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
}
.world {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px;
  color: #fff;
  text-decoration: none;
  border: 2px solid transparent;
}
.world:hover, .world:focus-visible { outline: none; border-color: #a0a0a0; background: rgba(255, 255, 255, .04); }
.block-icon {
  flex: none;
  width: 48px;
  height: 48px;
  background-color: #555;
  background-image: var(--icon, none);
  background-size: cover;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .3);
}
.world__body { display: flex; flex-direction: column; min-width: 0; }
.world__name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.world__stats { display: flex; flex-wrap: wrap; gap: 16px; margin: 4px 0; font-size: 12px; }
.world__stars { display: inline-flex; align-items: center; gap: 8px; color: var(--yellow); }
.world__downloads { color: #a8e6a0; }
.world__role { font-size: 11px; color: #a8e6a0; border: 1px solid #567d4a; padding: 2px 4px; font-weight: normal; }
.world__desc { color: #a0a0a0; font-size: 14px; }

/* ---------- skills (inventory) ---------- */
.inventory-panel {
  padding: 16px;
  color: var(--shadow);
  background: #c6c6c6;
  border: 2px solid #000;
  box-shadow: inset 4px 4px 0 #fff, inset -4px -4px 0 #555;
}
.inventory-panel__label { margin: 0 0 8px; font-size: 14px; font-weight: 400; }
.inventory { --slot: clamp(30px, 9vw, 44px); display: grid; grid-template-columns: repeat(9, var(--slot)); }
.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--slot);
  height: var(--slot);
  background: #8b8b8b;
  box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #fff;
}
.slot:not(.slot--empty):hover, .slot:focus-visible { outline: none; background: #a8a8a8; }
.item {
  display: grid;
  place-items: center;
  width: 80%;
  height: 80%;
  color: #fff;
  font-size: calc(var(--slot) * .3);
  text-shadow: 1px 1px 0 #000;
  background-color: #555;
  background-image: var(--icon, none);
  background-size: cover;
  image-rendering: pixelated;
}

/* ---------- about (book) ---------- */
.book {
  width: min(100%, 420px);
  min-height: 340px;
  padding: 28px 28px 20px;
  color: #2b1d0e;
  background: #f0e2b6;
  border: 2px solid #000;
  box-shadow: inset -6px 0 0 #c9b27a, 0 6px 0 rgba(0, 0, 0, .4);
}
.book__title { margin: 0 0 12px; font-size: 18px; font-weight: 400; text-align: center; }
.book p { margin: 0 0 10px; }
.book__page { text-align: right; color: #6b5532; font-size: 13px; }

/* ---------- contact (dialog) ---------- */
.dialog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 400px);
  padding: 20px;
  text-align: center;
  background: rgba(0, 0, 0, .6);
  border: 2px solid #000;
}
.dialog__email {
  margin: 0;
  padding: 8px;
  word-break: break-all;
  background: #000;
  border: 2px solid #a0a0a0;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- footer ---------- */
.foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 13px;
  text-shadow: 2px 2px 0 var(--shadow);
  pointer-events: none;
}

/* ---------- archery overlay ---------- */
@media (pointer: fine) {
  html.archery-on, html.archery-on * { cursor: none !important; }
}

.fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 20;
  pointer-events: none;
}

.crosshair {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  display: none;
  width: 0;
  height: 0;
  pointer-events: none;
  mix-blend-mode: difference;
  transform: translate(var(--x, -100px), var(--y, -100px));
}
.crosshair.is-visible { display: block; }
.crosshair__inner {
  position: absolute;
  left: -11px;
  top: -11px;
  width: 22px;
  height: 22px;
  transform: scale(var(--s, 1));
}
.crosshair__inner::before, .crosshair__inner::after { content: ""; position: absolute; background: #fff; }
.crosshair__inner::before { left: 0; top: 9px; width: 22px; height: 4px; }
.crosshair__inner::after { left: 9px; top: 0; width: 4px; height: 22px; }
.crosshair.is-locked, .crosshair.is-full { mix-blend-mode: normal; }
.crosshair.is-locked .crosshair__inner::before,
.crosshair.is-locked .crosshair__inner::after { background: #ff3b3b; }
.crosshair.is-full .crosshair__inner { animation: full-blink 240ms steps(1) infinite; will-change: opacity; }
.crosshair.is-full .crosshair__inner::before,
.crosshair.is-full .crosshair__inner::after { background: #fff; box-shadow: 0 0 0 1px #000; }
@keyframes full-blink { 50% { opacity: .35; } }

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  max-width: 260px;
  padding: 4px 8px 6px;
  font-size: 14px;
  text-shadow: 2px 2px 0 var(--shadow);
  background: rgba(16, 0, 16, .94);
  border: 2px solid #100010;
  box-shadow: inset 0 0 0 2px #3c0d8f;
  pointer-events: none;
  transform: translate(var(--x, 0px), var(--y, 0px));
}
.tooltip__title { color: #fff; }
.tooltip__desc { color: #a8a8a8; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bg, .title__splash { animation: none; }
  .title__splash { transform: translateX(-50%) rotate(-20deg); }
  .is-hit { animation: none; }
}

/* ---------- player dialogue ---------- */
.npc-widget { position: fixed; left: 20px; bottom: 34px; z-index: 6; }
.npc {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  text-shadow: 2px 2px 0 var(--shadow);
  cursor: pointer;
}
.npc-model { position: relative; display: block; width: 112px; height: 192px; transform-origin: 50% 100%; }
.npc-part img { display: block; width: 100%; height: 100%; image-rendering: pixelated; transform-origin: inherit; will-change: transform; }
.npc-part { position: absolute; display: block; image-rendering: pixelated; transform-origin: 50% 8%; }
.npc-part--head { width: 48px; height: 48px; left: 32px; top: 0; }
.npc-part--body { width: 48px; height: 72px; left: 32px; top: 48px; }
.npc-part--left-arm { will-change: transform; transform-origin: 33.333% 16.667%; width: 18px; height: 72px; left: 80px; top: 51px; }
.npc-part--right-arm { will-change: transform; transform-origin: 66.667% 16.667%; width: 18px; height: 72px; left: 14px; top: 51px; }
.npc-part--left-leg { width: 24px; height: 72px; left: 56px; top: 120px; }
.npc-part--right-leg { width: 24px; height: 72px; left: 32px; top: 120px; }
@keyframes npc-hurt { 0% { transform: translate(0, 0); } 30% { transform: translate(-12px, -10px) rotate(-12deg); } 70% { transform: translate(-5px, -4px) rotate(5deg); } 100% { transform: none; } }
.npc.is-hit .npc-model { animation: npc-hurt 250ms ease-out; }
.npc__name { padding: 3px 6px; background: rgba(0, 0, 0, .65); font-size: 12px; }
.npc:hover .npc-model, .npc:focus-visible .npc-model { filter: drop-shadow(0 0 4px #ffff55); }
.npc:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.npc.is-hit::after { display: none; }
.npc.is-hit .npc-part { filter: sepia(1) saturate(6) hue-rotate(320deg); }
.npc-dialog {
  position: absolute;
  left: 132px;
  bottom: 0;
  width: 310px;
  padding: 14px;
  background: rgba(16, 0, 16, .96);
  border: 2px solid #100010;
  box-shadow: inset 0 0 0 2px #3c0d8f;
  text-shadow: 2px 2px 0 var(--shadow);
  pointer-events: none;
}
.npc-dialog__name { font-size: 12px; color: #ffff55; }
.npc-dialog p { margin: 8px 0 0; font-size: 14px; line-height: 1.6; }
@media (max-width: 700px), (max-height: 620px) {
  .npc-widget { left: 10px; bottom: 30px; }
  .npc-model { width: 76px; height: 126px; }
  .npc-part { zoom: .65; }
  .npc__name { font-size: 10px; }
  .npc-dialog { position: fixed; left: 10px; bottom: 158px; width: min(310px, calc(100vw - 20px)); max-height: calc(100dvh - 178px); overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .npc-model, .npc-part, .npc.is-hit .npc-model { animation: none; }
}

/* NPC easter egg: fall over, dissolve into XP, then respawn. */
.npc.is-dead { pointer-events: none; }
.npc.is-dead .npc-model { animation: npc-death 650ms ease-in forwards; }
.npc.is-dead .npc__name { visibility: hidden; }
.npc.is-dead .npc-part { filter: sepia(1) saturate(6) hue-rotate(320deg); }
@keyframes npc-death {
  0% { transform: none; opacity: 1; }
  80% { transform: rotate(90deg); opacity: 1; }
  100% { transform: rotate(90deg); opacity: 0; }
}
.npc-xp { position: absolute; left: 50%; bottom: 24px; pointer-events: none; }
.npc-xp__orb {
  position: absolute; width: 12px; height: 12px;
  background: #80e526; border: 3px solid #3a8d16;
  box-shadow: inset 3px 3px #e6ff89;
  clip-path: polygon(25% 0, 75% 0, 75% 25%, 100% 25%, 100% 75%, 75% 75%, 75% 100%, 25% 100%, 25% 75%, 0 75%, 0 25%, 25% 25%);
  animation: npc-xp 1700ms var(--xp-delay) ease-out both;
}
@keyframes npc-xp {
  0% { transform: translate(0, 0) scale(.5); opacity: 0; }
  15% { opacity: 1; }
  65% { transform: translate(var(--xp-x), var(--xp-y)) scale(1); opacity: 1; }
  100% { transform: translate(var(--xp-x), -10px) scale(.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .npc.is-dead .npc-model { animation: none; opacity: 0; }
  .npc-xp__orb { animation-duration: 400ms; }
}
