:root {
  --bg: #050407;
  --panel: rgba(14, 11, 16, 0.88);
  --line: #3a3040;
  --ink: #ece4d8;
  --muted: #a89ca0;
  --gold: #f2c45a;
  --green: #5ab84a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "VT323", "Courier New", monospace;
  font-size: 18px;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: pointer;
}

#minimap {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 140px);
  image-rendering: pixelated;
  background: rgba(5, 4, 7, 0.9);
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 #000;
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 8px 16px;
  pointer-events: none;
}

.hud a, .hud button { pointer-events: auto; }

.hud.top {
  top: 0;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(5, 4, 7, 0.9), rgba(5, 4, 7, 0));
}

.hud.bottom {
  bottom: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.row, .left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
}

.left { justify-content: flex-start; gap: 8px; }

h1 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: clamp(11px, 2.2vw, 16px);
  color: var(--gold);
  text-shadow: 2px 2px 0 #4a2a00;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 22px;
  color: var(--muted);
}

.stats b { color: var(--ink); font-weight: 400; }

#keyStat b { color: var(--gold); }

.hearts { letter-spacing: 1px; font-size: 22px; }
.hearts .full { color: #e04a3a; text-shadow: 1px 1px 0 #000; }
.hearts .empty { color: #3a2a2e; }

.toast {
  margin: 8px auto 0;
  width: fit-content;
  padding: 4px 10px;
  font-size: 20px;
  background: var(--panel);
  border: 2px solid var(--line);
  color: var(--gold);
}

button {
  font-family: "VT323", "Courier New", monospace;
  font-size: 18px;
  line-height: 1;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 6px 9px;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}

button:hover { border-color: #5a4a62; }

button:disabled { opacity: 0.4; cursor: default; }

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.home {
  color: var(--muted);
  text-decoration: none;
  font-size: 18px;
  text-shadow: 1px 1px 0 #000;
}

.home:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Turn-based combat bar ---------- */

.combat-bar {
  position: fixed;
  left: 50%;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--panel);
  border: 2px solid #6a2a2a;
  box-shadow: 3px 3px 0 #000;
  font-size: 20px;
  white-space: nowrap;
}

#turnLabel { color: var(--gold); }

.ap { display: inline-flex; gap: 4px; }

.ap span {
  width: 10px;
  height: 10px;
  border: 1px solid #000;
  background: #2a2228;
  transform: rotate(45deg);
}

.ap span.on { background: #5ad06a; box-shadow: 0 0 4px #5ad06a; }

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 2, 5, 0.6);
}

.overlay.solid { background: #050407; }

.card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 22px;
  background: #110d14;
  border: 3px solid var(--line);
  box-shadow: 6px 6px 0 #000;
  text-align: center;
}

.card h2 {
  margin: 0 0 12px;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
  font-size: clamp(14px, 3.6vw, 20px);
  color: var(--gold);
  text-shadow: 3px 3px 0 #4a2a00;
}

.card p { margin: 0 0 12px; font-size: 21px; }

.card ul {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 19px;
  color: var(--muted);
}

.card li { margin: 5px 0; }

.card li b { color: var(--ink); font-weight: 400; }

.portrait {
  display: block;
  width: 56px;
  height: 80px;
  margin: 0 auto 12px;
  image-rendering: pixelated;
}

button.primary {
  margin-top: 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 13px 18px;
  color: #2a1800;
  background: var(--gold);
  border-color: #ffe6a0;
  box-shadow: 3px 3px 0 #000;
}

button.primary:hover { background: #ffd47a; }

button.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
