:root {
  --ink: #080807;
  --ash: #b8b5a9;
  --ember: #e6a45b;
  --blood: #9f2727;
  --green: #9cbe4c;
  --gold: #cbb078;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #161614;
  color: var(--ash);
  font-family: Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

#viewport, #viewport canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#vignette, #hitFlash, #healGlow, #whiteout, #fadeBlack {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#vignette {
  z-index: 2;
  background: radial-gradient(ellipse at 50% 46%, transparent 34%, rgba(3,3,3,.28) 72%, rgba(3,3,3,.78) 100%);
  mix-blend-mode: multiply;
}

#hitFlash {
  z-index: 4;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(120,7,7,.06) 20%, rgba(139,0,0,.56) 100%);
  transition: opacity .22s ease-out;
}

#healGlow {
  z-index: 4;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(255,195,98,.22), transparent 58%);
  transition: opacity .3s ease-out;
}

#whiteout {
  z-index: 12;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 48%, #fffdf4 0%, #e4e2d9 45%, #9c9a92 100%);
}

#fadeBlack { z-index: 20; opacity: 0; background: #000; transition: opacity .6s ease; }

.hidden { display: none !important; }

#hud { position: fixed; inset: 0; z-index: 6; pointer-events: none; }

#playerPanel { position: absolute; left: 28px; bottom: 26px; width: min(39vw, 430px); }

.bar-row { display: flex; flex-direction: column; gap: 8px; }

.bar-shell {
  position: relative;
  height: 14px;
  background: rgba(2,2,2,.72);
  border: 1px solid rgba(208,191,148,.42);
  box-shadow: 0 2px 12px #000a, inset 0 0 8px #000;
  overflow: hidden;
}

#healthShell { height: 17px; width: 100%; }
#staminaShell { height: 10px; width: 78%; }

.bar-fill { position: absolute; inset: 0 auto 0 0; width: 100%; transform-origin: left center; }

