:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #141414;
  color: #e8e4da;
}

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

#world:active {
  cursor: grabbing;
}

#hud {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px clamp(14px, 3vw, 34px);
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#top {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  text-shadow: 0 1px 0 #000;
}

#clock {
  font-size: 14px;
  letter-spacing: 0.04em;
}

#moral-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

#moral-bar {
  width: 120px;
  height: 6px;
  border: 1px solid rgba(232, 228, 218, 0.35);
  background: rgba(20, 20, 20, 0.6);
}

#moral-fill {
  display: block;
  height: 100%;
  width: 60%;
  background: #8a6a2f;
  transition: width 0.6s linear;
}

nav {
  margin-left: auto;
  display: flex;
  gap: 16px;
  pointer-events: auto;
}

nav a {
  color: #8a6a2f;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.06em;
}

nav a:hover {
  color: #e8e4da;
}

#narrations {
  max-width: min(680px, 80vw);
  min-height: 66px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(17px, 2vw, 24px);
  line-height: 1.35;
  text-shadow: 0 2px 8px #000;
}

#narrations p {
  margin: 0 0 6px;
  opacity: 0.92;
}

#narrations p:nth-child(2) {
  opacity: 0.65;
}

#narrations p:nth-child(3) {
  opacity: 0.4;
}

#status {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  background: rgba(20, 20, 20, 0.86);
  border: 1px solid rgba(232, 228, 218, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

#help {
  font-size: 11px;
  letter-spacing: 0.06em;
  opacity: 0.45;
}

.debug-page {
  overflow: auto;
  padding: 32px 20px 80px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.debug-page main {
  max-width: 720px;
  margin: 0 auto;
}

.debug-page h1 {
  font-size: 20px;
  letter-spacing: 0.04em;
}

.debug-page h2 {
  margin-top: 30px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #8a6a2f;
}

.debug-page a {
  color: #8a6a2f;
}

.debug-page section {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-bottom: 1px solid rgba(232, 228, 218, 0.12);
}

.debug-page label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.debug-page input,
.debug-page select,
.debug-page button {
  background: #1d1d1c;
  border: 1px solid rgba(232, 228, 218, 0.3);
  color: #e8e4da;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.debug-page input {
  min-width: 180px;
}

.debug-page input[type='number'] {
  min-width: 70px;
}

.debug-page button {
  cursor: pointer;
  background: #8a6a2f;
  border-color: #8a6a2f;
  color: #141414;
  font-weight: bold;
}

.debug-page button:hover {
  background: #a8833c;
}

#out {
  margin-top: 24px;
  padding: 14px;
  min-height: 80px;
  background: #0f0f0e;
  border: 1px solid rgba(232, 228, 218, 0.16);
  font-size: 12px;
  white-space: pre-wrap;
}

nav button {
  appearance: none;
  padding: 0;
  background: none;
  border: 0;
  color: #8a6a2f;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

nav button:hover {
  color: #e8e4da;
}

#character {
  color: rgba(232, 228, 218, 0.6);
  font-size: 12px;
  letter-spacing: 0.04em;
}

#character:empty {
  display: none;
}

#login-dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 22px;
  background: #1a1a18;
  border: 1px solid rgba(232, 228, 218, 0.25);
  color: #e8e4da;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#login-dialog::backdrop {
  background: rgba(10, 10, 9, 0.72);
}

#login-dialog h2 {
  margin: 0;
  font-size: 15px;
  font-weight: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a6a2f;
}

.login-hint {
  margin: 6px 0 18px;
  font-size: 11px;
  opacity: 0.55;
}

#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

#login-form input {
  padding: 9px 10px;
  background: #0f0f0e;
  border: 1px solid rgba(232, 228, 218, 0.28);
  color: #e8e4da;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

#login-form input:focus-visible {
  outline: 1px solid #8a6a2f;
}

#login-error {
  min-height: 16px;
  margin: 0 0 12px;
  font-size: 11px;
  color: #b4462a;
}

#login-form menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

#login-form button {
  padding: 8px 14px;
  border: 1px solid rgba(232, 228, 218, 0.3);
  background: transparent;
  color: #e8e4da;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

#login-form button[type='submit'] {
  background: #8a6a2f;
  border-color: #8a6a2f;
  color: #141414;
  font-weight: bold;
}

#login-form button[disabled] {
  opacity: 0.5;
  cursor: default;
}

#npc-tip {
  position: fixed;
  z-index: 20;
  max-width: min(280px, 70vw);
  padding: 10px 12px;
  background: rgba(20, 20, 20, 0.94);
  border: 1px solid rgba(232, 228, 218, 0.2);
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.03em;
}

#npc-tip .tip-name {
  font-size: 13px;
  letter-spacing: 0.06em;
}

#npc-tip .tip-owner {
  color: #8a6a2f;
}

#npc-tip .tip-meta {
  color: rgba(232, 228, 218, 0.55);
}

#npc-tip .tip-event {
  margin-top: 6px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  letter-spacing: 0;
  color: rgba(232, 228, 218, 0.8);
}
