:root {
  --ink: #080a09;
  --ash: #151a17;
  --stone: #242b27;
  --iron: #39413c;
  --bone: #d9d0bd;
  --muted-bone: #a49d90;
  --ember: #b56b35;
  --ember-bright: #e0a064;
  --ember-dark: #60361e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--bone);
  background: var(--ink);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 280px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  touch-action: none;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

button,
canvas {
  touch-action: none;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
canvas:focus-visible,
#joystick-base:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 4px;
}

[hidden],
.is-hidden {
  display: none !important;
}

#game-shell,
#game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
}

#game-shell {
  isolation: isolate;
  overflow: hidden;
  background: var(--ink);
}

#game-stage {
  overflow: hidden;
}

#gpu-world-layer {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

html[data-renderer="phaser-gpu"] #gpu-world-layer[data-state="active"] {
  opacity: 1;
}

.gpu-game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}

#game {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

html[data-renderer="phaser-gpu"] #game {
  z-index: 1;
  background: transparent;
}

html[data-renderer="phaser-gpu"][data-gpu-live="active"] #game {
  opacity: 0;
}

#gpu-overlay-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}

#world-lighting-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#world-overlay-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint style;
}

.world-overlay-label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: min(240px, 52vw);
  padding: 3px 7px;
  border: 1px solid rgba(216, 207, 187, 0.3);
  border-radius: 3px;
  color: #f5ead3;
  background: rgba(6, 8, 7, 0.82);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.42);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  will-change: transform;
}

.world-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  overflow: visible;
  pointer-events: none;
  will-change: transform;
}

.world-drop-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  height: 100%;
  transform: translateX(-50%);
  pointer-events: none;
  cursor: default;
}

.world-drop-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  max-width: min(240px, 52vw);
  padding: 0;
  border: 0;
  color: #fff;
  background: none;
  box-shadow: none;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
  pointer-events: none;
}

.world-overlay-label--emote {
  margin-top: -54px;
  border: 1px solid rgba(143, 201, 223, 0.48);
  border-radius: 18px 18px 18px 4px;
  color: #eefaff;
  background: linear-gradient(145deg, rgba(24, 43, 49, 0.96), rgba(11, 19, 22, 0.9));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
  animation: emote-bubble-arrive 360ms cubic-bezier(.2,.9,.25,1.15) both;
}

@keyframes emote-bubble-arrive {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(.72); }
  70% { opacity: 1; transform: translate(-50%, -3px) scale(1.06); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.world-overlay-label--npc {
  padding: 0;
  border: 0;
  color: #fff;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.world-overlay-label--player {
  padding: 0;
  border: 0;
  color: #fff;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.world-overlay-label--emote[data-emote-art] {
  display: flex;
  min-height: 40px;
  padding-left: 4px;
  align-items: center;
  gap: 5px;
}

.world-overlay-label--emote[data-emote-art]::before,
.emote-option[data-emote-art]::before {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  content: "";
  border-radius: 50%;
  background-image: url("/assets/adventure/emotes-atlas.png");
  background-repeat: no-repeat;
  background-size: 200% 200%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}

[data-emote-art="wave"]::before { background-position: 0 0; }
[data-emote-art="cheer"]::before { background-position: 100% 0; }
[data-emote-art="laugh"]::before { background-position: 0 100%; }
[data-emote-art="thanks"]::before { background-position: 100% 100%; }

.damage-vignette {
  position: absolute;
  z-index: 18;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}

.damage-vignette__hit,
.damage-vignette__pulse {
  position: absolute;
  inset: -8%;
  opacity: 0;
  pointer-events: none;
  transform: translateZ(0);
  will-change: opacity, transform;
}

.damage-vignette__hit {
  background: radial-gradient(
    ellipse at center,
    transparent 15%,
    rgba(124, 0, 0, 0.08) 42%,
    rgba(196, 8, 8, 0.48) 72%,
    rgba(102, 0, 0, 0.9) 100%
  );
}

.damage-vignette__hit.is-flashing {
  animation: damage-vignette-hit 560ms cubic-bezier(0.16, 0.78, 0.28, 1)
    both;
}

.damage-vignette__pulse {
  background: radial-gradient(
    ellipse at center,
    transparent 15%,
    rgba(110, 0, 0, 0.035) 38%,
    rgba(181, 0, 0, 0.4) 72%,
    rgba(88, 0, 0, 0.76) 100%
  );
}

.damage-vignette__pulse::after {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 43%,
    rgba(154, 0, 0, 0.1) 56%,
    rgba(210, 4, 4, 0.5) 78%,
    rgba(112, 0, 0, 0.82) 100%
  );
  content: "";
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

.damage-vignette__pulse.is-active {
  animation: damage-vignette-heartbeat
    var(--damage-vignette-beat-duration, 1000ms) ease-in-out infinite;
}

.damage-vignette__pulse.is-active::after {
  animation: damage-vignette-heartbeat-clarity
    var(--damage-vignette-beat-duration, 1000ms) ease-in-out infinite;
}

@keyframes damage-vignette-hit {
  0% {
    opacity: 0;
    transform: scale(1.08) translateZ(0);
  }
  12% {
    opacity: 0.92;
  }
  42% {
    opacity: 0.54;
    transform: scale(1) translateZ(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.97) translateZ(0);
  }
}

@keyframes damage-vignette-heartbeat {
  0%,
  100% {
    opacity: var(--damage-vignette-trough-opacity, 0.055);
    transform: scale(1.035) translateZ(0);
  }
  50% {
    opacity: var(--damage-vignette-peak-opacity, 0.38);
    transform: scale(var(--damage-vignette-peak-scale, 0.99)) translateZ(0);
  }
}

@keyframes damage-vignette-heartbeat-clarity {
  0%,
  100% {
    opacity: 0.08;
  }
  50% {
    opacity: var(--damage-vignette-sharp-opacity, 0.48);
  }
}

@media (prefers-reduced-motion: reduce) {
  .damage-vignette__hit.is-flashing {
    animation: damage-vignette-hit-reduced 300ms ease-out both;
  }

  .damage-vignette__pulse.is-active {
    animation-name: damage-vignette-heartbeat-reduced;
    transform: none;
  }
}

@keyframes damage-vignette-heartbeat-reduced {
  0%,
  100% {
    opacity: var(--damage-vignette-trough-opacity, 0.055);
  }
  50% {
    opacity: var(--damage-vignette-peak-opacity, 0.38);
  }
}

@keyframes damage-vignette-hit-reduced {
  0% {
    opacity: 0.65;
  }
  100% {
    opacity: 0;
  }
}

html[data-renderer="phaser-gpu"][data-gpu-live="active"] #gpu-overlay-layer {
  display: block;
}

