:root {
  color-scheme: dark;
  --ink: #090b09;
  --stone: #111611;
  --stone-light: #1b231c;
  --bone: #d6d1bc;
  --muted: #7e8475;
  --ember: #b43a32;
  --ember-bright: #e35a47;
  --moss: #7e9a69;
  font-family: "Courier New", "Noto Sans SC", monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--bone);
  background:
    linear-gradient(rgba(9, 11, 9, .94), rgba(9, 11, 9, .96)),
    repeating-linear-gradient(90deg, transparent 0 63px, #1a1e19 64px),
    repeating-linear-gradient(0deg, transparent 0 63px, #1a1e19 64px),
    #080a08;
  overflow: auto;
}

button { font: inherit; }

.game-shell {
  width: min(1120px, calc(100vw - 48px));
  padding: 28px 0;
}

.topbar, .footer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { margin-bottom: 14px; }

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 27px;
  height: 35px;
  position: relative;
  display: block;
  border: 3px solid var(--bone);
  border-top-color: transparent;
  transform: rotate(45deg);
  box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 7px var(--ember);
}

.brand h1 {
  margin: 0 0 3px;
  font-size: 25px;
  letter-spacing: .18em;
  line-height: 1;
}

.brand p, .footer-strip p { margin: 0; color: var(--muted); font-size: 12px; }

