:root {
  --bg: #080b11;
  --ink: #1e1220;
  --paper: #f4e9cf;
  --dim: #8a7f9e;
  --accent: #f0c55c;
  --rust: #8c3330;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--paper);
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  background: radial-gradient(ellipse 70% 60% at 50% 48%, #1b2638 0%, #0f1520 55%, #080b11 100%);
  transition: background-color .6s;
  background-color: var(--bg);
}

.title {
  position: fixed;
  top: 22px;
  left: 26px;
  z-index: 5;
}
.title h1 {
  margin: 0;
  font-family: 'Silkscreen', monospace;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.title p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--dim);
}

.scene {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 70px 12px 96px;
}

.stage {
  position: relative;
  line-height: 0;
  opacity: 0;
  transition: opacity .5s ease;
}
.ready .stage { opacity: 1; }

#room {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-tap-highlight-color: transparent;
}
#room { cursor: grab; touch-action: none; }
#room.pointer { cursor: pointer; }
#room.grabbing { cursor: grabbing; }

.fade {
  position: absolute;
  inset: -2px;
  background: #080b11;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  z-index: 8;
}
.fade.on { opacity: 1; }

.tag {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 8px 6px;
  color: #fff;
  background: #1c2a3a;
  border: 2px solid #000;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px #4f6b88;
  transform: translate(14px, -32px);
}
.tag em { font-style: normal; font-weight: 400; color: #ffd45c; margin-left: 4px; }

.bubble {
  position: absolute;
  z-index: 20;
  width: max-content;
  max-width: min(280px, 74vw);
  padding: 7px 11px 8px;
  line-height: 1.3;
  font-size: 15px;
  color: #111;
  background: #fff;
  border: 2px solid #000;
  border-radius: 7px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  transform: translate(-50%, calc(-100% - 14px));
}
.bubble strong { font-weight: 600; }
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 12px;
  height: 10px;
  margin-left: -6px;
  background: #000;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.bubble::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 8px;
  height: 7px;
  margin-left: -4px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: 1;
}
.bubble.below { transform: translate(-50%, 14px); }
.bubble.below::after { bottom: auto; top: -11px; transform: scaleY(-1); }
.bubble.below::before { bottom: auto; top: -7px; transform: scaleY(-1); }

.rotate {
  position: fixed;
  left: 50%;
  bottom: 46px;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
  z-index: 6;
}
.rotate button {
  width: 40px;
  height: 34px;
  font: 600 18px/1 'Pixelify Sans', ui-monospace, monospace;
  color: #fff;
  background: #1c2a3a;
  border: 2px solid #000;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #4f6b88, 0 3px 0 rgba(0, 0, 0, .4);
  cursor: pointer;
}
.rotate button:hover { background: #26394f; }
.rotate button:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px #4f6b88; }
.rotate button:focus-visible { outline: 2px solid #ffd45c; outline-offset: 2px; }

.hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--dim);
  transition: opacity .6s ease;
}
.hint.gone { opacity: 0; }