.gpu-monster-health-bar {
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(236, 229, 209, 0.78);
  background: rgba(15, 12, 10, 0.86);
  contain: layout paint style;
  transform-origin: top left;
}

.gpu-monster-health-bar-fill {
  display: block;
  height: 100%;
}

.gpu-monster-health-bar--boss {
  border-color: rgba(245, 196, 90, 0.96);
  box-shadow: 0 0 7px rgba(168, 85, 247, 0.72);
}

#hud {
  position: absolute;
  z-index: 20;
  top: calc(var(--safe-top) + clamp(12px, 2.2vh, 24px));
  right: calc(var(--safe-right) + clamp(14px, 2.5vw, 32px));
  left: calc(var(--safe-left) + clamp(14px, 2.5vw, 32px));
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: start;
  pointer-events: none;
}

#logo {
  grid-column: 2;
  justify-self: center;
  display: flex;
  width: min(52vw, 360px);
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 3px 5px #000);
}

.logo-title {
  color: #e1d8c4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(19px, 3vw, 32px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: clamp(0.11em, 0.7vw, 0.22em);
  text-align: center;
  text-shadow:
    0 1px #000,
    0 0 14px rgba(201, 145, 87, 0.26);
  white-space: nowrap;
}

.logo-mark {
  width: clamp(7px, 1vw, 10px);
  height: clamp(7px, 1vw, 10px);
  margin-bottom: 6px;
  border: 1px solid var(--ember-bright);
  transform: rotate(45deg);
  background: #362114;
  box-shadow:
    0 0 0 2px rgba(17, 13, 10, 0.8),
    0 0 11px rgba(224, 160, 100, 0.48);
}

.logo-rule {
  width: min(72%, 220px);
  height: 1px;
  margin-top: 9px;
  background: linear-gradient(90deg, transparent, #84512e 18% 82%, transparent);
}

#server-version {
  max-width: 100%;
  margin-top: 5px;
  color: rgba(216, 207, 187, 0.72);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: clamp(8px, 1.2vw, 10px);
  letter-spacing: 0.08em;
  line-height: 1;
  overflow-wrap: anywhere;
  text-align: center;
  text-shadow: 0 1px 3px #000;
  white-space: normal;
}

#world-environment {
  max-width: 100%;
  margin-top: 4px;
  color: rgba(244, 218, 168, 0.86);
  font-size: clamp(9px, 1.25vw, 11px);
  letter-spacing: 0.06em;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

.icon-button {
  grid-column: 3;
  justify-self: end;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(216, 207, 187, 0.25);
  border-radius: 3px;
  color: var(--bone);
  background:
    linear-gradient(145deg, rgba(56, 62, 57, 0.72), rgba(13, 16, 14, 0.82));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 4px 16px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  pointer-events: auto;
}

.icon-button:hover {
  border-color: rgba(224, 160, 100, 0.58);
  color: #fff5df;
}

.icon-button:active {
  transform: translateY(1px);
  background: rgba(10, 13, 11, 0.9);
}

.fullscreen-icon {
  width: 17px;
  height: 17px;
  background:
    linear-gradient(var(--bone), var(--bone)) left top / 7px 1.5px no-repeat,
    linear-gradient(var(--bone), var(--bone)) left top / 1.5px 7px no-repeat,
    linear-gradient(var(--bone), var(--bone)) right top / 7px 1.5px no-repeat,
    linear-gradient(var(--bone), var(--bone)) right top / 1.5px 7px no-repeat,
    linear-gradient(var(--bone), var(--bone)) left bottom / 7px 1.5px no-repeat,
    linear-gradient(var(--bone), var(--bone)) left bottom / 1.5px 7px no-repeat,
    linear-gradient(var(--bone), var(--bone)) right bottom / 7px 1.5px no-repeat,
    linear-gradient(var(--bone), var(--bone)) right bottom / 1.5px 7px no-repeat;
}

#identity-badge {
  grid-column: 2;
  justify-self: start;
  align-self: end;
  display: flex;
  min-width: 0;
  margin-top: 42px;
  padding: 5px 9px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(216, 207, 187, 0.18);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(8, 10, 9, 0.72);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  pointer-events: auto;
}

#identity-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#identity-role {
  padding-left: 7px;
  border-left: 1px solid rgba(216, 207, 187, 0.22);
  color: var(--muted-bone);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.identity-logout-button {
  min-height: 28px;
  margin-left: 2px;
  padding: 3px 7px;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(3, 6, 4, 0.52);
  cursor: pointer;
  font-size: 10px;
  touch-action: manipulation;
}

.identity-logout-button:hover:not(:disabled),
.identity-logout-button:focus-visible {
  border-color: rgba(224, 160, 100, 0.62);
  color: #fff0d5;
  outline: 0;
}

.identity-logout-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

#loading {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  padding:
    calc(var(--safe-top) + 24px)
    calc(var(--safe-right) + 24px)
    calc(var(--safe-bottom) + 24px)
    calc(var(--safe-left) + 24px);
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(25, 31, 27, 0.68), rgba(5, 7, 6, 0.92) 76%);
  backdrop-filter: blur(3px);
  transition:
    opacity 280ms ease,
    visibility 280ms ease;
}

#loading.is-ready {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.login-panel {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  padding:
    calc(var(--safe-top) + 24px)
    calc(var(--safe-right) + 24px)
    calc(var(--safe-bottom) + 24px)
    calc(var(--safe-left) + 24px);
  place-items: center;
  overflow-y: auto;
  background:
    radial-gradient(circle at center, rgba(30, 37, 32, 0.82), rgba(5, 7, 6, 0.97) 76%);
  backdrop-filter: blur(5px);
}

