:root {
  --gold: #c9b07a;
  --gold-dim: #8a7344;
  --blood: #8b1c1c;
  --ink: #0c0a08;
  --parchment: #e8dcc0;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050406;
  color: var(--parchment);
  font-family: "Noto Sans KR", sans-serif;
  user-select: none;
  cursor: crosshair;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

#vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0,0,0,.55) 100%);
  z-index: 2;
}

#grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

#hurt-flash {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(120,0,0,.65) 100%);
  opacity: 0;
  transition: opacity .15s ease-out;
}
#hurt-flash.on { opacity: 1; transition: none; }

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
#hud.hidden { display: none; }

#player-hud {
  position: absolute;
  top: 24px;
  left: 24px;
  width: min(300px, 40vw);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.bar-label {
  width: 32px;
  font-size: 11px;
  letter-spacing: .12em;
  color: #b9aa88;
  text-shadow: 0 1px 3px #000;
}
.bar {
  flex: 1;
  height: 9px;
  background: #140b0b;
  border: 1px solid var(--gold-dim);
  box-shadow: 0 0 0 1px #000, inset 0 0 8px rgba(0,0,0,.7);
  overflow: hidden;
}
.bar .fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transition: transform .08s linear;
}
.bar.hp .fill {
  background: linear-gradient(#d63b3b, #7a1414);
}
.bar.sta .fill {
  background: linear-gradient(#d8c278, #6e5a22);
}
.bar.sta.empty .fill { filter: saturate(.3); }

#flasks {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-left: 42px;
}
.flask {
  width: 22px;
  height: 26px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(#3a2a18, #1a120c);
  box-shadow: inset 0 0 6px rgba(0,0,0,.6);
  position: relative;
  clip-path: polygon(20% 0, 80% 0, 90% 28%, 90% 100%, 10% 100%, 10% 28%);
}
.flask::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 10%;
  top: 36%;
  background: linear-gradient(#7ec8ff, #2a6aa8);
  opacity: .95;
}
.flask.used { opacity: .28; }
.flask.used::after { background: #222; }

#boss-hud {
  position: absolute;
  left: 50%;
  bottom: 7.5%;
  transform: translateX(-50%);
  width: min(680px, 72vw);
  text-align: center;
}
#boss-name {
  font-family: "Noto Serif KR", serif;
  font-weight: 600;
  font-size: clamp(14px, 1.7vw, 18px);
  letter-spacing: .28em;
  color: var(--parchment);
  text-shadow: 0 2px 10px #000, 0 0 18px rgba(0,0,0,.8);
  margin-bottom: 10px;
}
.boss-bar {
  height: 12px;
  background: #160808;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 1px #000, 0 6px 18px rgba(0,0,0,.55), inset 0 0 10px #000;
  overflow: hidden;
}
.boss-bar .fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(#c42e2e 0%, #8a1515 55%, #5c0d0d 100%);
  transition: transform .12s linear;
}
#boss-hud.phase2 #boss-name { color: #f0c989; }
#boss-hud.phase2 .boss-bar { border-color: #e0c07a; }
#boss-hud.phase2 .boss-bar .fill {
  background: linear-gradient(#e25a1a 0%, #9a2010 60%, #4a0a08 100%);
}

#lock-hint {
  position: absolute;
  top: 28px;
  right: 28px;
  font-size: 11px;
  letter-spacing: .16em;
  color: #9a8b6a;
  text-shadow: 0 1px 4px #000;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12,8,6,.72) 0%, rgba(0,0,0,.88) 100%);
}
.overlay.hidden { display: none; }

.title-inner, .end-inner { text-align: center; padding: 24px; }
.eyebrow {
  font-size: 12px;
  letter-spacing: .28em;
  color: #9b8a66;
  margin-bottom: 14px;
}
h1 {
  font-family: "Noto Serif KR", serif;
  font-size: clamp(56px, 10vw, 104px);
  font-weight: 700;
  letter-spacing: .22em;
  color: #f1e6c8;
  text-shadow: 0 4px 30px rgba(0,0,0,.9);
  line-height: 1;
}
.subtitle {
  margin: 16px 0 32px;
  font-family: "Noto Serif KR", serif;
  font-size: 18px;
  letter-spacing: .2em;
  color: #cabb96;
}

button {
  pointer-events: auto;
  cursor: pointer;
  font-family: "Noto Serif KR", serif;
  font-size: 16px;
  letter-spacing: .2em;
  color: #1a140c;
  background: linear-gradient(#e8d7a8, #b8964e);
  border: 1px solid #f3e6c0;
  padding: 12px 36px;
  box-shadow: 0 0 0 1px #000, 0 8px 24px rgba(0,0,0,.5);
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.controls {
  list-style: none;
  margin-top: 36px;
  color: #bbae8c;
  font-size: 13px;
  line-height: 1.9;
}
.controls kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  margin-right: 2px;
  border: 1px solid #6a5b3a;
  background: rgba(0,0,0,.45);
  color: #e8dcc0;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .04em;
}

#end-title {
  font-family: "Noto Serif KR", serif;
  font-size: clamp(42px, 8vw, 88px);
  letter-spacing: .18em;
  line-height: 1.15;
  text-shadow: 0 6px 28px #000;
}
#end-screen.dead #end-title { color: #a51c1c; }
#end-screen.win #end-title {
  color: #f0e0b0;
  font-size: clamp(28px, 4.8vw, 48px);
  letter-spacing: .16em;
}
#end-sub {
  margin: 18px 0 32px;
  color: #c2b48f;
  letter-spacing: .12em;
}

#load-status {
  min-height: 1.4em;
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: .18em;
  color: #9a8b66;
}
#start-btn:disabled {
  opacity: .4;
  cursor: default;
  filter: none;
}
.credits {
  margin-top: 28px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: .06em;
  color: #7a6e55;
}
#vignette {
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0,0,0,.62) 100%);
}
#grain { opacity: .055; }
.dmg-num {
  position: fixed;
  z-index: 6;
  pointer-events: none;
  font-family: "Noto Serif KR", serif;
  font-weight: 700;
  text-shadow: 0 2px 8px #000, 0 0 12px rgba(0,0,0,.8);
  letter-spacing: .04em;
  transform: translate(-50%, -50%);
}
