@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Spectral:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg-deep: #0b0a10;
  --bg-panel: #17141f;
  --bg-panel-alt: #201b29;
  --border-gold: #8a6d3b;
  --text-main: #e8ddc7;
  --text-dim: #a99a83;
  --accent: #c9a35a;
  --danger: #a33a3a;
  --heal: #4a8f5c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Spectral', serif;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

#hud {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border-gold);
  position: relative;
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

#hud-inventory {
  padding-top: 0.4rem;
  border-top: 1px solid rgba(138, 109, 59, 0.35);
}

/* Before a game is running (state is null, e.g. the boot/language-choice
   screen) there are no player stats to show yet -- hide the stat blocks
   instead of rendering a row of empty hearts/icons. The music/manual/lang
   toggle buttons stay visible and usable throughout. */
#hud.pregame .hero-block,
#hud.pregame .hp-block,
#hud.pregame .weapon-block,
#hud.pregame .armor-block,
#hud.pregame #hud-inventory {
  display: none;
}

.hud-toggles {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.hero-name {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

.hud-block {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  min-width: 3.5rem;
}

.stat .label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

.stat span:last-child {
  font-weight: 600;
  color: var(--text-main);
}

.hp-block, .weapon-block, .armor-block {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hp-block .label, .weapon-block .label, .armor-block .label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

/* Health hearts: two stacked SVGs per slot -- a dim outline behind, a red
   fill in front clipped via clip-path to a per-instance --fill custom
   property (0-100%), giving full/empty (or partial) states without any
   image assets. Always a single row (up to 30 slots, 1 heart = 1 HP, for
   both the player's HUD and a monster's combat-narrative stats), each one
   kept small so the whole row fits without wrapping. */
.heart-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.08rem;
}
.heart-icon {
  position: relative;
  width: 0.42rem;
  height: 0.38rem;
  flex: none;
}
.heart-icon svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.heart-icon .heart-bg path {
  fill: rgba(232, 221, 199, 0.15);
}
.heart-icon .heart-fg {
  clip-path: inset(0 calc(100% - var(--fill, 0%)) 0 0);
}
.heart-icon .heart-fg path {
  fill: var(--danger);
  filter: drop-shadow(0 0 2px rgba(163, 58, 58, 0.6));
}

/* Armor shields: solid filled icons, one per armor point -- no partial-fill
   states needed since armor has no "max" concept in this game. */
.shield-row {
  display: flex;
  gap: 0.2rem;
}
.shield-icon {
  width: 0.9rem;
  height: 1.05rem;
  flex: none;
}
.shield-icon svg {
  width: 100%;
  height: 100%;
}
.shield-icon path {
  fill: var(--accent);
  stroke: #6b4f22;
  stroke-width: 1;
}

/* Weapon icon: the reimagined item art draws each weapon upright/vertical
   in a square canvas; force it into a square box bigger than the wide,
   short display slot and rotate 90deg so it reads as lying flat
   ("waagerecht"), cropping the transparent padding via overflow:hidden. */
.weapon-icon-wrap {
  position: relative;
  width: 3.2rem;
  height: 1.3rem;
  overflow: hidden;
  flex: none;
}
.weapon-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  transform: translate(-50%, -50%) rotate(90deg);
}

/* Repeated miniature item icons (lockpicks, fire vials, potions,
   artifacts) replacing plain counts. */
.mini-icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  max-width: 8rem;
}
.mini-icon-row img {
  width: 1.05rem;
  height: 1.05rem;
  object-fit: contain;
  flex: none;
}

.lang-toggle {
  background: var(--bg-panel-alt);
  color: var(--text-main);
  border: 1px solid var(--border-gold);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.05em;
}
.lang-toggle:hover { background: var(--accent); color: var(--bg-deep); }

#stage {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-bottom: 2px solid var(--border-gold);
}

