/* =========================================================================
   ASHEN SOULS — Dark Souls-style HUD & chrome
   ========================================================================= */

:root {
  --bronze: #8a7a5c;
  --bronze-dim: #57492f;
  --bone: #cfc5a5;
  --blood: #a01c10;
  --blood-bright: #d13b1e;
  --stam: #3e7c2e;
  --stam-bright: #5aa83d;
  --gold: #d9b45c;
  --serif: "Adobe Garamond Pro", "Palatino Linotype", Palatino, "Book Antiqua",
           Garamond, "Iowan Old Style", Georgia, "Times New Roman", serif;
}

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

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: var(--serif);
  -webkit-user-select: none; user-select: none;
}

#game-root { position: fixed; inset: 0; background: #000; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: none; }
#game-root.menu-open #gl { cursor: default; }
.hidden { display: none !important; }

/* ================= Loading ================= */
#loading {
  position: absolute; inset: 0; z-index: 60;
  background: #000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  transition: opacity 0.8s ease;
}
#loading.gone { opacity: 0; pointer-events: none; }
#loading span {
  color: var(--bone); font-size: 30px; letter-spacing: 0.42em;
  text-indent: 0.42em; opacity: 0.85;
}
.loading-bar { width: 220px; height: 2px; background: #2a2419; }
#loading-fill { width: 0%; height: 100%; background: var(--gold); transition: width 0.25s ease; }

/* ================= Title screen ================= */
#title-screen {
  position: absolute; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at 50% 62%, #17140f 0%, #0a0806 55%, #020202 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1.6s ease;
}
#title-screen.gone { opacity: 0; pointer-events: none; }
#title-embers { position: absolute; inset: 0; }
#title-inner {
  position: relative; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transform: translateY(-3vh);
}
#title-logo { line-height: 0.94; filter: drop-shadow(0 0 24px rgba(255, 120, 30, 0.18)); }
#title-ashen, #title-souls {
  display: block;
  font-size: clamp(56px, 9vw, 110px);
  letter-spacing: 0.30em; text-indent: 0.30em;
  color: #d8cdb2;
  text-shadow: 0 2px 3px #000, 0 0 34px rgba(240, 170, 80, 0.22);
}
#title-ashen { font-weight: 400; }
#title-souls {
  color: #b9462a;
  text-shadow: 0 2px 3px #000, 0 0 40px rgba(230, 90, 40, 0.4);
}
#title-sub {
  margin-top: 18px; color: #7d745e; font-size: 15px;
  font-style: italic; letter-spacing: 0.14em;
}
#title-menu {
  list-style: none; margin-top: 54px;
  display: flex; flex-direction: column; gap: 14px;
}
#title-menu li {
  color: #9c937d; font-size: 21px; letter-spacing: 0.22em; text-indent: 0.22em;
  padding: 3px 26px; position: relative; cursor: default;
  transition: color 0.15s ease;
}
#title-menu li.selected { color: #efe6cc; }
#title-menu li.selected::before, #title-menu li.selected::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px;
  background: var(--gold); transform: translateY(-50%) rotate(45deg);
  box-shadow: 0 0 8px rgba(217, 180, 92, 0.8);
}
#title-menu li.selected::before { left: -4px; }
#title-menu li.selected::after { right: -4px; }
#title-foot {
  position: absolute; bottom: 7vh; left: 0; right: 0; text-align: center;
  color: #6a614d; font-size: 14px; letter-spacing: 0.3em; text-indent: 0.3em;
  animation: titleFoot 2.6s ease-in-out infinite;
}
@keyframes titleFoot { 0%,100% { opacity: 0.25; } 50% { opacity: 0.9; } }

/* ================= HUD bars ================= */
#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }

#status-bars { position: absolute; top: 26px; left: 30px; display: flex; flex-direction: column; gap: 7px; }

