:root {
  color-scheme: dark;
  --bg: #10100e;
  --panel: #171815;
  --panel-soft: #20211d;
  --line: #3b3b34;
  --text: #ece6d6;
  --muted: #aaa28e;
  --gold: #c7a350;
  --red: #a94e44;
  --green: #6f9f63;
  --blue: #536d8e;
}

/* Compact pause menu: controls, audio and non-intrusive account exit. */
.game-pause-menu {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 42px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 34%, rgba(122, 91, 42, 0.17), transparent 38%),
    rgba(3, 3, 3, 0.76);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.game-pause-menu[hidden] {
  display: none;
}

.game-pause-card {
  display: grid;
  gap: 18px;
  width: min(680px, 100%);
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(199, 163, 80, 0.52);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(47, 40, 27, 0.97) 0 5px, rgba(17, 16, 13, 0.98) 6px 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.78), inset 0 0 28px rgba(165, 119, 45, 0.06);
}

.game-pause-header span {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.game-pause-header h2,
.game-pause-section h3,
.pause-control-list {
  margin: 0;
}

.game-pause-header h2 {
  color: #f1e7ce;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.game-pause-content {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.9fr);
  gap: 16px;
}

.game-pause-section {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(123, 105, 72, 0.42);
  border-radius: 7px;
  background: rgba(7, 7, 6, 0.45);
}

.game-pause-section h3 {
  margin-bottom: 11px;
  color: #d4bb7a;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.pause-control-list {
  display: grid;
  gap: 6px;
}

.pause-control-list > div {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) minmax(120px, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 24px;
  border-bottom: 1px solid rgba(111, 100, 77, 0.18);
}

.pause-control-list > div:last-child {
  border-bottom: 0;
}

.pause-control-list dt,
.pause-control-list dd {
  margin: 0;
  font-size: 0.78rem;
}

.pause-control-list dt {
  color: #eee4cc;
  font-weight: 700;
}

.pause-control-list dd {
  color: #aaa28e;
}

.pause-control-list kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid #5b513d;
  border-bottom-color: #87744c;
  border-radius: 4px;
  background: #242119;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  color: #f0e4c9;
  font: inherit;
  text-align: center;
}

.pause-audio-section {
  align-content: start;
}

.pause-audio-section label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.pause-audio-section label:last-child {
  margin-bottom: 0;
}

.pause-audio-section label > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d8c9a8;
  font-size: 0.8rem;
  font-weight: 700;
}

.pause-audio-section output {
  color: #efbd63;
  font-variant-numeric: tabular-nums;
}

.pause-audio-section input[type="range"] {
  width: 100%;
  accent-color: #b77a32;
  cursor: pointer;
}

.game-pause-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.game-pause-continue,
.game-pause-logout {
  min-width: 150px;
  min-height: 42px;
  padding: 0 20px;
  font-weight: 800;
}

.game-pause-continue {
  border-color: rgba(199, 163, 80, 0.66);
  background: linear-gradient(180deg, #4b3b22, #292116);
  color: #f3e5c6;
}

.game-pause-logout {
  border-color: rgba(137, 105, 71, 0.58);
  background: rgba(22, 19, 15, 0.82);
  color: #c9bca2;
}

body.pause-menu-open,
body.pause-menu-open #game,
body[data-game-state="paused"],
body[data-game-state="paused"] #game {
  cursor: default;
}

@media (max-width: 680px) {
  .game-pause-menu {
    place-items: start center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .game-pause-content {
    grid-template-columns: 1fr;
  }

  .game-pause-card {
    gap: 13px;
    padding: 15px;
  }

  .game-pause-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #24251f;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

button:hover {
  border-color: var(--gold);
  background: #313227;
}

button:active {
  transform: translateY(1px);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 400px);
  gap: 10px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.play-shell {
  grid-template-columns: minmax(0, 1fr);
}

.viewport-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid #2b2b27;
  border-radius: 8px;
  background: #050504;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

body.hud-cursor-active .viewport-wrap,
body.hud-cursor-active #game {
  cursor: default;
}

.view-overlay {
  --companion-hud-bottom: 18px;
  --companion-hud-orb-size: clamp(76px, 6.2vw, 88px);
  --companion-hud-frame-extra: 14px;
  --companion-avatar-size: 48px;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hit-scratches {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  mix-blend-mode: screen;
}

.hit-scratches.active {
  opacity: 1;
}

.hit-scratch-mark {
  position: absolute;
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent 0%, rgba(34, 3, 3, 0.72) 10%, rgba(180, 20, 16, 0.88) 42%, rgba(255, 224, 180, 0.62) 54%, rgba(82, 5, 4, 0.72) 76%, transparent 100%);
  box-shadow: 0 0 12px rgba(142, 10, 8, 0.42);
  filter: blur(0.25px);
  opacity: 0;
  transform-origin: 50% 50%;
  animation: hit-scratch-flash 620ms ease-out forwards;
}

@keyframes hit-scratch-flash {
  0% {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
  }
  14% {
    opacity: 0.92;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

.compass,
.message {
  position: absolute;
  border: 1px solid rgba(236, 230, 214, 0.18);
  border-radius: 6px;
  background: rgba(11, 11, 9, 0.72);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.compass {
  top: 14px;
  left: 14px;
  z-index: 4;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 800;
}

.player-health {
  position: absolute;
  top: 14px;
  left: 68px;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(96px, 180px) 34px;
  align-items: center;
  gap: 9px;
  max-width: calc(100% - 300px);
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(236, 230, 214, 0.18);
  border-radius: 6px;
  background: rgba(11, 11, 9, 0.72);
  color: var(--text);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.player-health span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.player-health strong {
  color: var(--gold);
  font-size: 0.82rem;
  text-align: right;
}

.player-health meter {
  height: 12px;
}

.player-health-low strong {
  color: #e0a06c;
}

.player-health-empty strong {
  color: var(--red);
}

.player-arcane-hud {
  position: absolute;
  top: 66px;
  left: 68px;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
  width: min(370px, calc(100% - 310px));
  padding: 9px 10px 10px;
  border: 1px solid rgba(214, 126, 48, 0.32);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(18, 14, 10, 0.9), rgba(10, 10, 9, 0.82));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34), inset 0 0 20px rgba(151, 58, 18, 0.08);
  color: var(--text);
  font-size: 0.76rem;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.arcane-experience,
.arcane-power {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(74px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.arcane-experience > span,
.arcane-power > span,
.fireball-strength > span {
  color: #bdb39c;
  font-weight: 700;
}

.arcane-experience strong,
.arcane-power strong {
  color: #f0b453;
  font-variant-numeric: tabular-nums;
}

.arcane-experience small {
  justify-self: end;
  color: #948b77;
  font-size: 0.66rem;
}

.arcane-experience small.arcane-unlocked {
  color: #f08a3b;
  text-shadow: 0 0 9px rgba(243, 93, 21, 0.48);
}

.arcane-power meter {
  height: 12px;
}

.arcane-power meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #6a1e13, #e45d1f 58%, #ffc154);
  box-shadow: 0 0 8px rgba(238, 91, 28, 0.42);
}

.player-arcane-hud button {
  min-height: 36px;
  min-width: 0;
  padding: 0 9px;
  border-color: rgba(224, 119, 44, 0.38);
  color: #ffe2b6;
  background: rgba(62, 28, 16, 0.78);
  font-size: 0.72rem;
  font-weight: 750;
}

.player-arcane-hud button:disabled {
  color: #867b69;
  background: rgba(28, 25, 20, 0.72);
  cursor: default;
  opacity: 0.82;
}

.fireball-strength {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.fireball-strength > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.68rem;
}

.fireball-strength output {
  color: #ffb458;
  font-variant-numeric: tabular-nums;
}

.fireball-strength input {
  width: 100%;
  margin: 0;
  accent-color: #e45d1f;
  cursor: ew-resize;
}

.fireball-strength input:disabled {
  cursor: default;
  opacity: 0.46;
}

.message {
  left: 50%;
  bottom: clamp(64px, 9vh, 96px);
  z-index: 4;
  max-width: min(620px, calc(100% - 32px));
  padding: 9px 12px;
  transform: translate(-50%, 8px);
  color: var(--muted);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.message-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.message-hidden {
  opacity: 0;
}

.message.message-drowning {
  bottom: clamp(110px, 22vh, 190px);
  z-index: 8;
  width: max-content;
  max-width: calc(100% - 20px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  color: #e7f3f5;
  font-size: clamp(0.78rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.015em;
  white-space: nowrap;
  opacity: 1;
  transform: translate(-50%, 0);
  transition: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.98);
  box-shadow: none;
}

.interaction-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  padding: 7px 12px;
  border: 1px solid rgba(199, 163, 80, 0.52);
  border-radius: 6px;
  background: rgba(11, 11, 9, 0.82);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

.interaction-hint[hidden] {
  display: none;
}

.companion-world-comment {
  position: absolute;
  z-index: 14;
  width: max-content;
  max-width: min(340px, calc(100vw - 36px));
  padding: 7px 10px;
  border: 1px solid rgba(218, 179, 85, 0.72);
  border-radius: 7px;
  background: rgba(9, 10, 8, 0.94);
  color: #fffaf0;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 7px));
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.62);
  animation: companion-comment-in 180ms ease-out;
}

.companion-world-comment::after {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-right: 1px solid rgba(218, 179, 85, 0.72);
  border-bottom: 1px solid rgba(218, 179, 85, 0.72);
  background: rgba(9, 10, 8, 0.94);
  content: "";
  transform: translate(-50%, -4px) rotate(45deg);
}

.companion-world-comment[hidden] {
  display: none;
}

.companion-commands {
  position: absolute;
  z-index: 21;
  left: 14px;
  bottom: calc(
    var(--companion-hud-bottom)
    + var(--companion-hud-orb-size)
    + var(--companion-hud-frame-extra)
    - var(--companion-avatar-size)
  );
  max-width: calc(100% - 28px);
  pointer-events: auto;
}

.companion-commands[hidden],
.companion-avatar-bubble[hidden],
.companion-command-menu[hidden] {
  display: none;
}

.companion-roster {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.companion-roster-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  max-width: 100%;
}

.companion-portrait-button {
  position: relative;
  display: grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  place-items: stretch;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(218, 179, 85, 0.78);
  border-radius: 9px;
  background: rgba(12, 13, 10, 0.96);
  color: #fff4d0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.58);
}

.companion-portrait-button::after {
  content: "C";
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid rgba(255, 239, 190, 0.82);
  border-radius: 4px;
  background: rgba(5, 6, 5, 0.88);
  color: #fff4d0;
  font: 800 10px/1 system-ui, sans-serif;
  pointer-events: none;
}

.companion-portrait-button:hover,
.companion-portrait-button[aria-expanded="true"] {
  border-color: #e4bd5e;
  background: rgba(43, 36, 20, 0.98);
}

.companion-portrait-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.companion-portrait-button:disabled {
  cursor: default;
  opacity: 1;
}

.companion-portrait {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 30%, rgba(116, 97, 55, 0.48), rgba(10, 11, 9, 0.98) 72%);
}

.companion-portrait img {
  position: absolute;
  width: 220%;
  max-width: none;
  height: 220%;
  max-height: none;
  left: -60%;
  top: -18%;
  object-fit: fill;
  pointer-events: none;
}

.companion-portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f3d68d;
  font-family: Cinzel, Georgia, serif;
  font-size: 1.25rem;
  font-weight: 800;
}

.companion-portrait img[hidden],
.companion-portrait-fallback[hidden] {
  display: none;
}

.companion-health-meter {
  position: absolute;
  z-index: 2;
  left: 3px;
  right: 19px;
  bottom: 3px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 9, 9, 0.88);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

.companion-health-meter[hidden] {
  display: none;
}

.companion-health-meter > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #6fbd67;
  transition: width 180ms ease, background-color 180ms ease;
}

.companion-health-meter[data-state="medium"] > span {
  background: #d2a84f;
}

.companion-health-meter[data-state="low"] > span {
  background: #c9544c;
}

.companion-avatar-bubble {
  width: max-content;
  max-width: min(360px, calc(100vw - 82px));
  padding: 7px 10px;
  overflow-wrap: anywhere;
  border: 1px solid rgba(218, 179, 85, 0.68);
  border-radius: 7px;
  background: rgba(9, 10, 8, 0.94);
  color: #fffaf0;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.28;
  pointer-events: none;
  word-break: break-word;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  opacity: 1;
  transform: translateX(0);
  transition: opacity 260ms ease, transform 260ms ease;
}

.companion-avatar-bubble[data-state="leaving"] {
  opacity: 0;
  transform: translateX(-4px);
}

.companion-command-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
  max-height: min(430px, calc(100dvh - 150px));
  min-height: 0;
  padding: 13px;
  overflow: hidden;
  border: 1px solid rgba(218, 179, 85, 0.7);
  border-radius: 9px;
  background: rgba(12, 13, 10, 0.98);
  color: #fffaf0;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.companion-command-menu header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 2px;
}

.companion-command-heading {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.companion-command-menu header strong {
  font-size: 1rem;
}

.companion-command-menu header small {
  overflow-wrap: anywhere;
  color: #cfc4a7;
}

.companion-command-close {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: rgba(218, 179, 85, 0.42);
  font-size: 1.25rem;
  line-height: 1;
}

.companion-command-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.companion-command-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 0 9px;
  overflow-wrap: anywhere;
}

.companion-command-actions button:disabled {
  opacity: 0.44;
}

.companion-command-log-section {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  padding-top: 9px;
  overflow: hidden;
  border-top: 1px solid rgba(218, 179, 85, 0.34);
}

.companion-command-log-title {
  flex: 0 0 auto;
  color: #ead596;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.companion-speech-log {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 74px;
  max-height: min(190px, 28dvh);
  flex: 0 1 auto;
  padding: 5px 9px;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
  border: 1px solid rgba(218, 179, 85, 0.48);
  border-radius: 7px;
  background: rgba(4, 5, 4, 0.52);
  color: #fffaf0;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.32;
  pointer-events: auto;
  touch-action: pan-y;
  word-break: break-word;
  overscroll-behavior: contain;
  scrollbar-color: rgba(218, 179, 85, 0.72) rgba(255, 255, 255, 0.06);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.companion-speech-log-entry {
  max-width: 100%;
  margin: 0;
  padding: 5px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.companion-speech-log-entry + .companion-speech-log-entry {
  border-top: 1px solid rgba(218, 179, 85, 0.2);
}

.companion-speech-log-empty {
  margin: 0;
  padding: 5px 0;
  color: #b9af98;
  font-style: italic;
  font-weight: 550;
}

.companion-decision {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: calc(var(--hud-notice-bottom, 128px) + 12px);
  display: grid;
  gap: 8px;
  width: min(520px, calc(100% - 28px));
  padding: 15px;
  border: 1px solid rgba(218, 179, 85, 0.72);
  border-radius: 9px;
  background: rgba(12, 13, 10, 0.97);
  color: #fffaf0;
  pointer-events: auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.72), 0 0 24px rgba(199, 163, 80, 0.16);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.companion-decision[hidden] {
  display: none;
}

.companion-decision > span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.companion-decision h2,
.companion-decision p {
  margin: 0;
}

.companion-decision h2 {
  font-size: 1.12rem;
}

.companion-decision p {
  color: #e7dfca;
  line-height: 1.42;
}

.companion-decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

.companion-decision-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.companion-decision-actions button:first-child {
  border-color: rgba(218, 179, 85, 0.72);
  background: #302817;
}

.companion-decision-actions button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.weapon-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.combat-vfx-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.combat-vfx-sprite {
  position: absolute;
  display: block;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--combat-vfx-angle, 0deg)) scale(0.72);
  transform-origin: center;
  filter: blur(0.15px) drop-shadow(0 0 8px rgba(238, 229, 196, 0.16));
  animation: combat-vfx-hit 320ms cubic-bezier(0.16, 0.82, 0.22, 1) both;
}

.combat-vfx-reward {
  position: absolute;
  z-index: 2;
  display: block;
  color: #ff3b38;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.88);
  text-shadow:
    0 2px 2px rgba(0, 0, 0, 0.95),
    0 0 7px rgba(0, 0, 0, 0.9),
    0 0 12px rgba(171, 0, 0, 0.54);
  animation: combat-vfx-reward-rise 1800ms cubic-bezier(0.18, 0.78, 0.22, 1) both;
}

.vision-vfx {
  position: absolute;
  inset: 0;
  z-index: 13;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(0);
}

.vision-vfx[hidden] {
  display: none;
}

.vision-vfx::before,
.vision-vfx::after {
  content: "";
  position: absolute;
}

.vision-vfx::before {
  left: 50%;
  top: 50%;
  z-index: 1;
  width: min(34vw, 42vh);
  height: min(26vw, 32vh);
  border-radius: 50%;
  box-shadow:
    0 0 68px 42px rgba(0, 0, 0, 0.82),
    0 0 0 240vmax rgba(0, 0, 0, 0.96),
    inset 0 0 44px rgba(0, 0, 0, 0.88),
    0 0 46px rgba(199, 163, 80, 0.08);
  filter: blur(18px);
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.16);
}

.vision-vfx::after {
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 0%, transparent 34%, rgba(0, 0, 0, 0.32) 62%, rgba(0, 0, 0, 0.82) 100%),
    radial-gradient(ellipse at center, rgba(224, 210, 160, 0.08) 0%, transparent 28%);
  opacity: 0;
}