#room-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#screen-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen-overlay.reveal-active {
  background: rgba(5, 4, 6, 0.72);
  animation: reveal-fade-in 0.2s ease-out;
}

#screen-overlay .reveal-image {
  max-width: 55%;
  max-height: 70%;
  filter: drop-shadow(0 0 18px rgba(201, 163, 90, 0.55));
  animation: reveal-pop-in 0.25s ease-out;
}

@keyframes reveal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes reveal-pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#room-transition-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 3;
}
#room-transition-overlay.active {
  opacity: 1;
}

#compass.locked,
#action-bar.locked {
  pointer-events: none;
  opacity: 0.5;
}

#compass {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  width: 9.2rem;
  height: 9.2rem;
  z-index: 2;
}

#compass .compass-dir {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  color: var(--text-dim);
  background: rgba(11, 10, 16, 0.65);
  border: 1px solid rgba(138, 109, 59, 0.4);
  border-radius: 6px;
}

#compass .compass-dir.active {
  color: var(--bg-deep);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(201, 163, 90, 0.7);
}

#compass .compass-dir.clickable {
  cursor: pointer;
}
#compass .compass-dir.clickable:hover {
  filter: brightness(1.2);
}
#compass .compass-dir.clickable:active {
  filter: brightness(0.85);
}

#compass .compass-n { top: 0; left: 50%; transform: translateX(-50%); }
#compass .compass-s { bottom: 0; left: 50%; transform: translateX(-50%); }
#compass .compass-w { left: 0; top: 50%; transform: translateY(-50%); }
#compass .compass-e { right: 0; top: 50%; transform: translateY(-50%); }
#compass .compass-center {
  position: absolute;
  top: 50%; left: 50%;
  width: 0.8rem; height: 0.8rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(138, 109, 59, 0.5);
}

#narrative-box {
  flex: 1;
  padding: 1rem 1.2rem;
  background: var(--bg-panel);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 5rem;
  white-space: pre-line;
}

#narrative-box .flavor {
  color: var(--text-main);
}

#narrative-box .monster-status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#narrative-box .monster-stats {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

#narrative-box .info {
  color: var(--accent);
  margin-top: 0.6rem;
  font-style: italic;
}

#action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 1rem 1.2rem 1.4rem;
  background: var(--bg-panel-alt);
}

.action-btn {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-gold);
  border-radius: 5px;
  padding: 0.55rem 1rem;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.action-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg-deep);
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.action-btn.key-hint::after {
  content: attr(data-key);
  margin-left: 0.4rem;
  opacity: 0.6;
  font-size: 0.7rem;
}

#lang-toggle:focus,
.action-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* In-game manual modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 6, 0.8);
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 2rem 1rem;
}
.modal-overlay.open {
  display: flex;
}
.modal-panel {
  position: relative;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  max-width: 42rem;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 1.5rem 1.8rem;
}
.modal-close {
  position: sticky;
  float: right;
  top: 0;
  background: var(--bg-panel-alt);
  color: var(--text-main);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  background: var(--accent);
  color: var(--bg-deep);
}
.modal-content h1 {
  font-family: 'Cinzel', serif;
  color: var(--accent);
  font-size: 1.4rem;
  margin: 0 0 1rem;
}
.modal-content h2 {
  font-family: 'Cinzel', serif;
  color: var(--accent);
  font-size: 1.05rem;
  margin: 1.4rem 0 0.5rem;
}
.modal-content p {
  line-height: 1.55;
  margin: 0.6rem 0;
}
.modal-content ul {
  margin: 0.4rem 0;
  padding-left: 1.3rem;
}
.modal-content li {
  margin: 0.25rem 0;
  line-height: 1.5;
}
.modal-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.6rem 0 1rem;
  font-size: 0.9rem;
}
.modal-content th, .modal-content td {
  border: 1px solid rgba(138, 109, 59, 0.4);
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.modal-content th {
  color: var(--accent);
  background: var(--bg-panel-alt);
}