.bar-frame {
  position: relative; height: 11px;
  background: linear-gradient(180deg, #14120e 0%, #26221a 45%, #0c0a07 100%);
  border: 1px solid #000;
  box-shadow:
    0 0 0 1px rgba(138, 122, 92, 0.55),
    0 0 0 2px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(0, 0, 0, 0.9);
  transform: skewX(-14deg);
}
#hp-frame { width: min(400px, 40vw); }
#st-frame { width: min(328px, 33vw); height: 9px; }

.bar-fill {
  position: absolute; left: 1px; top: 1px; bottom: 1px; width: 100%;
  transform-origin: left;
}
#hp-fill {
  background: linear-gradient(180deg, #e0502f 0%, #a01c10 55%, #6d1009 100%);
  box-shadow: inset 0 1px 1px rgba(255, 190, 160, 0.45);
}
.bar-fill.ghost { background: linear-gradient(180deg, #e8d9a0, #b09a55); opacity: 0.9; }
#st-fill.stamina {
  background: linear-gradient(180deg, #74b352 0%, #3e7c2e 55%, #255117 100%);
  box-shadow: inset 0 1px 1px rgba(210, 255, 190, 0.4);
}
#status-bars.exhausted #st-fill.stamina {
  background: linear-gradient(180deg, #c8a23a 0%, #9c7a1e 60%, #6d520e 100%);
}

/* ================= Boss bar ================= */
#boss-bar {
  position: absolute; left: 50%; bottom: 64px;
  transform: translateX(-50%);
  width: min(680px, 72vw);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 1; transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.9, 0.25, 1);
}
#boss-bar.sweep-in { animation: bossSweep 1.4s cubic-bezier(0.16, 0.84, 0.3, 1) both; }
@keyframes bossSweep {
  0% { opacity: 0; transform: translateX(-50%) translateY(26px); }
  35% { opacity: 1; }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#boss-name {
  color: #e7ddc2; font-size: 21px; letter-spacing: 0.3em; text-indent: 0.3em;
  text-shadow: 0 2px 4px #000, 0 0 18px rgba(0,0,0,0.9);
}
#boss-frame { width: 100%; height: 13px; transform: none; }
#boss-fill.boss {
  background: linear-gradient(180deg, #d8462a 0%, #8e150b 60%, #580a04 100%);
  box-shadow: inset 0 1px 1px rgba(255, 170, 140, 0.4);
}
#boss-ghost { background: linear-gradient(180deg, #e8d9a0, #a08a4a); }

/* ================= Souls / items ================= */
#souls-box {
  position: absolute; right: 34px; bottom: 26px; text-align: right;
  text-shadow: 0 2px 4px #000;
}
#souls-current {
  color: #e5dcc3; font-size: 34px; letter-spacing: 0.06em;
  text-shadow: 0 2px 5px #000, 0 0 14px rgba(0,0,0,0.8);
  font-variant-numeric: tabular-nums;
}
#souls-gain {
  color: var(--gold); font-size: 18px; opacity: 0;
  transition: opacity 0.3s ease;
}
#souls-gain.show { opacity: 1; }

#item-box { position: absolute; left: 30px; bottom: 26px; display: flex; align-items: center; gap: 12px; }
.slot {
  width: 62px; height: 62px; position: relative;
  background: linear-gradient(160deg, rgba(28, 24, 17, 0.92), rgba(10, 9, 6, 0.92));
  border: 1px solid #3d3524;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.8), 0 4px 14px rgba(0,0,0,0.6), inset 0 0 18px rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
}
.slot.active { border-color: #6b5c3d; }
.slot svg { width: 46px; height: 46px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.8)); }
#estus-count {
  position: absolute; right: 4px; bottom: 1px;
  color: #efe6cc; font-size: 19px; text-shadow: 0 1px 3px #000;
  font-variant-numeric: tabular-nums;
}
#item-name {
  color: #9a9179; font-size: 15px; font-style: italic; letter-spacing: 0.05em;
  text-shadow: 0 1px 3px #000;
}

/* ================= Lock-on reticle ================= */
#reticle {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.9));
}
.ret-diamond {
  position: absolute; inset: 10px;
  background: rgba(232, 222, 190, 0.95);
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(240, 230, 200, 0.5);
  animation: retPulse 1.6s ease-in-out infinite;
}
.ret-ring {
  position: absolute; inset: 0;
  border: 1px solid rgba(232, 222, 190, 0.45);
  border-radius: 50%;
}
@keyframes retPulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }

/* ================= Prompt / vignettes ================= */
#prompt {
  position: absolute; left: 50%; bottom: 21vh;
  transform: translateX(-50%);
  color: #d8cfae; font-size: 19px; letter-spacing: 0.08em;
  background: rgba(8, 7, 5, 0.55);
  border: 1px solid rgba(138, 122, 92, 0.4);
  padding: 8px 22px;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
}
#prompt b {
  display: inline-block; min-width: 30px; text-align: center;
  border: 1px solid #8a7a5c; margin-right: 10px; padding: 0 6px;
  color: var(--gold); font-weight: 400; background: rgba(0,0,0,0.4);
}

#hurt-vignette {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 46%, rgba(140, 8, 4, 0.55) 100%);
  transition: opacity 0.5s ease;
}
#heal-glow {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at 50% 80%, rgba(255, 190, 90, 0.28), transparent 62%);
  transition: opacity 0.45s ease;
}
#stamina-flash {
  position: absolute; left: 30px; top: 26px; width: min(328px, 33vw); height: 9px;
  margin-top: 20px; opacity: 0;
  background: rgba(200, 160, 60, 0.0);
}

/* ================= Banners ================= */
#banner {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.72) 100%);
}
#banner-text {
  font-size: clamp(52px, 8.5vw, 118px);
  letter-spacing: 0.22em; text-indent: 0.22em;
  color: #8c1710;
  text-shadow: 0 0 18px rgba(120, 10, 5, 0.65), 0 0 60px rgba(90, 8, 4, 0.8), 0 3px 6px #000;
  opacity: 0;
}
#banner.show #banner-text { animation: bannerIn 4.6s ease-out both; }
#banner.show { animation: bannerBg 4.6s ease-out both; }
#banner.gold #banner-text {
  color: #c9a44f;
  text-shadow: 0 0 18px rgba(190, 150, 70, 0.55), 0 0 60px rgba(150, 110, 40, 0.7), 0 3px 6px #000;
}
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(0.94); }
  18% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.015); }
}
@keyframes bannerBg {
  0% { opacity: 0; } 14% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; }
}

