@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Inter:wght@400;500;700&display=swap');

:root {
  --gold: #d7b96d;
  --gold-soft: rgba(215, 185, 109, 0.34);
  --ink: rgba(5, 4, 5, 0.72);
  --ink-strong: rgba(5, 4, 5, 0.91);
  --text: #f5efe6;
  --muted: #c2b5a7;
  --blood: #65151c;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030203;
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

button {
  font: inherit;
}

#room-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: var(--room-image);
  background-size: cover;
  background-position: center center;
  transform: scale(1.025);
  transition:
    background-image 0ms linear,
    transform 900ms ease,
    filter 900ms ease;
  filter: brightness(0.9) contrast(1.08) saturate(0.95);
}

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.55;
}

#dark-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, transparent 0%, rgba(0,0,0,0.05) 42%, rgba(0,0,0,0.58) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.10), rgba(0,0,0,0.28) 55%, rgba(0,0,0,0.68));
}

#transition {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: #000;
  opacity: 0;
  transition: opacity 460ms ease;
}

#transition.active {
  opacity: 1;
}

.topbar {
  position: fixed;
  top: 22px;
  left: 30px;
  right: 30px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 2px 14px rgba(0,0,0,0.8);
}

h1,
h2 {
  margin: 0;
  font-family: Cinzel, Georgia, serif;
  line-height: 0.95;
  text-shadow: 0 3px 20px rgba(0,0,0,0.9);
}

h1 {
  font-size: clamp(36px, 5vw, 78px);
}

h2 {
  font-size: 18px;
  color: var(--gold);
  margin-bottom: 14px;
}

.pill-button {
  border: 1px solid var(--gold-soft);
  color: var(--text);
  background: rgba(5, 4, 5, 0.62);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.pill-button:hover {
  transform: translateY(-1px);
  border-color: rgba(215, 185, 109, 0.75);
  background: rgba(40, 14, 16, 0.78);
}

.game-ui {
  position: fixed;
  left: 30px;
  right: 30px;
  bottom: 28px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  gap: 22px;
  align-items: end;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.text-box {
  border: 1px solid var(--gold-soft);
  background: var(--ink);
  box-shadow: 0 24px 80px rgba(0,0,0,0.48);
  border-radius: 18px;
  backdrop-filter: blur(14px);
}

.narrative-box {
  padding: 20px 24px;
  min-height: 114px;
}

#room-description {
  margin: 0;
  max-width: 980px;
  color: var(--text);
  font-size: clamp(15px, 1.45vw, 18px);
  line-height: 1.6;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9);
}

.help-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  align-items: center;
  margin-right: 6px;
  padding: 2px 7px;
  border: 1px solid rgba(215,185,109,0.38);
  border-radius: 6px;
  color: var(--gold);
  background: rgba(0,0,0,0.32);
  font-size: 12px;
}

.actions-box,
.inventory-box {
  padding: 18px;
}

#actions {
  display: grid;
  gap: 10px;
}

.action-button {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(215,185,109,0.28);
  color: var(--text);
  background: rgba(7, 5, 6, 0.52);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition:
    transform .16s ease,
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease;
}

.action-button:hover {
  transform: translateX(2px);
  border-color: rgba(215,185,109,0.72);
  background: rgba(55, 16, 20, 0.56);
  box-shadow: inset 0 0 24px rgba(215,185,109,0.04);
}

.action-button strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.action-button span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#inventory {
  min-height: 42px;
  color: var(--muted);
}

.inventory-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px 0;
  padding: 8px 11px;
  border: 1px solid rgba(215,185,109,0.30);
  border-radius: 999px;
  color: var(--text);
  background: rgba(101, 21, 28, 0.42);
}

.inventory-item::before {
  content: "⚿";
  color: var(--gold);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(680px, 100%);
  border: 1px solid var(--gold-soft);
  background: var(--ink-strong);
  border-radius: 22px;
  padding: 30px;
  box-shadow: 0 30px 110px rgba(0,0,0,0.65);
}

.modal-card h2 {
  color: var(--text);
  font-size: clamp(30px, 4vw, 54px);
  margin-bottom: 18px;
}

#modal-text {
  margin: 0 0 24px;
  color: #eee3d6;
  white-space: pre-line;
  line-height: 1.7;
  font-size: 16px;
}

@media (max-width: 980px) {
  .topbar {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  h1 {
    font-size: clamp(32px, 9vw, 54px);
  }

  .game-ui {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: 1fr;
    max-height: 54vh;
    overflow: auto;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .narrative-box {
    min-height: auto;
  }

  .help-row {
    display: none;
  }

  .actions-box,
  .inventory-box,
  .narrative-box {
    padding: 14px;
  }

  #room-bg {
    background-position: center center;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
  }

  .pill-button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .eyebrow {
    font-size: 10px;
  }

  .action-button strong {
    font-size: 14px;
  }
}


/* === MAPA VERTICAL ESTRECHO BAJO EL TÍTULO === */

#castle-map {
  position: fixed !important;
  top: 175px !important;
  left: 34px !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 8 !important;

  width: 230px !important;
  height: auto !important;

  border: 1px solid rgba(215, 185, 109, 0.24) !important;
  border-radius: 16px !important;
  background:
    radial-gradient(circle at 50% 20%, rgba(100, 42, 24, 0.10), transparent 60%),
    rgba(5, 4, 5, 0.42) !important;
  box-shadow: 0 18px 60px rgba(0,0,0,0.30) !important;
  backdrop-filter: blur(8px) !important;

  padding: 11px !important;
  transform: none !important;
}

