:root {
  --ink: #14221a;
  --leaf: #3f8f4b;
  --leaf-dark: #24643a;
  --mint: #dfffe8;
  --paper: #fbfff7;
  --gold: #f7ce57;
  --coral: #ef6a52;
  --cyan: #68d7d2;
  --shadow: rgba(7, 15, 10, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #244c36;
  color: var(--ink);
  font-family: "Lucida Console", "Courier New", monospace;
}

button,
a {
  font: inherit;
}

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

#game,
.world-ui {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game {
  z-index: 1;
  image-rendering: pixelated;
}

.world-ui {
  z-index: 2;
  pointer-events: none;
}

.hud {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  right: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 10px;
  width: min(600px, calc(100vw - 24px));
  padding: 9px 11px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 92%, var(--mint));
  box-shadow: 0 5px 0 var(--shadow);
}

.eyebrow,
.subtitle,
.guide span,
.toast,
.world-panel .meta,
.world-panel .skills,
.world-panel .small-note {
  font-size: 12px;
  line-height: 1.45;
}

.hud > div:first-child {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--leaf-dark);
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.15;
}

.subtitle {
  margin-bottom: 0;
  max-width: none;
  font-size: 10px;
  white-space: nowrap;
}

.hud-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.hud-actions a,
.hud-actions button,
.quick-map button,
.touch-pad button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.hud-actions a,
.hud-actions button {
  flex: 0 0 auto;
  font-size: 13px;
  padding: 5px 6px;
}

.hud-actions button:active,
.hud-actions a:active,
.quick-map button:active,
.touch-pad button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.quick-map {
  position: absolute;
  z-index: 5;
  left: 16px;
  bottom: 18px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  max-width: calc(100vw - 250px);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}

.quick-map::-webkit-scrollbar {
  display: none;
}

.quick-map button {
  flex: 0 0 auto;
  min-width: 88px;
  padding: 7px 9px;
  background: var(--cyan);
  white-space: nowrap;
}

.guide {
  position: absolute;
  z-index: 5;
  right: 16px;
  bottom: 58px;
  display: grid;
  gap: 5px;
  width: 210px;
  padding: 12px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 0 var(--shadow);
}

.asset-credit {
  position: absolute;
  z-index: 5;
  right: 16px;
  bottom: 18px;
  width: 210px;
  margin: 0;
  padding: 7px 9px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--mint);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 5px 0 var(--shadow);
}

.mission-button {
  position: absolute;
  z-index: 6;
  top: 12px;
  right: 16px;
  width: 210px;
  min-height: 36px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  pointer-events: auto;
}

.mission-button.is-complete {
  background: #9be58f;
}

.mission-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.mission-window {
  position: absolute;
  z-index: 6;
  top: 60px;
  right: 16px;
  display: grid;
  gap: 7px;
  width: 210px;
  padding: 10px 12px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--shadow);
  pointer-events: none;
}

.mission-complete-mark {
  position: absolute;
  top: 8px;
  right: 10px;
  display: none;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: #9be58f;
  color: var(--ink);
}

.mission-window.is-complete .mission-complete-mark {
  display: inline-flex;
}

.mission-window.is-hidden {
  display: none;
}

.mission-window strong,
.mission-window span {
  font-size: 11px;
  line-height: 1.35;
}

.mission-window p {
  margin-bottom: 0;
  padding-right: 24px;
  font-size: 10px;
  line-height: 1.35;
}

.mission-window ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mission-window li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--mint);
}

.mission-window li.is-complete {
  background: var(--cyan);
}

.mission-hint {
  color: var(--leaf-dark);
}

.mission-modal {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 34, 26, 0.45);
  pointer-events: auto;
}

.mission-modal.is-hidden {
  display: none;
}

.mission-modal-card {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 32px));
  padding: 22px 18px 18px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 0 var(--shadow);
  text-align: center;
}

.mission-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  min-height: 30px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
}

.mission-modal-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
}