.health {
  background: linear-gradient(180deg, #e0695e 0%, #b02d27 46%, #661614 100%);
  box-shadow: inset 0 1px 0 #ffb6a373, 0 0 10px #a62c2c59;
  transition: transform .16s ease-out;
}

.stamina {
  background: linear-gradient(180deg, #d3e983 0%, #82ad3f 48%, #415d22 100%);
  box-shadow: inset 0 1px 0 #f0ffb885;
  transition: transform .08s linear;
}

.stamina-ghost {
  background: linear-gradient(180deg, #e4d493, #8b7440);
  opacity: .68;
  transition: transform .55s ease-out .16s;
}

.stat-row { display: flex; gap: 22px; align-items: center; margin-top: 9px; font-size: 12px; letter-spacing: .16em; color: #d4c7a7; text-shadow: 0 2px 4px #000; }
.stat-row b { font-weight: normal; color: #efe2c1; }
.estus { display: inline-flex; gap: 7px; align-items: center; }
.flask { display: inline-block; width: 14px; height: 17px; border: 1px solid #bfa66d; border-radius: 3px 3px 6px 6px; background: radial-gradient(circle at 50% 75%, #f0b963, #8c4719 70%); box-shadow: 0 0 8px #e0a44a70; }
.soul { display: inline-block; width: 9px; height: 9px; transform: rotate(45deg); background: #a8e3d5; box-shadow: 0 0 8px #9fe4d4; }

#bossHud { position: absolute; bottom: 27px; left: 50%; width: min(54vw, 660px); transform: translateX(-50%); text-align: center; }
#bossName { font-size: 13px; letter-spacing: .34em; color: #dfd3af; text-shadow: 0 2px 6px #000, 0 0 12px #000; margin-bottom: 7px; white-space: nowrap; }
#bossBarShell { position: relative; height: 11px; background: #050403cc; border: 1px solid #c1a46b80; box-shadow: 0 2px 12px #000; overflow: hidden; }
#bossBarFill { position: absolute; inset: 0 auto 0 0; width: 100%; transform-origin: left; background: linear-gradient(180deg, #e4a25a 0%, #ad5729 40%, #712819 100%); transition: transform .22s ease-out; }
#phaseMarks { position: absolute; inset: 0; display: flex; }
#phaseMarks i { flex: 1; border-right: 1px solid #0a0707aa; }
#phaseMarks i:last-child { border: 0; }

#controlHint { position: absolute; top: 18px; right: 22px; font-family: ui-monospace, "Courier New", monospace; font-size: 10px; line-height: 1.8; letter-spacing: .06em; color: #d8cfb8ad; text-align: right; text-shadow: 0 1px 4px #000; }
#controlHint b { color: #f0dfb3; font-weight: normal; }

#equipment { position: absolute; bottom: 88px; right: 26px; display: flex; gap: 5px; opacity: .8; }
.slot { width: 44px; height: 38px; position: relative; border: 1px solid #776f5b; background: linear-gradient(180deg,#26241fdd,#0d0c0add); box-shadow: inset 0 0 9px #000; display: flex; align-items: flex-end; justify-content: center; }
.slot.selected { border-color: #c8ad70; box-shadow: inset 0 0 9px #000, 0 0 10px #b0833d55; }
.slot span { position: absolute; top: 1px; left: 3px; font: 9px ui-monospace, monospace; color: #b9a77d; }
.slot em { font: normal 8px/1.1 ui-monospace, monospace; color: #c9b995; text-align: center; margin-bottom: 3px; letter-spacing: .05em; }

#prompt { position: absolute; left: 50%; top: 64%; transform: translateX(-50%); font-size: 14px; letter-spacing: .2em; color: #eee0bd; text-shadow: 0 2px 6px #000; background: #06060599; border: 1px solid #c4aa6e66; padding: 7px 16px; white-space: nowrap; }

#statusText { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 15px; letter-spacing: .3em; color: #e9c784; text-shadow: 0 2px 8px #000; opacity: 0; transition: opacity .28s; white-space: nowrap; }
#statusText.show { opacity: 1; }

#lockReticle { position: absolute; left: 50%; top: 47%; width: 18px; height: 18px; margin: -9px; border: 1px solid #f1dfb9; border-radius: 50%; box-shadow: 0 0 8px #fff6, inset 0 0 6px #fff4; }
#lockReticle::before, #lockReticle::after { content: ""; position: absolute; background: #f1dfb9; }
#lockReticle::before { width: 1px; height: 7px; left: 8px; top: -5px; }
#lockReticle::after { height: 1px; width: 7px; top: 8px; left: -5px; }

#titleScreen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #25231de8 0%, #0c0b09fa 74%), linear-gradient(#24221e, #080807); transition: opacity .8s ease; }
#titleScreen.dismiss { opacity: 0; pointer-events: none; }
.title-embers { position: absolute; inset: 0; background-image: radial-gradient(circle at 50% 76%, #d8872c2e 0, transparent 28%), radial-gradient(circle at 22% 15%, #ffffff08 1px, transparent 2px), radial-gradient(circle at 78% 30%, #ffffff07 1px, transparent 2px); background-size: 100% 100%, 90px 90px, 130px 130px; animation: emberDrift 9s linear infinite; }
@keyframes emberDrift { to { background-position: 0 0, 40px -90px, -50px -130px; } }
.title-content { position: relative; text-align: center; width: min(92vw, 720px); padding: 24px; }
.title-kicker { font-size: 10px; letter-spacing: .58em; color: #a99771; margin-bottom: 14px; }
h1 { margin: 0; font-size: clamp(54px, 11vw, 112px); line-height: .84; letter-spacing: .16em; font-weight: normal; color: #d8cdb2; text-shadow: 0 3px 0 #000, 0 0 34px #d7a15b33; }
.title-rule { width: 172px; height: 1px; margin: 26px auto; background: linear-gradient(90deg, transparent, #b69760, transparent); }
.title-content p { font-size: 14px; letter-spacing: .09em; color: #b1a88f; font-style: italic; }
#startButton { margin-top: 22px; padding: 13px 34px; background: transparent; color: #eee0bd; border: 1px solid #bda06c; letter-spacing: .26em; font-size: 12px; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; pointer-events: auto; }
#startButton:hover, #startButton:focus-visible { background: #bda06c; color: #14120e; box-shadow: 0 0 22px #c9944a66; outline: none; }
.title-controls { margin-top: 32px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font: 9px ui-monospace, monospace; letter-spacing: .1em; color: #9d9480; }
.title-foot { margin-top: 18px; font-size: 10px; letter-spacing: .12em; color: #7d7665; }

#centerBanner { position: fixed; inset: 0; z-index: 14; display: grid; place-content: center; text-align: center; pointer-events: none; }
#bannerMain { font-size: clamp(38px, 8vw, 92px); letter-spacing: .26em; text-indent: .26em; color: #d9cfb4; text-shadow: 0 4px 2px #000, 0 0 28px #000; }
#bannerSub { margin-top: 12px; font: 11px ui-monospace, monospace; letter-spacing: .32em; color: #b39d71; }
#centerBanner.death #bannerMain { color: #a92a26; text-shadow: 0 4px 2px #000, 0 0 32px #9c141466; }
#centerBanner.victory #bannerMain { color: #f0d59b; }

#fatalError { position: fixed; left: 20px; right: 20px; top: 20px; z-index: 30; padding: 16px; background: #200b0b; border: 1px solid #a33; color: #ffd2c8; font: 13px ui-monospace, monospace; white-space: pre-wrap; }

@media (max-width: 900px) {
  #playerPanel { left: 14px; bottom: 96px; width: min(60vw, 330px); }
  #bossHud { width: min(76vw, 560px); bottom: 24px; }
  #controlHint { display: none; }
  #equipment { bottom: 106px; right: 12px; transform: scale(.88); transform-origin: bottom right; }
  .title-controls { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .title-embers { animation: none; }
  #hitFlash, #healGlow, #fadeBlack { transition-duration: .01s; }
}