#castle-map .map-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: baseline !important;
  gap: 10px !important;
  margin-bottom: 10px !important;

  color: var(--gold) !important;
  font-family: Cinzel, Georgia, serif !important;
  font-size: 11px !important;
}

#castle-map .map-header small {
  color: var(--muted) !important;
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 8px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
}

#castle-map .map-grid {
  position: relative !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px !important;
  height: auto !important;
}

#castle-map .map-grid::before {
  content: "" !important;
  position: absolute !important;
  left: 50% !important;
  top: 8px !important;
  bottom: 8px !important;
  width: 1px !important;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(215, 185, 109, 0.24),
    transparent
  ) !important;
  z-index: 1 !important;
}

#castle-map .map-room,
#castle-map .map-room.facade,
#castle-map .map-room.vestibule,
#castle-map .map-room.library,
#castle-map .map-room.umbra,
#castle-map .map-room.corridor,
#castle-map .map-room.crypt {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;

  z-index: 2 !important;
  width: auto !important;

  border: 1px solid rgba(215, 185, 109, 0.24) !important;
  background: rgba(12, 9, 10, 0.72) !important;
  color: rgba(245, 239, 230, 0.58) !important;

  border-radius: 999px !important;
  padding: 6px 8px !important;
  font-size: 10px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  text-align: center !important;
}

#castle-map .map-room.facade,
#castle-map .map-room.vestibule,
#castle-map .map-room.corridor,
#castle-map .map-room.crypt {
  grid-column: 1 / 3 !important;
  justify-self: center !important;
  min-width: 92px !important;
}

#castle-map .map-room.library {
  grid-column: 1 !important;
}

#castle-map .map-room.umbra {
  grid-column: 2 !important;
}

#castle-map .map-room.visited {
  color: var(--text) !important;
  border-color: rgba(215, 185, 109, 0.52) !important;
  background: rgba(50, 26, 20, 0.76) !important;
}

#castle-map .map-room.current {
  color: #fff !important;
  border-color: rgba(255, 215, 130, 0.95) !important;
  background: rgba(101, 21, 28, 0.88) !important;
  box-shadow:
    0 0 16px rgba(215, 185, 109, 0.20),
    inset 0 0 18px rgba(255, 190, 90, 0.08) !important;
  transform: scale(1.04) !important;
}

#castle-map .map-room.locked {
  color: rgba(194, 181, 167, 0.32) !important;
  border-color: rgba(120, 120, 120, 0.22) !important;
  background: rgba(0, 0, 0, 0.48) !important;
  cursor: not-allowed !important;
}

#castle-map .map-room.locked::after {
  content: " ✕" !important;
  color: #8f3038 !important;
}

#castle-map .map-line {
  display: none !important;
}

@media (max-width: 1180px) {
  #castle-map {
    top: 145px !important;
    left: 24px !important;
    width: 215px !important;
  }
}

@media (max-width: 900px) {
  #castle-map {
    display: none !important;
  }
}

/* === AJUSTE MÓVIL CASTILLO V2 === */

@media (max-width: 720px) {
  html,
  body,
  #app {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #app {
    position: relative;
  }

  #room-bg {
    position: fixed;
    inset: 0;
    height: 100vh;
    background-size: cover;
    background-position: center center;
    transform: scale(1.02);
    filter: brightness(1.05) contrast(1.06) saturate(0.98);
  }

  #fx-canvas {
    position: fixed;
    inset: 0;
    height: 100vh;
    opacity: 0.38;
  }

  #dark-vignette {
    position: fixed;
    inset: 0;
    min-height: 100vh;
    background:
      linear-gradient(
        to bottom,
        rgba(0,0,0,0.02) 0%,
        rgba(0,0,0,0.10) 28%,
        rgba(0,0,0,0.48) 62%,
        rgba(0,0,0,0.88) 100%
      );
  }

  .topbar {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    z-index: 5;
    padding: 18px 10px 0;
  }

  h1 {
    max-width: 82vw;
    font-size: clamp(42px, 13vw, 62px);
    line-height: 0.88;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.22em;
  }

  #sound-toggle {
    position: fixed;
    top: 12px;
    right: 10px;
    z-index: 20;
    padding: 8px 11px;
    font-size: 13px;
    line-height: 1.05;
  }

  .game-ui {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: none;
    overflow: visible;
    padding: 300px 0 18px;
  }

  .side-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .text-box {
    border-radius: 14px;
    background: rgba(5, 4, 5, 0.70);
    backdrop-filter: blur(10px);
  }

  .narrative-box,
  .actions-box,
  .inventory-box {
    padding: 14px 16px;
  }

  #room-description {
    font-size: 17px;
    line-height: 1.55;
  }

  .help-row {
    display: none;
  }

  h2 {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .action-button {
    padding: 14px 16px;
  }

  .action-button strong {
    font-size: 16px;
  }

  .action-button span {
    font-size: 14px;
  }

  #castle-map {
    display: none !important;
  }
}

/* === ENCUADRES MÓVIL POR SALA === */
/* Requiere que main.js añada: document.body.dataset.room = id; dentro de renderRoom(). */

@media (max-width: 720px) {
  body[data-room="facade"] #room-bg {
    background-position: center top;
  }

  body[data-room="vestibule"] #room-bg,
  body[data-room="library"] #room-bg,
  body[data-room="umbra"] #room-bg,
  body[data-room="corridor"] #room-bg,
  body[data-room="crypt"] #room-bg {
    background-position: center center;
  }
}