.vision-vfx-thought {
  position: absolute;
  left: 50%;
  bottom: var(--vision-thought-bottom, clamp(78px, 16vh, 170px));
  z-index: 3;
  width: min(620px, calc(100% - 32px));
  color: rgba(236, 230, 214, 0.94);
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 600ms ease, transform 600ms ease;
}

.vision-vfx-thought-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body:is(
  [data-game-state="boot"],
  [data-game-state="intro"],
  [data-game-state="account"],
  [data-game-state="orientation"],
  [data-game-state="wake"]
) :is(
  .dungeon-hud,
  .compass,
  .message,
  .interaction-hint,
  .companion-world-comment,
  .companion-commands,
  .companion-decision,
  .weapon-overlay,
  .combat-vfx-overlay,
  .mobile-game-controls,
  .mobile-game-topbar
),
body.entrance-wake-pending .dungeon-hud,
body.entrance-wake-pending .compass,
body.entrance-wake-pending .message,
body.entrance-wake-pending .interaction-hint,
body.entrance-wake-pending .companion-world-comment,
body.entrance-wake-pending .companion-decision,
body.entrance-wake-pending .companion-commands,
body.entrance-wake-pending .weapon-overlay,
body.entrance-wake-pending .combat-vfx-overlay,
body.entrance-wake-pending .mobile-game-controls,
body.entrance-wake-pending .mobile-game-topbar {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: none !important;
}

.vision-vfx-wakeup-long {
  animation: vision-vfx-wakeup-long var(--vision-duration, 30000ms) cubic-bezier(0.16, 0.84, 0.22, 1) both;
}

.vision-vfx-wakeup-long::before {
  animation: vision-vfx-lens-open-long var(--vision-duration, 30000ms) cubic-bezier(0.16, 0.84, 0.22, 1) both;
}

.vision-vfx-wakeup-long::after {
  animation: vision-vfx-vignette-wakeup-long var(--vision-duration, 30000ms) ease-out both;
}

.vision-vfx-wakeup-short {
  animation: vision-vfx-wakeup-short var(--vision-duration, 10800ms) cubic-bezier(0.16, 0.84, 0.22, 1) both;
}

.vision-vfx-wakeup-short::before {
  animation: vision-vfx-lens-open-short var(--vision-duration, 10800ms) cubic-bezier(0.16, 0.84, 0.22, 1) both;
}

.vision-vfx-wakeup-short::after {
  animation: vision-vfx-vignette-wakeup-short var(--vision-duration, 10800ms) ease-out both;
}

.vision-vfx-death-close {
  animation: vision-vfx-death-close var(--vision-duration, 9600ms) ease-in both;
}

.vision-vfx-death-close::before {
  animation: vision-vfx-lens-close var(--vision-duration, 9600ms) ease-in both;
}

.vision-vfx-death-close::after {
  animation: vision-vfx-vignette-death var(--vision-duration, 9600ms) ease-in both;
}

.vision-vfx-hold {
  opacity: 1;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(12px);
}

.vision-vfx-hold::before {
  transform: translate(-50%, -50%) scale(0.14);
}

.vision-vfx-hold::after {
  opacity: 1;
}

.combat-vfx-club-swing {
  filter: blur(0.2px) drop-shadow(0 0 7px rgba(166, 82, 58, 0.14));
}

.combat-vfx-blade-slash {
  filter: blur(0.12px) drop-shadow(0 0 8px rgba(196, 48, 38, 0.13));
}

.attack-effect {
  position: absolute;
  left: 50%;
  top: 54%;
  width: min(54vw, 560px);
  height: min(16vh, 128px);
  border-top: 3px solid rgba(238, 229, 196, 0.82);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 52% 58%, rgba(238, 229, 196, 0.22), transparent 62%),
    linear-gradient(90deg, transparent 0%, rgba(199, 163, 80, 0.18) 45%, transparent 100%);
  filter: blur(0.2px) drop-shadow(0 0 12px rgba(199, 163, 80, 0.3));
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-13deg) scale(0.74);
}

.weapon-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(236, 230, 214, 0.24);
  border-radius: 8px;
  background: rgba(11, 11, 9, 0.66);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
  opacity: 0.78;
}

.weapon-status::before,
.weapon-status::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  transform: translate(-50%, -50%);
}

.weapon-symbol-fist::before {
  width: 19px;
  height: 14px;
  border: 2px solid rgba(236, 230, 214, 0.86);
  border-radius: 7px 7px 5px 5px;
  box-shadow:
    -7px -3px 0 -4px rgba(236, 230, 214, 0.86),
    0 -4px 0 -4px rgba(236, 230, 214, 0.86),
    7px -3px 0 -4px rgba(236, 230, 214, 0.86);
}

.weapon-symbol-fist::after {
  width: 12px;
  height: 18px;
  border: 2px solid rgba(199, 163, 80, 0.72);
  border-top: 0;
  border-radius: 0 0 7px 7px;
  transform: translate(-18%, -8%) rotate(-24deg);
}

.weapon-symbol-club::before {
  width: 9px;
  height: 29px;
  border-radius: 6px;
  background: rgba(139, 91, 50, 0.88);
  box-shadow: 0 -8px 0 3px rgba(95, 58, 31, 0.9);
  transform: translate(-50%, -50%) rotate(35deg);
}

.weapon-symbol-rung::before {
  width: 7px;
  height: 32px;
  border: 1px solid rgba(221, 208, 173, 0.45);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(76, 51, 31, 0.96), rgba(163, 121, 73, 0.92) 48%, rgba(70, 48, 31, 0.96));
  box-shadow:
    0 0 0 1px rgba(39, 27, 19, 0.7),
    0 0 8px rgba(181, 129, 70, 0.18);
  transform: translate(-50%, -50%) rotate(58deg);
}

.weapon-symbol-rung::after {
  width: 10px;
  height: 4px;
  border-radius: 999px;
  background: rgba(48, 31, 21, 0.86);
  box-shadow: 0 12px 0 rgba(48, 31, 21, 0.7);
  transform: translate(-50%, -8px) rotate(58deg);
}

.weapon-symbol-blade::before {
  width: 8px;
  height: 30px;
  border-radius: 7px 7px 1px 1px;
  background: linear-gradient(90deg, rgba(236, 230, 214, 0.86), rgba(116, 126, 128, 0.9));
  transform: translate(-50%, -54%) rotate(40deg);
}

.weapon-symbol-blade::after {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: rgba(199, 163, 80, 0.82);
  transform: translate(-50%, 48%) rotate(40deg);
}

.weapon-overlay.weapon-attacking .attack-effect {
  animation: weapon-strike-sweep var(--weapon-attack-duration, 520ms) cubic-bezier(0.18, 0.86, 0.2, 1) both;
}

.weapon-overlay.weapon-attacking .weapon-status {
  animation: weapon-symbol-pulse var(--weapon-attack-duration, 520ms) ease-out both;
}

.weapon-overlay.weapon-hit::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 48%;
  width: clamp(90px, 13vw, 170px);
  height: clamp(26px, 4vw, 48px);
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(255, 236, 172, 0.9) 0%, rgba(255, 236, 172, 0.22) 42%, transparent 72%);
  transform: translate(-50%, -50%) rotate(-10deg);
  animation: weapon-hit-flash 170ms ease-out both;
}

