* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: "EB Garamond", Garamond, Georgia, serif;
  user-select: none;
}

canvas { display: block; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.label { font-size: 13px; letter-spacing: 2px; font-weight: 600; }
.dim { opacity: 0.7; }

#crosshair, #hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
#crosshair { opacity: 0.85; filter: drop-shadow(0 0 2px #000); }
#hitmarker { opacity: 0; color: #fff; transition: opacity 0.15s; }
#hitmarker.show { opacity: 1; transition: none; }
#hitmarker.kill { color: #ff3b3b; }

#top-left { position: absolute; top: 20px; left: 24px; display: grid; gap: 4px; }
#top-right { position: absolute; top: 20px; right: 24px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
#compass { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: block; }
#minimap { display: block; margin: 0 26px 12px 0; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6)); }
#objective { margin-top: 6px; font-size: 14px; color: #ffd6dc; max-width: 320px; }
#objective::before { content: '▸ '; color: #ff2a40; }
/* "Press E" prompt for doors */
#prompt {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  padding: 8px 16px;
  font-size: 16px;
  letter-spacing: 1px;
  background: rgba(20, 0, 6, 0.65);
  border: 1px solid rgba(255, 42, 64, 0.5);
  border-radius: 4px;
  display: none;
}
#prompt.show { display: block; }
#prompt.locked { color: #c9a0a8; border-color: rgba(255, 255, 255, 0.2); }
/* Short tips that fade in near the bottom of the screen */
#hint {
  position: absolute;
  left: 50%;
  bottom: 170px;
  transform: translateX(-50%);
  padding: 10px 18px;
  font-size: 17px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  background: rgba(20, 0, 6, 0.7);
  border: 1px solid rgba(255, 42, 64, 0.5);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.4s;
}
#hint.show { opacity: 1; }

/* What enemies say, as subtitles along the bottom, newest at the bottom */
#bubbles {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(56vw, 760px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.subtitle {
  max-width: 100%;
  padding: 5px 14px;
  font-size: 19px;
  line-height: 1.35;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 4px;
}
.subtitle .speaker { color: #ffcf6a; font-weight: 700; }
#score { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }

#health-wrap { position: absolute; left: 24px; bottom: 24px; width: 260px; }
#health-bar {
  height: 10px;
  margin: 6px 0 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  overflow: hidden;
}
#health-fill { height: 100%; width: 100%; background: #d0142a; transition: width 0.15s, background 0.3s; }
/* Black bile shield bar, above the Blood bar */
#shield-wrap { display: none; margin-bottom: 8px; }
#shield-wrap.show { display: block; }
#shield-text { color: #cdd1da; }
#shield-bar {
  height: 8px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
}
#shield-fill { height: 100%; width: 0; background: linear-gradient(90deg, #0b0b0f, #3a3d48 60%, #8a90a0); box-shadow: inset 0 0 4px rgba(200, 206, 220, 0.5); transition: width 0.15s; }
#health-text { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