.login-card {
  display: flex;
  width: min(88vw, 390px);
  padding: clamp(26px, 5vw, 42px);
  flex-direction: column;
  align-items: stretch;
  border: 1px solid rgba(224, 160, 100, 0.38);
  border-radius: 5px;
  background:
    linear-gradient(155deg, rgba(42, 48, 44, 0.97), rgba(9, 12, 10, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 24px 64px rgba(0, 0, 0, 0.58);
}

.login-card .loading-sigil {
  align-self: center;
  margin-bottom: 20px;
}

.login-card h2 {
  margin: 0;
  color: #e1d8c4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 7vw, 38px);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-align: center;
  text-indent: 0.12em;
}

.login-card p {
  margin: 12px 0 20px;
  color: var(--muted-bone);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--bone);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  height: 44px;
  padding: 8px 11px;
  border: 1px solid rgba(216, 207, 187, 0.26);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(3, 6, 4, 0.76);
  font: inherit;
  user-select: text;
}

.login-card input:focus {
  border-color: var(--ember-bright);
  outline: 1px solid rgba(224, 160, 100, 0.35);
}

.login-card button,
.google-login-button {
  display: flex;
  min-height: 44px;
  margin-top: 18px;
  padding: 8px 14px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(224, 160, 100, 0.52);
  border-radius: 3px;
  color: #fff0d5;
  background: linear-gradient(180deg, rgba(119, 68, 37, 0.95), rgba(77, 42, 24, 0.95));
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  touch-action: manipulation;
}

.login-card button:hover,
.login-card button:focus-visible,
.google-login-button:hover,
.google-login-button:focus-visible {
  border-color: var(--ember-bright);
  outline: 0;
  background: linear-gradient(180deg, rgba(141, 82, 45, 0.98), rgba(88, 48, 27, 0.98));
}

.login-card button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.login-card .secondary-login-button {
  min-height: 38px;
  margin-top: 10px;
  border-color: rgba(216, 207, 187, 0.24);
  color: var(--muted-bone);
  background: rgba(3, 6, 4, 0.42);
  font-size: 12px;
}

.google-login-button {
  color: #24313a;
  background: #f6f8fb;
  font-weight: 700;
}

.google-login-button:hover,
.google-login-button:focus-visible {
  border-color: #fff;
  color: #172127;
  background: #fff;
}

.google-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #4285f4;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(23, 33, 39, 0.14);
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.login-card .selected-character {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(3, 6, 4, 0.5);
  font-weight: 700;
}

.character-roster {
  display: grid;
  gap: 0.45rem;
  width: 100%;
}

.character-roster button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 1px solid rgba(224, 194, 121, 0.32);
  background: rgba(15, 12, 10, 0.82);
  color: #eee7da;
}

.character-roster button[aria-pressed="true"] {
  border-color: #e7c46b;
  box-shadow: 0 0 0 1px rgba(231, 196, 107, 0.42), 0 0 14px rgba(231, 196, 107, 0.2);
  color: #fff6cf;
}

#party-hud {
  position: fixed;
  z-index: 45;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  pointer-events: none;
}

.party-hud-member {
  display: grid;
  min-width: 0;
  padding: 6px 7px;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.7fr);
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(174, 162, 139, 0.38);
  background: rgba(9, 9, 12, 0.76);
  color: #f3eee5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

.party-hud-member.is-controlled {
  border-color: #f1ce68;
  background: rgba(42, 34, 16, 0.9);
  box-shadow: inset 0 0 0 1px rgba(255, 226, 129, 0.45), 0 0 12px rgba(255, 204, 72, 0.3);
}

.party-hud-identity {
  min-width: 0;
}

.party-hud-name {
  display: block;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-hud-levels {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #d9cfbd;
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-hud-bars {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.party-hud-bar {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.72);
}

.party-hud-bar > span {
  display: block;
  height: 100%;
  width: var(--party-value, 0%);
  transition: width 120ms linear;
}

.party-hud-bar > small {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: #fff;
  font-size: 8px;
  font-style: normal;
  line-height: 12px;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.party-hud-bar.hp > span { background: #b73538; }
.party-hud-bar.mp > span { background: #356cc1; }
.party-hud-bar.exp > span { background: #c39d35; }

.character-automation {
  margin-top: 0.75rem;
}

#character-automation-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.8rem;
}

#character-automation-controls label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

#login-error {
  margin: 10px 0 0;
  color: #f0a58d;
  font-weight: 700;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

[hidden] {
  display: none !important;
}

.loading-panel {
  display: flex;
  width: min(84vw, 420px);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.loading-sigil {
  position: relative;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  border: 1px solid rgba(224, 160, 100, 0.22);
  transform: rotate(45deg);
}

.loading-sigil::before,
.loading-sigil::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--ember);
  animation: sigil-pulse 1.7s ease-in-out infinite;
}

.loading-sigil::after {
  inset: 15px;
  background: var(--ember-bright);
  box-shadow: 0 0 18px rgba(224, 160, 100, 0.46);
  animation-delay: -0.45s;
}

.loading-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 5vw, 38px);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  text-shadow: 0 2px 6px #000;
}

#status {
  min-height: 1.5em;
  margin-top: 13px;
  color: var(--muted-bone);
  font-size: clamp(12px, 2vw, 14px);
  letter-spacing: 0.04em;
}

.loading-track {
  position: relative;
  width: min(70vw, 280px);
  height: 2px;
  margin-top: 24px;
  overflow: hidden;
  background: rgba(216, 207, 187, 0.12);
}

.loading-track-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 36%;
  background: linear-gradient(90deg, transparent, var(--ember-bright), transparent);
  animation: loading-sweep 1.45s ease-in-out infinite;
}

#spell-hud {
  position: absolute;
  z-index: 23;
  bottom: calc(var(--safe-bottom) + 64px);
  left: 50%;
  display: grid;
  width: min(760px, calc(100vw - 40px));
  transform: translateX(-50%);
  gap: 6px;
  pointer-events: none;
}

.spell-hud-summary {
  display: flex;
  min-height: 22px;
  padding: 3px 8px;
  justify-self: center;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(216, 207, 187, 0.12);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(6, 8, 7, 0.72);
  font-size: 11px;
  pointer-events: auto;
}

#selected-skill-label {
  max-width: 180px;
  overflow: hidden;
  color: #f1ce85;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#magic-mana {
  color: #8dc9df;
  font-weight: 700;
  white-space: nowrap;
}

#player-health {
  color: #ef8f82;
  font-weight: 700;
  white-space: nowrap;
}

#magic-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#magic-status[data-state="error"] {
  color: #ffab91;
}

#magic-status[data-state="success"] {
  color: #a9e3c2;
}

