/* The conversation with an NPC (NpcDialog, r182): as Minibia's, a dark panel with the NPC's portrait and name, its line
   with the keywords in gold, the keywords as buttons and the free text line at the bottom */
.npc-dialog {
  --npc-panel: rgba(38, 37, 35, 0.97);
  --npc-well: rgba(24, 23, 22, 0.92);
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5000;
  width: min(420px, 92vw);
  box-sizing: border-box;
  padding: 0 8px 8px;
  background: var(--npc-panel);
  color: #ece6d6;
  border: 1px solid #0c0c0c;
  outline: 1px solid #4a4741;
  border-radius: 3px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
  font: 13px Verdana, Arial, sans-serif;
}

.npc-dialog-faded {
  --npc-panel: rgba(38, 37, 35, 0.62);
  --npc-well: rgba(18, 17, 16, 0.55);
}

.npc-dialog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #0c0c0c;
  background: linear-gradient(180deg, rgba(60, 58, 54, 0.9), rgba(40, 39, 36, 0.9));
}

.npc-dialog-portrait {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  image-rendering: pixelated;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #0c0c0c;
  border-radius: 3px;
}

.npc-dialog-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: bold;
  color: #f4efe2;
}

.npc-dialog-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  flex: 0 0 22px;
  font-size: 13px;
  line-height: 20px;
  color: #e9e4d8;
  background: #1d1c1a;
  border: 1px solid #55514a;
  border-radius: 3px;
  cursor: pointer;
}

.npc-dialog-fade::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  vertical-align: -1px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.npc-dialog-icon:hover {
  background: #2c2a27;
}

.npc-dialog-text {
  max-height: 190px;
  overflow: auto;
  padding: 8px 10px;
  background: var(--npc-well);
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3b3833;
  border-radius: 4px;
  font-weight: bold;
  line-height: 1.5;
  white-space: pre-wrap;
  scrollbar-width: thin;
}

.npc-dialog-line + .npc-dialog-line {
  margin-top: 6px;
}

.npc-dialog-highlight {
  color: #f0c24b;
}

.npc-dialog-keywords,
.npc-dialog-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.npc-dialog-keywords {
  gap: 8px 10px;
  margin-top: 10px;
}

.npc-dialog-keywords:empty {
  display: none;
}

.npc-dialog-options {
  gap: 4px 5px;
  margin-top: 8px;
  max-height: 50px;
  overflow: auto;
  scrollbar-width: thin;
}

.npc-dialog-options:empty {
  display: none;
}

.npc-dialog-keyword,
.npc-dialog-option {
  font-family: inherit;
  font-weight: bold;
  background: #1b1a18;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
  cursor: pointer;
}

.npc-dialog-keyword {
  padding: 6px 14px;
  font-size: 12px;
  color: #f0c24b;
  border-radius: 6px;
}

.npc-dialog-option {
  padding: 3px 9px;
  font-size: 11px;
  color: #cfc7b3;
  border-radius: 5px;
}

.npc-dialog-keyword:hover,
.npc-dialog-option:hover {
  background: #2e2b26;
  color: #ffd866;
}

.npc-dialog-form {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.npc-dialog-form input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font: 12px Verdana, Arial, sans-serif;
  color: #ece6d6;
  background: var(--npc-well);
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3b3833;
  border-radius: 4px;
}

.npc-dialog-form input:focus {
  outline: 1px solid #8a7334;
}

.npc-dialog-form button {
  padding: 5px 14px;
  font: bold 12px Verdana, Arial, sans-serif;
  color: #f0c24b;
  background: #1b1a18;
  border: 1px solid #0c0c0c;
  box-shadow: inset 0 0 0 1px #3d3a34;
  border-radius: 4px;
  cursor: pointer;
}

/* r183 (user 2026-11-01: "siempre que se pueda muestre mas grande la ventana ... se vea digamos mas opciones"): on the
   desktop the window is wider and the line and the other topics get more room, up to what the screen allows. The mobile
   HUD (body.force-mobile) keeps the sizes above until it is checked against Minibia's ("ten en cuenta el movil") */
body:not(.force-mobile) .npc-dialog {
  width: min(560px, 92vw);
}

body:not(.force-mobile) .npc-dialog-text {
  max-height: min(260px, 32vh);
}

body:not(.force-mobile) .npc-dialog-options {
  max-height: min(156px, 22vh);
}

/* r183, the phone (user 2026-11-02 with Minibia's screenshots: "siempre la interfaz se come parte de la estructura
   durante un momento, hazlo asi para que se vea bien"): the window sits over the HUD in the middle of the screen, as tall
   as the line and the topics need up to the height of the screen; the line and the topics scroll inside it only when
   they do not fit. Buttons and icons the size of a finger (34 px), the topics in rows as the keywords */
body.force-mobile .npc-dialog[style*="display: block"] {
  display: flex !important;
}