#bile-wrap { position: absolute; right: 24px; bottom: 24px; width: 280px; text-align: right; }
#bile-bar {
  position: relative;
  height: 10px;
  margin: 6px 0 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  overflow: hidden;
}
#bile-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #3a1070, #a86cff); } /* Sin */
/* Marks the Sin needed for the selected spell */
#bile-tick { position: absolute; top: 0; bottom: 0; left: 30%; width: 2px; background: rgba(255, 255, 255, 0.6); }
#bile-text { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: #e6d4ff; }
#spells { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; margin-top: 6px; font-size: 13px; }
.spell { white-space: nowrap; } /* keep each hint on one line; wrap between hints */
.spell.bolt { color: #ff8a9a; }
.spell.cast { color: #ff5a6e; }
#life-price { display: none; color: #ff2a40; font-weight: 700; }
#life-price.show { display: inline; }

/* Grimoire: the three right-click spells, the selected one highlighted */
#grimoire { display: grid; gap: 4px; margin: 0 0 10px auto; width: 230px; }
.slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 13px;
  text-align: left;
  border-left: 3px solid transparent;
  background: rgba(20, 0, 6, 0.35);
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.slot .name { flex: 1; }
.slot .cost { font-variant-numeric: tabular-nums; color: #ff8a9a; }
.slot.selected { opacity: 1; border-left-color: #ff2a40; background: rgba(120, 0, 20, 0.55); }
.slot.off .name { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.4); }
.slot.active .cost { color: #fff; font-weight: 700; }

#banner {
  position: absolute;
  top: 22%;
  width: 100%;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
}
#banner.show { opacity: 1; }
#banner-title { font-family: "Germania One", Georgia, serif; font-size: 56px; font-weight: 400; letter-spacing: 6px; }
#banner-sub { font-size: 16px; letter-spacing: 3px; opacity: 0.8; }

/* An item picked up: shown turning in a pool of light, named beneath */
/* The game holds still behind it, dimmed, until you choose to carry on */
#itemget {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.8) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
#itemget.show { opacity: 1; pointer-events: auto; }
#itemget .card {
  width: 680px;
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.45s;
}
#itemget.show .card { transform: scale(1); }
#itemget-go {
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-top: 26px;
  padding: 12px 40px;
  color: #fff;
  background: #a3122a;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.3s, background 0.2s;
}
#itemget-go:hover { background: #c8173a; }
/* A moment's grace before it can be pressed, so a held click doesn't skip the screen */
#itemget-go:disabled { opacity: 0.35; cursor: default; }
#itemget-keys { font-size: 12px; letter-spacing: 1px; opacity: 0.55; margin-top: 10px; }
#itemget-view {
  display: block;
  margin: 0 auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(70, 30, 20, 0.85) 0%, rgba(20, 8, 8, 0.75) 45%, rgba(0, 0, 0, 0) 70%);
}
#itemget-title { font-family: "Germania One", Georgia, serif; font-size: 34px; letter-spacing: 3px; margin-top: -6px; text-shadow: 0 2px 8px #000; }
#itemget-sub { font-size: 15px; letter-spacing: 2px; opacity: 0.85; margin-top: 6px; text-shadow: 0 1px 6px #000; }
#itemget-sub kbd { font-size: 12px; }

/* Black-out between levels */
#fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 0.7s; }
#fade.show { opacity: 1; }

/* Extra lives, under the Blood readout */
#lives-wrap { display: none; margin-top: 8px; }
#lives-wrap.show { display: block; }
#lives { color: #d6f5a8; }
/* Green flare when you spend a life and rise again */
#revive {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(200, 255, 140, 0.25) 20%, rgba(120, 200, 60, 0.6) 100%);
  opacity: 0;
}

/* The serpent's power waking: a violet-white flash */
#flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255, 245, 255, 0.95) 10%, rgba(154, 76, 255, 0.75) 60%, rgba(60, 10, 120, 0.6) 100%);
  opacity: 0;
  pointer-events: none;
}
/* The charge filling round the crosshair, bright when it's full */
#charge-ring { stroke: #9a4cff; opacity: 0; transition: opacity 0.1s; }
#charge-ring.full { stroke: #f0e0ff; filter: drop-shadow(0 0 3px #b88cff); }

#feed {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(255, 60, 100, 0.5) 100%);
  opacity: 0;
}

#damage {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(220, 0, 0, 0.75) 100%);
  opacity: 0;
}

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 4, 10, 0.78);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
#overlay.hidden { display: none; }
.card { text-align: center; padding: 32px 40px; max-width: 560px; }
.card h1 { font-family: "Germania One", Georgia, serif; font-size: 64px; letter-spacing: 10px; font-weight: 400; }
.card p { margin: 8px 0 28px; opacity: 0.85; font-size: 17px; line-height: 1.45; }
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  text-align: left;
  font-size: 15px;
  margin-top: 32px; /* controls sit below the button */
  opacity: 0.75;
}
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 6px;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-bottom-width: 3px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  text-align: center;
}
#play {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 14px 36px;
  color: #fff;
  background: #a3122a;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#play:hover { background: #c8173a; }

/* Opening cutscene: black bars top and bottom, subtitles in the lower bar,
   and the rest of the HUD hidden while it plays */
#letterbox .bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 12vh;
  background: #000;
  transform: scaleY(0);
  transition: transform 0.6s ease;
}
#letterbox .top { top: 0; transform-origin: top; }
#letterbox .bottom { bottom: 0; transform-origin: bottom; }
body.cutscene #letterbox .bar { transform: scaleY(1); }
#skip { position: absolute; right: 24px; top: 10px; font-size: 13px; letter-spacing: 1px; opacity: 0.55; }
body.cutscene #hud > :not(#letterbox):not(#bubbles):not(#banner):not(#fade):not(#flash) { visibility: hidden; }
body.cutscene #bubbles { bottom: 3vh; }