#skill-bar {
  display: none;
  min-width: 0;
  padding: 5px;
  overflow-x: auto;
  justify-content: flex-start;
  gap: 5px;
  border: 1px solid rgba(216, 207, 187, 0.12);
  border-radius: 4px;
  background: rgba(6, 8, 7, 0.7);
  box-shadow: 0 5px 22px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  scrollbar-width: thin;
}

#touch-skill-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, 76px));
  gap: 8px;
  align-self: center;
  pointer-events: auto;
}

#touch-skill-buttons button {
  min-height: 52px;
  border: 1px solid rgba(113, 184, 209, 0.45);
  border-radius: 50%;
  color: #f4fbff;
  background: rgba(22, 42, 47, 0.88);
  font: 700 10px/1.15 inherit;
}

#touch-skill-buttons button:disabled { opacity: 0.36; }

.skill-button {
  position: relative;
  display: grid;
  min-width: 86px;
  min-height: 48px;
  padding: 5px 8px;
  flex: 0 0 auto;
  place-items: center;
  gap: 2px;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 3px;
  color: var(--bone);
  background:
    radial-gradient(circle at 50% 0, rgba(72, 132, 153, 0.2), transparent 62%),
    rgba(21, 28, 27, 0.94);
  cursor: pointer;
  font: inherit;
}

.skill-button::before {
  content: attr(data-hotkey);
  position: absolute;
  top: 4px;
  left: 5px;
  min-width: 15px;
  padding: 1px 3px;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 2px;
  color: rgba(236, 227, 207, 0.72);
  background: rgba(5, 8, 7, 0.66);
  font: 700 9px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-align: center;
}

.skill-button:hover:not(:disabled),
.skill-button:focus-visible,
.skill-button[aria-pressed="true"] {
  border-color: #71b8d1;
  color: #f4fbff;
  outline: 0;
  background: rgba(37, 71, 78, 0.95);
}

.skill-button[aria-pressed="true"] {
  box-shadow:
    inset 0 0 0 1px rgba(113, 184, 209, 0.35),
    0 0 12px rgba(80, 161, 190, 0.2);
}

.skill-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.48;
}

.skill-button[data-empty="true"] {
  border-style: dashed;
  background: rgba(13, 17, 16, 0.82);
}

.skill-button-name {
  overflow: hidden;
  max-width: 100%;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-button-detail {
  color: var(--muted-bone);
  font-size: 10px;
  white-space: nowrap;
}

#spell-target-panel,
#death-panel {
  position: absolute;
  z-index: 25;
  left: 50%;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  padding: 13px;
  transform: translateX(-50%);
  gap: 9px;
  border: 1px solid rgba(113, 184, 209, 0.46);
  border-radius: 5px;
  color: var(--bone);
  background:
    linear-gradient(155deg, rgba(36, 49, 48, 0.98), rgba(8, 12, 11, 0.98));
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.52);
  pointer-events: auto;
}

#spell-target-panel {
  bottom: calc(var(--safe-bottom) + 130px);
}

#spell-target-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#spell-target-panel p,
#death-panel p {
  margin: 0;
  color: var(--muted-bone);
  font-size: 11px;
  line-height: 1.4;
}

#spell-target-panel button,
#death-panel button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(216, 207, 187, 0.24);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(29, 42, 40, 0.96);
  cursor: pointer;
  font: inherit;
}

#spell-target-panel button:hover:not(:disabled),
#spell-target-panel button:focus-visible,
#death-panel button:hover:not(:disabled),
#death-panel button:focus-visible {
  border-color: #71b8d1;
  color: #fff;
  outline: 0;
}

#spell-target-list {
  display: grid;
  max-height: min(36vh, 230px);
  overflow: auto;
  gap: 5px;
}

#spell-target-list:empty {
  display: none;
}

.spell-target-option {
  display: flex;
  width: 100%;
  justify-content: space-between;
  text-align: left;
}

.spell-target-option span:last-child {
  color: var(--muted-bone);
  font-size: 10px;
}

#death-panel {
  top: 50%;
  bottom: auto;
  place-items: center;
  transform: translate(-50%, -50%);
  border-color: rgba(205, 111, 90, 0.5);
  text-align: center;
}

#system-menu {
  position: absolute;
  z-index: 24;
  top: calc(var(--safe-top) + clamp(70px, 10vh, 92px));
  right: calc(var(--safe-right) + clamp(14px, 2.5vw, 32px));
  display: grid;
  width: 58px;
  gap: 5px;
  pointer-events: auto;
}

#system-menu button {
  position: relative;
  display: grid;
  min-height: 52px;
  padding: 5px 3px 4px;
  place-items: center;
  gap: 1px;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 4px;
  color: var(--bone);
  background:
    radial-gradient(circle at 50% 0, rgba(181, 107, 53, 0.16), transparent 62%),
    rgba(10, 14, 12, 0.84);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  font: inherit;
  backdrop-filter: blur(4px);
}

#system-menu button > span:first-child {
  color: var(--ember-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1;
}

#system-emotes-button > span:first-child {
  width: 24px;
  height: 24px;
  overflow: hidden;
  border-radius: 50%;
  color: transparent;
  background: url("/assets/adventure/emotes-atlas.png") 0 0 / 200% 200%
    no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.62));
  font-size: 0;
}

#system-menu button > span:nth-child(2) {
  font-size: 9px;
  font-weight: 700;
}

#system-menu button kbd {
  position: absolute;
  top: 2px;
  right: 3px;
  color: rgba(216, 207, 187, 0.56);
  font: 700 8px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
}

#system-menu button:hover,
#system-menu button:focus-visible,
#system-menu button[aria-expanded="true"] {
  border-color: rgba(224, 160, 100, 0.68);
  color: #fff5df;
  outline: 0;
  background: rgba(70, 43, 27, 0.92);
}

#system-panel-backdrop {
  position: absolute;
  z-index: 26;
  inset: 0;
  background: rgba(2, 4, 3, 0.58);
  pointer-events: auto;
  backdrop-filter: blur(2px);
}

.system-panel {
  position: absolute;
  z-index: 27;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(560px, calc(100vw - var(--safe-left) - var(--safe-right) - 32px));
  max-height: min(78vh, 720px);
  padding: 16px;
  overflow: auto;
  transform: translate(-50%, -50%);
  gap: 13px;
  border: 1px solid rgba(224, 160, 100, 0.46);
  border-radius: 6px;
  color: var(--bone);
  background:
    radial-gradient(circle at 50% 0, rgba(124, 75, 42, 0.2), transparent 38%),
    linear-gradient(150deg, rgba(40, 46, 42, 0.98), rgba(7, 10, 8, 0.99));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 22px 70px rgba(0, 0, 0, 0.72);
  pointer-events: auto;
  user-select: none;
}

