:root {
  --ink: #17140f;
  --panel: rgba(24, 26, 32, 0.92);
  --panel-edge: #3a3f4b;
  --text: #f3f1ea;
  --muted: #a9adb8;
  --gold: #ffc367;
  --green: #5fd07a;
  --blue: #4dd6ff;
  --gap: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#office {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  outline: none;
  touch-action: none;
}

body:not(.ready) #office { opacity: 0; }
#office { transition: opacity .4s; }

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  box-shadow: 0 0 0 2px #0b0c0f, 0 8px 24px rgba(0, 0, 0, 0.35);
}

button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font-family: Silkscreen, monospace;
  font-size: 11px;
  background: #2c313c;
  border: 1px solid #4a5160;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
}

/* ——— Logo (arriba izquierda) ——— */
.brand {
  position: fixed;
  top: var(--gap);
  left: var(--gap);
  padding: 10px 16px;
}
.logo {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ——— Idioma y directorio (arriba derecha) ——— */
.top-right {
  position: fixed;
  top: var(--gap);
  right: var(--gap);
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.lang { display: flex; padding: 3px; gap: 2px; }
.lang button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: Silkscreen, monospace;
  font-size: 13px;
  padding: 4px 9px;
  border-radius: 5px;
}
.lang button[aria-pressed="true"] { background: var(--gold); color: #1d1f24; }
.lang button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn-dir {
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
}
.btn-dir:hover, .btn-dir:focus-visible { border-color: var(--gold); outline: none; }

/* ——— Estado (abajo izquierda) ——— */
.status {
  position: fixed;
  left: var(--gap);
  bottom: calc(var(--gap) + var(--safe-b));
  padding: 10px 14px;
  width: 300px;
}
.tagline {
  margin: 0 0 8px;
  font-family: Silkscreen, monospace;
  font-size: 10px;
  color: var(--gold);
  text-transform: uppercase;
}
.bars { margin: 0; display: grid; gap: 5px; }
.bar {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  font-family: Silkscreen, monospace;
  font-size: 11px;
}
.bar dt { color: var(--muted); }
.bar dd {
  margin: 0;
  padding: 1px 8px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  color: #0f1512;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.bar-human dd { background: linear-gradient(#ffd68f, var(--gold)); }
.bar-agent dd { background: linear-gradient(#8ae6ff, var(--blue)); }
.where {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.where span { color: var(--text); font-weight: 700; }
.controls {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--panel-edge);
  font-size: 11px;
  color: var(--muted);
}

/* ——— Aviso al entrar a una sala ——— */
.toast {
  position: fixed;
  top: var(--gap);
  left: 50%;
  transform: translate(-50%, -140%);
  max-width: min(440px, calc(100vw - 2 * var(--gap)));
  padding: 10px 16px;
  text-align: center;
  border-color: var(--room, var(--panel-edge));
  pointer-events: none;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.show { transform: translate(-50%, 0); }
.toast strong {
  display: block;
  font-family: Silkscreen, monospace;
  font-weight: 400;
  font-size: 18px;
  color: var(--room);
}
.toast span { font-size: 13px; color: var(--muted); }

/* ——— Zoom y minimapa (abajo derecha) ——— */
.map-dock {
  position: fixed;
  right: var(--gap);
  bottom: calc(var(--gap) + var(--safe-b));
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.zoom { display: flex; flex-direction: column; padding: 3px; gap: 3px; }
.zoom button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #22262e;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.zoom button:hover:not(:disabled), .zoom button:focus-visible { border-color: var(--gold); outline: none; }
.zoom button:disabled { opacity: .35; cursor: default; }
.zoom button[aria-pressed="true"] { background: var(--gold); color: #1d1f24; }

.minimap {
  position: relative;
  padding: 6px;
  line-height: 0;
  border-color: #2e5a3a;
}
#minimap {
  width: 200px;
  border-radius: 4px;
  cursor: crosshair;
  background: #0c100e;
}
.minimap-label {
  position: absolute;
  right: -2px;
  bottom: -2px;
  padding: 3px 7px;
  line-height: 1;
  font-family: Silkscreen, monospace;
  font-size: 11px;
  background: #0b0c0f;
  border-radius: 6px 0 8px 0;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--safe-b) + 4px);
  transform: translateX(-50%);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  border-color: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 2px #0b0c0f, 0 0 18px rgba(255, 195, 103, 0.45); } }

/* ——— Diálogo ——— */
.dialog {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--safe-b));
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 2 * var(--gap)));
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border-color: #d9d2c5;
  background: rgba(20, 22, 28, 0.96);
}
#dlg-portrait {
  flex: none;
  width: 80px;
  height: 100px;
  image-rendering: pixelated;
  border-radius: 6px;
  border: 2px solid var(--panel-edge);
}
.dlg-body { flex: 1; min-width: 0; }
.dlg-body header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-right: 28px; }
.dlg-body h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.chip {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--role, #888) 22%, transparent);
  color: var(--role, var(--text));
  border: 1px solid color-mix(in srgb, var(--role, #888) 55%, transparent);
}
.chip-room { --role: #c9c3b6; }
#dlg-bio { margin: 8px 0 6px; font-size: 14px; line-height: 1.5; min-height: 3em; }
#dlg-tasks { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
#dlg-tasks li::before { content: '▸ '; color: var(--gold); }
.now { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.now span:last-child { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 2px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--panel-edge);
  background: #22262e;
  font-size: 14px;
}
.close:hover, .close:focus-visible { border-color: var(--gold); outline: none; }

/* ——— Panel de los bloques "?" ——— */
.info {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 2 * var(--gap)));
  padding: 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-color: var(--room, var(--gold));
  background: rgba(20, 22, 28, 0.97);
  z-index: 6;
}
.info-q {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-family: Silkscreen, monospace;
  font-size: 30px;
  color: #fff;
  text-shadow: 2px 2px 0 #6b3f0e;
  background: var(--gold);
  border: 3px solid #8a5a1a;
  border-radius: 4px;
  box-shadow: inset 3px 3px 0 #ffe3a8, inset -3px -3px 0 #d48f2c;
}
.info-body { flex: 1; min-width: 0; padding-right: 24px; }
.info h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--room); }
#info-text { margin: 8px 0 14px; font-size: 14px; line-height: 1.55; }
.info-links { display: flex; flex-wrap: wrap; gap: 8px; }
.info-links a {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--room);
  color: #14161b;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.info-links a:hover, .info-links a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ——— Directorio ——— */