.mission-modal-actions button,
.mission-modal-actions a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--cyan);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.touch-pad {
  position: absolute;
  z-index: 6;
  right: 16px;
  bottom: 150px;
  display: none;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 42px);
  gap: 6px;
}

.touch-pad button {
  width: 48px;
  min-height: 42px;
  padding: 0;
  background: var(--paper);
  font-size: 10px;
}

.touch-pad [data-dir="up"] {
  grid-column: 2;
}

.touch-pad [data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-pad [data-dir="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-pad [data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 92px;
  max-width: min(520px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--mint);
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 6px 0 var(--shadow);
}

.toast.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  pointer-events: none;
}

.npc-prompt,
.npc-dialog,
.collect-prompt,
.collect-dialog {
  position: absolute;
  z-index: 6;
  border: 3px solid var(--ink);
  border-radius: 6px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  box-shadow: 0 5px 0 var(--shadow);
}

.npc-prompt,
.collect-prompt {
  padding: 5px 8px;
  background: var(--gold);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.2;
}

.npc-dialog {
  width: 310px;
  max-width: calc(100vw - 32px);
  padding: 11px 13px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.collect-dialog {
  min-width: 160px;
  max-width: calc(100vw - 32px);
  padding: 8px 10px;
  background: var(--mint);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.npc-prompt.is-hidden,
.npc-dialog.is-hidden,
.collect-prompt.is-hidden,
.collect-dialog.is-hidden {
  opacity: 0;
}

.world-panel {
  position: absolute;
  z-index: 2;
  width: 480px;
  max-width: calc(100vw - 42px);
  padding: 16px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 0 var(--shadow);
  pointer-events: auto;
  transition: filter 160ms ease, transform 160ms ease;
}

.player-sprite {
  position: absolute;
  z-index: 4;
  width: 48px;
  height: 48px;
  background-repeat: no-repeat;
  background-size: 384px 96px;
  image-rendering: pixelated;
  pointer-events: none;
  transform-origin: center bottom;
}

.player-sprite::after {
  content: "";
  position: absolute;
  left: 6px;
  bottom: -1px;
  z-index: -1;
  width: 36px;
  height: 14px;
  border-radius: 50%;
  background: rgba(10, 20, 12, 0.35);
}

.world-panel::before {
  content: "";
  position: absolute;
  inset: -12px 26px auto;
  height: 12px;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--coral);
}

.world-panel.is-near {
  filter: saturate(1.18);
}

.world-panel h2 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
  color: var(--leaf-dark);
}

.world-panel h3 {
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.25;
}

.world-panel p {
  line-height: 1.5;
}

.world-panel ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.world-panel li {
  margin-bottom: 8px;
  line-height: 1.45;
}

.world-panel .entry {
  padding: 9px 0;
  border-top: 3px dotted rgba(63, 143, 75, 0.55);
  border-top: 3px dotted color-mix(in srgb, var(--leaf) 55%, transparent);
}

.world-panel .entry:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.world-panel .meta {
  margin-bottom: 7px;
  color: #3c6049;
}

.world-panel .skills {
  margin: 7px 0 0;
  color: #225f60;
}

.world-panel .small-note {
  margin-bottom: 0;
  color: #485a50;
}

@media (max-width: 760px) {
  .hud {
    display: grid;
    padding: 12px;
  }

  h1 {
    font-size: 17px;
  }

  .hud-actions {
    justify-content: flex-start;
  }

  .quick-map {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }

  .quick-map button {
    min-width: 76px;
    font-size: 10px;
  }

  .guide {
    display: none;
  }

  .asset-credit {
    display: none;
  }

  .mission-button {
    top: 108px;
    right: 12px;
    width: 190px;
  }

  .mission-window {
    top: 156px;
    right: 12px;
    width: 190px;
  }

  .touch-pad {
    display: grid;
  }

  .toast {
    bottom: 176px;
  }

  .world-panel {
    width: 410px;
    padding: 14px;
  }
}

@media (max-height: 620px) {
  .guide,
  .asset-credit,
  .mission-button,
  .mission-window,
  .toast {
    display: none;
  }
}