.system-panel:focus {
  outline: 1px solid rgba(224, 160, 100, 0.34);
  outline-offset: -4px;
}

.system-panel--wide {
  width: min(920px, calc(100vw - var(--safe-left) - var(--safe-right) - 32px));
}

.system-panel--compact {
  width: min(420px, calc(100vw - var(--safe-left) - var(--safe-right) - 32px));
}

#inventory-panel {
  overflow: hidden;
}

.system-panel-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(216, 207, 187, 0.14);
  padding-bottom: 11px;
}

.system-panel-header > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.system-panel-header > div > span {
  color: rgba(224, 160, 100, 0.76);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.system-panel h2,
.system-panel h3,
.system-panel p {
  margin: 0;
}

.system-panel h2 {
  overflow: hidden;
  color: #f0e4ca;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-panel h3 {
  color: #d9cfbb;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.system-panel button {
  border: 1px solid rgba(216, 207, 187, 0.22);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(28, 37, 33, 0.96);
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}

.system-panel button:hover:not(:disabled),
.system-panel button:focus-visible {
  border-color: rgba(224, 160, 100, 0.72);
  color: #fff4dc;
  outline: 0;
  background: rgba(73, 48, 31, 0.96);
}

.system-panel button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55);
  opacity: 0.46;
}

.system-panel-close {
  width: 36px;
  height: 36px;
  padding: 0;
  flex: 0 0 auto;
  font-size: 22px !important;
  line-height: 1;
}

.system-summary-row,
.character-summary {
  display: flex;
  min-width: 0;
  padding: 8px 10px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(216, 207, 187, 0.13);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(3, 7, 5, 0.48);
  font-size: 12px;
}

.inventory-section-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.inventory-section-tabs button {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 11px;
}

.inventory-section-tabs button[aria-pressed="true"] {
  border-color: var(--ember-bright);
  color: #fff4dc;
  background: rgba(73, 48, 31, 0.96);
  box-shadow: inset 0 0 12px rgba(224, 160, 100, 0.16);
}

#inventory-panel[data-section-tabs="true"] {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

#inventory-panel[data-section-tabs="true"] .inventory-layout {
  width: min(100%, 340px);
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: none;
  justify-self: center;
}

#inventory-panel[data-section-tabs="true"] .inventory-layout > .system-section {
  grid-area: auto;
  overflow: hidden;
}

#inventory-gold,
.shop-gold {
  color: #eec66f;
}

.shop-repair-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shop-repair-row[hidden] {
  display: none;
}

#shop-repair-cost {
  color: #eec66f;
  font-size: 12px;
}

#inventory-gold {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

#inventory-gold::before {
  width: 25px;
  height: 25px;
  content: "";
  background: url("/assets/adventure/gold-pile.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
}

.inventory-layout {
  display: grid;
  min-height: 360px;
  grid-template-columns: minmax(270px, 1fr) minmax(270px, 1fr) minmax(210px, 0.8fr);
  grid-template-areas:
    "bag shared equipment"
    "bag shared detail";
  gap: 12px;
}

.inventory-layout > .system-section:nth-child(1) {
  grid-area: bag;
}

.inventory-layout > .system-section:nth-child(2) {
  grid-area: shared;
}

.inventory-layout > .system-section:nth-child(3) {
  grid-area: equipment;
}

.inventory-layout > .system-section:nth-child(4) {
  grid-area: detail;
}

.system-section {
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 11px;
  align-content: start;
  gap: 9px;
  border: 1px solid rgba(216, 207, 187, 0.13);
  border-radius: 4px;
  background: rgba(4, 8, 6, 0.46);
}

.inventory-section-heading {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-pagination {
  display: grid;
  grid-template-columns: repeat(2, 24px) minmax(42px, auto) repeat(2, 24px);
  align-items: center;
  gap: 3px;
}

.item-pagination[hidden] {
  display: none;
}

.item-pagination button {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.item-pagination output {
  color: #eec66f;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.item-grid {
  display: grid;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
}

.item-slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  padding: 5px;
  overflow: hidden;
  grid-template-rows: 34px minmax(2.6em, auto);
  place-items: start center;
  background:
    radial-gradient(circle at 50% 20%, rgba(105, 121, 108, 0.16), transparent 58%),
    rgba(12, 17, 14, 0.96) !important;
  font-size: 10px !important;
  line-height: 1.3;
}

.item-slot[data-empty="true"] {
  border-style: dashed;
  color: rgba(164, 157, 144, 0.35);
}

.item-slot[data-empty="true"] .item-slot-name {
  grid-row: 1 / span 2;
  align-self: center;
}

.item-slot[aria-pressed="true"] {
  border-color: var(--ember-bright);
  box-shadow: inset 0 0 14px rgba(224, 160, 100, 0.16);
}

.item-slot-art {
  width: 34px;
  height: 34px;
  background: var(--item-art-image) center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.68));
}

.item-slot-name {
  display: -webkit-box;
  min-width: 0;
  max-width: 100%;
  min-height: 2.6em;
  margin-top: 3px;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-slot-quantity {
  position: absolute;
  z-index: 1;
  top: 27px;
  left: calc(50% + 3px);
  min-width: 17px;
  padding: 0 3px;
  border: 1px solid rgba(238, 198, 111, 0.62);
  border-radius: 7px;
  color: #fff8e8;
  background: rgba(4, 7, 5, 0.9);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.88);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}

.equipment-grid,
.shop-list,
.skills-list,
.stats-list {
  display: grid;
  min-height: 0;
  overflow: auto;
  gap: 6px;
  scrollbar-width: thin;
}

.shop-inventory-group {
  display: grid;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgba(216, 207, 187, 0.13);
}

.shop-inventory-group > h4 {
  margin: 0;
  color: #eec66f;
  font-size: 12px;
}

.equipment-slot,
.shop-item {
  min-height: 38px;
  padding: 6px 9px;
  text-align: left;
}

.equipment-slot[data-item-art],
.shop-item[data-item-art] {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
}

.equipment-slot[data-item-art]::before,
.shop-item[data-item-art]::before {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  content: "";
  background: var(--item-art-image) center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.68));
}