.room-nav {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.room-nav:focus-within {
  position: fixed;
  left: 50%;
  bottom: 52px;
  width: auto;
  height: auto;
  max-width: 92vw;
  clip: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  transform: translateX(-50%);
  white-space: normal;
}
.room-nav button {
  font: inherit;
  font-size: 13px;
  padding: 3px 8px;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--dim);
  cursor: pointer;
}
.room-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 600px) {
  .title { top: 16px; left: 16px; }
  .title h1 { font-size: 15px; }
  .title p { font-size: 12px; }
  .bubble { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage, .hint { transition: none; }
}

.fixed-room .rotate { display: none; }
html.dark-room, html.dark-room body {
  background: radial-gradient(ellipse 70% 60% at 50% 48%, #1a0d10 0%, #0b0608 60%, #050304 100%);
  background-color: #050304;
}
.dark-room .title p { color: #7d5a60; }

/* ---------- conversation box ---------- */
.dialog {
  position: absolute;
  left: 2.5%;
  right: 2.5%;
  bottom: 2.5%;
  z-index: 30;
  line-height: 1.25;
  cursor: pointer;
}
#dlgPortrait {
  position: absolute;
  left: 3%;
  bottom: calc(100% - 8px);
  width: min(30%, 280px);
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}
.dialog.you #dlgPortrait { left: auto; right: 3%; }
.dialog-box {
  position: relative;
  min-height: 4.4em;
  padding: 24px 26px 20px;
  color: #f4ecd8;
  background: #3e4c6d;
  border: 3px solid #f1e6cf;
  border-radius: 12px;
  box-shadow: 0 0 0 3px #161c2c, inset 0 0 0 2px #2a3550, 0 8px 0 3px rgba(0, 0, 0, .35);
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  font-size: clamp(14px, 2.1vw, 20px);
}
.dialog-name {
  position: absolute;
  top: -24px;
  left: 18px;
  padding: 4px 16px 5px;
  color: #f4ecd8;
  background: #3e4c6d;
  border: 3px solid #f1e6cf;
  border-radius: 10px;
  box-shadow: 0 0 0 3px #161c2c;
  font-family: 'Silkscreen', monospace;
  font-size: 13px;
  letter-spacing: 1px;
}
.dialog.vamp .dialog-name { color: #ffb3b3; }
.dialog.mage .dialog-name { color: #8ff3ee; }
.dialog.you .dialog-name { left: auto; right: 18px; }
.dialog-text { margin: 0; letter-spacing: .5px; white-space: pre-wrap; }
.dialog-more {
  position: absolute;
  right: 16px;
  bottom: 9px;
  font-size: 14px;
  color: #f1e6cf;
  animation: dlg-bob 0.9s steps(2) infinite;
}
.dialog-choices { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.dialog-choices:empty { display: none; }
.dialog-choices button {
  font: inherit;
  text-align: left;
  color: #f4ecd8;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 2px 10px;
  cursor: pointer;
}
.dialog-choices button::before { content: '\25B6\00a0'; opacity: 0; }
.dialog-choices button:hover, .dialog-choices button:focus-visible { border-color: #f1e6cf; background: #2f3b57; outline: none; }
.dialog-choices button:hover::before, .dialog-choices button:focus-visible::before { opacity: 1; }
@keyframes dlg-bob { 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .dialog-more { animation: none; } }

.version {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 5;
  padding: 3px 9px 4px;
  font-family: 'Silkscreen', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: #ffd45c;
  background: #1c2a3a;
  border: 2px solid #000;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px #4f6b88;
}

html.space-room, html.space-room body {
  background: radial-gradient(ellipse 70% 60% at 50% 48%, #0d1030 0%, #070818 60%, #04050d 100%);
  background-color: #04050d;
}
.space-room .title p { color: #7f8fd0; }
/* the worlds behind the gates: the page takes on the colour of each world's sky */
html.world-room, html.world-room body { background: var(--world-bg, #04050d); }
.world-room .title p { color: rgba(255, 255, 255, .62); }

.stage.quake { animation: quake .38s steps(6) 1; }
@keyframes quake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 3px); }
  40% { transform: translate(4px, -4px); }
  60% { transform: translate(-3px, -2px); }
  80% { transform: translate(3px, 2px); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) { .stage.quake { animation: none; } }
.dialog.holo .dialog-name { color: #ff8ccf; }
/* ---------- dev console (only rendered after logging in at /dev) ---------- */
.dev-toggle {
  position: fixed; top: 50px; right: 24px; z-index: 40;
  padding: 3px 9px 4px; font: 12px/1 'Silkscreen', monospace; letter-spacing: 1px; color: #ff8ccf; cursor: pointer;
  background: #1c2a3a; border: 2px solid #000; border-radius: 6px; box-shadow: inset 0 0 0 1px #4f6b88;
}
.dev-toggle:hover, .dev-toggle[aria-expanded="true"] { background: #2a2140; }
.dev-toggle:focus-visible, .dev-panel button:focus-visible { outline: 2px solid #ffd45c; outline-offset: 2px; }
.dev-panel {
  position: fixed; top: 80px; right: 24px; z-index: 40; width: min(320px, calc(100vw - 32px)); max-height: calc(100vh - 110px); overflow: auto;
  padding: 12px 14px 14px; color: #f4ecd8; font-family: 'Pixelify Sans', ui-monospace, monospace;
  background: #141c2a; border: 2px solid #000; border-radius: 10px; box-shadow: inset 0 0 0 1px #4f6b88, 0 8px 0 rgba(0, 0, 0, .35);
}
.dev-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.dev-head b { font: 13px 'Silkscreen', monospace; letter-spacing: 2px; color: #ffd45c; font-weight: 400; }
.dev-x { width: 28px; height: 28px; font: 18px/1 'Pixelify Sans', monospace; color: #fff; background: #26394f; border: 2px solid #000; border-radius: 6px; cursor: pointer; }
.dev-panel h3 { margin: 12px 0 6px; font: 11px 'Silkscreen', monospace; letter-spacing: 1px; color: #8a9ab2; font-weight: 400; }
.dev-row { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-row button {
  padding: 6px 9px; font: 600 13px/1.1 'Pixelify Sans', ui-monospace, monospace; color: #f4ecd8; cursor: pointer;
  background: #22324a; border: 2px solid #000; border-radius: 6px; box-shadow: inset 0 0 0 1px #4f6b88;
}
.dev-row button:hover { background: #2d4260; }
.dev-row button.on { color: #1a1020; background: #ffd45c; box-shadow: inset 0 0 0 1px #fff3c4; }
@media (max-width: 600px) { .dev-toggle { top: 44px; right: 16px; } .dev-panel { top: 74px; right: 16px; } }