@keyframes weapon-strike-sweep {
  0% {
    opacity: 0;
    transform: translate(-58%, -42%) rotate(-17deg) scale(0.58);
  }
  38% {
    opacity: 0.95;
    transform: translate(-50%, -50%) rotate(-11deg) scale(1.02);
  }
  100% {
    opacity: 0;
    transform: translate(-42%, -56%) rotate(-6deg) scale(1.18);
  }
}

@keyframes weapon-symbol-pulse {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.78;
  }
  42% {
    transform: translateY(-2px) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.78;
  }
}

@keyframes weapon-hit-flash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-10deg) scale(0.75);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-10deg) scale(1.18);
  }
}

@keyframes combat-vfx-hit {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-vfx-angle, 0deg)) scale(0.68);
  }
  22% {
    opacity: 0.68;
    transform: translate(-50%, -50%) rotate(var(--combat-vfx-angle, 0deg)) scale(0.98);
  }
  58% {
    opacity: 0.48;
    transform: translate(-50%, -50%) rotate(var(--combat-vfx-angle, 0deg)) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-vfx-angle, 0deg)) scale(1.16);
  }
}

@keyframes combat-vfx-reward-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.82);
  }
  16% {
    opacity: 1;
    transform: translate(-50%, -68%) scale(1);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -118px) scale(1.04);
  }
}

@keyframes vision-vfx-wakeup-long {
  0% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(18px);
  }
  18% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(17px);
  }
  42% {
    opacity: 0.96;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(13px);
  }
  68% {
    opacity: 0.74;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(7px);
  }
  88% {
    opacity: 0.36;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(2px);
  }
  100% {
    opacity: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
}

@keyframes vision-vfx-wakeup-short {
  0% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(16px);
  }
  42% {
    opacity: 0.9;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(10px);
  }
  78% {
    opacity: 0.46;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(4px);
  }
  100% {
    opacity: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
}

@keyframes vision-vfx-death-close {
  0% {
    opacity: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
  28% {
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(6px);
  }
  74% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(13px);
  }
  100% {
    opacity: 1;
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(12px);
  }
}

@keyframes vision-vfx-lens-open-long {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.13);
  }
  18% {
    transform: translate(-50%, -50%) scale(0.24);
  }
  36% {
    transform: translate(-50%, -50%) scale(0.54);
  }
  58% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  78% {
    opacity: 0.86;
    transform: translate(-50%, -50%) scale(2.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.8);
  }
}

@keyframes vision-vfx-lens-open-short {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.16);
  }
  42% {
    transform: translate(-50%, -50%) scale(0.82);
  }
  78% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.9);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.5);
  }
}

@keyframes vision-vfx-lens-close {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.3);
  }
  24% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(2.1);
  }
  68% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.58);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.14);
  }
}

@keyframes vision-vfx-vignette-wakeup-long {
  0%,
  46% {
    opacity: 1;
  }
  78% {
    opacity: 0.58;
  }
  100% {
    opacity: 0;
  }
}

@keyframes vision-vfx-vignette-wakeup-short {
  0%,
  42% {
    opacity: 1;
  }
  82% {
    opacity: 0.42;
  }
  100% {
    opacity: 0;
  }
}

@keyframes vision-vfx-vignette-death {
  0% {
    opacity: 0;
  }
  34% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}

.worlds-launcher {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  padding:
    max(28px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  color: #eee8db;
  background: #050709;
  opacity: 1;
  transition: opacity 380ms ease, transform 380ms ease;
}

.worlds-launcher[hidden] {
  display: none;
}

main.shell[hidden] {
  display: none;
}

.worlds-launcher-leaving {
  pointer-events: none;
  opacity: 0;
  transform: scale(1.012);
}

.worlds-launcher-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 14%, rgba(74, 95, 118, 0.2), transparent 28%),
    radial-gradient(circle at 82% 76%, rgba(116, 82, 40, 0.14), transparent 30%),
    linear-gradient(135deg, rgba(3, 5, 8, 0.98), rgba(9, 11, 13, 0.96) 48%, rgba(4, 5, 7, 0.99));
}

.worlds-launcher-backdrop::before,
.worlds-launcher-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
}

.worlds-launcher-backdrop::before {
  opacity: 0.38;
  background-image:
    radial-gradient(circle, rgba(220, 228, 238, 0.68) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(188, 165, 109, 0.46) 0 1px, transparent 1.3px);
  background-position: 0 0, 43px 57px;
  background-size: 97px 97px, 131px 131px;
  mask-image: linear-gradient(180deg, #000, transparent 74%);
}

.worlds-launcher-backdrop::after {
  background:
    linear-gradient(90deg, transparent, rgba(186, 201, 217, 0.06), transparent),
    radial-gradient(ellipse at 50% 100%, rgba(155, 125, 72, 0.12), transparent 58%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.82);
}

.worlds-launcher-content {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: auto;
}

.worlds-launcher-heading {
  width: min(720px, 100%);
  margin: 0 auto clamp(28px, 5vh, 52px);
  text-align: center;
}

.worlds-launcher-brand {
  margin: 0 0 13px;
  color: #bca56d;
  font: 700 clamp(11px, 1.2vw, 14px) / 1.2 system-ui, sans-serif;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
}

.worlds-launcher-heading h1 {
  margin: 0;
  color: #f2eee4;
  font: 600 clamp(38px, 6vw, 72px) / 1.02 Georgia, "Palatino Linotype", serif;
  letter-spacing: 0.025em;
  text-shadow: 0 10px 38px rgba(0, 0, 0, 0.78);
}

.worlds-launcher-heading > p:last-child {
  max-width: 600px;
  margin: 18px auto 0;
  color: rgba(222, 224, 224, 0.68);
  font: 450 clamp(14px, 1.5vw, 17px) / 1.55 system-ui, sans-serif;
}

.worlds-game-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(190px, 0.85fr);
  gap: clamp(16px, 2.5vw, 28px);
  align-items: stretch;
}

.worlds-game-card {
  position: relative;
  min-width: 0;
  min-height: clamp(320px, 47vh, 500px);
  overflow: hidden;
  border: 1px solid rgba(197, 179, 136, 0.24);
  background: rgba(11, 13, 14, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
}

.worlds-game-card-dungeon {
  isolation: isolate;
}

.worlds-game-card-dungeon img,
.worlds-game-card-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.worlds-game-card-dungeon img {
  z-index: -2;
  object-fit: cover;
  object-position: center 48%;
  transform: scale(1.015);
  transition: transform 800ms ease, filter 800ms ease;
}

.worlds-game-card-shade {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(4, 5, 5, 0.96) 0%, rgba(4, 5, 5, 0.78) 43%, rgba(4, 5, 5, 0.18) 76%, rgba(4, 5, 5, 0.34) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.66));
}

.worlds-game-card-dungeon:hover img,
.worlds-game-card-dungeon:focus-within img {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.worlds-game-card-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  width: min(410px, 78%);
  min-height: inherit;
  box-sizing: border-box;
  padding: clamp(28px, 5vw, 58px);
}

.worlds-game-eyebrow {
  margin: 0 0 10px;
  color: #c7aa68;
  font: 750 10px / 1.2 system-ui, sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.worlds-game-card-content h2 {
  margin: 0;
  color: #f0e7d1;
  font: 700 clamp(38px, 5vw, 64px) / 0.95 Georgia, "Palatino Linotype", serif;
  letter-spacing: 0.04em;
  text-shadow: 0 8px 26px #000;
}

.worlds-game-card-content > p:not(.worlds-game-eyebrow) {
  margin: 18px 0 28px;
  color: rgba(236, 230, 215, 0.76);
  font: 500 clamp(13px, 1.3vw, 16px) / 1.55 system-ui, sans-serif;
  text-shadow: 0 2px 10px #000;
}

.worlds-game-launch {
  min-height: 48px;
  padding: 13px 25px;
  border: 1px solid rgba(229, 207, 151, 0.72);
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(233, 210, 151, 0.18), transparent 44%),
    rgba(21, 20, 16, 0.92);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  color: #f0d99f;
  font: 750 13px / 1.2 system-ui, sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.worlds-game-launch:hover,
.worlds-game-launch:focus-visible {
  border-color: #efd99e;
  background:
    linear-gradient(135deg, rgba(233, 210, 151, 0.28), transparent 48%),
    rgba(31, 28, 20, 0.98);
  box-shadow: 0 15px 34px rgba(0, 0, 0, 0.58), 0 0 26px rgba(207, 176, 105, 0.18);
  transform: translateY(-2px);
  outline: 2px solid rgba(239, 217, 158, 0.34);
  outline-offset: 4px;
}

.worlds-game-card-coming {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: rgba(216, 213, 204, 0.45);
  background:
    linear-gradient(145deg, rgba(29, 33, 37, 0.68), rgba(8, 10, 12, 0.9)),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.018) 18px 19px);
}

.worlds-game-card-coming div {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.worlds-game-card-coming span {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
  border: 1px solid rgba(216, 213, 204, 0.2);
  border-radius: 50%;
  font: 300 28px / 1 system-ui, sans-serif;
}

.worlds-game-card-coming strong {
  font: 600 15px / 1.2 system-ui, sans-serif;
  letter-spacing: 0.08em;
}

.worlds-game-card-coming small {
  font: 600 10px / 1.2 system-ui, sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.worlds-launcher-footnote {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1;
  margin: 0;
  color: rgba(213, 214, 212, 0.28);
  font: 600 9px / 1 system-ui, sans-serif;
  letter-spacing: 0.14em;
}

@media (max-width: 720px) {
  .worlds-launcher {
    place-items: start center;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .worlds-launcher-heading {
    margin-bottom: 24px;
  }

  .worlds-launcher-heading h1 {
    font-size: clamp(35px, 11vw, 54px);
  }

  .worlds-launcher-heading > p:last-child {
    margin-top: 12px;
    font-size: 13px;
  }

  .worlds-game-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .worlds-game-card {
    min-height: 360px;
  }

  .worlds-game-card-content {
    width: min(360px, 88%);
    padding: 28px 24px;
  }

  .worlds-game-card-shade {
    background:
      linear-gradient(90deg, rgba(4, 5, 5, 0.94), rgba(4, 5, 5, 0.48) 72%, rgba(4, 5, 5, 0.56)),
      linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.76));
  }

  .worlds-game-card-coming {
    min-height: 118px;
  }
}

.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  isolation: isolate;
  overflow: hidden;
  background: #000;
  opacity: 1;
  transition: opacity 240ms ease;
}

.intro-screen::before,
.intro-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.intro-screen::before {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.56) 0%, rgba(0, 0, 0, 0.05) 43%, rgba(0, 0, 0, 0.12) 66%, rgba(0, 0, 0, 0.38) 100%),
    radial-gradient(circle at 50% 18%, transparent 0 16%, rgba(0, 0, 0, 0.26) 62%, rgba(0, 0, 0, 0.48) 100%);
}

.intro-screen::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.34), transparent 24% 76%, rgba(0, 0, 0, 0.34));
}

.intro-screen[hidden] {
  display: none;
}

.intro-screen-hidden {
  pointer-events: none;
  opacity: 0;
}

.intro-screen img,
.intro-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1500ms ease;
}

.intro-screen img {
  object-fit: cover;
  object-position: center center;
  background: #050504;
}

