* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #f2f4ff;
  font: 15px/1.4 system-ui, sans-serif;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#water, #fade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
#water { background: rgba(25, 70, 170, 0.45); }
#fade { background: #fff; transition: opacity 0.3s; }

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  mix-blend-mode: difference;
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
}

#status, #hint {
  position: fixed;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#status {
  left: 12px;
  top: 12px;
  font-variant-numeric: tabular-nums;
}
#hint {
  left: 12px;
  top: 46px;
}
#hint:empty { display: none; }

#hotbar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#hotbar canvas {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  border: 2px solid transparent;
  border-radius: 4px;
}
#hotbar canvas.selected { border-color: #fff; }

#labels span {
  position: fixed;
  left: 0;
  top: 0;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

.bubble {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  max-width: 240px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff;
  color: #14162b;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

#markers .ally { border-color: rgba(120, 230, 140, 0.8); color: #c6f7d0; background: rgba(0, 50, 15, 0.35); }

#markers span {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 24px;
  min-height: 24px;
  padding: 2px 4px;
  border: 1px solid;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
#markers .enemy { border-color: rgba(255, 90, 80, 0.8); }
#markers .friend { border-color: rgba(110, 190, 255, 0.5); }
#markers .boss { border: 2px solid #ff4030; color: #ffb0a8; background: rgba(60, 0, 0, 0.35); }

#damage {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(transparent 45%, rgba(255, 30, 10, 0.55));
}

#shield, #boss {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
  font-size: 13px;
  text-align: center;
}
#shield { bottom: 78px; }
#boss { top: 88px; font-weight: 600; }
#shield.hidden, #boss.hidden, #banner.hidden, #travel li.hidden { display: none; }

.bar {
  height: 10px;
  margin-top: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
}
.bar > div { height: 100%; background: #62b6ff; transition: width 0.15s; }
#boss .bar > div { background: #ff4030; }
#warning {
  margin-top: 6px;
  color: #7dff8a;
  font-size: 16px;
  font-weight: 700;
}
#warning:empty { display: none; }

#banner {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

#travel {
  position: fixed;
  right: 12px;
  top: 12px;
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(8, 10, 32, 0.9);
  pointer-events: none;
}
#travel.hidden { display: none; }
#travel h2 { margin: 0; font-size: 18px; }
#travel p { margin: 2px 0 8px; font-size: 13px; color: #a9b0d8; }
#travel ol { margin: 0; padding: 0; list-style: none; }
#travel li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
#travel li.here { color: #8f96bd; }
#travel kbd {
  width: 20px;
  border-radius: 4px;
  background: #e8ecff;
  color: #0a0d2a;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
#travel .dist { margin-left: auto; font-size: 13px; color: #a9b0d8; }

#inventory {
  position: fixed;
  inset: 0 0 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 3, 16, 0.4);
}
#inventory.hidden { display: none; }
#inventory h2 { margin: 0; font-size: 20px; }
#inventory p { min-height: 20px; margin: 2px 0 10px; font-size: 13px; color: #a9b0d8; }
#inventory h3 { margin: 10px 0 4px; font-size: 14px; color: #cfd5f7; }
#inventory .panel { width: min(780px, 100%); padding: 16px 18px; }
.inventory-columns { display: flex; flex-wrap: wrap; gap: 18px; }
.inventory-main { flex: 1 1 340px; min-width: 0; }
.avatar-editor { flex: 0 0 190px; }
.avatar-editor p { margin: 6px 0 0; font-size: 12px; }
#avatar-canvas {
  display: block;
  width: 128px;
  height: 256px;
  image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: repeating-conic-gradient(#3a3d52 0 25%, #2a2c3e 0 50%) 0 0 / 16px 16px;
  cursor: crosshair;
  touch-action: none;
}
#avatar-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin: 6px 0; }
#avatar-palette button {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}
#avatar-palette button.selected { border-color: #fff; }
.gear-list { display: flex; flex-wrap: wrap; gap: 4px; }
.gear-list button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.gear-list button:hover { background: rgba(255, 255, 255, 0.18); }
.gear-list button.selected { border-color: #fff; }
.gear-list i { width: 12px; height: 12px; border-radius: 3px; }
#inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
}
#inventory-grid canvas {
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
#inventory-grid canvas:hover { border-color: #fff; }
#hotbar.open { pointer-events: auto; }
#hotbar.open canvas { cursor: pointer; }

#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 3, 16, 0.55);
}
#menu.hidden { display: none; }

.panel {
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(8, 10, 32, 0.88);
}
.panel h1 { margin: 0; font-size: 34px; }
.lead { margin: 4px 0 16px; color: #b8bfe6; }

#player-name {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
}
.name-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

#play {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: #e8ecff;
  color: #0a0d2a;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
#play:hover:enabled { background: #fff; }
#play:disabled { opacity: 0.6; cursor: wait; }

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 18px 0 0;
  font-size: 14px;
}
dt { font-weight: 600; color: #cfd5f7; }
dd { margin: 0; color: #a9b0d8; }