.directory {
  position: fixed;
  top: calc(var(--gap) + 52px);
  right: var(--gap);
  bottom: calc(var(--gap) + var(--safe-b));
  width: min(360px, calc(100vw - 2 * var(--gap)));
  overflow-y: auto;
  padding: 16px;
  z-index: 5;
}
.directory > header { position: relative; }
.directory h2 { margin: 0; font-family: Silkscreen, monospace; font-weight: 400; font-size: 20px; }
.directory .close { top: -4px; right: -4px; }
.about { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 8px 0 14px; }
.dir-room { border-top: 1px solid var(--panel-edge); padding: 12px 0 4px; }
.dir-room h3 {
  margin: 0;
  font-family: Silkscreen, monospace;
  font-weight: 400;
  font-size: 15px;
  color: var(--room);
}
.dir-room p { margin: 4px 0 8px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.dir-room a { color: var(--room); text-decoration: none; font-weight: 700; }
.dir-room ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dir-room button {
  width: 100%;
  display: grid;
  grid-template-columns: 28px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  text-align: left;
  background: #22262e;
  border: 1px solid transparent;
  border-radius: 6px;
}
.dir-room button:hover, .dir-room button:focus-visible { border-color: var(--role); outline: none; }
.dir-room button canvas {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  border-radius: 50%;
  background: color-mix(in srgb, var(--role) 28%, #15171c);
  box-shadow: 0 0 0 2px var(--role);
}
.dir-room button strong { font-size: 14px; }
.dir-room button small { font-size: 12px; color: var(--muted); }
.dir-room button em { font-style: normal; font-size: 12px; color: var(--role); }


/* ——— Pantallas chicas ——— */
@media (max-width: 700px) {
  :root { --gap: 10px; }
  .brand { padding: 8px 12px; }
  .logo { font-size: 20px; }
  .status { display: none; }
  #minimap { width: 128px; }
  .zoom button { width: 30px; height: 26px; font-size: 17px; }
  .top-right { gap: 6px; }
  .lang button { padding: 4px 6px; font-size: 12px; }
  .btn-dir { padding: 8px 10px; font-size: 13px; }
  .dialog { padding: 12px; gap: 10px; }
  #dlg-portrait { width: 56px; height: 70px; }
  #dlg-bio { font-size: 13px; }
  .directory { top: calc(var(--gap) + 46px); }
  .hint { bottom: calc(var(--gap) + var(--safe-b) + 104px); }
}
@media (max-width: 380px) {
  .btn-dir [data-i18n] { display: none; }
}

[hidden] { display: none !important; }

/* ——— Vista simple ——— */
/* Con JavaScript la vista simple es un panel que se abre; sin JavaScript es la página. */
html:not(.js) body > :not(.simple) { display: none !important; }
html:not(.js) body { overflow: auto; }
.js .simple { display: none; }
.js body.simple-open .simple { display: block; }

.simple {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  background: #f7f5f0;
  color: #1d1f24;
  padding: 0 var(--gap) 48px;
  font-size: 16px;
  line-height: 1.6;
}
html:not(.js) .simple { position: static; min-height: 100vh; }
.simple > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.s-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  background: #f7f5f0;
  border-bottom: 1px solid #e3ded3;
  z-index: 1;
}
.s-logo { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.s-tag { margin: 2px 0 0; font-family: Silkscreen, monospace; font-size: 11px; color: #9a6a1c; text-transform: uppercase; }
.s-back {
  flex: none;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid #1d1f24;
  background: #1d1f24;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
html:not(.js) .s-back { display: none; }
.simple section { padding-top: 32px; }
.simple h2 { margin: 0 0 10px; font-size: 13px; font-family: Silkscreen, monospace; font-weight: 400; letter-spacing: .04em; text-transform: uppercase; color: #6b6f78; }
.simple h3 { margin: 0 0 4px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.simple h4 { margin: 0; font-size: 17px; font-weight: 800; }
.simple p { margin: 0 0 10px; }
.simple a { color: #1d5fd1; font-weight: 600; }
.s-lead { font-size: 19px; line-height: 1.55; }
.s-people { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.s-person { display: flex; gap: 14px; align-items: flex-start; padding: 14px; background: #fff; border: 1px solid #e3ded3; border-radius: 10px; }
.s-person canvas {
  flex: none;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  border-radius: 50%;
  background: color-mix(in srgb, var(--role) 30%, #1d1f24);
  box-shadow: 0 0 0 2px var(--role);
}
.s-person p { font-size: 15px; }
.s-person p:last-child { margin-bottom: 0; }
.s-role { color: #6b6f78; font-size: 13px !important; font-weight: 600; margin-bottom: 4px !important; }
.s-products { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.s-product { padding: 18px; background: #fff; border-radius: 10px; border: 1px solid #e3ded3; border-top: 4px solid var(--room); }
.s-links { display: flex; gap: 14px; flex-wrap: wrap; margin: 0; }
.s-team { margin-top: 18px !important; color: color-mix(in srgb, var(--room) 70%, #1d1f24); }
.s-form { display: grid; gap: 12px; max-width: 520px; }
.s-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 700; }
.s-form input, .s-form textarea {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid #cfc9bd;
  border-radius: 8px;
  background: #fff;
  color: inherit;
}
.s-form input:focus, .s-form textarea:focus { outline: 2px solid #1d5fd1; outline-offset: 1px; border-color: transparent; }
.s-form button {
  justify-self: start;
  padding: 10px 22px;
  border: 0;
  border-radius: 8px;
  background: #ffc367;
  color: #1d1f24;
  font-weight: 800;
  font-size: 15px;
}
.s-form button:disabled { opacity: .6; cursor: default; }
.s-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.s-status { min-height: 1.6em; margin: 0; font-weight: 600; }
.s-status.ok { color: #1f7a38; }
.s-status.bad { color: #b3261e; }
.s-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid #e3ded3; font-size: 13px; color: #6b6f78; }

.dlg-links { margin: 6px 0 0; font-size: 13px; }
.dlg-links a { color: var(--gold); font-weight: 700; text-decoration: none; }
.dlg-links a:hover { text-decoration: underline; }

@media (max-width: 700px) {
  #btn-simple [data-i18n] { font-size: 12px; }
  .s-logo { font-size: 22px; }
  .s-lead { font-size: 17px; }
}
@media (max-width: 480px) {
  /* En teléfonos el botón de vista simple va abajo a la izquierda para no amontonar. */
  #btn-simple { position: fixed; left: var(--gap); bottom: calc(var(--gap) + var(--safe-b)); }
}

/* Pista inicial en pantallas táctiles */
.touch-tip {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--safe-b) + 104px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2 * var(--gap));
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-color: var(--gold);
  pointer-events: none;
}