.intro-fallback {
  background:
    radial-gradient(circle at 50% 38%, rgba(77, 91, 72, 0.28), transparent 30%),
    linear-gradient(180deg, #111611 0%, #070a07 58%, #030403 100%);
}

.intro-story-shell {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(12px, 2.2vh, 22px);
  padding:
    max(clamp(22px, 4vh, 42px), env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(clamp(28px, 4.5vh, 48px), env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  text-align: center;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.98), 0 1px 2px #000;
}

.intro-story-heading {
  display: grid;
  justify-items: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 2400ms ease, transform 2400ms ease;
}

.intro-story-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 5px;
  color: #bca56d;
  font: 700 clamp(9px, 0.8vw, 11px) / 1.3 system-ui, sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 700ms ease;
}

.intro-story-kicker::before,
.intro-story-kicker::after {
  content: "";
  width: clamp(26px, 4vw, 52px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(188, 165, 109, 0.78));
}

.intro-story-kicker::after {
  transform: scaleX(-1);
}

.intro-story-heading h1 {
  margin: 0;
  color: #ded3bb;
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(38px, 5.2vw, 72px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.09em;
  text-indent: 0.09em;
  text-transform: uppercase;
  filter: drop-shadow(0 7px 8px rgba(0, 0, 0, 0.78));
}

.intro-story-viewport {
  position: relative;
  align-self: stretch;
  justify-self: center;
  width: min(790px, calc(100% - 24px));
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 900ms ease, visibility 0s linear 900ms;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 13%, #000 84%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 13%, #000 84%, transparent 100%);
}

.intro-screen[data-phase="title"] .intro-story-heading,
.intro-screen[data-phase="story"] .intro-story-heading,
.intro-screen[data-phase="complete"] .intro-story-heading {
  opacity: 1;
  transform: translateY(0);
}

.intro-screen[data-phase="story"] .intro-story-kicker,
.intro-screen[data-phase="complete"] .intro-story-kicker {
  opacity: 1;
}

.intro-screen[data-phase="story"] img,
.intro-screen[data-phase="story"] .intro-fallback,
.intro-screen[data-phase="complete"] img,
.intro-screen[data-phase="complete"] .intro-fallback {
  opacity: 1;
}

.intro-screen[data-phase="story"] .intro-story-viewport,
.intro-screen[data-phase="complete"] .intro-story-viewport {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.intro-story-viewport::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.intro-story-viewport:focus-visible {
  outline: 1px solid rgba(224, 201, 141, 0.28);
  outline-offset: 4px;
}

.intro-story-scroll {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: var(--intro-story-start-space, 82vh) 0 var(--intro-story-end-space, 45vh);
  color: #d1bf98;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(15px, 1.25vw, 19px);
  font-weight: 500;
  line-height: 1.58;
  letter-spacing: 0.018em;
  transform: none;
  will-change: auto;
}

.intro-story-scroll p {
  margin: 0 0 clamp(18px, 3vh, 30px);
}

.intro-story-voices {
  color: #bca981;
  font-style: italic;
}

.intro-story-warning {
  color: #d8c185;
}

.intro-story-final-choice {
  margin-bottom: 0;
  color: #e0c98d;
  font-size: 1.08em;
  letter-spacing: 0.045em;
}

.intro-story-action {
  display: flex;
  justify-content: center;
  margin: clamp(28px, 4.8vh, 48px) auto 0;
  padding-bottom: clamp(34px, 6vh, 64px);
}

.intro-start {
  position: relative;
  z-index: 1;
  min-width: clamp(154px, 24vw, 214px);
  padding: 15px 36px;
  border: 1px solid rgba(224, 201, 141, 0.76);
  border-radius: 0;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  background:
    linear-gradient(135deg, rgba(238, 215, 157, 0.18), transparent 22% 78%, rgba(238, 215, 157, 0.12)),
    radial-gradient(circle at 50% 0%, rgba(205, 174, 101, 0.2), transparent 58%),
    linear-gradient(180deg, rgba(48, 42, 28, 0.96), rgba(10, 10, 8, 0.98));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.78) inset,
    0 0 0 4px rgba(12, 11, 8, 0.52),
    0 11px 30px rgba(0, 0, 0, 0.68),
    0 0 22px rgba(201, 171, 101, 0.16);
  color: #ead39b;
  font: 700 clamp(15px, 1.25vw, 18px) / 1.15 Georgia, "Palatino Linotype", serif;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.intro-start::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(224, 201, 141, 0.24);
  clip-path: inherit;
  pointer-events: none;
}

.intro-start::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 34%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(238, 215, 157, 0.58), transparent);
  transform: translateX(-50%);
  pointer-events: none;
}

.intro-start:hover,
.intro-start:focus-visible {
  border-color: rgba(238, 215, 157, 0.92);
  background:
    linear-gradient(135deg, rgba(238, 215, 157, 0.24), transparent 24% 76%, rgba(238, 215, 157, 0.16)),
    radial-gradient(circle at 50% 0%, rgba(225, 194, 119, 0.28), transparent 62%),
    linear-gradient(180deg, rgba(66, 56, 35, 0.98), rgba(15, 14, 10, 0.98));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72) inset,
    0 0 0 4px rgba(12, 11, 8, 0.62),
    0 12px 34px rgba(0, 0, 0, 0.72),
    0 0 28px rgba(224, 193, 118, 0.3);
  color: #f0d99f;
  transform: translateY(-2px);
  outline: 2px solid rgba(238, 215, 157, 0.46);
  outline-offset: 4px;
}

.intro-start.is-ready {
  border-color: rgba(238, 215, 157, 0.84);
  color: #f0d99f;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72) inset,
    0 0 0 4px rgba(12, 11, 8, 0.58),
    0 10px 30px rgba(0, 0, 0, 0.68),
    0 0 30px rgba(224, 193, 118, 0.28);
  animation: intro-enter-ready-pulse 2.6s ease-in-out infinite;
}

@keyframes intro-enter-ready-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.13); }
}

.intro-skip {
  position: absolute;
  right: max(clamp(16px, 2.6vw, 34px), env(safe-area-inset-right));
  bottom: max(clamp(14px, 2.5vh, 26px), env(safe-area-inset-bottom));
  z-index: 4;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid rgba(207, 188, 143, 0.34);
  border-radius: 2px;
  background: rgba(8, 9, 7, 0.68);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.46);
  color: rgba(224, 207, 166, 0.76);
  font: 650 11px / 1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease, opacity 500ms ease;
}

.intro-screen[data-phase="story"] .intro-skip,
.intro-screen[data-phase="complete"] .intro-skip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.intro-skip:hover,
.intro-skip:focus-visible {
  border-color: rgba(238, 215, 157, 0.72);
  background: rgba(24, 22, 15, 0.9);
  color: #ead39b;
  transform: translateY(-1px);
  outline: 2px solid rgba(238, 215, 157, 0.35);
  outline-offset: 3px;
}

.intro-music-credit {
  position: absolute;
  left: max(clamp(16px, 2.6vw, 34px), env(safe-area-inset-left));
  bottom: max(clamp(14px, 2.5vh, 26px), env(safe-area-inset-bottom));
  z-index: 3;
  max-width: min(58vw, 520px);
  margin: 0;
  color: rgba(207, 188, 143, 0.48);
  font: 500 9px / 1.35 system-ui, sans-serif;
  letter-spacing: 0.035em;
  opacity: 0;
  transition: opacity 900ms ease;
}

.intro-screen[data-phase="story"] .intro-music-credit,
.intro-screen[data-phase="complete"] .intro-music-credit {
  opacity: 1;
}

.intro-music-credit a {
  color: inherit;
  text-decoration-color: rgba(207, 188, 143, 0.28);
  text-underline-offset: 2px;
}

.intro-music-credit a:hover,
.intro-music-credit a:focus-visible {
  color: rgba(223, 200, 142, 0.82);
}

@media (max-width: 640px) {
  .intro-story-shell {
    padding-inline: 12px;
  }

  .intro-story-viewport {
    width: calc(100% - 8px);
  }

  .intro-story-scroll {
    font-size: clamp(14px, 3.8vw, 16px);
    line-height: 1.5;
  }

  .intro-skip {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro-screen img,
  .intro-fallback,
  .intro-story-heading,
  .intro-story-viewport,
  .intro-music-credit {
    transition: none;
  }

  .intro-story-viewport {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .intro-story-scroll {
    padding-top: 16px;
  }

  .intro-start.is-ready {
    animation: none;
  }
}

.npc-dialog {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 5;
  display: grid;
  gap: 12px;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 14px;
  border: 1px solid rgba(199, 163, 80, 0.36);
  border-radius: 8px;
  background: rgba(15, 16, 13, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
}

.npc-dialog[hidden] {
  display: none;
}

.npc-dialog header {
  position: sticky;
  top: -14px;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 0;
  padding: 14px;
  background: rgba(15, 16, 13, 0.97);
}

.npc-dialog h2,
.npc-dialog p {
  margin: 0;
}

.npc-dialog h2 {
  font-size: 1.05rem;
}

#npcDialogRole {
  display: block;
  margin-bottom: 3px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

#npcDialogText,
#npcFeedback {
  color: var(--muted);
  line-height: 1.45;
}

#npcDialogText {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.npc-question {
  display: grid;
  gap: 9px;
}

.task-typeset {
  line-height: 1.7;
}

.task-math-fraction {
  display: inline-grid;
  grid-template-rows: auto auto;
  min-width: 1.35em;
  margin: 0 0.14em;
  vertical-align: -0.55em;
  color: inherit;
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
}

.task-math-numerator,
.task-math-denominator {
  display: block;
  padding: 0.04em 0.2em;
}

.task-math-numerator {
  border-bottom: 1.5px solid currentColor;
}

.task-math-superscript {
  position: relative;
  top: -0.12em;
  margin-left: 0.04em;
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif;
  font-size: 0.72em;
  line-height: 0;
}

.npc-question input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #10110f;
  color: var(--text);
  font: inherit;
}

.math-keyboard[hidden],
.math-keyboard-panel[hidden] {
  display: none;
}

.math-keyboard {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.math-keyboard-toggle {
  justify-self: start;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid rgba(205, 178, 104, 0.34);
  border-radius: 6px;
  background: rgba(63, 55, 31, 0.72);
  color: #f2dfaa;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.math-keyboard-open .math-keyboard-toggle {
  border-color: rgba(227, 189, 98, 0.72);
  background: rgba(91, 72, 26, 0.78);
}

.math-keyboard-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 5px;
  width: 100%;
  padding: 7px;
  border: 1px solid rgba(205, 178, 104, 0.26);
  border-radius: 7px;
  background: rgba(7, 8, 7, 0.78);
}

.math-keyboard-key {
  min-width: 0;
  min-height: 38px;
  padding: 4px 6px;
  border: 1px solid rgba(218, 198, 139, 0.25);
  border-radius: 6px;
  background: #202219;
  color: #f5e9c4;
  font-family: "Cambria Math", "STIX Two Math", Georgia, sans-serif;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.math-keyboard-key:hover,
.math-keyboard-key:focus-visible {
  border-color: #e3bd62;
  background: #313020;
}

.math-keyboard-key-wide {
  grid-column: span 2;
}

.npc-dialog-actions {
  display: flex;
  gap: 8px;
}

.npc-dialog-actions button,
#npcDialogClose {
  min-height: 36px;
  padding: 0 10px;
}

.npc-dialog button:focus-visible,
.npc-dialog input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.revive-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 18;
  display: grid;
  gap: 12px;
  width: min(460px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(195, 85, 42, 0.62);
  border-radius: 12px;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 12%, rgba(143, 48, 21, 0.2), transparent 42%),
    linear-gradient(145deg, rgba(25, 19, 15, 0.98), rgba(8, 10, 9, 0.98));
  box-shadow:
    0 0 0 100vmax rgba(1, 3, 3, 0.76),
    0 24px 64px rgba(0, 0, 0, 0.78),
    inset 0 0 34px rgba(137, 45, 20, 0.1);
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.arcane-charge-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  display: grid;
  gap: 10px;
  width: min(440px, calc(100% - 32px));
  padding: 16px;
  border: 1px solid rgba(226, 112, 37, 0.52);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 0%, rgba(125, 45, 15, 0.24), transparent 48%),
    rgba(14, 13, 10, 0.97);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.7), inset 0 0 28px rgba(185, 64, 16, 0.08);
  color: var(--text);
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.arcane-charge-dialog[hidden] {
  display: none;
}

.arcane-charge-dialog > span {
  color: #e28a3d;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arcane-charge-dialog h2,
.arcane-charge-dialog p {
  margin: 0;
}

.arcane-charge-dialog h2 {
  color: #f0c17b;
  font-size: 1.08rem;
}

.arcane-charge-dialog > p:not(#arcaneChargeFeedback) {
  color: #a9a08d;
}

#arcaneChargeQuestion {
  min-height: 1.6em;
  color: #fff1d6;
  font-size: 1.04rem;
}

.arcane-charge-dialog input {
  min-height: 42px;
  border: 1px solid rgba(224, 119, 44, 0.4);
  border-radius: 6px;
  padding: 0 11px;
  color: #fff4df;
  background: #0e0f0d;
  font: inherit;
}

.arcane-charge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.arcane-charge-actions button {
  min-height: 38px;
  padding: 0 11px;
}

#arcaneChargeFeedback {
  min-height: 1.25em;
  color: #d39a5b;
}