.equipment-slot[aria-pressed="true"] {
  border-color: var(--ember-bright);
  color: #fff4dc;
  box-shadow: inset 0 0 14px rgba(224, 160, 100, 0.15);
}

.item-hover-tooltip {
  position: fixed;
  z-index: 1200;
  width: max-content;
  max-width: min(340px, calc(100vw - 24px));
  padding: 10px 12px;
  pointer-events: none;
  border: 1px solid rgba(224, 160, 100, 0.62);
  border-radius: 4px;
  color: #fff8e8;
  background: rgba(5, 8, 6, 0.97);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62);
  font-size: 11px;
  line-height: 1.5;
}

.item-tooltip-title {
  display: block;
  color: #fff4dc;
  font-size: 13px;
}

.item-tooltip-description {
  margin: 5px 0 0;
  color: var(--muted-bone);
}

.item-tooltip-section {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(224, 160, 100, 0.22);
}

.item-tooltip-section h4 {
  margin: 0 0 4px;
  color: #e8c58a;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.item-tooltip-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 2px;
  list-style: none;
}

.item-tooltip-requirements li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  padding: 2px 4px;
  gap: 3px;
  border-left: 2px solid transparent;
  border-radius: 2px;
}

.item-tooltip-requirements li[data-met="true"] {
  color: #9ed4b1;
}

.item-tooltip-requirements li[data-met="false"] {
  border-left-color: #ff6c57;
  color: #ffe1da;
  background: rgba(143, 34, 22, 0.5);
  font-weight: 700;
}

.item-tooltip-requirement-icon {
  color: currentColor;
  text-align: center;
}

.item-detail {
  grid-template-rows: auto auto auto auto 1fr auto;
}

.item-detail > p,
.system-panel-help,
.empty-system-list {
  color: var(--muted-bone);
  font-size: 11px;
  line-height: 1.5;
}

.requirement-list {
  display: grid;
  margin: 0;
  padding: 8px 8px 8px 25px;
  gap: 4px;
  border: 1px solid rgba(216, 207, 187, 0.1);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(0, 0, 0, 0.16);
  font-size: 10px;
}

.item-property-list {
  display: grid;
  margin: 0;
  padding: 8px 8px 8px 25px;
  gap: 4px;
  border: 1px solid rgba(224, 160, 100, 0.22);
  border-radius: 3px;
  color: #f0d5a4;
  background: rgba(73, 48, 31, 0.2);
  font-size: 10px;
}

.requirement-list li[data-met="true"] {
  color: #9ed4b1;
}

.requirement-list li[data-met="false"] {
  color: #ef9b85;
}

.system-actions {
  display: flex;
  align-self: end;
  gap: 7px;
}

.system-actions button {
  min-height: 36px;
  padding: 6px 12px;
  flex: 1 1 0;
}

.system-status {
  min-height: 1.4em;
  color: var(--muted-bone);
  font-size: 10px;
}

.system-status[data-state="error"] {
  color: #f0a58d;
}

.system-status[data-state="pending"] {
  color: #e7c984;
}

.character-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

#character-experience {
  grid-column: 1 / -1;
}

.profession-summary {
  display: grid;
  padding: 7px 9px;
  gap: 4px;
  border: 1px solid rgba(216, 207, 187, 0.12);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(3, 7, 5, 0.38);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stat-points {
  color: #eec66f;
  font-size: 12px;
  font-weight: 700;
}

.stat-row {
  display: grid;
  min-height: 42px;
  padding: 6px 8px;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(216, 207, 187, 0.12);
  border-radius: 3px;
  background: rgba(3, 7, 5, 0.46);
  font-size: 12px;
}

.stat-add {
  width: 30px;
  height: 28px;
  padding: 0;
  color: var(--ember-bright) !important;
  font-weight: 800 !important;
}

.derived-stats-section {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.derived-stats-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.derived-stat {
  display: flex;
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.derived-stat strong {
  flex: 0 0 auto;
  color: #f3d28e;
  font-variant-numeric: tabular-nums;
}

.derived-stat[aria-pressed="true"] {
  border-color: rgba(224, 160, 100, 0.72);
  color: #fff4dc;
  background: rgba(73, 48, 31, 0.96);
}

.derived-stat-tooltip {
  display: grid;
  min-height: 68px;
  padding: 9px 10px;
  gap: 5px;
  border: 1px solid rgba(216, 207, 187, 0.16);
  border-radius: 3px;
  color: var(--muted-bone);
  background: rgba(0, 0, 0, 0.22);
  font-size: 10px;
  line-height: 1.45;
}

.derived-stat-tooltip p {
  margin: 0;
  overflow-wrap: anywhere;
}

#derived-stat-formula {
  color: #e7dcc4;
}

#derived-stat-calculation {
  color: #eec66f;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.skill-card {
  display: grid;
  padding: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  border: 1px solid rgba(216, 207, 187, 0.14);
  border-radius: 4px;
  background:
    radial-gradient(circle at 0 50%, rgba(87, 142, 159, 0.13), transparent 42%),
    rgba(4, 9, 8, 0.55);
}

.skill-card[data-item-art] {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.skill-card[data-item-art]::before {
  width: 40px;
  height: 40px;
  grid-column: 1;
  grid-row: 1 / span 2;
  content: "";
  background: var(--item-art-image) center / contain no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.72));
}

.skill-card[data-item-art] > strong {
  grid-column: 2;
}

.skill-card[data-item-art] > span {
  grid-column: 3;
}

.skill-card[data-item-art] > p {
  grid-column: 2 / -1;
}

.skill-card > span {
  color: #93cadc;
  font-size: 11px;
  font-weight: 700;
}

.skill-card > p {
  grid-column: 1 / -1;
  color: var(--muted-bone);
  font-size: 10px;
  line-height: 1.4;
}

.skill-card[data-learned="false"] {
  filter: grayscale(0.7);
  opacity: 0.64;
}

.skill-hotbar-assignment {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) minmax(116px, auto);
  align-items: center;
  gap: 10px;
  color: var(--muted-bone);
  font-size: 10px;
}

.skill-hotbar-assignment select {
  min-height: 34px;
  padding: 5px 26px 5px 8px;
  border: 1px solid rgba(216, 207, 187, 0.24);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(21, 29, 26, 0.98);
  font: inherit;
}

.skill-hotbar-assignment select:focus-visible {
  border-color: rgba(224, 160, 100, 0.72);
  outline: 1px solid rgba(224, 160, 100, 0.45);
}

