:root {
  --ink: #07080a;
  --ink-2: #0d1014;
  --paper: #e8ddc8;
  --paper-dim: #b9ac95;
  --red: #b3312b;
  --red-bright: #e0553f;
  --jade: #7fb3a8;
  --gold: #c9a45c;
  --font-cn: "Songti SC", "STSong", "Noto Serif SC", "SimSun", "NSimSun", serif;
  --font-en: "Cinzel", "Times New Roman", serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050608;
  color: var(--paper);
  font-family: var(--font-cn);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ---------- atmosphere ---------- */
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 38%, rgba(0,0,0,.72) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.28), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,.42));
  mix-blend-mode: multiply;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  transition: opacity .5s ease;
}

.hud-left {
  position: absolute;
  left: 38px;
  top: 34px;
  width: 300px;
}

.statline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 24px;
  color: var(--paper);
  text-shadow: 0 0 12px rgba(200,60,40,.65), 0 2px 3px #000;
  width: 26px;
  text-align: center;
}
.stat-label.jade { color: var(--jade); text-shadow: 0 0 12px rgba(80,180,160,.6); }

.bar {
  position: relative;
  flex: 1;
  height: 12px;
  background: rgba(10, 12, 14, .82);
  border: 1px solid rgba(232, 221, 200, .16);
  box-shadow: inset 0 0 12px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.6);
  overflow: hidden;
  transform: skewX(-14deg);
}

.bar i {
  position: absolute;
  inset: 0;
  right: auto;
  width: 100%;
  display: block;
  transition: width .22s cubic-bezier(.2,.8,.2,1);
  background:
    linear-gradient(90deg, #7d1a18, #c8432f 54%, #e8a06d);
  box-shadow: 0 0 14px rgba(200, 70, 45, .55);
}
.bar.hp i { width: 100%; }
.bar.sp { height: 7px; margin-top: 2px; border-color: rgba(127,179,168,.2); }
.bar.sp i {
  width: 0%;
  background: linear-gradient(90deg, #1e4a45, #4d8f82 60%, #a9ded1);
  box-shadow: 0 0 12px rgba(90, 200, 175, .5);
}
.bar-brush {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 1px, transparent 1px 9px);
  mix-blend-mode: overlay;
}
.stat-num {
  font-family: var(--font-en);
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--paper-dim);
  width: 34px;
  text-align: right;
  text-shadow: 0 1px 2px #000;
}
.stat-num.dim { opacity: .55; }

.hud-right {
  position: absolute;
  right: 42px;
  top: 34px;
  text-align: right;
}
#room-name {
  font-size: 21px;
  letter-spacing: .42em;
  color: var(--paper);
  text-shadow: 0 0 16px rgba(179,49,43,.55), 0 2px 4px #000;
}
#room-sub {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .32em;
  color: rgba(232, 221, 200, .5);
}
#audio-badge {
  margin-top: 16px;
  font-size: 10px;
  letter-spacing: .26em;
  color: rgba(127,179,168,.5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
#audio-badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 8px var(--jade);
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%,100%{opacity:.35} 50%{opacity:1} }

#cycle-badge {
  position: absolute;
  right: 44px;
  bottom: 38px;
  font-size: 11px;
  letter-spacing: .3em;
  color: rgba(201,164,92,.45);
}

/* ---------- boss bar ---------- */
#boss {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 56vw);
  text-align: center;
  transition: opacity .4s ease;
}
#boss-name {
  font-size: 17px;
  letter-spacing: .7em;
  text-indent: .7em;
  color: #e4d3b8;
  text-shadow: 0 0 22px rgba(210, 50, 40, .8), 0 2px 4px #000;
  margin-bottom: 9px;
}
.boss-bar {
  height: 8px;
  background: rgba(8,8,10,.9);
  border: 1px solid rgba(232,221,200,.14);
  position: relative;
  overflow: hidden;
}
#boss-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, #5c1312, #b3312b 45%, #e2744b);
  box-shadow: 0 0 18px rgba(220, 60, 40, .7);
  transition: width .3s cubic-bezier(.2,.8,.2,1);
}
#boss-tag {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: .35em;
  color: rgba(232,221,200,.35);
}