/* The unseen voice in the undercroft: no one there, just words in her head */
.subtitle.voice { font-style: italic; color: #e6d6ff; background: rgba(18, 6, 30, 0.7); }
.subtitle.voice .speaker { color: #b48cff; font-style: normal; }
/* Lilith herself speaking */
.subtitle.lilith .speaker { color: #ff5a6e; }

/* Instructions: a scrollable codex opened from the menu */
#open-instructions, #close-instructions, #start-over {
  font: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 10px 28px;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  cursor: pointer;
}
#open-instructions, #start-over { display: block; margin: 12px auto 0; }
#start-over.hidden { display: none; }
#open-instructions:hover, #close-instructions:hover, #start-over:hover { border-color: #fff; background: rgba(255, 255, 255, 0.08); }
/* Arena and Main Menu share the Instructions look; Arena only on the title screen,
   Main Menu only on the pause and death screens */
#arena, #to-menu {
  display: block;
  margin: 12px auto 0;
  min-width: 190px;
  font: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 10px 28px;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  cursor: pointer;
}
#open-instructions, #start-over { min-width: 190px; }
#arena:hover, #to-menu:hover { border-color: #fff; background: rgba(255, 255, 255, 0.08); }
#overlay:not(.title) #arena, #overlay.title #to-menu { display: none; }
#play { min-width: 190px; }
#instructions {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: rgba(20, 4, 10, 0.94);
  backdrop-filter: blur(6px);
  user-select: text;
  z-index: 10;
}
#instructions.hidden { display: none; }
.codex { max-width: 760px; margin: 0 auto; padding: 48px 24px 64px; line-height: 1.45; }
.codex h1 { font-family: "Germania One", Georgia, serif; font-size: 52px; font-weight: 400; letter-spacing: 8px; text-align: center; }
.codex section { margin-top: 36px; }
.codex h2 {
  font-family: "Germania One", Georgia, serif;
  font-size: 26px; font-weight: 400; letter-spacing: 3px;
  color: #e8475e;
  padding-bottom: 6px; margin-bottom: 14px;
  border-bottom: 1px solid rgba(232, 71, 94, 0.35);
}
.codex .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; font-size: 16px; }
.codex .humors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.codex .humor {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}
.codex .humor h3 { font-size: 19px; letter-spacing: 1px; color: var(--c); margin-bottom: 4px; }
.codex .humor p { font-size: 16px; opacity: 0.88; }
.humor.blood, .dot.blood { --c: #e8384e; }
.humor.sin, .dot.sin { --c: #b07cff; }
.humor.black, .dot.black { --c: #a8acb8; }
.humor.life { --c: #b0d86a; }
.dot.grimoire { --c: #ff2a40; }
.dot.key { --c: #ffd76a; }
.codex .list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; font-size: 16px; }
.codex .list + .list { margin-top: 18px; padding-top: 14px; border-top: 1px dashed rgba(255, 255, 255, 0.15); }
.codex dt { font-weight: 700; white-space: nowrap; }
.codex dd { opacity: 0.88; }
.codex .note { margin-top: 14px; font-size: 15px; font-style: italic; opacity: 0.75; }
.codex .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c); box-shadow: 0 0 8px var(--c); }
#close-instructions { display: block; margin: 44px auto 0; }
@media (max-width: 600px) {
  .codex .keys, .codex .humors { grid-template-columns: 1fr; }
  .codex .list { grid-template-columns: 1fr; gap: 2px; }
  .codex dd { margin-bottom: 10px; }
}

/* Title screen: a dark wall lit by two torches, instead of the blurred game */
#overlay.title {
  background:
    radial-gradient(ellipse 30% 55% at 14% 42%, rgba(255, 120, 40, 0.16), transparent 70%),
    radial-gradient(ellipse 30% 55% at 86% 42%, rgba(255, 120, 40, 0.16), transparent 70%),
    radial-gradient(ellipse at center, #1a0a0c 0%, #070304 75%);
  backdrop-filter: none;
}
.card { position: relative; z-index: 1; }
.torch { display: none; }
#overlay.title .torch {
  display: block;
  position: absolute;
  top: 50%;
  width: 60px;
  height: 260px;
  margin-top: -170px;
  pointer-events: none;
}
.torch.left { left: 12%; }
.torch.right { right: 12%; }
.torch .handle {
  position: absolute; left: 22px; top: 112px; width: 16px; height: 120px;
  background: linear-gradient(90deg, #1c0f08, #4a2a16 45%, #24130a);
  clip-path: polygon(0 0, 100% 0, 75% 100%, 25% 100%);
}
.torch .cup {
  position: absolute; left: 12px; top: 96px; width: 36px; height: 22px;
  background: linear-gradient(90deg, #2a2420, #6a5a4a 40%, #2a2420);
  clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%);
}
.torch .bracket {
  position: absolute; left: 16px; top: 170px; width: 28px; height: 8px;
  background: #2e2824; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
/* Warm light thrown on the wall, breathing with the flame */
.torch .halo {
  position: absolute; left: -110px; top: -70px; width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 150, 60, 0.35), rgba(255, 90, 30, 0.08) 45%, transparent 70%);
  animation: halo 2.6s ease-in-out infinite alternate;
}
.torch .flame {
  position: absolute; left: 8px; top: 18px; width: 44px; height: 86px;
  transform-origin: 50% 100%;
  animation: sway 1.9s ease-in-out infinite alternate;
}
.torch .flame span {
  position: absolute; bottom: 0; left: 50%;
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  transform-origin: 50% 100%;
}
.torch .flame .outer {
  width: 44px; height: 86px; margin-left: -22px;
  background: radial-gradient(ellipse at 50% 80%, #ff7a1a, #d8300a 55%, rgba(160, 20, 0, 0) 75%);
  filter: blur(3px);
  animation: flicker 0.32s ease-in-out infinite alternate;
}
.torch .flame .mid {
  width: 28px; height: 60px; margin-left: -14px;
  background: radial-gradient(ellipse at 50% 80%, #ffd060, #ff8a20 60%, rgba(255, 100, 20, 0) 80%);
  filter: blur(2px);
  animation: flicker 0.24s ease-in-out infinite alternate-reverse;
}
.torch .flame .core {
  width: 14px; height: 30px; margin-left: -7px; bottom: 2px;
  background: radial-gradient(ellipse at 50% 75%, #fffbe8, #ffe08a 70%, rgba(255, 220, 120, 0) 100%);
  filter: blur(1px);
  animation: flicker 0.2s ease-in-out infinite alternate;
}
.torch.right .flame { animation-delay: -0.7s; }
.torch.right .flame span { animation-delay: -0.13s; }
.torch.right .halo { animation-delay: -1.1s; }
/* Sparks drifting up out of the flame */
.torch .embers i {
  position: absolute; bottom: 160px; left: 30px; width: 3px; height: 3px;
  border-radius: 50%; background: #ffb050; box-shadow: 0 0 6px #ff7a1a;
  opacity: 0;
  animation: ember 2.4s linear infinite;
}
.torch .embers i:nth-child(1) { --x: -14px; animation-delay: 0s; }
.torch .embers i:nth-child(2) { --x: 10px; animation-delay: 0.5s; }
.torch .embers i:nth-child(3) { --x: -4px; animation-delay: 1.1s; }
.torch .embers i:nth-child(4) { --x: 16px; animation-delay: 1.6s; }
.torch .embers i:nth-child(5) { --x: -10px; animation-delay: 2s; }
.torch.right .embers i { animation-duration: 2.9s; }
@keyframes flicker {
  0% { transform: scale(1, 1) skewX(0deg); }
  50% { transform: scale(0.94, 1.08) skewX(2deg); }
  100% { transform: scale(1.04, 0.95) skewX(-2deg); }
}
@keyframes sway {
  from { transform: rotate(-3deg); }
  to { transform: rotate(3deg); }
}
@keyframes halo {
  0% { opacity: 0.8; transform: scale(0.96); }
  40% { opacity: 1; transform: scale(1.03); }
  70% { opacity: 0.85; transform: scale(0.99); }
  100% { opacity: 1; transform: scale(1.02); }
}
@keyframes ember {
  0% { opacity: 0; transform: translate(0, 0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), -120px); }
}
@media (prefers-reduced-motion: reduce) {
  .torch .flame, .torch .flame span, .torch .halo, .torch .embers i { animation: none; }
}
@media (max-width: 900px) {
  .torch.left { left: 3%; }
  .torch.right { right: 3%; }
}
@media (max-width: 640px) {
  #overlay.title .torch { display: none; }
}

/* Waking from stone: your sight starts grey and clears */
#stone {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(130, 124, 114, 0.55) 0%, rgba(74, 70, 64, 0.97) 72%);
  opacity: 0;
  transition: opacity 3.2s ease-out;
}
#stone.show { opacity: 1; transition: none; }