.character-class-choice {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(216, 207, 187, 0.18);
  background: rgba(8, 12, 11, 0.58);
}

.character-class-choice > span {
  display: block;
  margin-bottom: 8px;
  color: #d9caa7;
  font-weight: 700;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audio-settings {
  display: grid;
  gap: 10px;
}

.audio-settings > label {
  display: grid;
  min-width: 0;
  grid-template-columns: 92px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  color: #d9cfbb;
  font-size: 12px;
  font-weight: 700;
}

.audio-settings input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--ember-bright);
  cursor: pointer;
}

.audio-settings output {
  color: #f0e4ca;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.audio-settings > .audio-settings-mute {
  grid-template-columns: 1fr auto;
  border-top: 1px solid rgba(216, 207, 187, 0.12);
  padding-top: 10px;
}

.audio-settings-mute input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ember-bright);
  cursor: pointer;
}

.presentation-settings {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(216, 207, 187, 0.12);
}

.presentation-settings > label {
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr minmax(120px, 0.7fr);
  align-items: center;
  gap: 10px;
  color: #d9cfbb;
  font-size: 12px;
  font-weight: 700;
}

.presentation-settings select {
  min-height: 34px;
  padding: 5px 28px 5px 9px;
  border: 1px solid rgba(216, 207, 187, 0.24);
  border-radius: 3px;
  color: var(--bone);
  background: rgba(21, 29, 26, 0.98);
  font: inherit;
  cursor: pointer;
}

.presentation-settings select:focus-visible {
  border-color: rgba(224, 160, 100, 0.72);
  outline: 1px solid rgba(224, 160, 100, 0.45);
}

.presentation-settings-toggle input {
  justify-self: end;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ember-bright);
  cursor: pointer;
}

.settings-actions {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.settings-actions > button {
  min-height: 34px;
  padding: 6px 10px;
}

.settings-actions .system-status {
  text-align: right;
}

.help-control-list {
  display: grid;
  margin: 0;
  gap: 8px;
}

.help-control-list > div {
  display: grid;
  padding-bottom: 8px;
  grid-template-columns: minmax(118px, 0.7fr) minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border-bottom: 1px solid rgba(216, 207, 187, 0.1);
}

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

.help-control-list dt,
.help-control-list dd {
  margin: 0;
}

.help-control-list dd {
  color: var(--muted-bone);
  font-size: 11px;
  line-height: 1.45;
}

.help-control-list kbd {
  display: inline-block;
  margin: 1px 2px 1px 0;
  padding: 3px 5px;
  border: 1px solid rgba(216, 207, 187, 0.25);
  border-bottom-color: rgba(216, 207, 187, 0.42);
  border-radius: 2px;
  color: #f0e4ca;
  background: rgba(34, 42, 38, 0.9);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.34);
  font: 700 9px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: nowrap;
}

.emote-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.emote-option {
  display: flex;
  min-height: 54px;
  padding: 8px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
}

.shop-layout {
  display: grid;
  min-height: 300px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#interaction-prompt {
  position: absolute;
  z-index: 25;
  bottom: calc(var(--safe-bottom) + 142px);
  left: 50%;
  display: flex;
  max-width: min(520px, calc(100vw - 32px));
  padding: 7px 8px 7px 12px;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(224, 160, 100, 0.48);
  border-radius: 4px;
  transform: translateX(-50%);
  color: var(--bone);
  background: rgba(9, 13, 11, 0.9);
  box-shadow: 0 7px 26px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}

#interaction-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#interaction-action {
  min-height: 32px;
  padding: 5px 10px;
  flex: 0 0 auto;
  border: 1px solid rgba(224, 160, 100, 0.5);
  border-radius: 3px;
  color: #fff0d5;
  background: rgba(89, 51, 29, 0.96);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.system-world-status {
  position: absolute;
  z-index: 25;
  top: calc(var(--safe-top) + clamp(118px, 18vh, 154px));
  left: 50%;
  max-width: min(560px, calc(100vw - var(--safe-left) - var(--safe-right) - 32px));
  margin: 0;
  padding: 7px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(216, 207, 187, 0.28);
  border-radius: 4px;
  color: var(--bone);
  background: rgba(9, 13, 11, 0.92);
  box-shadow: 0 7px 26px rgba(0, 0, 0, 0.5);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.system-world-status[data-state="pending"] {
  border-color: rgba(231, 201, 132, 0.5);
  color: #f2d997;
}

.system-world-status[data-state="error"] {
  border-color: rgba(240, 165, 141, 0.58);
  color: #ffc0ad;
}

#town-revive-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#touch-controls {
  position: absolute;
  z-index: 22;
  right: calc(var(--safe-right) + clamp(20px, 5vw, 58px));
  bottom: calc(var(--safe-bottom) + clamp(20px, 5vh, 52px));
  left: calc(var(--safe-left) + clamp(20px, 5vw, 58px));
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

#joystick-base {
  position: relative;
  width: clamp(112px, 18vw, 148px);
  height: clamp(112px, 18vw, 148px);
  flex: 0 0 auto;
  border: 1px solid rgba(216, 207, 187, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 39%, rgba(213, 203, 183, 0.05) 40% 41%, transparent 42%),
    radial-gradient(circle, rgba(47, 54, 49, 0.52), rgba(10, 13, 11, 0.66));
  box-shadow:
    inset 0 0 22px rgba(0, 0, 0, 0.38),
    0 8px 28px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

#joystick-base::before,
#joystick-base::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  opacity: 0.2;
  background: var(--bone);
  transform: translate(-50%, -50%);
}

#joystick-base::before {
  width: 54%;
  height: 1px;
}

#joystick-base::after {
  width: 1px;
  height: 54%;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 45%;
  height: 45%;
  border: 1px solid rgba(226, 216, 195, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 38% 33%, rgba(131, 137, 126, 0.32), transparent 42%),
    linear-gradient(145deg, #39403b, #171b18);
  box-shadow:
    inset 0 -5px 12px rgba(0, 0, 0, 0.32),
    0 5px 12px rgba(0, 0, 0, 0.42);
  will-change: transform;
}