/* ---------- narration ---------- */
#narration {
  position: absolute;
  left: 50%;
  bottom: 15%;
  transform: translateX(-50%);
  width: min(820px, 84vw);
  text-align: center;
  pointer-events: none;
  transition: opacity .8s ease;
}
#narration-text {
  font-size: clamp(18px, 2.2vw, 30px);
  letter-spacing: .34em;
  text-indent: .34em;
  color: #f1e6d1;
  min-height: 1.4em;
  text-shadow: 0 0 24px rgba(0,0,0,.95), 0 0 42px rgba(179,49,43,.35), 0 2px 3px #000;
}
#narration-sub {
  margin-top: 10px;
  font-size: clamp(11px, 1vw, 14px);
  letter-spacing: .26em;
  color: rgba(232,221,200,.48);
  text-shadow: 0 2px 5px #000;
}

#prompt {
  position: absolute;
  left: 50%;
  bottom: 27%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: .3em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(201,164,92,.5), 0 2px 4px #000;
  transition: opacity .3s ease;
  animation: promptPulse 2s infinite;
}
@keyframes promptPulse { 0%,100%{ opacity:.55 } 50%{ opacity:1 } }

#hint {
  position: absolute;
  left: 38px;
  bottom: 34px;
  display: flex;
  gap: 22px;
  font-size: 11px;
  letter-spacing: .16em;
  color: rgba(232,221,200,.34);
  transition: opacity .6s ease;
}
#hint b {
  color: rgba(232,221,200,.72);
  font-weight: 400;
  font-family: var(--font-en);
  letter-spacing: .1em;
  border: 1px solid rgba(232,221,200,.22);
  padding: 2px 6px;
  margin-right: 5px;
  border-radius: 2px;
  background: rgba(255,255,255,.03);
}

/* ---------- damage floaters ---------- */
#floaters {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.floater {
  position: absolute;
  left: 0; top: 0;
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 600;
  color: #f5e8d2;
  text-shadow: 0 0 8px rgba(0,0,0,.9), 0 2px 3px #000;
  will-change: transform, opacity;
  pointer-events: none;
}
.floater.crit {
  font-size: 23px;
  color: #ffb36b;
  text-shadow: 0 0 14px rgba(220,70,40,.9), 0 2px 3px #000;
}
.floater.heal { color: #a9ded1; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity .6s ease;
}
.overlay:not(.hidden) { pointer-events: auto; }

