:root {
  color-scheme: dark;
  --ink: #d8d4cc;
  --dim: #8a8579;
}

* { box-sizing: border-box; }

/*
 * A display of our own beats the browser's built-in rule for hidden. Overlay
 * and progress bar set both and therefore stayed visible. This line covers
 * every element that is toggled through hidden.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d0f10;
  color: var(--ink);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overscroll-behavior: none;
}

#view {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: none;
}

#hud {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 260px;
  padding: 12px 14px;
  border: 1px solid #2a2e31;
  border-radius: 6px;
  background: rgba(13, 15, 16, 0.86);
  backdrop-filter: blur(6px);
  pointer-events: none;
  color: var(--dim);
}

#hud .head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

#hud b { color: var(--ink); font-weight: 600; }

#hud .bar {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
}

#hud .bar i {
  height: 6px;
  border-radius: 3px;
  background: #22272a;
}

/* The fill rides in the background, which saves a nested element. */
#hud .bar i::before {
  content: '';
  display: block;
  width: var(--fill, 100%);
  height: 100%;
  border-radius: 3px;
  background: var(--color, #7f8a92);
  transition: width 0.2s linear, background 0.4s ease;
}

#hud .foot {
  margin-top: 9px;
  font-size: 10px;
  line-height: 1.7;
  white-space: pre-line;
  color: #5c5f56;
}

#over {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 10, 0.88);
  text-align: center;
  line-height: 2;
}

#over b { display: block; font-size: 20px; color: var(--ink); }
#over span { color: var(--dim); }

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0d0f10;
  color: var(--dim);
  text-align: center;
  line-height: 2;
  transition: opacity 0.4s ease;
}

#loading small {
  display: block;
  font-size: 11px;
  color: #5c5f56;
}

#loading.done { opacity: 0; pointer-events: none; }

#legend {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 18px 20px;
  border: 1px solid #2a2e31;
  border-radius: 8px;
  background: rgba(13, 15, 16, 0.93);
  backdrop-filter: blur(8px);
}

#legend h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--ink);
}

#legend p {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}

#legend table {
  width: 100%;
  border-collapse: collapse;
}

#legend th {
  padding: 0 0 6px;
  border-bottom: 1px solid #2a2e31;
  color: var(--dim);
  font-weight: 400;
  font-size: 11px;
  text-align: left;
}

#legend td {
  padding: 5px 0;
  color: var(--ink);
  font-size: 12px;
  vertical-align: middle;
}

#legend .num {
  text-align: right;
  color: var(--dim);
  white-space: nowrap;
}

#legend .dot,
#legend .box {
  display: inline-block;
  vertical-align: middle;
}

#legend .dot {
  width: 9px;
  height: 9px;
  margin-right: 10px;
  border: 1px solid #0a0c0d;
  border-radius: 50%;
}

#legend .box {
  width: 24px;
  height: 14px;
  border: 1.5px solid transparent;
  background: #1a2023;
}

#legend .dot.none,
#legend .box.none {
  background: none;
  border-color: transparent;
}

#legend .hint {
  margin: 14px 0 0;
  color: #5c5f56;
}

#action {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 9px 16px;
  border: 1px solid #2a2e31;
  border-radius: 6px;
  background: rgba(13, 15, 16, 0.88);
  backdrop-filter: blur(6px);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#action.idle { opacity: 0; }
#action .what { color: var(--ink); }

#action .progress {
  display: block;
  height: 4px;
  margin-top: 8px;
  border-radius: 2px;
  background: #22272a;
}

#action .progress::before {
  content: '';
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  border-radius: 2px;
  background: #8fb45f;
}

#action .log { display: block; color: var(--dim); }
#action .log b { display: block; margin-top: 5px; font-weight: 400; color: #9fb37a; }

/*
 * Anchored to the top rather than stacked above the status bars: those grew
 * from four rows to six and the pack ended up covering them.
 */
#bag {
  position: fixed;
  left: 16px;
  top: 16px;
  width: min(340px, calc(100vw - 32px));
  /* Leaves room for the status panel at the bottom. */
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid #2a2e31;
  border-radius: 8px;
  background: rgba(13, 15, 16, 0.93);
  backdrop-filter: blur(8px);
}

#bag h2 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

#bag h2 span { color: var(--dim); font-weight: 400; font-size: 12px; }
#bag table { width: 100%; border-collapse: collapse; }
#bag td { padding: 4px 0; font-size: 12px; color: var(--ink); vertical-align: top; }
#bag td.key { width: 22px; color: #5c5f56; }
#bag td.num { text-align: right; color: var(--dim); white-space: nowrap; }
#bag small { display: block; color: var(--dim); font-size: 10px; }
#bag tr.worn td { color: #c98f5a; }
#bag tr.worn td.key { color: #8a6a45; }
#bag .hint { margin: 12px 0 0; color: #5c5f56; font-size: 11px; }
