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

:root {
  --gold: #c8a96e;
  --gold-dim: #8a744c;
  --parchment: #d8c9a8;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'Cormorant Garamond', Georgia, serif; color: var(--gold); }

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

#errlog {
  position: fixed; top: 0; left: 0; max-width: 60%; z-index: 99;
  font: 11px monospace; color: #ff6666; background: rgba(0,0,0,.7);
  white-space: pre-wrap; pointer-events: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#status { position: absolute; top: 22px; left: 26px; }

.bar {
  position: relative; height: 12px; margin-bottom: 6px;
  background: rgba(10, 8, 6, .82);
  border: 1px solid #5a4a32;
  box-shadow: 0 0 0 1px rgba(0,0,0,.8), inset 0 0 6px rgba(0,0,0,.9);
}
.bar .fill, .bar .chip {
  position: absolute; inset: 1px; transform-origin: left center;
  transform: scaleX(1);
}
.bar .chip { background: #d8c050; transition: transform .08s linear; }
.bar.hp { width: 270px; }
.bar.hp .fill { background: linear-gradient(#c33b2e, #7d1f16); }
.bar.st { width: 200px; height: 9px; }
.bar.st .fill { background: linear-gradient(#3f7d4a, #28522f); }
.bar.st .chip { display: none; }

#flasks { display: flex; gap: 6px; margin-top: 10px; }
.flask {
  width: 16px; height: 24px; position: relative; opacity: 1;
  background: radial-gradient(circle at 50% 65%, #d8323c 0%, #7c1220 70%);
  border: 1px solid #caa66a; border-radius: 45% 45% 50% 50%;
}
.flask::before {
  content: ''; position: absolute; top: -6px; left: 4px; width: 6px; height: 6px;
  background: #2c2620; border: 1px solid #caa66a;
}
.flask.empty { background: #1c1714; opacity: .45; }

#runes {
  position: absolute; right: 26px; bottom: 22px;
  display: flex; align-items: center; gap: 9px;
  padding: 4px 16px; min-width: 110px; justify-content: flex-end;
  border: 1px solid #5a4a32; background: rgba(8, 7, 5, .75);
  font-size: 21px; letter-spacing: 1px; color: #d6c08c;
}
#runes .rune-glyph { font-size: 15px; color: #9b8a64; }
#runes.pop { animation: runepop .35s ease; }
@keyframes runepop { 30% { transform: scale(1.12); } }

#bossbar {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  width: min(720px, 72vw);
}
#bossbar .boss-name {
  font-size: 23px; letter-spacing: 2px; color: #e2cf9a;
  text-shadow: 0 2px 6px #000; margin-bottom: 4px; padding-left: 2px;
}
.bar.boss { width: 100%; height: 10px; }
.bar.boss .fill { background: linear-gradient(#b8a14c, #6e5a1d); }
.bar.boss .chip { background: #efe6c0; }

#prompt {
  position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%);
  padding: 7px 26px; font-size: 21px; letter-spacing: 1px; color: #e6d7ae;
  background: rgba(8, 7, 5, .72); border: 1px solid #5a4a32;
  border-left: none; border-right: none;
  text-shadow: 0 1px 4px #000;
}
#prompt b { color: #fff0c8; font-weight: 600; }

#enemy-bars { position: absolute; inset: 0; }
.ebar {
  position: absolute; width: 64px; height: 5px; transform: translate(-50%, -50%);
  background: rgba(10,8,6,.85); border: 1px solid rgba(90,74,50,.9);
}
.ebar .efill { position: absolute; inset: 1px; transform-origin: left center; background: #b03126; }

#lockdot {
  position: absolute; width: 14px; height: 14px; transform: translate(-50%,-50%) rotate(45deg);
  background: radial-gradient(#fff8e0, #c8a96e 65%, transparent 70%);
  box-shadow: 0 0 12px 2px rgba(230, 205, 140, .8);
}

/* ---------- Center text (YOU DIED / felled / area names) ---------- */
#center-text {
  position: fixed; left: 0; right: 0; top: 42%; z-index: 8;
  text-align: center; pointer-events: none;
  opacity: 0; transition: opacity .7s ease;
}
#center-text.show { opacity: 1; }
#center-text.died {
  font-size: clamp(54px, 9vw, 110px); letter-spacing: 14px; color: #8c1812;
  text-shadow: 0 0 38px rgba(140, 24, 18, .85), 0 0 4px #000;
  background: linear-gradient(transparent, rgba(0,0,0,.62) 35%, rgba(0,0,0,.62) 65%, transparent);
  padding: 30px 0;
}
#center-text.felled {
  font-size: clamp(34px, 5.4vw, 64px); letter-spacing: 10px; color: #d9bf7f;
  text-shadow: 0 0 30px rgba(217, 191, 127, .7), 0 0 4px #000;
  background: linear-gradient(transparent, rgba(0,0,0,.55) 35%, rgba(0,0,0,.55) 65%, transparent);
  padding: 24px 0;
}
#center-text.area {
  top: 30%;
  font-size: clamp(38px, 5.5vw, 66px); font-style: italic; font-weight: 500;
  letter-spacing: 6px; color: #e3cf9c; text-shadow: 0 2px 22px rgba(0,0,0,.9);
}
#center-text.area::after {
  content: ''; display: block; width: 320px; max-width: 50vw; height: 1px;
  margin: 10px auto 0; background: linear-gradient(90deg, transparent, #c8a96e, transparent);
}
#center-text.notice {
  top: 60%;
  font-size: clamp(20px, 2.4vw, 30px); color: #e3cf9c;
  text-shadow: 0 1px 8px #000;
}

/* ---------- Tutorial message popup ---------- */
#tutorial {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  z-index: 9; width: min(560px, 86vw);
}
.tut-inner {
  background: linear-gradient(rgba(20,17,12,.96), rgba(12,10,7,.96));
  border: 1px solid #6a5638; box-shadow: 0 0 60px rgba(0,0,0,.9), inset 0 0 40px rgba(0,0,0,.6);
  padding: 26px 34px; text-align: center;
}
.tut-title { font-size: 15px; letter-spacing: 6px; color: #8a744c; margin-bottom: 14px; }
#tutorial-text { font-size: 23px; line-height: 1.45; color: var(--parchment); }
#tutorial-text b { color: #ffe9b0; font-weight: 600; }
.tut-close { margin-top: 18px; font-size: 14px; letter-spacing: 2px; color: #776348; }

/* ---------- Overlays ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(120, 10, 5, .55) 100%);
  opacity: 0; transition: opacity .12s linear;
}
#fader {
  position: fixed; inset: 0; background: #000; pointer-events: none; z-index: 20;
  opacity: 0; transition: opacity .5s ease;
}

/* ---------- Title screen ---------- */
#title-screen, #end-screen, #paused {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #17130c 0%, #060504 70%);
}
.title-inner { text-align: center; max-width: 640px; padding: 24px; }
.game-title {
  font-size: clamp(46px, 7vw, 84px); letter-spacing: 18px; color: #e8d6a4; font-weight: 500;
  text-shadow: 0 0 50px rgba(200, 169, 110, .45), 0 2px 3px #000;
}
.game-subtitle { font-size: 19px; font-style: italic; color: #9b8a64; letter-spacing: 3px; margin: 6px 0 26px; }
.class-card {
  border: 1px solid #4a3d28; background: rgba(14,12,8,.6); padding: 14px 22px; margin-bottom: 22px;
}
.class-name { font-size: 24px; letter-spacing: 8px; color: #d9bf7f; }
.class-desc { font-size: 16px; font-style: italic; color: #a08c62; margin: 6px 0; line-height: 1.4; }
.class-gear { font-size: 16px; color: #c2ad7f; letter-spacing: 1px; }
.controls-grid {
  display: grid; grid-template-columns: auto auto auto auto; gap: 3px 18px;
  justify-content: center; font-size: 16px; margin-bottom: 28px;
}
.controls-grid span:nth-child(odd) { color: #efe0b4; text-align: right; }
.controls-grid span:nth-child(even) { color: #8a744c; text-align: left; }

button {
  font-family: inherit; font-size: 22px; letter-spacing: 4px; color: #e8d6a4;
  background: linear-gradient(rgba(60,48,28,.5), rgba(28,22,12,.5));
  border: 1px solid #6a5638; padding: 12px 42px; cursor: pointer;
  transition: all .2s ease;
}
button:hover { color: #fff3cf; border-color: #c8a96e; box-shadow: 0 0 24px rgba(200,169,110,.25); }
.title-footer { margin-top: 22px; font-size: 13px; color: #5d4f38; font-style: italic; }

/* ---------- Pause ---------- */
#paused { background: rgba(4,3,2,.78); cursor: pointer; }
.pause-title { font-size: 42px; letter-spacing: 12px; color: #d9bf7f; text-align: center; }
.pause-hint { font-size: 17px; color: #8a744c; text-align: center; margin-top: 10px; font-style: italic; }

/* ---------- End screen ---------- */
#end-screen { background: rgba(3,2,1,.0); transition: background 2s ease; }
#end-screen.dim { background: rgba(3,2,1,.82); }
.end-inner { text-align: center; max-width: 600px; padding: 24px; }
.end-title {
  font-size: clamp(40px, 6vw, 70px); letter-spacing: 12px; color: #e8d6a4;
  text-shadow: 0 0 50px rgba(200,169,110,.5);
}
.end-quote { font-size: 20px; font-style: italic; color: #a08c62; margin: 14px 0 26px; }
#end-stats { font-size: 19px; color: #c2ad7f; line-height: 1.7; margin-bottom: 30px; letter-spacing: 1px; }