#title {
  background: radial-gradient(ellipse at 50% 45%, rgba(6,7,9,.36) 0%, rgba(4,5,7,.9) 58%, #030405 100%);
  cursor: default;
}
#end {
  background: radial-gradient(ellipse at 50% 45%, rgba(4,5,7,.66) 0%, rgba(3,4,6,.95) 62%, #020304 100%);
  cursor: default;
}
.title-veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 62%, rgba(124, 28, 24, .16), transparent 55%),
    radial-gradient(circle at 50% 30%, rgba(60, 82, 90, .1), transparent 60%);
  pointer-events: none;
}
.title-grain {
  position: absolute; inset: 0;
  opacity: .12;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
  pointer-events: none;
}
.title-inner {
  position: relative;
  text-align: center;
  padding: 20px;
  animation: titleIn 1.4s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.title-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -56%);
  font-size: clamp(220px, 30vw, 460px);
  color: rgba(150, 38, 32, .13);
  text-shadow: 0 0 60px rgba(160,40,30,.1);
  pointer-events: none;
  line-height: 1;
  animation: markBreathe 8s ease-in-out infinite;
}
@keyframes markBreathe {
  0%,100% { opacity: .85; transform: translate(-50%, -56%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -56%) scale(1.03); }
}
.title-inner h1 {
  position: relative;
  font-size: clamp(46px, 6vw, 88px);
  font-weight: 400;
  letter-spacing: .32em;
  text-indent: .32em;
  color: #efe3cc;
  text-shadow:
    0 0 30px rgba(0,0,0,.9),
    0 0 60px rgba(179,49,43,.32),
    0 4px 10px #000;
}
#end-title { font-size: clamp(36px, 4.4vw, 64px); }
.title-en {
  margin-top: 16px;
  font-family: var(--font-en);
  font-size: clamp(9px, .9vw, 12px);
  letter-spacing: .36em;
  color: rgba(201,164,92,.55);
}
.title-copy {
  margin: 34px 0 40px;
  font-size: clamp(13px, 1.1vw, 16px);
  line-height: 2.1;
  letter-spacing: .2em;
  color: rgba(232,221,200,.62);
}
#end-copy { margin: 26px 0 36px; max-width: 560px; }
.title-foot {
  margin-top: 30px;
  font-size: 10px;
  letter-spacing: .28em;
  color: rgba(127,179,168,.45);
}
.ink-btn {
  position: relative;
  font-family: var(--font-cn);
  font-size: 19px;
  letter-spacing: .45em;
  text-indent: .45em;
  color: #f2e6d0;
  background: linear-gradient(180deg, rgba(34,20,18,.9), rgba(18,12,12,.96));
  border: 1px solid rgba(179,49,43,.5);
  padding: 16px 54px;
  cursor: pointer;
  outline: none;
  box-shadow: 0 0 30px rgba(120, 30, 25, .22), inset 0 0 20px rgba(140,40,30,.12);
  transition: all .3s ease;
}
.ink-btn::before, .ink-btn::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  border: 1px solid rgba(201,164,92,.4);
  transition: all .3s ease;
}
.ink-btn::before { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
.ink-btn::after { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
.ink-btn:hover {
  color: #fff6e2;
  border-color: rgba(224,85,63,.9);
  box-shadow: 0 0 46px rgba(179,49,43,.5), inset 0 0 26px rgba(179,49,43,.22);
  transform: translateY(-2px);
}
.ink-btn:hover::before, .ink-btn:hover::after { border-color: rgba(224,85,63,.9); }

/* ---------- boons ---------- */
#boons {
  background: radial-gradient(ellipse at 50% 50%, rgba(8,9,11,.72), rgba(3,4,5,.96) 75%);
  backdrop-filter: blur(3px);
}
#boons .panel {
  position: relative;
  width: min(940px, 92vw);
  padding: 10px 20px 16px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 26px;
}
.seal {
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #f0ddc0;
  background: rgba(150, 34, 28, .85);
  border: 1px solid rgba(240,210,170,.3);
  box-shadow: 0 0 24px rgba(179,49,43,.45);
  transform: rotate(-4deg);
}
.head-text { text-align: left; }
.panel-head h2 {
  font-size: 25px;
  font-weight: 400;
  letter-spacing: .4em;
  color: #efe3cc;
}
.panel-head p {
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: .22em;
  color: rgba(232,221,200,.4);
}
#boon-cards {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
}
.boon-card {
  position: relative;
  width: min(250px, 27vw);
  min-height: 292px;
  padding: 28px 22px 24px;
  background:
    linear-gradient(180deg, rgba(34, 32, 30, .78), rgba(14, 15, 17, .92));
  border: 1px solid rgba(201,164,92,.22);
  box-shadow: 0 12px 50px rgba(0,0,0,.55);
  cursor: pointer;
  text-align: center;
  transition: transform .28s cubic-bezier(.2,.8,.2,1), border-color .28s, box-shadow .28s;
  animation: cardIn .5s cubic-bezier(.2,.8,.2,1) both;
  overflow: hidden;
}
.boon-card:nth-child(2) { animation-delay: .07s; }
.boon-card:nth-child(3) { animation-delay: .14s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(26px) rotate(1deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}
.boon-card::before {
  content: "";
  position: absolute; inset: 8px;
  border: 1px solid rgba(232,221,200,.06);
  pointer-events: none;
}
.boon-card:hover {
  transform: translateY(-8px);
  border-color: rgba(224,85,63,.65);
  box-shadow: 0 18px 70px rgba(120,30,24,.35), 0 0 40px rgba(179,49,43,.18);
}
.boon-card .card-seal {
  width: 34px; height: 34px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  color: #f3e2c6;
  background: rgba(143, 34, 28, .8);
  border: 1px solid rgba(240,210,170,.24);
  transform: rotate(-3deg);
  box-shadow: 0 0 18px rgba(179,49,43,.3);
}
.boon-card h3 {
  font-size: 26px;
  font-weight: 400;
  letter-spacing: .28em;
  text-indent: .28em;
  color: #f0e3cc;
  margin-bottom: 7px;
}
.boon-card .card-kind {
  font-family: var(--font-en);
  font-size: 9px;
  letter-spacing: .3em;
  color: rgba(201,164,92,.55);
  margin-bottom: 20px;
}
.boon-card p {
  font-size: 12.5px;
  line-height: 1.95;
  letter-spacing: .12em;
  color: rgba(232,221,200,.6);
  min-height: 74px;
}
.boon-card .card-key {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: .18em;
  color: rgba(232,221,200,.28);
}
.boon-hint {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .2em;
  color: rgba(232,221,200,.32);
}
.boon-hint b { color: rgba(201,164,92,.7); font-weight: 400; font-family: var(--font-en); }

/* ---------- fx ---------- */
#flash {
  position: absolute; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease-out;
  mix-blend-mode: screen;
}
#glitch {
  position: absolute; inset: 0;
  opacity: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.055) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, rgba(255,0,0,.06), transparent 30%, transparent 70%, rgba(0,255,255,.05));
  mix-blend-mode: overlay;
}
#glitch.on { animation: glitchRun .28s steps(2) 1; }
@keyframes glitchRun {
  0% { opacity: .0; transform: translateX(0); }
  20% { opacity: 1; transform: translateX(-7px); }
  40% { opacity: .3; transform: translateX(6px); }
  60% { opacity: .9; transform: translateX(-3px); }
  80% { opacity: .2; transform: translateX(4px); }
  100% { opacity: 0; transform: translateX(0); }
}
#reticle {
  position: absolute;
  left: 0; top: 0;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  pointer-events: none;
  transition: opacity .2s;
}
#reticle i {
  position: absolute; inset: 0;
  border: 1px solid rgba(224, 85, 63, .65);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(179,49,43,.5), inset 0 0 8px rgba(179,49,43,.2);
}
#reticle i::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px;
  background: rgba(240, 220, 190, .85);
  border-radius: 50%;
}