.revive-dialog[hidden] {
  display: none;
}

.revive-dialog > .revive-kicker {
  color: #d36e43;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.revive-dialog h2,
.revive-dialog p {
  margin: 0;
}

.revive-dialog h2 {
  color: #f1c58b;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  line-height: 1.12;
}

.revive-cause {
  color: #d8c4ae;
  font-weight: 700;
}

.revive-instruction {
  color: #a89e90;
  line-height: 1.48;
}

.revive-sigil {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid rgba(206, 92, 39, 0.5);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(202, 70, 24, 0.16), transparent 72%),
    rgba(8, 9, 8, 0.78);
  box-shadow: inset 0 0 24px rgba(173, 53, 17, 0.09);
  text-align: center;
}

.revive-sigil > span {
  color: #c77548;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.revive-dialog input {
  min-height: 44px;
  border: 1px solid rgba(192, 91, 50, 0.5);
  border-radius: 7px;
  padding: 0 12px;
  background: #0b0d0c;
  color: #fff1dc;
  font: inherit;
}

.revive-dialog input:focus {
  border-color: #dc8654;
  outline: 2px solid rgba(209, 94, 44, 0.2);
}

#reviveSubmit {
  min-height: 42px;
  border-color: rgba(202, 90, 42, 0.64);
  color: #ffe4c4;
  background: linear-gradient(180deg, rgba(105, 43, 21, 0.88), rgba(59, 27, 17, 0.92));
}

#reviveSubmit:disabled,
.revive-dialog input:disabled {
  cursor: default;
  opacity: 0.66;
}

#reviveQuestion {
  min-height: 1.5em;
  color: #fff0d5;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.4;
}

#reviveFeedback {
  min-height: 1.2em;
  color: #d98a5e;
  font-weight: 700;
}

.revive-dialog.revive-success {
  border-color: rgba(223, 165, 76, 0.82);
  box-shadow:
    0 0 0 100vmax rgba(1, 3, 3, 0.76),
    0 24px 64px rgba(0, 0, 0, 0.78),
    inset 0 0 44px rgba(211, 129, 45, 0.18);
}

.revive-dialog.revive-success #reviveFeedback {
  color: #eac07c;
}

.inventory-panel {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 4;
  display: grid;
  gap: 8px;
  width: min(230px, calc(100% - 86px));
  max-height: min(260px, calc(100% - 120px));
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(236, 230, 214, 0.16);
  border-radius: 8px;
  background: rgba(11, 11, 9, 0.68);
  color: var(--text);
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.inventory-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.inventory-panel header strong {
  color: var(--gold);
  text-transform: none;
}

.inventory-list {
  display: grid;
  gap: 6px;
}

.inventory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(236, 230, 214, 0.12);
  border-radius: 6px;
  background: rgba(5, 5, 4, 0.45);
}

.inventory-item.equipped {
  border-color: rgba(199, 163, 80, 0.48);
}

.inventory-thumb {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(236, 230, 214, 0.16);
  border-radius: 6px;
  background: rgba(5, 5, 4, 0.45);
  object-fit: contain;
}

.inventory-thumb-empty {
  display: inline-block;
  background:
    radial-gradient(circle at 50% 50%, rgba(199, 163, 80, 0.38), transparent 52%),
    rgba(5, 5, 4, 0.45);
}

.inventory-item div {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
}

.inventory-item strong,
.inventory-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-item span {
  color: var(--muted);
  font-size: 0.72rem;
}

.inventory-item button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.pickup-dialog {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title action"
    "stats action";
  align-items: center;
  gap: 2px 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px 9px 8px 11px;
  border: 1px solid rgba(199, 163, 80, 0.42);
  border-radius: 7px;
  background: rgba(15, 16, 13, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  color: var(--text);
  transform: translateX(-50%);
}

.pickup-dialog[hidden] {
  display: none;
}

.pickup-dialog h2,
.pickup-dialog p {
  margin: 0;
}

.pickup-dialog h2 {
  grid-area: title;
  max-width: min(180px, 48vw);
  overflow: hidden;
  font-size: 0.92rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pickup-dialog p {
  grid-area: stats;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.2;
  white-space: nowrap;
}

.pickup-dialog button {
  grid-area: action;
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.dev-login-dialog {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 5, 4, 0.62);
}

.dev-login-dialog[hidden] {
  display: none;
}

.dev-login-dialog form {
  display: grid;
  gap: 10px;
  width: min(360px, 100%);
  padding: 16px;
  border: 1px solid rgba(199, 163, 80, 0.36);
  border-radius: 8px;
  background: rgba(15, 16, 13, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
}

.dev-login-dialog h2,
.dev-login-dialog p {
  margin: 0;
}

.dev-login-dialog h2 {
  font-size: 1.05rem;
}

.dev-login-dialog label {
  color: var(--muted);
  font-size: 0.88rem;
}

.dev-login-dialog input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #10110f;
  color: var(--text);
  font: inherit;
}

#devLoginFeedback {
  min-height: 1.2em;
  color: var(--gold);
  font-size: 0.86rem;
}

.dev-login-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.dev-login-actions button {
  min-height: 36px;
  padding: 0 10px;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.brand,
.party,
.controls,
.map-box,
.log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.level-name {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-actions {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px;
}

#reset,
.icon-link {
  display: inline-grid;
  min-width: 48px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #24251f;
  color: var(--text);
  font-size: 0.78rem;
  text-decoration: none;
}

.party {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
}

.hero {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

meter {
  width: 100%;
  height: 14px;
}

meter::-webkit-meter-bar {
  border: 1px solid #313128;
  border-radius: 4px;
  background: #0e0f0d;
}

meter::-webkit-meter-optimum-value {
  border-radius: 3px;
  background: linear-gradient(90deg, var(--red), var(--green));
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
}

.controls button {
  aspect-ratio: 1 / 0.56;
  min-width: 0;
  font-size: clamp(1rem, 2.2vh, 1.35rem);
  touch-action: none;
  user-select: none;
}

.mobile-game-controls,
.mobile-game-topbar {
  display: none;
}

.map-box {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
}

#map {
  display: block;
  width: min(100%, 34vh, 320px);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid #2f302a;
  border-radius: 6px;
  background: #0c0d0b;
}

.log {
  padding: 10px 12px;
}

.log h2 {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 0.82rem;
}

.log p {
  margin: 0;
  color: var(--muted);
  line-height: 1.3;
  font-size: 0.86rem;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 8px;
  }

  .viewport-wrap {
    min-height: 0;
  }

  .side-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto auto;
    gap: 8px;
  }

  .brand {
    grid-column: 1 / 3;
  }

  .party {
    grid-column: 3 / 5;
  }

  .controls {
    grid-column: 1 / 3;
  }

  .map-box {
    grid-column: 3 / 4;
  }

  .log {
    grid-column: 4 / 5;
  }

  #map {
    width: min(100%, 18vh, 160px);
  }
}

@media (max-width: 620px) {
  .shell {
    grid-template-rows: minmax(0, 1fr) minmax(148px, 34vh);
    padding: 6px;
  }

  .play-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto;
    gap: 6px;
  }

  .brand,
  .log {
    display: none;
  }

  .party {
    grid-column: 1 / 3;
    padding: 8px;
  }

  .controls {
    grid-column: 1 / 3;
    padding: 8px;
  }

  .map-box {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    padding: 8px;
  }

  .viewport-wrap {
    min-height: 0;
  }

  #map {
    width: min(100%, 22vh, 140px);
  }

  .hero {
    grid-template-columns: 48px 1fr;
    gap: 6px;
    font-size: 0.82rem;
  }

  .controls button {
    font-size: 1rem;
  }

  .message {
    bottom: 70px;
    font-size: 0.86rem;
  }

  .player-health {
    top: 62px;
    left: 12px;
    grid-template-columns: auto minmax(80px, 1fr) 32px;
    width: min(230px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    min-height: 38px;
  }

  .player-arcane-hud {
    top: 110px;
    left: 12px;
    width: min(370px, calc(100% - 24px));
  }

  .inventory-panel {
    top: 274px;
    right: 12px;
    width: min(230px, calc(100% - 24px));
    max-height: min(160px, calc(100% - 130px));
  }

  .weapon-status {
    right: 12px;
    bottom: 12px;
    width: 40px;
    height: 40px;
  }

  .attack-effect {
    width: min(68vw, 360px);
    height: min(14vh, 92px);
  }

  .npc-dialog {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: min(68%, calc(100% - 24px));
    transform: none;
  }
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  &,
  body {
    overscroll-behavior: none;
  }

  .math-keyboard-toggle,
  .math-keyboard-key {
    min-height: 42px;
  }

  .shell,
  .play-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
  }

  .viewport-wrap {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .side-panel {
    display: none;
  }

  .mobile-game-controls {
    position: absolute;
    z-index: 4;
    inset: 0;
    display: block;
    overflow: hidden;
    pointer-events: none;
  }

  .mobile-game-controls button,
  .mobile-game-topbar button {
    min-width: 54px;
    min-height: 54px;
    border-color: rgba(236, 230, 214, 0.34);
    background: rgba(20, 21, 18, 0.68);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.38);
    color: #fff5cf;
    font-weight: 700;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    backdrop-filter: blur(6px);
    pointer-events: auto;
  }

  .mobile-game-controls button:active,
  .mobile-game-controls button.pressed {
    border-color: var(--gold);
    background: rgba(86, 72, 37, 0.88);
    transform: scale(0.96);
  }

  .mobile-look-zone {
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 40%;
    display: block;
    border: 0;
    background: transparent;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .mobile-look-zone.is-active {
    background: linear-gradient(90deg, transparent 0%, rgba(221, 191, 118, 0.035) 100%);
  }

  .mobile-move-joystick {
    position: absolute;
    z-index: 3;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 116px;
    height: 116px;
    border: 1px solid rgba(236, 221, 185, 0.34);
    border-radius: 50%;
    background:
      radial-gradient(circle, rgba(236, 221, 185, 0.08) 0 28%, transparent 29%),
      radial-gradient(circle, rgba(10, 10, 9, 0.6) 0 69%, rgba(10, 10, 9, 0.28) 70% 100%);
    box-shadow:
      inset 0 0 18px rgba(0, 0, 0, 0.62),
      0 8px 24px rgba(0, 0, 0, 0.38);
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    backdrop-filter: blur(3px);
  }

  .mobile-joystick-guide {
    position: absolute;
    inset: 20px;
    border: 1px solid rgba(236, 221, 185, 0.16);
    border-radius: 50%;
    pointer-events: none;
  }

  .mobile-joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border: 1px solid rgba(255, 238, 194, 0.58);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(203, 168, 88, 0.94), rgba(73, 58, 29, 0.94) 72%);
    box-shadow:
      inset 0 2px 7px rgba(255, 239, 191, 0.24),
      0 5px 12px rgba(0, 0, 0, 0.54);
    transform: translate3d(0, 0, 0);
    will-change: transform;
    pointer-events: none;
  }

  .mobile-move-joystick.is-active {
    border-color: rgba(223, 184, 91, 0.76);
    background:
      radial-gradient(circle, rgba(223, 184, 91, 0.12) 0 28%, transparent 29%),
      radial-gradient(circle, rgba(18, 15, 9, 0.68) 0 69%, rgba(18, 15, 9, 0.34) 70% 100%);
  }

  .mobile-action-pad {
    position: absolute;
    z-index: 3;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(2, minmax(58px, 1fr));
    gap: 6px;
    width: min(32vw, 154px);
    pointer-events: none;
  }

  .mobile-action-pad button {
    min-width: 0;
    padding: 0 7px;
    font-size: 0.78rem;
  }

  .mobile-game-topbar {
    position: absolute;
    z-index: 7;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: max(10px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
  }

  .mobile-game-topbar button {
    min-height: 44px;
    padding: 0 12px;
    font-size: 0.76rem;
    pointer-events: auto;
  }

  body.mobile-map-open .side-panel {
    position: fixed;
    z-index: 12;
    inset: max(66px, calc(env(safe-area-inset-top) + 56px)) 10px auto auto;
    display: block;
    width: min(74vw, 340px);
    height: min(74vw, 340px);
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(16, 16, 14, 0.96);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.58);
  }

  body.mobile-map-open .side-panel > :not(.map-box) {
    display: none;
  }

  body.mobile-map-open .map-box {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 0;
  }

  body.mobile-map-open #map {
    width: 100%;
    max-width: none;
  }

  .npc-dialog,
  .pickup-dialog,
  .revive-dialog,
  .arcane-charge-dialog,
  .intro-screen {
    z-index: 15;
  }

  .weapon-status {
    bottom: max(142px, calc(env(safe-area-inset-bottom) + 132px));
  }

  @media (orientation: landscape) {
    .mobile-move-joystick {
      left: max(20px, env(safe-area-inset-left));
      bottom: max(16px, env(safe-area-inset-bottom));
      width: 108px;
      height: 108px;
    }

    .mobile-game-controls button {
      min-width: 50px;
      min-height: 50px;
    }

    .mobile-action-pad {
      right: max(18px, env(safe-area-inset-right));
      bottom: max(18px, env(safe-area-inset-bottom));
      width: min(25vw, 146px);
    }

    .player-health {
      top: max(12px, env(safe-area-inset-top));
      left: 50%;
      transform: translateX(-50%);
    }

    .player-arcane-hud {
      top: max(60px, calc(env(safe-area-inset-top) + 48px));
      left: 50%;
      width: min(330px, calc(100% - 350px));
      transform: translateX(-50%);
    }

    .weapon-status {
      right: max(176px, calc(env(safe-area-inset-right) + 166px));
      bottom: max(12px, env(safe-area-inset-bottom));
    }
  }
  }
}

