:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #141216;
  --panel-soft: #1c191d;
  --panel-line: #423932;
  --ink: #e7dfcf;
  --muted: #9c9386;
  --ember: #d76534;
  --ember-bright: #ef8a4e;
  --blue: #718bb7;
  --gold: #d8bd68;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #5a483b;
  border-radius: 4px;
  color: var(--ink);
  background: linear-gradient(#2c2522, #171518);
  cursor: pointer;
  min-height: 42px;
  touch-action: manipulation;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--ember-bright);
  outline: none;
  filter: brightness(1.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.primary {
  position: relative;
  min-height: 50px;
  padding: 0.75rem 1.5rem;
  border-color: #9a4e31;
  background: linear-gradient(180deg, #783721, #3a1d18);
  box-shadow: inset 0 1px #d38154, 0 8px 30px #0009;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.secondary,
.quiet,
.text-button {
  background: #151316cc;
}

.text-button {
  border: 0;
  color: var(--muted);
}

.wide {
  width: 100%;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--ember-bright);
  font: 700 0.68rem/1.2 Arial, sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.title-screen,
.selection-screen {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  padding: calc(2rem + var(--safe-top)) calc(1.25rem + var(--safe-right))
    calc(2rem + var(--safe-bottom)) calc(1.25rem + var(--safe-left));
  isolation: isolate;
  text-align: center;
  background:
    radial-gradient(circle at 50% 34%, #4e201860 0 2%, transparent 25%),
    linear-gradient(165deg, #08090c, #151114 55%, #08090c);
}

.title-screen::before,
.selection-screen::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    repeating-linear-gradient(115deg, transparent 0 46px, #ffffff05 47px 48px),
    radial-gradient(ellipse at bottom, #54241833, transparent 60%);
  content: "";
}

.title-screen::after,
.selection-screen::after {
  position: absolute;
  z-index: -1;
  width: min(80vw, 680px);
  height: min(80vw, 680px);
  border: 1px solid #b25c3840;
  border-radius: 50%;
  box-shadow: inset 0 0 80px #000, 0 0 80px #9b40211f;
  content: "";
}

.title-screen h1 {
  margin: 0;
  color: #d8cfbf;
  font-size: clamp(3.1rem, 13vw, 7rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.78;
  text-shadow: 0 6px 0 #000, 0 0 45px #b64a2c66;
}

.title-screen h1 span {
  display: block;
  margin-top: 0.25em;
  color: var(--ember-bright);
  font-size: 0.66em;
  font-style: italic;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-screen__lead {
  max-width: 420px;
  margin: 1.75rem auto;
  color: #bbb09e;
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  font-style: italic;
}

.title-actions {
  display: flex;
  width: min(100%, 350px);
  gap: 0.7rem;
  flex-direction: column;
}

.title-foot {
  position: absolute;
  bottom: calc(0.6rem + var(--safe-bottom));
  color: #6f6861;
  font: 0.64rem Arial, sans-serif;
  letter-spacing: 0.05em;
}

.title-moon {
  position: absolute;
  z-index: -1;
  top: 9%;
  width: min(72vw, 430px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 44% 42%, #b65e2e26 0 2%, transparent 3%),
    radial-gradient(circle at 58% 32%, #0008 0 9%, transparent 10%),
    radial-gradient(circle at 40% 70%, #0007 0 14%, transparent 15%),
    radial-gradient(circle, #5e251c, #1d1114 68%, #0000 70%);
  filter: drop-shadow(0 0 42px #8b321f55);
  opacity: 0.7;
}

.title-mark {
  position: relative;
  display: flex;
  width: 100px;
  height: 100px;
  align-items: end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 1rem;
}

.title-mark i {
  display: block;
  width: 15px;
  height: 72px;
  border-radius: 60% 10% 40% 40%;
  background: linear-gradient(#e17b40, #6e231b 70%, transparent);
  box-shadow: 0 0 20px #cc582c55;
  transform: rotate(-13deg);
}

.title-mark i:nth-child(2) {
  height: 90px;
  transform: translateY(-6px);
}

.title-mark i:nth-child(3) {
  transform: rotate(13deg);
}

.selection-screen {
  justify-content: flex-start;
  overflow-y: auto;
  text-align: left;
}

.selection-screen__back {
  align-self: flex-start;
}

.selection-screen h2 {
  margin: 0 0 1rem;
  align-self: center;
  font-size: clamp(2.2rem, 7vw, 4rem);
  font-weight: 400;
}

.name-field {
  display: flex;
  width: min(100%, 420px);
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 auto 1.2rem;
  color: var(--muted);
  font: 0.75rem Arial, sans-serif;
  text-transform: uppercase;
}

.name-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #4d443c;
  border-radius: 3px;
  outline: 0;
  color: var(--ink);
  background: #0b0b0ddd;
  padding: 0 0.9rem;
  text-transform: none;
}

.name-field input:focus {
  border-color: var(--ember);
}

.class-grid {
  display: grid;
  width: min(100%, 880px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.class-card {
  display: grid;
  min-height: 300px;
  grid-template-rows: auto auto auto 1fr auto;
  justify-items: center;
  padding: 1.4rem;
  border-color: #4b4038;
  background:
    linear-gradient(180deg, #201b1cdd, #0d0d10ee),
    radial-gradient(circle at 50% 0, #814025, transparent 55%);
  text-align: center;
}

.class-card strong {
  margin-top: 1rem;
  font-size: 1.7rem;
}

.class-card em {
  margin: 0.3rem 0 1rem;
  color: var(--ember-bright);
  font-size: 0.78rem;
}

.class-card small {
  color: var(--muted);
  line-height: 1.5;
}

.class-card__skills {
  color: #cabda8;
  font-size: 0.7rem;
}

.class-sigil {
  position: relative;
  display: block;
  width: 74px;
  height: 84px;
}

.class-sigil::before,
.class-sigil::after {
  position: absolute;
  inset: 5px 20px;
  border: 3px solid #b96b43;
  content: "";
  transform: skew(-12deg);
}

.class-sigil::after {
  inset: 22px 4px;
  border-color: #8f98b4;
  border-radius: 50% 0;
  transform: rotate(45deg);
}

.selection-hint {
  align-self: center;
  color: #746e66;
  font-size: 0.75rem;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #09090c;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.accessible-world {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

.accessible-world:focus-within {
  z-index: 18;
  top: calc(4.5rem + var(--safe-top));
  left: calc(0.7rem + var(--safe-left));
  width: min(90vw, 480px);
  height: auto;
  max-height: 70dvh;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--panel-line);
  clip-path: none;
  white-space: normal;
  background: #0b0b0ff2;
  box-shadow: 0 12px 40px #000;
  padding: 0.8rem;
}

.accessible-world h2,
.accessible-world h3 {
  margin: 0.5rem 0;
}

.accessible-world p,
.accessible-world ul {
  margin: 0.35rem 0 0.8rem;
}

.accessible-world ul {
  padding: 0;
  list-style: none;
}

.accessible-world li + li {
  margin-top: 0.35rem;
}

.accessible-world button {
  width: 100%;
  min-height: 44px;
  text-align: left;
}

.hud-top {
  position: absolute;
  top: var(--safe-top);
  right: var(--safe-right);
  left: var(--safe-left);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.75rem;
  pointer-events: none;
}

.zone-title {
  display: flex;
  padding: 0.55rem 1.2rem 0.65rem;
  border-left: 2px solid var(--ember);
  flex-direction: column;
  background: linear-gradient(90deg, #09090de8, transparent);
  text-shadow: 0 2px 4px #000;
}

.zone-title small {
  color: var(--ember-bright);
  font: 700 0.6rem Arial, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.zone-title strong {
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  font-weight: 400;
}

.icon-button {
  width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 50%;
  pointer-events: auto;
}

.quest-tracker {
  position: absolute;
  z-index: 2;
  top: calc(4.5rem + var(--safe-top));
  left: calc(0.75rem + var(--safe-left));
  display: flex;
  max-width: min(60vw, 360px);
  padding: 0.45rem 0.75rem;
  border: 1px solid #514338;
  border-radius: 2px;
  flex-direction: column;
  background: #0d0d10d8;
  pointer-events: none;
}

.quest-tracker span {
  color: var(--gold);
  font: 0.58rem Arial, sans-serif;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.quest-tracker strong {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-strip {
  position: absolute;
  z-index: 2;
  top: calc(0.75rem + var(--safe-top));
  left: 50%;
  display: grid;
  width: min(38vw, 300px);
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.5rem;
  color: #bdb4a5;
  font: 0.68rem Arial, sans-serif;
  transform: translateX(-50%);
  pointer-events: none;
}

.hero-strip b {
  color: #8c8378;
  font-size: 0.6rem;
}

.xp-track {
  height: 3px;
  grid-column: 1 / -1;
  background: #000b;
}

.xp-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 0.3s;
}

.quick-menu {
  position: absolute;
  z-index: 3;
  top: calc(4.8rem + var(--safe-top));
  right: calc(0.7rem + var(--safe-right));
  display: grid;
  gap: 0.35rem;
}

.quick-menu button {
  display: flex;
  width: 48px;
  min-height: 45px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-color: #4a4038;
  border-radius: 50%;
  color: #c9bba8;
  background: #111115dd;
  font-size: 1rem;
}

.quick-menu small {
  color: #82786d;
  font: 0.48rem Arial, sans-serif;
}

.resource-globe {
  position: absolute;
  z-index: 3;
  bottom: calc(0.8rem + var(--safe-bottom));
  width: clamp(68px, 16vw, 106px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #4b4036;
  border-radius: 50%;
  background: #08080b;
  box-shadow: inset 0 0 22px #000, 0 5px 22px #000;
  pointer-events: none;
}

.resource-globe::after {
  position: absolute;
  inset: 5px;
  border: 1px solid #ffffff1f;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fff3, transparent 22%);
  content: "";
}

.resource-globe i {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 100%;
  transition: height 0.2s;
}

.resource-globe span {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 18%;
  left: 0;
  font: 700 0.55rem Arial, sans-serif;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

.resource-globe--health {
  left: calc(0.7rem + var(--safe-left));
}

.resource-globe--health i {
  background: linear-gradient(#b53f31, #581b23);
}

.resource-globe--mana {
  right: calc(0.7rem + var(--safe-right));
}

.resource-globe--mana i {
  background: linear-gradient(#446fae, #1e315f);
}

.action-bar {
  position: absolute;
  z-index: 4;
  bottom: calc(0.8rem + var(--safe-bottom));
  left: 50%;
  display: flex;
  align-items: end;
  gap: clamp(0.25rem, 1vw, 0.6rem);
  transform: translateX(-50%);
}

.action-bar button {
  position: relative;
  display: flex;
  width: clamp(45px, 10vw, 68px);
  min-height: 0;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-width: 2px;
  border-radius: 50%;
  flex-direction: column;
  box-shadow: inset 0 0 12px #000, 0 3px 12px #000a;
}

.action-bar button b {
  font-size: clamp(1rem, 4vw, 1.5rem);
}

.action-bar button span {
  display: none;
}

.action-bar button small {
  position: absolute;
  right: -1px;
  bottom: -2px;
  min-width: 17px;
  border-radius: 8px;
  color: #c8bba9;
  background: #09090d;
  font: 0.52rem Arial, sans-serif;
}

.attack-button {
  border-color: #a65b38;
  background: radial-gradient(circle, #572818, #171316) !important;
}

.skill-buttons {
  display: flex;
  gap: clamp(0.2rem, 0.8vw, 0.45rem);
}

.skill-button--fire {
  border-color: #a54c32 !important;
}

.skill-button--shadow {
  border-color: #586f9c !important;
}

.skill-button--physical {
  border-color: #8c806b !important;
}

.potion-button b {
  color: #c4473d;
}

.move-hint {
  position: absolute;
  z-index: 2;
  right: 50%;
  bottom: 145px;
  display: none;
  width: 80px;
  height: 80px;
  border: 1px solid #fff2;
  border-radius: 50%;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(0.7rem + var(--safe-top)) calc(0.7rem + var(--safe-right))
    calc(0.7rem + var(--safe-bottom)) calc(0.7rem + var(--safe-left));
  background: #050508c4;
  backdrop-filter: blur(5px);
}

.game-panel,
.dialogue-card {
  position: relative;
  width: min(940px, 100%);
  max-height: min(90dvh, 850px);
  overflow: auto;
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  background:
    linear-gradient(145deg, #211c1d, #100f12 70%),
    repeating-linear-gradient(45deg, transparent 0 10px, #ffffff05 11px);
  box-shadow: 0 20px 80px #000, inset 0 1px #69564a;
  padding: clamp(1rem, 4vw, 2rem);
  scrollbar-color: #694331 #111;
}

.game-panel h3,
.dialogue-card h3 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 400;
}

.game-panel h4 {
  margin: 1rem 0 0.65rem;
  color: #c9bba8;
  font: 700 0.7rem Arial, sans-serif;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.panel-close {
  position: sticky;
  z-index: 5;
  top: 0;
  float: right;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: #0d0c0fdd;
  font: 300 1.8rem Arial, sans-serif;
}

.panel-columns {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 1.4rem;
}

.panel-columns > section + section {
  padding-left: 1.4rem;
  border-left: 1px solid #443a33;
}

.panel-columns h3 small {
  color: var(--muted);
  font-size: 0.7rem;
}

.equipment-grid,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.inventory-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.item-card,
.empty-slot {
  min-width: 0;
  border: 1px solid #443c36;
  border-top: 2px solid #aaa;
  border-radius: 3px;
  background: #0d0d10cc;
  padding: 0.65rem;
}

.item-card header {
  display: flex;
  min-height: 45px;
  flex-direction: column;
}

.item-card header span {
  color: var(--muted);
  font: 0.55rem Arial, sans-serif;
  text-transform: uppercase;
}

.item-card header strong {
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.item-card ul {
  margin: 0.5rem 0;
  padding: 0;
  color: #b7ad9e;
  font: 0.65rem/1.45 Arial, sans-serif;
  list-style: none;
}

.item-card footer {
  display: flex;
  gap: 0.3rem;
}

.item-card button {
  min-height: 30px;
  padding: 0.25rem 0.45rem;
  font-size: 0.62rem;
}

.item-effect,
.item-card__sockets {
  color: var(--gold);
  font-size: 0.68rem;
  font-style: italic;
}

.rarity-common {
  border-top-color: #bdb6aa;
}

.rarity-magic {
  border-top-color: #8298df;
}

.rarity-rare {
  border-top-color: #dcc35f;
}

.rarity-unique {
  border-top-color: #d58343;
}

.rarity-runeword {
  border-top-color: #d9a069;
  box-shadow: inset 0 0 20px #b65a2033;
}

.empty-slot {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #5f5852;
  font: 0.6rem Arial, sans-serif;
  text-transform: uppercase;
}

.empty-state {
  padding: 2rem;
  border: 1px dashed #3f3934;
  color: #746d65;
  text-align: center;
}

.skill-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.skill-points {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.skill-points strong {
  display: grid;
  width: 45px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--ember);
  border-radius: 50%;
  color: var(--ember-bright);
  font-size: 1.4rem;
}

.skill-points span {
  max-width: 50px;
  color: var(--muted);
  font: 0.58rem Arial, sans-serif;
}

.skill-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
}

.skill-node {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr 38px;
  gap: 0.65rem;
  align-items: center;
  min-height: 105px;
  margin-bottom: 0.65rem;
  border: 1px solid #3f3934;
  background: #0d0d10b8;
  padding: 0.7rem;
}

.skill-node.learned {
  border-color: #754b36;
  background: linear-gradient(90deg, #3d211a66, #0d0d10b8);
}

.skill-node.locked {
  filter: saturate(0.25);
  opacity: 0.58;
}

.skill-glyph {
  display: grid;
  width: 42px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #786a5d;
  border-radius: 50%;
  color: #c5b9a7;
  background: #18151a;
}

.skill-glyph--fire {
  border-color: #a55537;
  color: #df7849;
}

.skill-glyph--shadow {
  border-color: #5e6e93;
  color: #91a2cf;
}

.skill-node header {
  display: flex;
  justify-content: space-between;
}

.skill-node p {
  margin: 0.3rem 0;
  color: #a59c90;
  font-size: 0.72rem;
}

.skill-node small {
  color: #716a62;
  font: 0.56rem Arial, sans-serif;
}

.skill-node > button {
  width: 36px;
  min-height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
}

.skill-slots {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.45rem;
}

.skill-slots span {
  margin-right: 0.2rem;
  color: var(--muted);
  font: 0.55rem Arial, sans-serif;
  text-transform: uppercase;
}

.skill-slots button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50%;
}

.skill-slots button.active {
  border-color: var(--ember-bright);
  color: var(--ember-bright);
  background: #43241b;
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
}

.forge-intro,
.socket-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.reforge-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(220px, 1fr);
  gap: 0.7rem;
  margin: 0.5rem 0;
  border: 1px solid #413a34;
  background: #0d0d10a8;
  padding: 0.65rem;
}

.reforge-row > div {
  display: flex;
  gap: 0.35rem;
  flex-direction: column;
}

.reforge-row > div:last-child {
  flex-direction: row;
  flex-wrap: wrap;
}

.reforge-row small {
  color: var(--muted);
}

.reforge-row button {
  min-height: 34px;
  padding: 0.3rem 0.65rem;
  font-size: 0.67rem;
}

.forge-intro p {
  color: var(--muted);
}

.forge-anvil {
  display: grid;
  width: 70px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #a9603b;
  color: var(--ember-bright);
  font-size: 2rem;
  transform: rotate(45deg);
}

.rune-pouch > div {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.rune {
  display: flex;
  width: 104px;
  min-height: 94px;
  align-items: center;
  justify-content: center;
  border: 1px solid #62564b;
  border-radius: 50% 50% 44% 56%;
  flex-direction: column;
  background: #19171a;
}

.rune b {
  color: #d8b879;
  font-size: 1rem;
}

.rune small {
  color: var(--muted);
}

.rune button {
  min-height: 28px;
  margin-top: 0.3rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.55rem;
}

.rune em {
  margin-top: 0.25rem;
  color: #746d64;
  font: 0.5rem Arial, sans-serif;
}

.recipe-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.recipe-list article {
  display: flex;
  border-left: 2px solid var(--gold);
  flex-direction: column;
  background: #0c0c0fa8;
  padding: 0.8rem;
}

.recipe-list span {
  margin: 0.3rem 0;
  color: var(--gold);
}

.recipe-list small,
.socket-row small {
  color: var(--muted);
}

.socket-row {
  justify-content: space-between;
  margin: 0.5rem 0;
  border: 1px solid #413a34;
  padding: 0.65rem;
}

.socket-row > div {
  display: flex;
  gap: 0.3rem;
  flex-direction: column;
}

.socket-row > div:last-child {
  flex-direction: row;
}

.socket-row button {
  min-height: 34px;
  padding: 0.3rem 0.65rem;
}

.codex-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
}

.codex-entries {
  display: grid;
  gap: 0.75rem;
}

.codex-entries article {
  border-left: 2px solid #756759;
  background: #0d0d10aa;
  padding: 0.9rem 1.1rem;
}

.codex-entries span {
  color: var(--ember);
  font: 0.55rem Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.codex-entries h4 {
  margin: 0.2rem 0 0.5rem;
  color: var(--ink);
  font: 1.15rem Georgia, serif;
  text-transform: none;
}

.codex-entries p {
  margin: 0;
  color: #aaa093;
  line-height: 1.55;
}

.difficulty-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.difficulty-row button,
.waypoint-list button {
  display: flex;
  min-height: 75px;
  align-items: flex-start;
  justify-content: center;
  padding: 0.7rem;
  flex-direction: column;
  text-align: left;
}

.difficulty-row button.active {
  border-color: var(--ember);
  box-shadow: inset 0 0 20px #9c402333;
}

.difficulty-row small,
.waypoint-list small {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.6rem;
}

.waypoint-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.waypoint-list button {
  position: relative;
  min-height: 110px;
  border-color: #4d4e55;
  background:
    radial-gradient(circle at right top, #53668533, transparent 50%),
    #101014;
}

.waypoint-list strong {
  font-size: 1.1rem;
}

.waypoint-list em {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  color: #d56140;
  font: 0.55rem Arial, sans-serif;
  text-transform: uppercase;
}

.setting-row {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  margin: 0.35rem 0;
  padding: 0 0.8rem;
}

.setting-row b {
  color: var(--ember-bright);
}

.odds {
  margin-top: 1rem;
  border: 1px solid #443a33;
  background: #0b0b0db8;
  padding: 1rem;
}

.odds p {
  color: #a89d8e;
  font-size: 0.78rem;
  line-height: 1.5;
}

.current-quest {
  display: grid;
  grid-template-columns: 1fr auto;
  margin-bottom: 0.8rem;
  border-left: 2px solid var(--gold);
  background: #0b0b0db8;
  padding: 0.8rem;
}

.current-quest span {
  grid-column: 1 / -1;
  color: var(--gold);
  font: 0.55rem Arial, sans-serif;
  text-transform: uppercase;
}

.current-quest small {
  color: var(--muted);
}

.npc-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.npc-card {
  display: grid;
  min-height: 90px;
  grid-template-columns: 58px 1fr;
  gap: 0.8rem;
  padding: 0.65rem;
  text-align: left;
}

.npc-card > span {
  display: grid;
  width: 52px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--npc-color);
  border-radius: 50%;
  color: var(--npc-color);
  font-size: 1.4rem;
}

.npc-card div {
  display: flex;
  flex-direction: column;
}

.npc-card small {
  color: var(--ember-bright);
  font: 0.55rem Arial, sans-serif;
}

.npc-card p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-style: italic;
}

.dialogue-card {
  width: min(540px, 100%);
  overflow: visible;
  text-align: center;
}

.dialogue-card > p:not(.eyebrow) {
  color: #b5aa9b;
  font-size: 1rem;
  line-height: 1.55;
}

.npc-portrait {
  display: grid;
  width: 86px;
  aspect-ratio: 1;
  place-items: center;
  margin: -70px auto 1rem;
  border: 2px solid #b66841;
  border-radius: 50%;
  color: #d58a5c;
  background: #171318;
  box-shadow: 0 0 40px #9a3c2733;
  font-size: 2rem;
}

.death-screen,
.victory-screen {
  text-align: center;
}

.death-screen article,
.victory-screen article {
  width: min(520px, 100%);
}

.death-screen h2,
.victory-screen h2 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 400;
}

.death-screen p:not(.eyebrow),
.victory-screen p:not(.eyebrow) {
  color: #aaa093;
  line-height: 1.55;
}

.death-rune {
  color: #ae4b35;
  font-size: 5rem;
}

.victory-unlocks {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.victory-unlocks span {
  border: 1px solid #6c503c;
  color: var(--gold);
  background: #171316;
  padding: 0.5rem 0.7rem;
  font-size: 0.7rem;
}

.toast-root {
  position: absolute;
  z-index: 50;
  top: calc(7.5rem + var(--safe-top));
  left: 50%;
  display: flex;
  width: min(90vw, 420px);
  flex-direction: column;
  gap: 0.35rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  border: 1px solid #50443b;
  border-left: 3px solid #8d7b69;
  color: #ddd3c3;
  background: #0b0b0ee8;
  box-shadow: 0 5px 25px #000b;
  padding: 0.65rem 0.8rem;
  animation: toast-in 0.22s ease-out, toast-out 0.4s ease-in 2.8s forwards;
  font-size: 0.75rem;
  text-align: center;
}

.toast--warning {
  border-left-color: #b44e3b;
}

.toast--success {
  border-left-color: #73956f;
}

.toast--rare,
.toast--unique,
.toast--runeword {
  border-color: var(--gold);
  color: #ead18a;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.high-contrast {
  --ink: #fff8ea;
  --muted: #c2b9ad;
  --panel-line: #8a7666;
}

@media (max-width: 720px) {
  .hero-strip {
    display: none;
  }

  .quick-menu {
    top: calc(4.5rem + var(--safe-top));
  }

  .resource-globe {
    bottom: calc(0.45rem + var(--safe-bottom));
    width: 72px;
  }

  .resource-globe--health {
    left: calc(0.35rem + var(--safe-left));
  }

  .resource-globe--mana {
    right: calc(0.35rem + var(--safe-right));
  }

  .action-bar {
    bottom: calc(0.55rem + var(--safe-bottom));
    width: calc(100% - 144px - var(--safe-left) - var(--safe-right));
    justify-content: center;
  }

  .action-bar button {
    width: clamp(39px, 10.5vw, 52px);
  }

  .utility-button {
    display: none !important;
  }

  .potion-button {
    display: flex !important;
  }

  .utility-button[data-action="interact"] {
    display: flex !important;
  }

  .panel-columns,
  .skill-branches,
  .codex-layout {
    grid-template-columns: 1fr;
  }

  .panel-columns > section + section {
    padding-top: 1rem;
    padding-left: 0;
    border-top: 1px solid #443a33;
    border-left: 0;
  }

  .inventory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .difficulty-row,
  .waypoint-list {
    grid-template-columns: 1fr;
  }

  .recipe-list {
    grid-template-columns: 1fr;
  }

  .game-panel {
    align-self: stretch;
    max-height: calc(100dvh - 1.4rem - var(--safe-top) - var(--safe-bottom));
  }

  .class-grid {
    grid-template-columns: 1fr;
  }

  .class-card {
    min-height: 270px;
  }
}

@media (max-width: 420px) {
  .quest-tracker {
    max-width: 65vw;
  }

  .quick-menu button {
    width: 44px;
    min-height: 44px;
  }

  .resource-globe {
    width: 66px;
  }

  .action-bar {
    bottom: calc(5.05rem + var(--safe-bottom));
    width: calc(100% - 1rem - var(--safe-left) - var(--safe-right));
    gap: 0.25rem;
  }

  .action-bar button {
    width: 44px;
    min-width: 44px;
  }

  .game-panel {
    padding: 0.85rem;
  }

  .equipment-grid,
  .inventory-grid {
    grid-template-columns: 1fr 1fr;
  }

  .item-card {
    padding: 0.5rem;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .quest-tracker {
    top: calc(3.5rem + var(--safe-top));
  }

  .quick-menu {
    top: calc(3.4rem + var(--safe-top));
    grid-template-columns: repeat(2, 42px);
  }

  .quick-menu button {
    width: 40px;
    min-height: 40px;
  }

  .resource-globe {
    width: 62px;
  }

  .action-bar {
    bottom: calc(0.25rem + var(--safe-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