/* a second cursor that is not yours */
#ghost-reticle {
  position: absolute;
  left: 0; top: 0;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
  z-index: 2;
}
#ghost-reticle i {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(150, 230, 214, .4);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(80, 200, 180, .35);
}
#ghost-reticle i::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 2px; height: 2px;
  margin: -1px 0 0 -1px;
  background: rgba(180, 245, 232, .8);
  border-radius: 50%;
}

#sys-line {
  position: absolute;
  right: 44px;
  bottom: 64px;
  max-width: 40vw;
  text-align: right;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 10px;
  letter-spacing: .18em;
  line-height: 1.8;
  color: rgba(127, 179, 168, .55);
  text-shadow: 0 0 10px rgba(60, 160, 150, .35), 0 1px 2px #000;
  opacity: 0;
  transition: opacity .8s ease;
  pointer-events: none;
  white-space: pre-line;
}

/* ---------- loading ---------- */
#loading {
  position: absolute; inset: 0;
  background: #050608;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: opacity .8s ease;
  z-index: 20;
}
.load-seal {
  font-size: 64px;
  color: rgba(179,49,43,.7);
  text-shadow: 0 0 34px rgba(179,49,43,.35);
  animation: markBreathe 3.4s ease-in-out infinite;
}
.load-text {
  font-size: 12px;
  letter-spacing: .34em;
  color: rgba(232,221,200,.4);
}

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .hud-left { width: 220px; left: 20px; top: 20px; }
  .hud-right { right: 22px; top: 20px; }
  #room-name { font-size: 16px; }
  #hint { display: none; }
  #cycle-badge { right: 22px; bottom: 20px; }
  #boon-cards { gap: 12px; }
  .boon-card { width: 30vw; min-height: 250px; padding: 18px 12px; }
  .boon-card h3 { font-size: 20px; }
}