/* Unified bottom frame: health, four inventory slots and magic form one object. */
.dungeon-hud {
  --hud-bottom: 18px;
  --orb-size: clamp(76px, 6.2vw, 86px);
  --inventory-slot-size: 62px;
  --inventory-arrow-size: 23px;
}

.dungeon-hud-frame {
  position: absolute;
  left: 50%;
  bottom: var(--hud-bottom);
  display: grid;
  grid-template-columns: var(--orb-size) auto var(--orb-size);
  align-items: center;
  min-height: calc(var(--orb-size) + 10px);
  padding: 5px 7px;
  border: 2px solid #62553d;
  border-radius: calc(var(--orb-size) * 0.54);
  background:
    linear-gradient(180deg, rgba(77, 65, 44, 0.96) 0 8%, rgba(31, 27, 20, 0.97) 9% 84%, rgba(10, 9, 8, 0.98) 85%),
    #17130f;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.72),
    inset 0 0 0 2px rgba(12, 10, 8, 0.82),
    inset 0 0 24px rgba(183, 137, 62, 0.08);
  pointer-events: none;
  transform: translateX(-50%);
}

body.hud-cursor-active .dungeon-hud-frame {
  border-color: #8b7446;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(205, 168, 88, 0.2),
    0 0 18px rgba(205, 168, 88, 0.16),
    inset 0 0 0 2px rgba(12, 10, 8, 0.82),
    inset 0 0 24px rgba(183, 137, 62, 0.12);
}

body.hud-cursor-active .hud-action-bar {
  border-top-color: rgba(215, 177, 92, 0.55);
}

.dungeon-hud-frame::before,
.dungeon-hud-frame::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  width: 16px;
  height: 46%;
  border-top: 2px solid #756446;
  border-bottom: 2px solid #362d21;
  background: linear-gradient(180deg, #443923, #15120e);
  transform: translateY(-50%);
}

.dungeon-hud-frame::before {
  left: -9px;
  border-left: 2px solid #5c4e36;
  border-radius: 8px 0 0 8px;
}

.dungeon-hud-frame::after {
  right: -9px;
  border-right: 2px solid #5c4e36;
  border-radius: 0 8px 8px 0;
}

.dungeon-hud-frame .resource-orb {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: var(--orb-size);
  height: var(--orb-size);
  transform: none;
}

.dungeon-hud-frame .player-health {
  left: auto;
}

.dungeon-hud-frame .player-arcane-hud {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  display: block;
  width: var(--orb-size);
  height: var(--orb-size);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.dungeon-hud-frame .arcane-power.resource-orb {
  right: auto;
  width: 100%;
  pointer-events: auto;
}

.dungeon-hud-frame .hud-action-bar {
  position: relative;
  left: auto;
  bottom: auto;
  display: grid;
  grid-template-columns: var(--inventory-arrow-size) auto var(--inventory-arrow-size);
  align-items: center;
  gap: 4px;
  width: auto;
  height: auto;
  margin: 0 -1px;
  padding: 6px 5px;
  border: 0;
  border-top: 1px solid rgba(171, 142, 79, 0.34);
  border-bottom: 1px solid rgba(20, 17, 13, 0.92);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(38, 33, 25, 0.97), rgba(12, 11, 9, 0.98));
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.48);
  pointer-events: auto;
  transform: none;
}

.dungeon-hud-frame .inventory-panel {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: auto;
  display: block;
  width: calc(var(--inventory-slot-size) * 4 + 12px);
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: none;
}

.dungeon-hud-frame .inventory-list {
  display: grid;
  grid-template-columns: repeat(4, var(--inventory-slot-size));
  gap: 4px;
}

.inventory-quick-slot {
  position: relative;
  display: grid;
  width: var(--inventory-slot-size);
  height: var(--inventory-slot-size);
  min-width: 0;
  min-height: 0;
  padding: 4px 3px 14px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(151, 128, 79, 0.46);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 38%, rgba(126, 100, 49, 0.13), transparent 54%),
    rgba(6, 6, 5, 0.86);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.58);
  color: #e6d7b6;
}

button.inventory-quick-slot {
  cursor: pointer;
}

button.inventory-quick-slot:hover,
button.inventory-quick-slot:focus-visible {
  border-color: #c8a85d;
  background-color: rgba(58, 46, 25, 0.9);
}

.inventory-quick-slot.selected {
  border-color: #d5ae51;
  box-shadow:
    inset 0 0 12px rgba(196, 146, 43, 0.2),
    0 0 7px rgba(205, 159, 52, 0.34);
}

.inventory-quick-slot.selected::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e4bd58;
  box-shadow: 0 0 5px #d99525;
}

.inventory-quick-slot-empty {
  background:
    linear-gradient(135deg, transparent 48%, rgba(122, 103, 66, 0.08) 49% 51%, transparent 52%),
    rgba(4, 4, 4, 0.52);
  opacity: 0.58;
}

.inventory-quick-name {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  overflow: hidden;
  color: #bfb397;
  font-size: 0.55rem;
  font-weight: 750;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-item-symbol {
  position: relative;
  display: grid;
  width: 38px;
  height: 36px;
  place-items: center;
}

.inventory-item-symbol::before,
.inventory-item-symbol::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  transform: translate(-50%, -50%);
}

.inventory-fist-symbol {
  width: auto;
  color: #e6d7b6;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  font-size: 2rem;
  line-height: 1;
  text-shadow: 0 2px 3px #000, 0 0 8px rgba(213, 174, 93, 0.24);
}

.inventory-fireball-symbol .fireball-glyph {
  width: 27px;
  height: 27px;
  margin: 3px 0 0;
}

.inventory-fist-symbol::before,
.inventory-fist-symbol::after,
.inventory-generic-symbol::before,
.inventory-generic-symbol::after {
  content: none;
}

.inventory-generic-symbol {
  color: #cdb579;
  font-size: 1.65rem;
  text-shadow: 0 2px 4px #000;
}

.inventory-quick-slot .inventory-thumb {
  width: calc(var(--inventory-slot-size) - 17px);
  height: calc(var(--inventory-slot-size) - 19px);
  border: 0;
  border-radius: 4px;
  background: transparent;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.72));
}

.inventory-scroll {
  width: var(--inventory-arrow-size);
  min-width: 0;
  height: calc(var(--inventory-slot-size) - 8px);
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(145, 121, 69, 0.42);
  border-radius: 5px;
  color: #e3cc93;
  background: linear-gradient(180deg, rgba(73, 60, 35, 0.72), rgba(16, 14, 11, 0.92));
  font-family: Georgia, serif;
  font-size: 1.35rem;
  line-height: 1;
}

.inventory-scroll:hover:not(:disabled),
.inventory-scroll:focus-visible {
  border-color: #c7a350;
  color: #fff0b8;
}

.inventory-scroll:disabled {
  color: #544d3e;
  background: rgba(9, 9, 8, 0.72);
  cursor: default;
  opacity: 0.68;
}

.dungeon-hud-frame .spell-progress {
  position: absolute;
  z-index: 3;
  right: 50%;
  bottom: -2px;
  min-width: 47px;
  margin: 0;
  padding: 3px 5px;
  border: 1px solid rgba(128, 112, 76, 0.6);
  border-radius: 7px;
  background: rgba(10, 9, 8, 0.9);
  transform: translateX(50%);
}

.dungeon-hud-frame .fireball-popover {
  right: 0;
  bottom: calc(100% + 15px);
  left: auto;
  width: 286px;
  transform: none;
  pointer-events: auto;
}

body.arcane-menu-open .dungeon-hud-frame .fireball-popover {
  width: min(360px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 130px));
  overflow-x: hidden;
  overflow-y: auto;
  border-width: 2px;
  box-shadow:
    0 20px 52px rgba(0, 0, 0, 0.86),
    0 0 0 1px rgba(198, 174, 255, 0.14),
    inset 0 0 24px rgba(91, 78, 176, 0.14);
}

body.arcane-menu-open .dungeon-hud-frame > :not(.player-arcane-hud),
body.arcane-menu-open .player-arcane-hud > :not(.fireball-popover) {
  pointer-events: none;
}

.arcane-popover-title {
  color: #c9c5ff;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
}

.arcane-archive-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.arcane-archive-header small {
  color: var(--spell-color, #9d96ff);
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
}

.arcane-archive-help {
  margin: 0;
  color: #b9af9b;
  font-size: 0.68rem;
  line-height: 1.35;
}

.arcane-spell-list {
  display: grid;
  gap: 4px;
}

.dungeon-hud-frame .arcane-spell-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  grid-template-areas:
    "glyph name ep"
    "glyph progress progress";
  align-items: center;
  gap: 2px 7px;
  width: 100%;
  min-height: 32px;
  padding: 4px 7px;
  border: 1px solid rgba(119, 112, 180, 0.28);
  border-radius: 5px;
  color: #ddd8cc;
  background: rgba(26, 23, 40, 0.84);
  text-align: left;
}

.dungeon-hud-frame .arcane-spell-row.is-active {
  border-color: var(--spell-color, #9d96ff);
  box-shadow: inset 0 0 11px color-mix(in srgb, var(--spell-color, #9d96ff) 22%, transparent);
}

.dungeon-hud-frame .arcane-spell-row.is-locked {
  opacity: 0.62;
}

.arcane-spell-glyph {
  grid-area: glyph;
  color: var(--spell-color);
  font-size: 1rem;
  text-align: center;
  text-shadow: 0 0 8px var(--spell-color);
}

.arcane-spell-name {
  grid-area: name;
  overflow: hidden;
  font-size: 0.69rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arcane-spell-ep {
  grid-area: ep;
  color: #a99f89;
  font-size: 0.6rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.arcane-spell-progress {
  grid-area: progress;
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.58);
}

.arcane-spell-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--spell-color);
  box-shadow: 0 0 6px var(--spell-color);
}

.arcane-popover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.dungeon-hud-frame .arcane-popover-actions button {
  min-height: 35px;
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 800;
}

.dungeon-hud-frame #arcanePowerRequest {
  border-color: rgba(126, 118, 224, 0.48);
  color: #ddd9ff;
  background: rgba(37, 32, 87, 0.88);
}

.dungeon-hud-frame #arcanePowerRequest:disabled {
  color: #736f83;
  background: rgba(22, 20, 31, 0.86);
}