#whiteout {
  position: absolute; inset: 0; z-index: 35; background: #efeade; opacity: 0;
  pointer-events: none; transition: opacity 0.28s ease;
}
#fade-black {
  position: absolute; inset: 0; z-index: 36; background: #000; opacity: 1;
  pointer-events: none; transition: opacity 1.1s ease;
}

/* ================= Menus ================= */
#menu-overlay {
  position: absolute; inset: 0; z-index: 45;
  background: rgba(2, 2, 1, 0.62);
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: clamp(40px, 12vw, 220px);
}
#menu-panel {
  min-width: 320px;
  background: linear-gradient(150deg, rgba(22, 19, 13, 0.96), rgba(9, 8, 5, 0.96));
  border: 1px solid #4a4028;
  box-shadow: 0 0 0 1px #000, 0 18px 60px rgba(0,0,0,0.85), inset 0 0 40px rgba(0,0,0,0.55);
  padding: 26px 34px 20px;
}
#menu-header {
  color: var(--bone); font-size: 24px; letter-spacing: 0.24em; text-indent: 0.24em;
  border-bottom: 1px solid #3d3524; padding-bottom: 12px; margin-bottom: 16px;
}
#menu-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
#menu-list li {
  color: #9c937d; font-size: 19px; letter-spacing: 0.12em;
  padding: 7px 14px; position: relative;
}
#menu-list li.selected { color: #efe6cc; background: linear-gradient(90deg, rgba(120, 100, 60, 0.25), transparent 80%); }
#menu-list li.selected::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; background: var(--gold);
  box-shadow: 0 0 8px rgba(217, 180, 92, 0.7);
}
#menu-list li .opt-val { float: right; color: var(--gold); font-size: 17px; }
#menu-hint { margin-top: 18px; color: #6a614d; font-size: 13px; font-style: italic; }

/* ================= Status sheet ================= */
#status-sheet {
  position: absolute; inset: 0; z-index: 44;
  background: rgba(2, 2, 1, 0.62);
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: clamp(40px, 12vw, 220px);
}
#status-panel {
  min-width: 560px;
  background: linear-gradient(150deg, rgba(22, 19, 13, 0.96), rgba(9, 8, 5, 0.96));
  border: 1px solid #4a4028;
  box-shadow: 0 0 0 1px #000, 0 18px 60px rgba(0,0,0,0.85), inset 0 0 40px rgba(0,0,0,0.55);
  padding: 26px 34px 20px;
}
#status-header {
  color: var(--bone); font-size: 24px; letter-spacing: 0.24em; text-indent: 0.24em;
  border-bottom: 1px solid #3d3524; padding-bottom: 12px; margin-bottom: 16px;
}
#status-cols { display: flex; gap: 44px; }
.status-col { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.srow { display: flex; justify-content: space-between; gap: 30px; border-bottom: 1px dotted rgba(90, 80, 55, 0.25); padding-bottom: 4px; }
.slabel { color: #8d846d; font-size: 16px; letter-spacing: 0.08em; }
.sval { color: #e2d9be; font-size: 16px; font-variant-numeric: tabular-nums; }
#status-hint { margin-top: 18px; color: #6a614d; font-size: 13px; font-style: italic; }

/* ================= Controls card ================= */
#controls-card {
  position: absolute; inset: 0; z-index: 46;
  background: rgba(2, 2, 1, 0.72);
  display: flex; align-items: center; justify-content: center;
}
#controls-panel {
  width: min(640px, 90vw);
  background: linear-gradient(150deg, rgba(22, 19, 13, 0.97), rgba(9, 8, 5, 0.97));
  border: 1px solid #4a4028;
  box-shadow: 0 0 0 1px #000, 0 18px 60px rgba(0,0,0,0.85);
  padding: 26px 34px 20px;
}
#controls-header {
  color: var(--bone); font-size: 24px; letter-spacing: 0.24em; text-indent: 0.24em;
  border-bottom: 1px solid #3d3524; padding-bottom: 12px; margin-bottom: 16px;
}
#controls-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 7px 22px; align-items: center;
}
#controls-grid .k {
  color: var(--gold); font-size: 15px; text-align: right; letter-spacing: 0.06em;
  white-space: nowrap;
}
#controls-grid span:not(.k) { color: #b9b098; font-size: 16px; }
#controls-hint { margin-top: 18px; color: #6a614d; font-size: 13px; font-style: italic; line-height: 1.5; }

/* ================= Small screens ================= */
@media (max-width: 760px) {
  #status-bars { top: 14px; left: 14px; }
  #item-box { left: 14px; bottom: 14px; }
  #souls-box { right: 16px; bottom: 14px; }
  #boss-bar { bottom: 84px; }
}