body.force-mobile .npc-dialog {
  left: 50% !important;
  top: 50% !important;
  flex-direction: column;
  width: min(400px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  font-size: 14px;
  z-index: 40000;
}

body.force-mobile .npc-dialog-header {
  flex: 0 0 auto;
}

body.force-mobile .npc-dialog-icon {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 16px;
  line-height: 32px;
}

body.force-mobile .npc-dialog-fade::before {
  width: 14px;
  height: 14px;
}

body.force-mobile .npc-dialog-text {
  flex: 0 1 auto;
  min-height: 3.2em;
  max-height: none;
}

/* r183b (user 2026-11-02: "cuando hablas con un NPC y tiene muchas opciones de mensaje ocupan toda la pantalla debería
   tener un tamaño fijo y que puedas utilizar para ver qué opciones tiene"): the keywords and the topics keep to a box
   of three rows of buttons that scrolls with the finger, so the window stays the same size whatever the NPC offers */
body.force-mobile .npc-dialog-keywords,
body.force-mobile .npc-dialog-options {
  flex: 0 1 auto;
  gap: 8px;
  min-height: 42px;
  max-height: 122px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 2px 0;
  scrollbar-width: thin;
  scrollbar-color: #8a7334 transparent;
}

body.force-mobile .npc-dialog-keyword,
body.force-mobile .npc-dialog-option {
  min-height: 34px;
  padding: 0 16px;
  font-size: 13px;
  border-radius: 6px;
}

body.force-mobile .npc-dialog-option {
  color: #e2d6b4;
}

body.force-mobile .npc-dialog-form {
  flex: 0 0 auto;
}

body.force-mobile .npc-dialog-form input,
body.force-mobile .npc-dialog-form button {
  min-height: 34px;
  font-size: 16px;
}

/* r228 (user 2026-11-15: "se abre bien al darle click or type something pero no se adapta bien ... cuando giras el
   movil"): with the phone turned and the keyboard of the game up, the window goes above it (VirtualKeyboard.__fitWindow)
   and keeps to that room: a smaller portrait, the NPC's line and the topics in a row each that scroll */
@media (orientation: landscape) {
  body.force-mobile.vk-open .npc-dialog-header {
    margin-bottom: 4px;
    padding: 3px 8px;
  }

  body.force-mobile.vk-open .npc-dialog-portrait {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  body.force-mobile.vk-open .npc-dialog-text {
    min-height: 1.5em;
    padding: 4px 10px;
    line-height: 1.4;
  }

  body.force-mobile.vk-open .npc-dialog-keywords,
  body.force-mobile.vk-open .npc-dialog-options {
    min-height: 38px;
    margin: 2px 0;
  }
}

/* Upright the text keeps to about half of the screen and the topics get the rest, as Minibia's */
@media (orientation: portrait) {
  body.force-mobile .npc-dialog {
    width: min(360px, calc(100vw - 16px));
  }

  body.force-mobile .npc-dialog-text {
    max-height: 30dvh;
  }
}

/* r187 (user 2026-11-02: "la mayoria de gente al hablar al npc busca trade ... todos los npcs que tengan trade deben
   mostrarlo al inicio de todo de los botones posibles, y aparte agregar algun icono o algo que haga destacar esa
   palabra"): an NPC's trade is the first button (NpcDialog.addTrade), in gold with the gold coin of the game, on a computer
   and on a phone */
.npc-dialog-keyword.npc-dialog-trade {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px 6px 12px;
  font-size: 13px;
  color: #1d1606;
  background: #d9a72c;
  border-color: #0c0c0c;
  box-shadow: inset 0 0 0 1px #f0cf6a, 0 0 8px rgba(217, 167, 44, 0.45);
}

.npc-dialog-keyword.npc-dialog-trade::before {
  content: "";
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background: url("../png/gold-coin.png") no-repeat center / 18px 18px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}

.npc-dialog-keyword.npc-dialog-trade:hover {
  color: #1d1606;
  background: #e7b63a;
}

body.force-mobile .npc-dialog-keyword.npc-dialog-trade {
  min-height: 38px;
  padding: 0 18px 0 14px;
  font-size: 14px;
}

body.force-mobile .npc-dialog-keyword.npc-dialog-trade::before {
  width: 20px;
  height: 20px;
  background-size: 20px 20px;
}

/* r202 (user 2026-11-04: "el boton de bye de cualquier npc marcarlo del mismo color rojo que tiene el boton de logout en
   movil ... no lo hagas mas grande ni nada simplemente color"): only the colours of mobile.css logout-button, same size */
.npc-dialog-keyword.npc-dialog-bye,
.npc-dialog-option.npc-dialog-bye,
body.force-mobile .npc-dialog-option.npc-dialog-bye {
  color: #ffb3a8;
  background: #3a1714;
  box-shadow: inset 0 0 0 1px #6e2a22;
}

.npc-dialog-keyword.npc-dialog-bye:hover,
.npc-dialog-option.npc-dialog-bye:hover {
  color: #ffd0c8;
  background: #4a1d19;
}