.dungeon-hud-frame #arcaneArchiveClose {
  border-color: color-mix(in srgb, var(--spell-color, #9d96ff) 62%, #8d7954);
  color: #fff7e4;
  background: linear-gradient(180deg, rgba(88, 72, 132, 0.94), rgba(35, 28, 58, 0.96));
}

.inventory-spell-symbol {
  color: var(--inventory-spell-color, #9d96ff);
  font-size: 1.8rem;
  line-height: 1;
  text-shadow:
    0 0 7px var(--inventory-spell-color, #9d96ff),
    0 0 16px color-mix(in srgb, var(--inventory-spell-color, #9d96ff) 55%, transparent);
}

.weapon-overlay #weaponStatus {
  display: none;
}

@media (max-width: 620px) {
  .dungeon-hud {
    --hud-bottom: 10px;
    --orb-size: 64px;
    --inventory-slot-size: 40px;
    --inventory-arrow-size: 18px;
  }

  .dungeon-hud-frame {
    min-height: calc(var(--orb-size) + 7px);
    padding: 3px 4px;
  }

  .dungeon-hud-frame .player-health,
  .dungeon-hud-frame .arcane-power.resource-orb {
    top: auto;
    right: auto;
    left: auto;
    width: var(--orb-size);
    transform: none;
  }

  .dungeon-hud-frame .hud-action-bar {
    gap: 3px;
    padding: 5px 3px;
  }

  .dungeon-hud-frame .inventory-panel {
    width: calc(var(--inventory-slot-size) * 4 + 9px);
  }

  .dungeon-hud-frame .inventory-list {
    gap: 3px;
  }

  .inventory-quick-slot {
    padding: 2px 2px 11px;
    border-radius: 4px;
  }

  .inventory-quick-name {
    bottom: 2px;
    font-size: 0.46rem;
  }

  .inventory-item-symbol {
    width: 29px;
    height: 27px;
  }

  .inventory-fist-symbol {
    font-size: 1.55rem;
  }

  .inventory-quick-slot .inventory-thumb {
    width: 29px;
    height: 25px;
  }

  .inventory-scroll {
    font-size: 1.05rem;
  }

  .dungeon-hud-frame .spell-progress {
    bottom: -4px;
    min-width: 42px;
    padding: 2px 4px;
    font-size: 0.54rem;
  }

  .dungeon-hud-frame .fireball-popover {
    right: -2px;
    width: min(286px, calc(100vw - 18px));
  }
}
}

@media (max-width: 360px) {
  .dungeon-hud {
    --orb-size: 58px;
    --inventory-slot-size: 36px;
    --inventory-arrow-size: 16px;
  }

  .dungeon-hud-frame {
    padding-right: 3px;
    padding-left: 3px;
  }

  .dungeon-hud-frame .hud-action-bar {
    padding-right: 2px;
    padding-left: 2px;
  }
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  .dungeon-hud {
    --hud-bottom: max(146px, calc(env(safe-area-inset-bottom) + 136px));
  }

  .dungeon-hud-frame .player-health,
  .dungeon-hud-frame .arcane-power.resource-orb {
    top: auto;
    right: auto;
    left: auto;
    transform: none;
  }

  .message,
  .interaction-hint {
    bottom: max(226px, calc(env(safe-area-inset-bottom) + 216px));
  }

  @media (orientation: landscape) {
    .dungeon-hud {
      --hud-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .message,
    .interaction-hint {
      bottom: max(94px, calc(env(safe-area-inset-bottom) + 84px));
    }

  }
  }
}

@media (max-width: 620px) {
  .companion-decision {
    bottom: max(102px, calc(env(safe-area-inset-bottom) + 92px));
    width: calc(100% - 20px);
    padding: 13px;
  }

  .companion-decision-actions {
    display: grid;
  }

  .companion-command-menu {
    width: min(330px, calc(100vw - 20px));
    max-height: min(390px, calc(100dvh - 132px));
  }

  .arcane-experience small {
    font-size: 0.62rem;
  }

  .companion-roster-row {
    min-height: 44px;
  }

  .companion-portrait-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .companion-avatar-bubble {
    max-width: min(300px, calc(100vw - 74px));
    padding: 6px 9px;
    font-size: 0.82rem;
  }

  .companion-speech-log {
    max-height: min(160px, 25dvh);
    padding: 5px 8px;
    font-size: 0.82rem;
  }

  .companion-world-comment {
    max-width: min(300px, calc(100vw - 24px));
    padding: 6px 9px;
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .companion-avatar-bubble,
  .companion-world-comment {
    animation: none;
    transition: none;
  }
}

.player-account-screen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  color: #eee6cf;
  background: radial-gradient(circle at 50% 35%, rgba(53, 45, 28, 0.98), rgba(8, 8, 7, 0.995) 68%);
}

.player-account-screen[hidden] {
  display: none;
}

.player-account-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid rgba(207, 169, 73, 0.45);
  border-radius: 14px;
  background: rgba(21, 21, 18, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.player-account-card h1 {
  margin: 0 0 18px;
  color: #e0b94f;
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.player-account-card form {
  display: grid;
  gap: 8px;
}

.player-account-card input {
  min-height: 48px;
  margin-bottom: 8px;
  padding: 0 13px;
  border: 1px solid #4e4938;
  border-radius: 8px;
  color: #fff8df;
  background: #11120f;
  font: inherit;
  font-size: 1.08rem;
}

.player-account-card #playerPin {
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
}

#playerEnter {
  min-height: 48px;
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 700;
}

#playerAccountFeedback {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: #cfc6aa;
}

@media (max-width: 620px) {
  .player-account-card {
    padding: 20px;
  }
}

/* Compact dungeon HUD: liquid resource orbs and contextual action slots. */
.dungeon-hud {
  --hud-bottom: 18px;
  --orb-size: clamp(76px, 6.2vw, 88px);
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
}

.resource-orb {
  --resource-fill: 1;
  --liquid: #b51f16;
  --liquid-deep: #4d0909;
  position: absolute;
  top: auto;
  bottom: var(--hud-bottom);
  display: grid;
  width: var(--orb-size);
  height: var(--orb-size);
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 3px solid #6f6045;
  border-radius: 50%;
  background: #100e0c;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.7),
    inset 0 0 0 2px #1f1a13,
    inset 0 0 16px rgba(0, 0, 0, 0.82),
    0 0 0 2px rgba(12, 10, 8, 0.78);
  color: #fff5dc;
  backdrop-filter: none;
  isolation: isolate;
}

.resource-orb::before,
.resource-orb::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.resource-orb::before {
  z-index: -2;
  inset: 6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.34), transparent 19%),
    linear-gradient(
      to top,
      var(--liquid-deep) 0%,
      var(--liquid) calc(var(--resource-fill) * 78%),
      rgba(14, 12, 13, 0.88) calc(var(--resource-fill) * 78% + 2%),
      rgba(5, 5, 5, 0.92) 100%
    );
  box-shadow: inset 0 0 17px rgba(0, 0, 0, 0.72);
  transition: background 220ms ease;
}

.resource-orb::after {
  z-index: -1;
  inset: 5px;
  border: 1px solid rgba(255, 244, 212, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 32% 20%, rgba(255, 255, 255, 0.2), transparent 27%),
    radial-gradient(ellipse at 68% 83%, transparent 45%, rgba(0, 0, 0, 0.38) 82%);
}

