:root {
  --ink: #0b0908;
  --ink2: #15110f;
  --bone: #ddd0bb;
  --bone2: #b7a993;
  --ash: #7f776c;
  --blood: #8b1a1a;
  --red: #b3261e;
  --ember: #e0702a;
  --gold: #a8875f;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --caps: 'Cinzel', 'Trajan Pro', 'Cormorant Garamond', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--bone); font-family: var(--serif); -webkit-font-smoothing: antialiased; }
body { user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.small { font-size: 15px; color: var(--ash); letter-spacing: 0.08em; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 20; }
.screen.dim { background: radial-gradient(ellipse at center, rgba(8, 6, 5, 0.72), rgba(0, 0, 0, 0.92)); z-index: 40; }

/* ---------- logo ---------- */
.logo { font-family: var(--caps); font-weight: 700; color: var(--bone); line-height: 0.9; text-align: center; filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.9)); }
.logo-row { display: flex; align-items: flex-end; justify-content: center; font-size: clamp(54px, 9vw, 118px); letter-spacing: 0.02em;
  background: linear-gradient(180deg, #f1e7d6 0%, #cdbfa8 55%, #8f8270 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-k { font-size: clamp(50px, 8.4vw, 110px); margin-top: -0.04em; }
.logo-sword { height: 1.32em; width: 0.42em; margin: 0 -0.02em -0.04em; fill: var(--red); filter: drop-shadow(0 0 10px rgba(179, 38, 30, 0.55)); }

/* ---------- loading ---------- */
#loading { background: #000; gap: 28px; }
#loading .logo-row { font-size: clamp(40px, 6vw, 72px); }
#loading .bar { width: min(320px, 70vw); height: 2px; background: rgba(221, 208, 187, 0.12); }
#loading .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blood), var(--ember)); transition: width 0.2s; }

/* ---------- title ---------- */
#title { align-items: flex-start; justify-content: center; padding-left: clamp(24px, 8vw, 140px); background: linear-gradient(90deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.35) 38%, rgba(0, 0, 0, 0) 60%); }
.title-col { display: flex; flex-direction: column; align-items: flex-start; gap: 22px; }
#title .logo { text-align: left; }
#title .logo-row { justify-content: flex-start; }
.tagline { font-family: var(--caps); font-size: 15px; letter-spacing: 0.42em; color: var(--bone2); text-transform: uppercase; line-height: 1.9; margin: 6px 0 18px 6px; }
.menu { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.menu button { appearance: none; background: none; border: 0; color: var(--bone2); font-family: var(--caps); font-size: 19px; letter-spacing: 0.24em; text-transform: uppercase;
  padding: 9px 4px 9px 26px; cursor: pointer; position: relative; transition: color 0.15s, letter-spacing 0.25s; }
.menu button::before { content: ''; position: absolute; left: 4px; top: 50%; width: 12px; height: 1px; background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform 0.2s; }
.menu button:hover, .menu button:focus-visible { color: var(--bone); letter-spacing: 0.28em; outline: none; }
.menu button:hover::before, .menu button:focus-visible::before { transform: scaleX(1); }
.menu button.primary { color: var(--bone); }
.foot { margin-top: 26px; font-size: 16px; color: var(--ash); letter-spacing: 0.1em; }

/* ---------- panels ---------- */
.panel { min-width: min(420px, 92vw); max-width: 92vw; padding: 34px 40px 28px; background: linear-gradient(180deg, rgba(20, 16, 14, 0.94), rgba(10, 8, 7, 0.96));
  border-top: 1px solid rgba(168, 135, 95, 0.4); border-bottom: 1px solid rgba(168, 135, 95, 0.4); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8); }
.panel.wide { width: min(640px, 92vw); }
.panel h2 { font-family: var(--caps); font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase; font-size: 22px; margin: 0 0 22px; color: var(--bone); }
.panel h2::after { content: ''; display: block; width: 46px; height: 1px; background: var(--red); margin-top: 14px; }
.rows { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.rows label { display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 19px; color: var(--bone2); }
.rows select, .rows input[type=range] { width: 52%; accent-color: var(--red); }
.rows select { background: #120e0c; color: var(--bone); border: 1px solid rgba(168, 135, 95, 0.4); font-family: var(--serif); font-size: 17px; padding: 4px 8px; }
.rows input[type=checkbox] { accent-color: var(--red); width: 18px; height: 18px; }
.keys { display: grid; grid-template-columns: 1fr; gap: 9px; margin-bottom: 22px; font-size: 18px; }
.keys div { display: flex; gap: 16px; align-items: baseline; }
.keys kbd { flex: 0 0 210px; font-family: var(--caps); font-size: 13px; letter-spacing: 0.12em; color: var(--bone); text-transform: uppercase; }
.keys span { color: var(--bone2); }
.keys .pad { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(221, 208, 187, 0.1); }
.credits-text { font-size: 18px; line-height: 1.55; color: var(--bone2); margin-bottom: 18px; }
.credits-text a { color: var(--bone); }
.credits-text .music { font-size: 16px; line-height: 1.5; }
.credits-text b { font-family: var(--caps); font-weight: 600; letter-spacing: 0.15em; font-size: 13px; color: var(--bone); }

/* ---------- intro ---------- */
#intro { background: #000; z-index: 30; }
.intro-text { max-width: 760px; padding: 0 28px; text-align: center; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.6; font-style: italic; color: var(--bone2); }
.intro-text p { margin: 0 0 0.9em; opacity: 0; transform: translateY(6px); transition: opacity 1.6s, transform 1.6s; }
.intro-text p.on { opacity: 1; transform: none; }
.intro-text p.place { font-style: normal; font-family: var(--caps); letter-spacing: 0.4em; font-size: 0.62em; color: var(--ash); text-transform: uppercase; margin-bottom: 1.6em; }
#intro .skip { position: absolute; bottom: 36px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.vitals { position: absolute; left: clamp(18px, 3vw, 44px); top: clamp(18px, 3vh, 36px); display: flex; flex-direction: column; gap: 6px; }
.vitals .bar { position: relative; height: 9px; background: rgba(10, 7, 6, 0.72); border: 1px solid rgba(221, 208, 187, 0.22); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.vitals .bar i { position: absolute; left: 0; top: 0; bottom: 0; }
.vitals .hp { width: 300px; }
.vitals .st { width: 240px; height: 6px; }
.hp .fill { background: linear-gradient(180deg, #b8322a, #7a1612); width: 100%; }
.hp .chip { background: rgba(232, 200, 160, 0.75); width: 100%; transition: width 0.6s 0.35s ease-out; }
.st .fill { background: linear-gradient(180deg, #cdbb8f, #8d7c55); width: 100%; }
.st.empty { border-color: rgba(179, 38, 30, 0.6); }
.tonic { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.tonic svg { width: 16px; height: 22px; fill: #6e8a5a; stroke: rgba(221, 208, 187, 0.6); stroke-width: 1.2; filter: drop-shadow(0 0 4px rgba(110, 138, 90, 0.5)); }
.tonic.none svg { fill: #2a2522; filter: none; }
.tonic b { font-family: var(--caps); font-size: 16px; font-weight: 600; color: var(--bone); text-shadow: 0 1px 4px #000; }

.reticle { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 1.5px solid rgba(240, 225, 200, 0.95); transform: rotate(45deg); box-shadow: 0 0 8px rgba(0, 0, 0, 0.7); }
.reticle::after { content: ''; position: absolute; inset: 4px; background: var(--red); }

#bars { position: absolute; inset: 0; }
.ebar { position: absolute; width: 74px; height: 4px; margin-left: -37px; background: rgba(10, 7, 6, 0.75); border: 1px solid rgba(221, 208, 187, 0.25); }
.ebar i { position: absolute; left: 0; top: 0; bottom: 0; }
.ebar .chip { background: rgba(232, 200, 160, 0.7); transition: width 0.5s 0.3s ease-out; }
.ebar .fill { background: #a8261d; }
.ebar .poise { position: absolute; left: 0; bottom: -4px; height: 2px; background: rgba(224, 180, 90, 0.85); }

.boss { position: absolute; left: 50%; bottom: clamp(48px, 9vh, 90px); width: min(820px, 76vw); transform: translateX(-50%); }
.boss-name { font-family: var(--caps); font-size: 17px; letter-spacing: 0.16em; color: var(--bone); text-shadow: 0 2px 6px #000; margin-bottom: 6px; }
.boss .bar { position: relative; height: 8px; background: rgba(10, 7, 6, 0.75); border: 1px solid rgba(221, 208, 187, 0.25); }
.boss .bar i { position: absolute; left: 0; top: 0; bottom: 0; }
.boss .fill { background: linear-gradient(180deg, #b8322a, #6e130f); width: 100%; }
.boss .chip { background: rgba(232, 200, 160, 0.7); width: 100%; transition: width 0.7s 0.4s ease-out; }

.area { position: absolute; left: 0; right: 0; top: 30%; text-align: center; opacity: 0; transition: opacity 1.4s; }
.area.on { opacity: 1; }
.area-name { font-family: var(--caps); font-size: clamp(30px, 4vw, 52px); letter-spacing: 0.3em; color: var(--bone); text-shadow: 0 4px 24px #000; }
.area-name::after { content: ''; display: block; width: 120px; height: 1px; margin: 16px auto 12px; background: linear-gradient(90deg, transparent, var(--bone2), transparent); }
.area-sub { font-style: italic; font-size: 22px; color: var(--bone2); text-shadow: 0 2px 10px #000; }

.objective { position: absolute; right: clamp(18px, 3vw, 44px); top: clamp(18px, 3vh, 36px); max-width: 340px; text-align: right; font-size: 18px; font-style: italic; color: var(--bone2);
  text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity 0.8s; }
.objective.on { opacity: 1; }
.objective::before { content: ''; display: inline-block; width: 7px; height: 7px; background: var(--red); transform: rotate(45deg); margin-right: 10px; vertical-align: 2px; }
.prompt { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); font-family: var(--caps); font-size: 15px; letter-spacing: 0.2em; color: var(--bone);
  padding: 9px 18px; background: rgba(8, 6, 5, 0.66); border-top: 1px solid rgba(168, 135, 95, 0.35); border-bottom: 1px solid rgba(168, 135, 95, 0.35); text-transform: uppercase; }
.prompt kbd { font-family: var(--caps); color: var(--ember); margin-right: 8px; }
.toast { position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%); font-size: 21px; font-style: italic; color: var(--bone); text-shadow: 0 2px 10px #000; opacity: 0; transition: opacity 0.5s; white-space: nowrap; }
.toast.on { opacity: 1; }
.hint { position: absolute; left: clamp(18px, 3vw, 44px); bottom: clamp(18px, 4vh, 40px); display: flex; flex-direction: column; gap: 7px; opacity: 0; transition: opacity 0.8s; }
.hint.on { opacity: 1; }
#hud.bossing .hint { bottom: calc(clamp(48px, 9vh, 90px) + 56px); }
.hint div { font-size: 17px; color: var(--bone2); text-shadow: 0 1px 6px #000; }
.hint kbd { display: inline-block; min-width: 22px; padding: 1px 7px; margin-right: 10px; font-family: var(--caps); font-size: 12px; letter-spacing: 0.08em; color: var(--bone);
  border: 1px solid rgba(221, 208, 187, 0.35); background: rgba(10, 8, 7, 0.6); text-align: center; }
.hurt { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(120, 10, 6, 0.55)); opacity: 0; transition: opacity 0.12s; }

/* ---------- notes ---------- */
.parchment { width: min(560px, 90vw); padding: 38px 44px 26px; background: radial-gradient(ellipse at 30% 20%, #d9c9a6, #b9a47c 70%, #8f7a54); color: #2a1d12;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), inset 0 0 60px rgba(70, 40, 10, 0.45); transform: rotate(-0.6deg); }
.note-title { font-family: var(--caps); font-size: 15px; letter-spacing: 0.18em; text-transform: uppercase; color: #4a2a14; margin-bottom: 16px; }
.note-text { font-size: 21px; line-height: 1.55; white-space: pre-line; font-style: italic; }
.note-close { margin-top: 22px; color: #6b5536; text-align: right; }

/* ---------- death / victory ---------- */
#death { background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.75)); pointer-events: none; opacity: 0; transition: opacity 1.2s; }
#death.on { opacity: 1; }
.death-word { font-family: var(--caps); font-size: clamp(54px, 9vw, 120px); letter-spacing: 0.32em; color: #9b1d16; text-shadow: 0 0 40px rgba(155, 29, 22, 0.45), 0 4px 20px #000; padding-left: 0.32em;
  transform: scale(1.06); transition: transform 4s ease-out; }
#death.on .death-word { transform: scale(1); }
.death-sub { margin-top: 10px; font-style: italic; font-size: 22px; color: var(--bone2); }
#victory { background: rgba(0, 0, 0, 0.82); gap: 14px; opacity: 0; transition: opacity 2.4s; }
#victory.on { opacity: 1; }
.victory-word { font-family: var(--caps); font-size: clamp(28px, 4vw, 54px); letter-spacing: 0.18em; color: var(--bone); text-align: center; padding: 0 20px; }
.victory-sub { font-style: italic; font-size: 22px; color: var(--bone2); }
.victory-end { margin: 26px 0 8px; }
#victory .menu { align-items: center; }

.fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 60; transition: opacity 0.8s; }
.fade.on { opacity: 1; }
.err { position: fixed; left: 16px; bottom: 16px; right: 16px; z-index: 99; color: #ffb4a8; background: rgba(40, 0, 0, 0.85); padding: 10px 14px; font: 13px/1.4 monospace; white-space: pre-wrap; }

@media (max-width: 700px) {
  .vitals .hp { width: 200px; } .vitals .st { width: 160px; }
  .keys kbd { flex-basis: 130px; }
}
