* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000000;
  color: #d8d8d0;
  font-family: "Courier New", monospace;
}

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

/* HUD: top-left stats panel over the canvas. */
#hud {
  position: fixed;
  top: 10px;
  left: 10px;
  padding: 8px 12px;
  background: rgba(8, 10, 16, 0.72);
  border: 1px solid #2a2f3a;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
  min-width: 240px;
}
#hud-title { color: #e8c060; font-weight: bold; letter-spacing: 1px; }
#hud-stats { color: #b8c0c8; white-space: pre; }

#hud-bar {
  margin-top: 4px;
  height: 8px;
  background: #1a1f28;
  border-radius: 3px;
  overflow: hidden;
}
#hud-bar-fill {
  height: 100%;
  width: 100%;
  background: #4caf50;
  transition: width 0.15s ease, background 0.15s ease;
}

/* Message log: bottom-left. */
#log {
  position: fixed;
  bottom: 10px;
  left: 10px;
  max-width: 60%;
  padding: 8px 12px;
  background: rgba(8, 10, 16, 0.66);
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.5;
  pointer-events: none;
  white-space: pre-wrap;
}

/* Older messages are dim; the newest is bright and bold so it reads clearly. */
.log-line {
  color: #79828c;
}
.log-latest {
  color: #f1f4f8;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

/* Connection status: bottom-right. */
#status {
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-size: 11px;
  color: #6a7480;
  pointer-events: none;
}

/* End-screen / message overlay. */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 6, 0.82);
  z-index: 10;
}
#overlay.hidden { display: none; }
#overlay-box {
  padding: 24px 32px;
  background: #0a0c12;
  border: 1px solid #3a4350;
  border-radius: 6px;
  text-align: center;
  max-width: 80%;
}
#overlay-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #d8d8d0;
  text-align: left;
}
#overlay-hint { margin-top: 16px; color: #8a94a0; font-size: 12px; }

/* Help button: a small round "?" in the bottom-right, above the status line. */
#help-btn {
  position: fixed;
  bottom: 38px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #3a4350;
  background: rgba(10, 12, 18, 0.7);
  color: #c8cdd4;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  z-index: 11;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
#help-btn:hover { background: #1a2230; color: #fff; border-color: #5a6678; }

/* Help overlay: centered modal listing the controls. */
#help {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 6, 0.78);
  z-index: 13;
}
#help.hidden { display: none; }
#help-box {
  min-width: 360px;
  max-width: 90%;
  max-height: 85%;
  overflow-y: auto;
  padding: 22px 28px;
  background: #0a0c12;
  border: 1px solid #3a4350;
  border-radius: 6px;
}
#help-title {
  color: #e8c060;
  font-size: 18px;
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-align: center;
}
#help-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 22px;
  align-items: center;
}
.help-sec { color: #9aa4ae; font-size: 13px; white-space: nowrap; }
.help-keys { color: #c8cdd4; font-size: 13px; }
#help-hint { margin-top: 20px; color: #6a7480; font-size: 12px; text-align: center; }
#help kbd, #help-hint kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 1px;
  font-family: monospace;
  font-size: 12px;
  text-align: center;
  color: #e8eef6;
  background: #1c2430;
  border: 1px solid #38424f;
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* Inventory panel: centered modal listing the pack. */
#inventory {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 6, 0.55);
  z-index: 12;
}
#inventory.hidden { display: none; }
#inventory-box {
  min-width: 360px;
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
  padding: 18px 22px;
  background: #0a0c12;
  border: 1px solid #3a4350;
  border-radius: 6px;
  font-size: 13px;
}
#inventory-title {
  color: #e8c060;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
#inventory-list { line-height: 1.7; }
.inv-group { color: #7a8290; margin-top: 8px; }
.inv-row { color: #cdd3da; cursor: pointer; padding: 1px 4px; border-radius: 3px; }
.inv-row:hover { background: #1a2330; }
.inv-letter { color: #e8c060; display: inline-block; width: 1.4em; }
.inv-equipped { color: #6fcf6f; }
.inv-note { color: #6a7480; font-size: 11px; }
#inventory-hint { margin-top: 14px; color: #8a94a0; font-size: 12px; }

/* Quest intro: the title-screen story, shown before play starts. */
#intro {
  position: fixed; inset: 0; z-index: 18;
  display: flex; align-items: center; justify-content: center;
  background: #000000;
}
#intro.hidden { display: none; }
#intro-box {
  max-width: 680px; padding: 32px 40px; text-align: center;
  background: #0a0c12; border: 1px solid #2a2f3a; border-radius: 8px;
}
#intro-title { color: #6fcf6f; font-size: 20px; letter-spacing: 1px; margin-bottom: 4px; }
#intro-occ { color: #e8c060; font-size: 13px; font-style: italic; margin-bottom: 18px; }
#intro-story { color: #c8cdd4; font-size: 14px; line-height: 1.6; text-align: left; margin: 0 0 16px; white-space: pre-wrap; }
#intro-goal { color: #9aa4ae; font-size: 13px; margin-bottom: 22px; }
#intro-hint { color: #6a7480; font-size: 12px; }

/* Start menu: name entry + live-game watch list. */
#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  z-index: 20;
}
#menu.hidden { display: none; }
#menu-box {
  text-align: center;
  padding: 32px 40px;
  background: #0a0c12;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  min-width: 320px;
}
#menu-title { color: #e050d0; font-size: 28px; letter-spacing: 6px; font-weight: bold; }
#menu-sub { color: #8a94a0; font-size: 12px; margin-bottom: 22px; }
#menu-form { display: flex; gap: 8px; justify-content: center; }
#menu-name {
  background: #12161e; border: 1px solid #3a4350; border-radius: 4px;
  color: #e8e8e0; font-family: inherit; font-size: 14px; padding: 8px 10px; width: 200px;
}
#menu-name:focus { outline: none; border-color: #e8c060; }
#menu-play, .watch-btn {
  background: #2a3340; border: 1px solid #3a4350; border-radius: 4px;
  color: #e8e8e0; font-family: inherit; font-size: 14px; padding: 8px 14px; cursor: pointer;
}
#menu-play:hover, .watch-btn:hover { background: #38445a; border-color: #e8c060; }
#menu-watch-label { color: #6a7480; font-size: 12px; margin: 22px 0 10px; }
#menu-games { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.watch-btn { width: 240px; display: flex; justify-content: space-between; }
.watch-kind { color: #8a94a0; font-size: 11px; }
#menu-scores { display: block; margin-top: 20px; color: #c8a040; font-size: 13px; text-decoration: none; }
#menu-scores:hover { color: #e8c060; }
.menu-empty { color: #5a6470; font-size: 12px; }