#attack-button {
  position: relative;
  display: grid;
  width: clamp(92px, 15vw, 120px);
  height: clamp(92px, 15vw, 120px);
  padding: 0;
  place-items: center;
  border: 1px solid rgba(224, 160, 100, 0.48);
  border-radius: 50%;
  color: #eadfc9;
  background:
    radial-gradient(circle at 38% 32%, rgba(183, 106, 52, 0.34), transparent 40%),
    linear-gradient(145deg, rgba(83, 48, 28, 0.94), rgba(27, 21, 16, 0.96));
  box-shadow:
    inset 0 0 0 5px rgba(5, 7, 6, 0.23),
    inset 0 -9px 15px rgba(0, 0, 0, 0.28),
    0 8px 28px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
}

#attack-button::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(229, 184, 135, 0.16);
  border-radius: 50%;
}

#attack-button:active,
#attack-button.is-active {
  transform: scale(0.94);
  border-color: var(--ember-bright);
  background:
    radial-gradient(circle at center, rgba(224, 160, 100, 0.34), transparent 52%),
    #3e2519;
  box-shadow:
    inset 0 4px 18px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(181, 107, 53, 0.26);
}

.attack-glyph {
  position: absolute;
  top: 28%;
  width: 37%;
  height: 4px;
  border-radius: 1px;
  transform: rotate(-43deg);
  background: linear-gradient(90deg, #756d60 0 18%, #e7dcc4 19% 78%, #98704e 79%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.attack-glyph::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 18%;
  width: 3px;
  height: 12px;
  background: #9e683c;
}

.attack-label {
  align-self: end;
  margin-bottom: 18%;
  font-size: clamp(10px, 1.8vw, 13px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.noscript-message {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  left: 20px;
  margin: 0;
  padding: 16px;
  border: 1px solid #83502e;
  color: var(--bone);
  background: #15110e;
  text-align: center;
}

@keyframes sigil-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.74);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes loading-sweep {
  0% {
    left: -38%;
  }

  100% {
    left: 102%;
  }
}

@media (hover: none), (pointer: coarse) {
  #game {
    cursor: default;
  }

  #touch-controls {
    display: flex;
  }

  #spell-hud {
    bottom: calc(var(--safe-bottom) + clamp(146px, 23vh, 190px));
    width: calc(100vw - 24px);
  }

  #skill-bar {
    justify-content: flex-start;
  }

  #spell-target-panel {
    bottom: calc(var(--safe-bottom) + clamp(205px, 31vh, 258px));
  }

  #system-menu {
    top: calc(var(--safe-top) + 66px);
    right: calc(var(--safe-right) + 10px);
    width: 52px;
  }

  #system-menu button {
    min-height: 48px;
  }

  #system-menu button kbd {
    display: none;
  }

  #interaction-prompt {
    bottom: calc(var(--safe-bottom) + clamp(200px, 30vh, 248px));
  }
}

@media (orientation: portrait) {
  #hud {
    top: calc(var(--safe-top) + 12px);
  }

  #logo {
    width: min(60vw, 300px);
  }

  .logo-title {
    font-size: clamp(18px, 6vw, 27px);
    letter-spacing: 0.1em;
  }

  #touch-controls {
    right: calc(var(--safe-right) + clamp(16px, 5vw, 28px));
    bottom: calc(var(--safe-bottom) + clamp(22px, 4vh, 40px));
    left: calc(var(--safe-left) + clamp(16px, 5vw, 28px));
  }

  #joystick-base {
    width: clamp(108px, 31vw, 138px);
    height: clamp(108px, 31vw, 138px);
  }

  #attack-button {
    width: clamp(88px, 25vw, 112px);
    height: clamp(88px, 25vw, 112px);
  }

  .skill-button {
    min-width: 78px;
  }

  .system-panel {
    top: auto;
    right: calc(var(--safe-right) + 8px);
    bottom: calc(var(--safe-bottom) + 8px);
    left: calc(var(--safe-left) + 8px);
    width: auto;
    max-height: min(82dvh, 760px);
    transform: none;
  }

  .inventory-layout,
  .shop-layout,
  .help-grid {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .settings-actions {
    grid-template-columns: 1fr;
  }

  .settings-actions .system-status {
    text-align: left;
  }

  .inventory-layout {
    grid-template-areas:
      "bag"
      "shared"
      "equipment"
      "detail";
  }

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

@media (max-height: 520px) {
  #hud {
    top: calc(var(--safe-top) + 8px);
  }

  .logo-mark {
    display: none;
  }

  .logo-rule {
    margin-top: 6px;
  }

  #touch-controls {
    right: calc(var(--safe-right) + 18px);
    bottom: calc(var(--safe-bottom) + 14px);
    left: calc(var(--safe-left) + 18px);
  }

  #joystick-base {
    width: clamp(88px, 23vh, 116px);
    height: clamp(88px, 23vh, 116px);
  }

  #attack-button {
    width: clamp(78px, 20vh, 102px);
    height: clamp(78px, 20vh, 102px);
  }

  #spell-hud {
    bottom: calc(var(--safe-bottom) + 108px);
  }

  #spell-target-panel {
    bottom: calc(var(--safe-bottom) + 156px);
  }

  .spell-hud-summary {
    max-width: min(70vw, 360px);
  }

  #player-health,
  #magic-mana,
  #magic-status {
    display: none;
  }

  .skill-button {
    min-width: 72px;
    min-height: 42px;
  }

  #system-menu {
    top: calc(var(--safe-top) + 48px);
    grid-template-columns: repeat(6, 44px);
    width: auto;
  }

  #system-menu button {
    min-height: 40px;
  }

  #system-menu button > span:nth-child(2),
  #system-menu button kbd {
    display: none;
  }

  .system-panel {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 16px);
  }

  .inventory-layout {
    min-height: 260px;
  }

  .login-panel {
    place-items: start center;
  }

  .login-card {
    padding-block: 22px;
  }
}

@media (max-width: 760px) {
  .inventory-layout {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "bag"
      "shared"
      "equipment"
      "detail";
  }

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

@media (max-width: 420px) {
  #hud {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    right: calc(var(--safe-right) + 10px);
    left: calc(var(--safe-left) + 10px);
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  #identity-badge {
    max-width: calc(100vw - 108px);
    padding: 4px 6px;
    gap: 4px;
  }

  #identity-role {
    display: none;
  }

  .identity-logout-button {
    flex: 0 0 auto;
    padding-inline: 5px;
  }

  .login-panel {
    padding-right: calc(var(--safe-right) + 12px);
    padding-left: calc(var(--safe-left) + 12px);
  }

  .login-card {
    width: min(100%, 390px);
  }

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

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