.room-status {
  height: 46px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 10px;
  padding-left: 18px;
  border-left: 1px solid #343b33;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}

.room-status strong {
  grid-row: 1 / 3;
  grid-column: 2;
  font-size: 32px;
  line-height: 1;
  color: var(--bone);
  font-family: Georgia, serif;
  font-weight: 400;
}

.room-status span:last-child { color: var(--moss); }

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #465045;
  border-radius: 2px;
  background: #0c100d;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55), inset 0 0 0 4px #080a08;
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    radial-gradient(circle, transparent 45%, rgba(0,0,0,.58) 100%);
  mix-blend-mode: screen, normal;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

.hud {
  position: absolute;
  z-index: 8;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  text-shadow: 2px 2px #000;
}

.hud-left { display: flex; align-items: flex-start; gap: 12px; }
.player-bars { display: grid; gap: 7px; padding-top: 4px; }
.player-portrait {
  width: 66px;
  height: 66px;
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  border: 1px solid #5a5d50;
  background: rgba(10, 13, 10, .88);
  box-shadow: inset 0 0 0 3px #090b09, 3px 3px 0 rgba(0, 0, 0, .45);
}
.player-portrait #portraitCanvas {
  width: 64px;
  height: 64px;
  cursor: default;
}
.player-portrait #companionCanvas {
  position: absolute;
  right: -8px;
  bottom: -7px;
  width: 32px;
  height: 32px;
  cursor: default;
  filter: drop-shadow(2px 2px 0 #050605);
}
.player-portrait #companionCanvas[hidden], .soul-line[hidden] { display: none; }
.stat-line { display: grid; grid-template-columns: 42px 170px 62px; gap: 8px; align-items: center; font-size: 11px; }
.stat-line > span { color: #b5b29f; }
.stat-line b { font-size: 10px; font-weight: 400; color: #aaa997; }

.bar { height: 8px; border: 1px solid #5a5d50; background: #171a16; padding: 1px; }
.bar i { display: block; width: 100%; height: 100%; background: var(--ember); transition: width .16s steps(4); }
.soul-segments { height: 10px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.soul-segments i {
  display: block;
  border: 1px solid #745632;
  background: rgba(65, 47, 25, .48);
  box-shadow: inset 0 0 0 1px #17130e;
}
.soul-segments i.active { background: #c68132; box-shadow: inset 0 0 0 1px #e3a54d, 0 0 5px rgba(198, 129, 50, .35); }

.status-effects { display: flex; min-height: 18px; gap: 5px; padding-left: 50px; }
.status-effects[hidden] { display: none; }
.status-effect {
  min-width: 42px;
  padding: 2px 7px;
  border: 1px solid #5b5143;
  color: #b9b39e;
  background: rgba(13, 16, 13, .78);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}
.status-effect[data-effect="bleed"] { border-color: #763b32; color: #d07a69; }
.status-effect[data-effect="poison"] { border-color: #52652b; color: #99ad57; }
.status-effect[data-effect="bloodlust"] { border-color: #6b354d; color: #c46d8d; }

.elapsed-time { display: flex; align-items: baseline; gap: 12px; padding-top: 4px; }
.elapsed-time span { color: var(--muted); font-size: 10px; }
.elapsed-time b { min-width: 42px; color: var(--bone); font-size: 13px; font-weight: 400; }

.scene-message {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 24px;
  min-width: 310px;
  max-width: 70%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 1px solid #5b4a38;
  color: #d9d1b9;
  background: rgba(8, 10, 8, .9);
  box-shadow: inset 0 0 0 3px #11140f, 4px 4px 0 rgba(0, 0, 0, .48);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
  text-shadow: 2px 2px #000;
}
.scene-message[hidden] { display: none; }

.interaction-prompt {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 78px;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid #6e5a40;
  color: #d8d0b8;
  background: rgba(8, 10, 8, .9);
  font-size: 10px;
  text-shadow: 2px 2px #000;
}
.interaction-prompt[hidden] { display: none; }
.interaction-prompt kbd {
  min-width: 22px;
  padding: 3px 5px;
  border: 1px solid #a77a43;
  color: #ffcf85;
  background: #21170f;
  text-align: center;
}

.boss-hud {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 22px;
  width: 420px;
  transform: translateX(-50%);
  text-align: center;
  color: #c8bda6;
  font-size: 12px;
  text-shadow: 2px 2px #000;
}
.boss-hud .bar { margin-top: 7px; height: 10px; }

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  place-items: center;
  align-content: center;
  padding: 40px;
  text-align: center;
  background: rgba(7, 9, 7, .9);
  backdrop-filter: blur(2px);
}
.screen-overlay.visible, .screen-overlay:not([hidden]) { display: grid; }

.screen-overlay h2 {
  margin: 3px 0 13px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(38px, 5vw, 67px);
  font-weight: 400;
  letter-spacing: .06em;
  color: #e0dbc8;
  text-shadow: 4px 4px 0 #351a17;
}

.eyebrow {
  margin: 0;
  color: var(--ember-bright);
  font-size: 11px;
  letter-spacing: .24em;
}

.intro, .end-screen > p:not(.eyebrow) {
  max-width: 460px;
  margin: 0 0 24px;
  color: #8f9383;
  font-size: 13px;
  line-height: 1.8;
}

.run-record,
.end-screen > .end-record {
  margin: -12px 0 20px;
  color: #697164;
  font-size: 10px;
  letter-spacing: .05em;
}

.end-screen > .end-record {
  color: #c08d4e;
}

.primary-button {
  min-width: 174px;
  padding: 13px 22px;
  color: #f0e7d0;
  border: 1px solid #dc5b4c;
  border-radius: 2px;
  background: #782b27;
  box-shadow: inset 0 0 0 3px #351817, 4px 4px 0 #050605;
  cursor: pointer;
  letter-spacing: .12em;
}
.primary-button:hover { background: #97352e; }
.primary-button:active { transform: translate(2px, 2px); box-shadow: inset 0 0 0 3px #351817, 2px 2px 0 #050605; }
.primary-button:focus-visible, .text-button:focus-visible, .upgrade-card:focus-visible { outline: 2px solid #e5d9b7; outline-offset: 4px; }

.controls { display: flex; gap: 24px; margin-top: 27px; color: #777d70; font-size: 10px; }
.touch-hint { display: none; }
kbd { color: #c9c5b2; border-bottom: 1px solid #6f7468; padding: 2px 4px; }

.rune { width: 55px; height: 55px; margin-bottom: 16px; border: 1px solid #80332d; transform: rotate(45deg); display: grid; place-items: center; }
.rune::before, .rune span { content: ""; display: block; border: 1px solid #80332d; }
.rune::before { width: 39px; height: 39px; border-radius: 50%; }
.rune span { position: absolute; width: 11px; height: 11px; background: #b43a32; animation: emberPulse 1.8s steps(4) infinite; }

.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: min(820px, 90%); margin-top: 22px; }
.upgrade-card {
  min-height: 174px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 20px;
  text-align: left;
  color: var(--bone);
  border: 1px solid #3d493d;
  border-radius: 2px;
  background: #121713;
  box-shadow: inset 0 0 0 3px #0a0d0b;
  cursor: pointer;
}
.upgrade-card:hover { border-color: #9a4239; background: #1b1815; transform: translateY(-3px); }
.upgrade-card b { color: var(--ember-bright); font-size: 10px; letter-spacing: .14em; }
.upgrade-card strong { font-family: Georgia, "Songti SC", serif; font-size: 21px; font-weight: 400; }
.upgrade-card span { color: #858a7b; font-size: 11px; line-height: 1.65; }

.weapon-screen h2 { font-size: clamp(30px, 4vw, 50px); }
.weapon-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 240px)); gap: 18px; margin-top: 16px; }
.weapon-card {
  min-height: 210px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 11px;
  padding: 18px;
  border: 1px solid #544b3d;
  color: var(--bone);
  background: #121410;
  box-shadow: inset 0 0 0 3px #090b09, 4px 4px 0 #050605;
  cursor: pointer;
}
.weapon-card:hover, .weapon-card:focus-visible { border-color: #d06b3c; background: #1c1712; }
.weapon-card img { width: 96px; height: 82px; object-fit: contain; image-rendering: pixelated; }
.weapon-card strong { color: #e1d7bd; font-size: 17px; font-weight: 400; }
.weapon-card span { color: #858a7b; font-size: 10px; line-height: 1.6; }
.weapon-hint { margin: 16px 0 0; color: #6f7569; font-size: 9px; }

.pause-badge { position: absolute; z-index: 12; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 12px 18px; color: var(--bone); border: 1px solid #6d7467; background: rgba(8,10,8,.85); letter-spacing: .2em; }

.touch-controls {
  display: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  min-height: 136px;
  padding: 10px 18px 4px;
  user-select: none;
  -webkit-user-select: none;
}

.touch-zone {
  display: grid;
  justify-items: start;
  gap: 5px;
  color: #697064;
  font-size: 9px;
  letter-spacing: .08em;
}

.touch-zone-aim {
  justify-items: end;
}

.touch-pad {
  position: relative;
  width: 102px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #3b443a;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 45, 37, .72), rgba(12, 16, 13, .86));
  box-shadow: inset 0 0 0 10px rgba(5, 7, 5, .3);
  touch-action: none;
}

.touch-knob {
  width: 38px;
  height: 38px;
  border: 1px solid #7b8573;
  border-radius: 50%;
  background: #242b23;
  box-shadow: 3px 3px 0 #050705;
  will-change: transform;
}

.aim-pad {
  border-color: #55332e;
  background: radial-gradient(circle, rgba(85, 38, 32, .35), rgba(12, 16, 13, .86));
}

.aim-mark,
.aim-mark::before,
.aim-mark::after {
  position: absolute;
  content: "";
}

.aim-mark {
  width: 34px;
  height: 34px;
  border: 1px solid #a04a3e;
  border-radius: 50%;
}

.aim-mark::before {
  top: 16px;
  left: -8px;
  width: 50px;
  border-top: 1px solid #a04a3e;
}

.aim-mark::after {
  top: -8px;
  left: 16px;
  height: 50px;
  border-left: 1px solid #a04a3e;
}

.dash-button {
  width: 62px;
  height: 62px;
  border: 1px solid #9d493f;
  border-radius: 50%;
  color: #ded5bd;
  background: #50231f;
  box-shadow: inset 0 0 0 5px #241311, 3px 3px 0 #050605;
  font-size: 11px;
  touch-action: manipulation;
}

.dash-button:active {
  transform: translate(2px, 2px);
  background: #743029;
  box-shadow: inset 0 0 0 5px #241311, 1px 1px 0 #050605;
}

.footer-strip { height: 42px; }
.footer-actions { display: flex; align-items: center; gap: 18px; }
.text-button { padding: 4px 0; color: #858b7c; border: 0; border-bottom: 1px solid #3d443c; background: none; cursor: pointer; font-size: 11px; text-decoration: none; }
.text-button:hover { color: var(--bone); }

.changelog-page {
  min-width: 0;
  display: block;
  padding: 0 24px 72px;
}

.changelog-shell {
  width: min(960px, 100%);
  margin: 0 auto;
}

.changelog-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #30372f;
}

.changelog-brand {
  color: var(--bone);
  text-decoration: none;
}

.changelog-brand strong,
.changelog-brand small {
  display: block;
}

.changelog-brand strong {
  margin-bottom: 4px;
  font-size: 17px;
  letter-spacing: .12em;
}

.changelog-brand small {
  color: var(--muted);
  font-size: 10px;
}

.version-badge {
  padding: 8px 11px;
  border: 1px solid #384137;
  color: #9aa18f;
  font-size: 10px;
}

.changelog-hero {
  padding: 92px 0 76px;
  border-bottom: 1px solid #30372f;
}

.changelog-hero h1 {
  margin: 10px 0 18px;
  color: #e0dbc8;
  font-family: Georgia, "Songti SC", serif;
  font-size: 64px;
  font-weight: 400;
}

.changelog-hero > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.release-entry {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 48px;
  padding: 64px 0;
  border-bottom: 1px solid #30372f;
}

.release-meta {
  display: grid;
  align-content: start;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.release-meta span {
  color: var(--ember-bright);
  font-size: 16px;
}

.release-content h2 {
  max-width: 620px;
  margin: 8px 0 28px;
  color: #d9d3bf;
  font-family: Georgia, "Songti SC", serif;
  font-size: 34px;
  font-weight: 400;
  line-height: 1.35;
}

.release-content ul {
  margin: 0;
  padding-left: 20px;
  color: #989e8d;
  font-size: 13px;
  line-height: 2;
}

.release-content li::marker {
  color: #985046;
}

.release-entry-muted {
  opacity: .72;
}

@media (max-width: 640px) {
  .changelog-page { padding-inline: 18px; }
  .changelog-header { min-height: 78px; }
  .changelog-brand .brand-mark { width: 22px; height: 29px; }
  .changelog-hero { padding: 64px 0 52px; }
  .changelog-hero h1 { font-size: 46px; }
  .release-entry { grid-template-columns: 1fr; gap: 24px; padding: 48px 0; }
  .release-content h2 { font-size: 28px; }
}

@keyframes emberPulse { 50% { background: #5e211d; box-shadow: 0 0 0 6px rgba(180,58,50,.07); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (hover: none) and (pointer: coarse), (max-width: 760px) {
  body {
    display: block;
    min-height: 100dvh;
  }

  .game-shell {
    width: calc(100% - 16px);
    margin: 0 auto;
    padding: 12px 0 4px;
  }

  .topbar {
    min-height: 42px;
    margin-bottom: 8px;
  }

  .brand { gap: 9px; }
  .brand-mark { width: 19px; height: 25px; border-width: 2px; }
  .brand h1 { font-size: 16px; letter-spacing: .12em; }
  .brand p { display: none; }

  .room-status {
    height: 36px;
    padding-left: 10px;
    column-gap: 7px;
    font-size: 9px;
  }

  .room-status strong { font-size: 24px; }
  .game-frame { border-radius: 0; box-shadow: 0 14px 36px rgba(0, 0, 0, .5); }

  .hud { top: 8px; left: 8px; right: 8px; }
  .hud-left { transform: scale(.55); transform-origin: top left; }
  .elapsed-time { transform: scale(.7); transform-origin: top right; }
  .scene-message { bottom: 8px; min-width: 220px; padding: 6px 10px; font-size: 8px; }
  .interaction-prompt { bottom: 46px; transform: translateX(-50%) scale(.75); }
  .weapon-grid { grid-template-columns: repeat(2, minmax(120px, 170px)); gap: 8px; }
  .weapon-card { min-height: 150px; padding: 10px; }
  .weapon-card img { width: 65px; height: 54px; }
  .boss-hud { bottom: 8px; width: calc(100% - 30px); transform: translateX(-50%) scale(.72); }

  .screen-overlay {
    padding: 10px 14px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .screen-overlay .rune { display: none; }
  .screen-overlay h2 { margin: 2px 0 6px; font-size: 26px; text-shadow: 2px 2px 0 #351a17; }
  .screen-overlay .eyebrow { font-size: 8px; }
  .intro, .end-screen > p:not(.eyebrow) { margin-bottom: 8px; font-size: 9px; line-height: 1.45; }
  .run-record, .end-screen > .end-record { margin: 0 0 8px; font-size: 8px; }
  .primary-button { min-width: 136px; padding: 8px 14px; font-size: 10px; }
  .controls { display: none; }
  .touch-hint { display: block; margin: 7px 0 0; color: #747b6d; font-size: 8px; }

  .upgrade-grid {
    width: 100%;
    display: flex;
    gap: 8px;
    margin-top: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }

  .upgrade-card {
    min-width: 170px;
    min-height: 118px;
    gap: 5px;
    padding: 11px;
    scroll-snap-align: center;
  }

  .upgrade-card strong { font-size: 15px; }
  .upgrade-card span { font-size: 9px; line-height: 1.4; }
  .touch-controls { display: grid; }
  .footer-strip { height: 34px; }
  .footer-strip > p { max-width: 55%; font-size: 9px; }
  .footer-actions { gap: 12px; }
  .text-button { font-size: 9px; }
}

@media (max-width: 390px) {
  .touch-controls { gap: 10px; padding-inline: 8px; }
  .touch-pad { width: 92px; }
  .dash-button { width: 56px; height: 56px; }
}