.resource-orb meter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.resource-orb strong {
  z-index: 1;
  align-self: center;
  margin-top: -3px;
  color: #fff4d2;
  font-size: clamp(1rem, 1.45vw, 1.24rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  text-shadow: 0 2px 5px #000, 0 0 8px rgba(255, 214, 164, 0.34);
}

.resource-orb-mark {
  z-index: 1;
  position: absolute;
  bottom: 14px;
  color: rgba(255, 238, 205, 0.74);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 1px 3px #000;
}

.resource-orb-symbol {
  bottom: 10px;
  width: 1rem;
  height: 1rem;
  display: grid;
  place-items: center;
  color: rgba(255, 244, 221, 0.94);
  letter-spacing: 0;
}

.resource-orb-symbol svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
  filter: drop-shadow(0 1px 2px #000) drop-shadow(0 0 4px currentColor);
}

.health-resource-symbol {
  color: #ffe3dc;
}

.energy-resource-symbol {
  color: #e6ddff;
}

.player-health {
  left: 18px;
  pointer-events: none;
}

.player-health.player-health-low {
  --liquid: #b35416;
  --liquid-deep: #4e1b08;
}

.player-health.player-health-empty {
  --liquid: #2e0909;
  --liquid-deep: #130405;
}

.player-health-low strong,
.player-health-empty strong {
  color: #fff0d0;
}

.player-arcane-hud {
  display: contents;
  width: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.arcane-power.resource-orb {
  --resource-fill: 0.4;
  --liquid: #615bd7;
  --liquid-deep: #15155f;
  right: 18px;
  left: auto;
  grid-template-columns: 1fr;
  gap: 0;
  min-width: 0;
  border-color: #6a6659;
  pointer-events: auto;
  cursor: pointer;
  appearance: none;
}

.arcane-power.resource-orb:hover:not(:disabled),
.arcane-power.resource-orb:focus-visible {
  border-color: #d1b965;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.7),
    inset 0 0 0 2px #1f1a13,
    0 0 16px rgba(108, 100, 255, 0.4);
}

.arcane-power.resource-orb:disabled {
  opacity: 1;
  cursor: default;
}

.hud-action-bar {
  position: absolute;
  left: 50%;
  bottom: var(--hud-bottom);
  display: flex;
  gap: 5px;
  height: 78px;
  padding: 6px 7px 5px;
  border: 2px solid #574c38;
  border-radius: 10px 10px 7px 7px;
  background:
    linear-gradient(180deg, rgba(49, 42, 31, 0.96), rgba(13, 12, 10, 0.94)),
    #15120e;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.64),
    inset 0 0 0 1px rgba(216, 187, 113, 0.12);
  pointer-events: auto;
  transform: translateX(-50%);
}

.hud-slot {
  position: relative;
  display: grid;
  width: 68px;
  height: 64px;
  min-width: 0;
  min-height: 0;
  padding: 3px 4px 15px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(174, 144, 78, 0.52);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 38%, rgba(118, 96, 53, 0.2), transparent 52%),
    rgba(8, 8, 7, 0.88);
  color: #e9dcc1;
  cursor: pointer;
}

.hud-slot:hover,
.hud-slot:focus-visible,
.hud-slot[aria-expanded="true"] {
  border-color: #c7a350;
  background-color: rgba(52, 43, 25, 0.92);
}

.hud-slot-label {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  overflow: hidden;
  color: #bdb39c;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-slot .weapon-status {
  position: relative;
  right: auto;
  bottom: auto;
  width: 36px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 1;
}

.fireball-control {
  position: relative;
  display: grid;
  width: 68px;
  align-content: start;
  justify-items: center;
}

.fireball-control .hud-slot {
  width: 68px;
  height: 50px;
  padding-bottom: 14px;
}

.fireball-glyph {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  margin-top: -2px;
  border-radius: 52% 48% 58% 42%;
  background:
    radial-gradient(circle at 43% 57%, #fff4a2 0 13%, #ff9c32 27%, #e53f13 54%, rgba(92, 13, 5, 0.96) 72%);
  box-shadow: 0 0 9px rgba(255, 85, 19, 0.72), inset -4px -5px 7px rgba(76, 5, 2, 0.58);
  transform: rotate(-11deg);
}

.fireball-glyph::before,
.fireball-glyph::after {
  content: "";
  position: absolute;
  border-radius: 60% 40% 65% 35%;
  background: #e74b16;
  filter: drop-shadow(0 0 4px rgba(255, 77, 17, 0.72));
}

.fireball-glyph::before {
  top: -9px;
  left: 8px;
  width: 11px;
  height: 17px;
  transform: rotate(16deg);
}

.fireball-glyph::after {
  top: -5px;
  right: 2px;
  width: 8px;
  height: 12px;
  background: #ff8e28;
  transform: rotate(31deg);
}

.fireball-slot.fireball-locked .fireball-glyph {
  background: radial-gradient(circle at 43% 57%, #665e50 0 18%, #302c28 48%, #111 76%);
  box-shadow: inset -3px -4px 6px #070707;
  filter: grayscale(1);
  opacity: 0.58;
}

.fireball-slot.fireball-locked .fireball-glyph::before,
.fireball-slot.fireball-locked .fireball-glyph::after {
  background: #302d29;
  filter: none;
}

.fireball-slot.fireball-empty .fireball-glyph {
  filter: saturate(0.28) brightness(0.62);
  box-shadow: none;
}

.spell-progress {
  display: block;
  min-height: 12px;
  margin-top: 3px;
  color: #968b75;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.spell-progress strong {
  color: #c8aa63;
  font-size: inherit;
}

.spell-progress.arcane-unlocked,
.spell-progress.arcane-unlocked strong {
  color: #f09a45;
  text-shadow: 0 0 8px rgba(238, 86, 23, 0.56);
}

.fireball-popover {
  position: absolute;
  z-index: 12;
  bottom: calc(100% + 13px);
  left: 50%;
  display: grid;
  gap: 9px;
  width: 286px;
  padding: 11px;
  border: 1px solid color-mix(in srgb, var(--spell-color, #8d86ff) 62%, transparent);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(84, 72, 164, 0.26), transparent 52%),
    rgba(12, 11, 9, 0.97);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), inset 0 0 18px rgba(91, 78, 176, 0.1);
  color: #eadcc0;
  transform: translateX(-50%);
}

.fireball-popover[hidden],
.inventory-panel[hidden] {
  display: none;
}

.fireball-popover .fireball-strength > span {
  display: flex;
  justify-content: space-between;
  color: #d6c7a7;
  font-size: 0.72rem;
}

.inventory-panel {
  top: auto;
  right: auto;
  bottom: calc(18px + 92px);
  left: 50%;
  z-index: 10;
  width: min(250px, calc(100% - 28px));
  max-height: min(310px, calc(100% - 150px));
  background: rgba(12, 11, 9, 0.95);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.66);
  transform: translateX(-50%);
}

.inventory-panel header button {
  min-height: 27px;
  padding: 0 7px;
  color: #cdbf9e;
  font-size: 0.64rem;
}

.message {
  bottom: clamp(118px, 15vh, 150px);
}

.interaction-hint {
  bottom: 110px;
}

@media (max-width: 620px) {
  .dungeon-hud {
    --hud-bottom: 12px;
    --orb-size: 66px;
  }

  .player-health {
    top: auto;
    left: 10px;
    width: var(--orb-size);
    max-width: none;
    min-height: 0;
  }

  .arcane-power.resource-orb {
    top: auto;
    right: 10px;
    left: auto;
    width: var(--orb-size);
    transform: none;
  }

  .resource-orb-mark {
    bottom: 11px;
  }

  .hud-action-bar {
    height: 68px;
    padding: 5px 6px 4px;
  }

  .hud-slot,
  .fireball-control {
    width: 59px;
  }

  .hud-slot {
    height: 55px;
  }

  .fireball-control .hud-slot {
    width: 59px;
    height: 43px;
  }

  .fireball-glyph {
    width: 24px;
    height: 24px;
  }

  .inventory-panel {
    bottom: 92px;
  }
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  .dungeon-hud {
    --hud-bottom: max(146px, calc(env(safe-area-inset-bottom) + 136px));
    --orb-size: 64px;
  }

  .player-health {
    left: max(10px, env(safe-area-inset-left));
  }

  .arcane-power.resource-orb {
    right: max(10px, env(safe-area-inset-right));
  }

  .inventory-panel {
    bottom: max(224px, calc(env(safe-area-inset-bottom) + 214px));
    max-height: min(240px, calc(100% - 250px));
  }

  .message,
  .interaction-hint {
    bottom: max(224px, calc(env(safe-area-inset-bottom) + 214px));
  }

  .weapon-status {
    right: auto;
    bottom: auto;
  }

  @media (orientation: landscape) {
    .dungeon-hud {
      --hud-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .player-health {
      top: auto;
      left: max(174px, calc(env(safe-area-inset-left) + 164px));
      transform: none;
    }

    .arcane-power.resource-orb {
      top: auto;
      right: max(174px, calc(env(safe-area-inset-right) + 164px));
      left: auto;
      width: var(--orb-size);
      transform: none;
    }

    .inventory-panel {
      bottom: max(90px, calc(env(safe-area-inset-bottom) + 80px));
      max-height: calc(100% - 112px);
    }

    .message,
    .interaction-hint {
      bottom: max(88px, calc(env(safe-area-inset-bottom) + 78px));
    }

  }
  }
}

/* Keep every transient game notice clear of the unified inventory HUD. */
.viewport-wrap {
  --hud-notice-bottom: 128px;
  --hud-notice-lane-gap: 44px;
}

.interaction-hint {
  z-index: 9;
  bottom: var(--hud-notice-bottom);
  max-width: calc(100% - 24px);
  white-space: normal;
  text-align: center;
}

.message {
  z-index: 9;
  bottom: calc(var(--hud-notice-bottom) + var(--hud-notice-lane-gap));
}

.message.message-drowning {
  bottom: max(
    calc(var(--hud-notice-bottom) + var(--hud-notice-lane-gap)),
    clamp(110px, 22vh, 190px)
  );
}

.pickup-dialog,
.npc-dialog {
  z-index: 9;
  bottom: var(--hud-notice-bottom);
  max-height: calc(100% - var(--hud-notice-bottom) - 16px);
}

@media (max-width: 620px) {
  .viewport-wrap {
    --hud-notice-bottom: 92px;
    --hud-notice-lane-gap: 40px;
  }
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  .viewport-wrap {
    --hud-notice-bottom: max(230px, calc(env(safe-area-inset-bottom) + 220px));
  }

  @media (orientation: landscape) {
    .viewport-wrap {
      --hud-notice-bottom: max(94px, calc(env(safe-area-inset-bottom) + 84px));
    }
  }
  }
}

/* Mobile game shell: landscape-only play and a compact swipe-away HUD. */
.mobile-landscape-gate,
.mobile-portrait-gate,
.mobile-hud-handle {
  display: none;
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  &.mobile-game-active,
  &.mobile-game-active body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
  }

  body.mobile-play-mode {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .mobile-landscape-gate > div,
  .mobile-portrait-gate > div {
    display: grid;
    gap: 10px;
    max-width: 320px;
    place-items: center;
  }

  .mobile-landscape-gate span,
  .mobile-portrait-gate span {
    color: #c9a754;
    font-size: 3rem;
    line-height: 1;
  }

  .mobile-landscape-gate strong,
  .mobile-portrait-gate strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.45rem;
    letter-spacing: 0.04em;
  }

  .mobile-landscape-gate p,
  .mobile-portrait-gate p {
    margin: 0;
    color: #b9ad94;
    font-size: 0.9rem;
  }

  .dungeon-hud-frame {
    transition: transform 220ms ease, opacity 170ms ease;
    will-change: transform, opacity;
  }

  .mobile-hud-handle {
    position: absolute;
    z-index: 20;
    left: 50%;
    bottom: calc(var(--hud-bottom) + var(--orb-size) + 16px);
    display: grid;
    width: 38px;
    height: 30px;
    min-width: 0;
    min-height: 0;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(216, 177, 83, 0.72);
    border-radius: 9px;
    background:
      linear-gradient(180deg, rgba(60, 49, 28, 0.96), rgba(15, 14, 12, 0.96));
    box-shadow:
      0 2px 7px rgba(0, 0, 0, 0.72),
      inset 0 1px rgba(255, 232, 164, 0.16);
    opacity: 0.96;
    pointer-events: auto;
    touch-action: none;
    transform: translateX(-50%);
    transition: bottom 220ms ease, opacity 160ms ease, background 160ms ease, border-color 160ms ease;
  }

  .mobile-hud-toggle-icon {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: #f0cf72;
    font-size: 0.78rem;
    line-height: 1;
    text-shadow: 0 1px 3px #000;
    transform: translateY(1px);
    transition: transform 200ms ease;
  }

  .mobile-hud-handle:active,
  .mobile-hud-handle:focus-visible {
    border-color: #ffe099;
    background: linear-gradient(180deg, rgba(92, 70, 29, 0.98), rgba(24, 20, 13, 0.98));
    opacity: 1;
  }

  .dungeon-hud.is-collapsed .dungeon-hud-frame {
    opacity: 0;
    transform: translate(-50%, calc(100% + 34px));
  }

  .dungeon-hud.is-collapsed .dungeon-hud-frame * {
    pointer-events: none !important;
  }

  .dungeon-hud.is-collapsed .mobile-hud-handle {
    bottom: max(7px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(60, 49, 28, 0.98), rgba(15, 14, 12, 0.98));
    opacity: 0.98;
  }

  .dungeon-hud.is-collapsed .mobile-hud-toggle-icon {
    transform: rotate(180deg) translateY(-1px);
  }

  body.mobile-hud-collapsed .viewport-wrap {
    --hud-notice-bottom: max(34px, calc(env(safe-area-inset-bottom) + 26px));
  }
  }
}

@media (pointer: coarse) and (any-hover: none) and (orientation: landscape) {
  html.mobile-touch-ui {
  body.mobile-portrait-mode .mobile-portrait-gate {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: grid;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    place-items: center;
    color: #f4e6c4;
    background: #050504;
    text-align: center;
  }

  .dungeon-hud {
    --hud-bottom: max(5px, env(safe-area-inset-bottom));
    --orb-size: 52px;
    --inventory-slot-size: 36px;
    --inventory-arrow-size: 32px;
  }

  .viewport-wrap {
    --vision-thought-bottom: max(112px, calc(env(safe-area-inset-bottom) + 102px));
  }

  .dungeon-hud-frame {
    min-height: calc(var(--orb-size) + 4px);
    padding: 2px 3px;
    border-width: 1px;
  }

  .dungeon-hud-frame::before,
  .dungeon-hud-frame::after {
    width: 10px;
    border-width: 1px;
  }

  .dungeon-hud-frame .resource-orb {
    width: var(--orb-size);
    height: var(--orb-size);
    border-width: 2px;
  }

  .dungeon-hud-frame .resource-orb::before {
    inset: 4px;
  }

  .dungeon-hud-frame .resource-orb::after {
    inset: 3px;
  }

  .dungeon-hud-frame .resource-orb strong {
    margin-top: -2px;
    font-size: 0.8rem;
  }

  .dungeon-hud-frame .resource-orb-mark {
    bottom: 8px;
    font-size: 0.4rem;
  }

  .dungeon-hud-frame .hud-action-bar {
    gap: 2px;
    padding: 2px;
  }

  .dungeon-hud-frame .inventory-panel {
    width: calc(var(--inventory-slot-size) * 5 + 8px);
  }

  .dungeon-hud-frame .inventory-list {
    grid-template-columns: repeat(5, var(--inventory-slot-size));
    gap: 2px;
  }

  .inventory-quick-slot {
    padding: 1px 1px 9px;
    border-radius: 3px;
  }

  .inventory-quick-name {
    right: 1px;
    bottom: 2px;
    left: 1px;
    font-size: 0.4rem;
  }

  .inventory-item-symbol {
    width: 24px;
    height: 22px;
  }

  .inventory-fist-symbol {
    font-size: 1.25rem;
  }

  .inventory-quick-slot .inventory-thumb {
    width: 25px;
    height: 22px;
  }

  .inventory-scroll {
    height: var(--inventory-slot-size);
    border-color: rgba(205, 169, 88, 0.72);
    font-size: 1.3rem;
    touch-action: manipulation;
  }

  .inventory-scroll:disabled {
    color: #81765e;
    opacity: 0.82;
  }

  .dungeon-hud-frame .spell-progress {
    bottom: -4px;
    min-width: 34px;
    padding: 1px 3px;
    font-size: 0.43rem;
  }

  .mobile-hud-handle {
    bottom: calc(var(--hud-bottom) + var(--orb-size) + 8px);
  }

  .viewport-wrap {
    --hud-notice-bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px));
  }
  }
}

@media (pointer: coarse) and (any-hover: none) and (orientation: portrait) {
  html.mobile-touch-ui {
  body.mobile-play-mode .mobile-landscape-gate {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: grid;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    place-items: center;
    color: #f4e6c4;
    background: #050504;
    text-align: center;
  }

  }
}

/* The Companion portrait and the unified HUD share one top edge at every responsive size. */
@media (max-width: 620px) {
  .view-overlay {
    --companion-hud-bottom: 12px;
    --companion-hud-orb-size: 66px;
    --companion-hud-frame-extra: 10px;
    --companion-avatar-size: 44px;
  }
}

@media (pointer: coarse) and (any-hover: none) {
  html.mobile-touch-ui {
  .view-overlay {
    --companion-hud-bottom: max(146px, calc(env(safe-area-inset-bottom) + 136px));
    --companion-hud-orb-size: 64px;
  }
  }
}

@media (pointer: coarse) and (any-hover: none) and (orientation: landscape) {
  html.mobile-touch-ui {
  .view-overlay {
    --companion-hud-bottom: max(5px, env(safe-area-inset-bottom));
    --companion-hud-orb-size: 52px;
    --companion-hud-frame-extra: 6px;
  }
  }
}
