:root {
  --ink: #070809;
  --panel: rgba(9, 10, 11, 0.94);
  --panel-soft: rgba(18, 20, 22, 0.9);
  --line: #f4f1e9;
  --line-muted: #77736d;
  --text: #f8f6ef;
  --muted: #aaa69e;
  --accent: #e6dfd2;
  --hp: #6ea43d;
  --hp-low: #b84538;
  --ap: #a9d6df;
  --guard: #d8d65b;
  --poison: #789a48;
  --fire: #c86432;
  --ice: #9ec9d8;

  --font-title: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-ui: "Oswald", "Arial Narrow", Arial, sans-serif;
  --font-body: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

[hidden],
.hidden {
  display: none !important;
  pointer-events: none !important;
}

/* Critical asset loading ------------------------------------------------- */

.loading-screen {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(58, 53, 43, 0.18), transparent 38%),
    #080908;
  color: #f0ece2;
  opacity: 1;
  transition: opacity 180ms linear;
}

.loading-screen.is-complete {
  opacity: 0;
  pointer-events: none;
}

.loading-panel {
  display: grid;
  justify-items: center;
  width: min(72vw, 560px);
}

.loading-kicker {
  color: #918b80;
  font-family: var(--font-ui);
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

#loading-title {
  margin: 10px 0 34px;
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 8vw, 6rem);
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 5px 6px 0 #000;
}

#loading-status,
#loading-percentage {
  font-family: var(--font-ui);
  font-size: clamp(0.78rem, 1.5vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#loading-status {
  margin: 0 0 10px;
  color: #bdb6a8;
}

.loading-progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid #6d6961;
  background: #171816;
  box-shadow: inset 0 0 0 2px #090a09;
}

.loading-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: #a33935;
  transition: width 80ms linear;
}

#loading-percentage {
  margin-top: 9px;
  color: #e7e1d5;
}

/* Title screen */

#title-screen {
  isolation: isolate;
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  background: #11110e;
  color: #fff;
}

/*
 * The title artwork is intentionally built as three independent layers:
 * background city -> goddess illustration -> interface. This keeps the
 * composition close to the mockup while allowing each asset to scale cleanly.
 */
.title-background,
.title-background-sketch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.title-background {
  z-index: -5;
  background-color: #2d2c25;
  background-image:
    linear-gradient(180deg, rgba(5, 5, 4, 0.14) 0%, rgba(4, 4, 3, 0.22) 52%, rgba(0, 0, 0, 0.44) 100%),
    var(--title-background-image, none);
  background-position: center 55%;
  background-size: cover;
  filter: sepia(0.18) saturate(0.52) contrast(1.12) brightness(0.78);
  transform: scale(1.012);
}

.title-background-sketch {
  z-index: -4;
  background:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.1) 0%,
      rgba(0, 0, 0, 0.02) 33%,
      rgba(0, 0, 0, 0.08) 52%,
      rgba(0, 0, 0, 0.34) 76%,
      rgba(0, 0, 0, 0.54) 100%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.16) 0%,
      transparent 28%,
      transparent 70%,
      rgba(0, 0, 0, 0.3) 100%
    );
}

#title-screen::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: 0;
  background:
    radial-gradient(ellipse at 43% 45%, transparent 24%, rgba(0, 0, 0, 0.08) 56%, rgba(0, 0, 0, 0.46) 122%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.title-studio-label,
.title-version {
  position: absolute;
  z-index: 30;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  text-shadow:
    -1px -1px 0 #000,
    2px 3px 0 #000;
}

.title-studio-label {
  top: clamp(10px, 1.25vw, 20px);
  left: clamp(10px, 1.15vw, 20px);
  font-size: clamp(1rem, 1.45vw, 1.65rem);
}

.title-version {
  right: clamp(12px, 1.15vw, 22px);
  bottom: clamp(10px, 1.15vw, 20px);
  font-size: clamp(0.9rem, 1.45vw, 1.55rem);
}

.title-illustration-stage {
  position: absolute;
  z-index: 4;
  bottom: -2.2vh;
  left: clamp(1.5vw, 4.6vw, 7vw);
  width: min(45vw, 790px);
  height: 92%;
  overflow: visible;
  pointer-events: none;
}

.title-illustration,
.title-illustration-placeholder {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

.title-illustration {
  object-fit: contain;
  object-position: center bottom;
  filter:
    sepia(0.08)
    saturate(0.82)
    contrast(1.02)
    brightness(0.96)
    drop-shadow(12px 14px 13px rgba(0, 0, 0, 0.5));
  transform: scale(1.015);
  transform-origin: 50% 100%;
}

.title-illustration-placeholder {
  opacity: 0.54;
  background:
    radial-gradient(ellipse at 50% 24%, rgba(210, 203, 177, 0.4) 0 7%, transparent 7.5%),
    radial-gradient(ellipse at 48% 48%, rgba(186, 180, 157, 0.3) 0 18%, transparent 18.5%),
    conic-gradient(from 153deg at 50% 95%, transparent 0 13%, rgba(155, 151, 132, 0.25) 14% 31%, transparent 32% 68%, rgba(155, 151, 132, 0.24) 69% 86%, transparent 87%);
  filter: blur(0.2px) drop-shadow(12px 12px 12px rgba(0, 0, 0, 0.42));
}

.title-interface {
  position: absolute;
  z-index: 20;
  top: 14.5%;
  right: clamp(3.2vw, 3.8vw, 5vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(44vw, 760px);
  height: 74.5%;
}

.title-brand {
  display: grid;
  grid-template-rows: 4px auto 4px;
  gap: clamp(9px, 1.25vh, 14px);
}

.title-rule {
  display: block;
  width: 100%;
  height: 4px;
  background: #fff;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.8);
}

#title-game-name {
  margin: 0;
  color: #fff;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(4.8rem, 10.45vw, 11.25rem);
  font-weight: 900;
  letter-spacing: 0.015em;
  line-height: 0.92;
  text-align: center;
  text-shadow:
    -3px -3px 0 #000,
    3px -3px 0 #000,
    -3px 3px 0 #000,
    4px 4px 0 #000,
    10px 13px 0 #000;
  white-space: nowrap;
}

.title-menu {
  align-self: center;
  display: grid;
  width: min(100%, 720px);
  margin-inline: auto;
  gap: clamp(0px, 0.1vh, 2px);
}

.title-menu-item {
  display: grid;
  grid-template-columns: minmax(54px, 0.9fr) minmax(0, 4.9fr) minmax(54px, 0.9fr);
  align-items: center;
  width: 100%;
  min-height: clamp(58px, 8.55vh, 82px);
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.7rem, 4.85vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 0.92;
  text-shadow:
    -3px -3px 0 #000,
    3px -3px 0 #000,
    -3px 3px 0 #000,
    3px 3px 0 #000,
    7px 8px 0 #000;
  cursor: pointer;
}

.title-menu-item:disabled {
  color: #aaa79f;
  cursor: not-allowed;
  filter: grayscale(0.75);
  opacity: 0.56;
}

.title-menu-label {
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  transform: scale(1);
  transform-origin: 50% 50%;
  transition: transform 100ms ease, filter 100ms ease;
}

.title-menu-item.is-selected:not(:disabled) .title-menu-label,
.title-menu-item:hover:not(:disabled) .title-menu-label,
.title-menu-item:focus-visible:not(:disabled) .title-menu-label {
  transform: scale(1.055);
  filter: brightness(1.08);
}

.title-menu-arrow {
  width: 0;
  height: 0;
  opacity: 0;
  filter: drop-shadow(3px 3px 0 #000);
  transition: opacity 90ms ease, transform 90ms ease;
}

.title-menu-arrow-left {
  justify-self: start;
  border-top: clamp(18px, 2.55vw, 34px) solid transparent;
  border-right: clamp(38px, 4.9vw, 68px) solid #ff3f3f;
  border-bottom: clamp(18px, 2.55vw, 34px) solid transparent;
  transform: translateX(12px);
}

.title-menu-arrow-right {
  justify-self: end;
  border-top: clamp(18px, 2.55vw, 34px) solid transparent;
  border-bottom: clamp(18px, 2.55vw, 34px) solid transparent;
  border-left: clamp(38px, 4.9vw, 68px) solid #ff3f3f;
  transform: translateX(-12px);
}

.title-menu-item.is-selected:not(:disabled) .title-menu-arrow,
.title-menu-item:hover:not(:disabled) .title-menu-arrow,
.title-menu-item:focus-visible:not(:disabled) .title-menu-arrow {
  opacity: 1;
  transform: translateX(0);
}

.title-menu-status {
  align-self: end;
  min-height: 1.2em;
  margin: 0;
  color: #d7d2c7;
  font-family: Arial, sans-serif;
  font-size: clamp(0.66rem, 0.86vw, 0.82rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
  text-transform: uppercase;
}

.title-menu-status:empty {
  visibility: hidden;
}

#battle-screen {
  isolation: isolate;
  position: relative;
  display: grid;
  grid-template-rows: clamp(46px, 6.5vh, 62px) minmax(0, 1fr) clamp(120px, 19vh, 168px);
  gap: clamp(6px, 1vh, 12px);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  padding: clamp(8px, 1.4vw, 20px);
  overflow: hidden;
  background: var(--ink);
}

#battle-screen::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 50% 43%, transparent 18%, rgba(3, 4, 5, 0.2) 88%);
  pointer-events: none;
}

.eyebrow {
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

/* Battle-state header */

.battle-state-header {
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: clamp(300px, 42vw, 560px);
  min-width: 0;
  padding: 6px clamp(10px, 1.4vw, 22px);
  border: 1px solid var(--line-muted);
  background: rgba(7, 8, 9, 0.8);
}

#turn-indicator {
  width: 100%;
  min-width: 0;
  text-align: center;
}

#turn-text {
  margin: 3px 0 0;
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: clamp(0.72rem, 1.2vw, 1rem);
  letter-spacing: 0.14em;
}

#battle-screen[data-turn="enemy"] #turn-text {
  color: #d9a0a0;
}

#battle-screen[data-battle-state="finished"] #turn-text {
  color: #f1d886;
}

/* Battlefield layers */

#battlefield {
  position: relative;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.enemy-presentation {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
  pointer-events: none;
}

#enemy-image {
  width: clamp(250px, 31vw, 500px);
  height: min(61vh, 580px);
  max-height: 116%;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 15px 18px rgba(0, 0, 0, 0.68));
  transform-origin: 50% 64%;
}

.party-stage {
  position: absolute;
  z-index: 3;
  right: 2%;
  bottom: -5%;
  left: 2%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  height: 68%;
  pointer-events: none;
}

.party-member {
  position: relative;
  height: 100%;
  min-width: 0;
  pointer-events: none;
}

.party-member:nth-child(2) {
  grid-column: 2;
}

.party-member:nth-child(3) {
  grid-column: 3;
}

#player-image {
  position: absolute;
  z-index: 1;
  bottom: -8%;
  left: 54%;
  width: clamp(190px, 21vw, 340px);
  height: min(45vh, 440px);
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.64));
  transform: translateX(-50%);
  transform-origin: 50% 75%;
}

#player-image.punching {
  scale: 1.06;
}

.active-character-label {
  position: absolute;
  z-index: 5;
  bottom: 43%;
  left: 54%;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: #111;
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  opacity: 0;
  text-transform: uppercase;
  transform: translateX(-50%);
  transition: opacity 0.15s ease;
}

.party-member.active-combatant .active-character-label {
  opacity: 1;
}

#battle-screen[data-turn="enemy"] .active-character-label,
#battle-screen[data-battle-state="finished"] .active-character-label {
  opacity: 0;
}

/* Character HUD */

.character-hud {
  position: absolute;
  z-index: 4;
  bottom: 23%;
  left: 0;
  width: clamp(154px, 13vw, 210px);
  padding: 8px;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.enemy-hud {
  top: 9%;
  bottom: auto;
  left: calc(50% - clamp(285px, 27vw, 430px));
  width: clamp(150px, 13vw, 205px);
}

.enemy-hud .hud-title-row {
  display: block;
}

.hud-side-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#enemy-name {
  margin: 0;
  overflow: hidden;
  font-size: clamp(0.88rem, 1.25vw, 1.12rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  padding: 1px 4px 4px;
  border-bottom: 1px solid var(--line-muted);
}

.hud-title-row h2 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(0.88rem, 1.25vw, 1.12rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-pip {
  width: 9px;
  height: 9px;
  border: 1px solid #111;
  background: var(--muted);
  box-shadow: 0 0 0 1px var(--line);
}

.active-combatant .turn-pip {
  background: #d8ec67;
  box-shadow: 0 0 0 1px var(--line), 0 0 9px rgba(216, 236, 103, 0.8);
}

.hud-bar {
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #211f1d;
}

.hud-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #4e752e, var(--hp));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.28);
  transition: width 0.24s ease-out, background 0.2s ease;
}

.hud-bar-fill.is-low {
  background: linear-gradient(90deg, #762b24, var(--hp-low));
}

.hud-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-values p,
#enemy-hp {
  margin: 3px 0 0;
  font-family: Arial, sans-serif;
  font-size: clamp(0.66rem, 0.9vw, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.04em;
}

#player-ap {
  color: var(--ap);
  white-space: nowrap;
}

.status-list {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  width: 56px;
  gap: 4px;
  pointer-events: none;
}

.player-status-list {
  bottom: 23%;
  left: calc(clamp(154px, 13vw, 210px) + 6px);
}

.enemy-status-list {
  top: 9%;
  left: calc(50% - clamp(125px, 13vw, 215px));
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid currentColor;
  background: #111;
  font-family: Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 1px #292929, 2px 2px 0 rgba(0, 0, 0, 0.38);
}

.status-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

.status-guard {
  color: var(--guard);
}

.status-poison {
  color: #afd477;
}

.status-generic {
  color: var(--accent);
}

/* Contextual action menu */

#battle-menu {
  position: absolute;
  z-index: 7;
  bottom: 28%;
  left: 82%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: start;
  gap: 7px;
  width: clamp(350px, 34vw, 520px);
  pointer-events: auto;
  transition: filter 0.16s ease, opacity 0.16s ease;
}

#command-box {
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.38);
}

#battle-menu button {
  min-width: 0;
  border: 1px solid var(--line-muted);
  border-radius: 0;
  outline: 0;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

#battle-menu button:hover:not(:disabled),
#battle-menu button:focus-visible:not(:disabled) {
  border-color: var(--line);
  background: #292a2a;
  box-shadow: inset 0 0 0 1px #111, 0 0 0 1px rgba(255, 255, 255, 0.35);
}

#command-box-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  min-height: clamp(48px, 6vw, 68px);
  background: var(--accent);
  color: #090909;
}

#command-category-title {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.45rem, 3vw, 2.7rem);
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.command-tab-arrow {
  align-self: stretch;
  border: 0 !important;
  background: transparent !important;
  color: #d5231d !important;
  font-family: Arial, sans-serif;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  font-weight: 900;
  opacity: 1 !important;
  filter: none !important;
}

.command-tab-arrow:hover:not(:disabled),
.command-tab-arrow:focus-visible:not(:disabled) {
  background: rgba(0, 0, 0, 0.09) !important;
  color: #f03830 !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.34) !important;
}

.command-tab-arrow:disabled {
  background: transparent !important;
  color: #252525 !important;
  cursor: default !important;
  opacity: 1 !important;
}

#menu-content {
  display: grid;
  min-height: 126px;
  padding: 5px 12px;
  background: var(--panel);
}

.command-page.tab-enter-forward {
  animation: command-tab-forward 0.13s ease-out;
}

.command-page.tab-enter-backward {
  animation: command-tab-backward 0.13s ease-out;
}

.command-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border-color: transparent !important;
  border-bottom-color: #4c4b48 !important;
  font-size: clamp(0.78rem, 1.08vw, 0.98rem);
  font-weight: 800;
  text-align: left;
}

.command-row:last-child {
  border-bottom-color: transparent !important;
}

.command-row.selected-action {
  background: var(--accent) !important;
  color: #111 !important;
}

.command-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: currentColor;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1;
}

.command-icon-image {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.command-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-cost {
  margin-left: 8px;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.selected-action .action-cost {
  color: #454545;
}

#battle-menu button:disabled {
  border-color: #353535;
  background: #171717;
  color: #656565;
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.76;
}

#battle-menu.is-locked {
  filter: grayscale(0.8);
  opacity: 0.48;
  pointer-events: none;
}

#battle-screen[data-battle-state="finished"] #battle-menu {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

@keyframes command-tab-forward {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes command-tab-backward {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Battle log */

.battle-log-frame {
  z-index: 9;
  position: relative;
  align-self: stretch;
  justify-self: center;
  width: min(880px, 76vw);
  min-width: 0;
  padding: 9px;
  border: 3px double var(--line);
  background: var(--panel);
  box-shadow: 0 -7px 24px rgba(0, 0, 0, 0.38);
}

.battle-log-label {
  position: absolute;
  top: -12px;
  left: 18px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  background: #0c0d0e;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#battle-log {
  height: 100%;
  padding: 8px clamp(12px, 2vw, 26px);
  overflow: auto;
  scrollbar-color: #69665f #171717;
  scrollbar-width: thin;
  font-size: clamp(0.83rem, 1.25vw, 1.12rem);
  line-height: 1.35;
  text-align: left;
}

#battle-log p {
  margin: 2px 0;
  color: #aaa9a5;
}

#battle-log p:last-child {
  color: var(--text);
  font-size: 1.12em;
  font-weight: 700;
}

/* Effects */

#turn-popup {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 50%;
  min-width: min(360px, 70vw);
  padding: 12px 24px;
  border-block: 2px solid var(--line);
  background: linear-gradient(90deg, transparent, rgba(4, 5, 6, 0.92) 18%, rgba(4, 5, 6, 0.92) 82%, transparent);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3.6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 3px 3px 0 #000;
  transform: translate(-50%, -50%) scale(0.82);
}

#turn-popup.turn-popup-active {
  animation: turn-popup var(--announcement-duration, 1.45s) ease-out forwards;
}

#turn-popup.result-announcement {
  color: #f1d886;
  font-size: clamp(2rem, 4.6vw, 4.2rem);
  letter-spacing: 0.12em;
}

#battle-screen[data-turn="enemy"] #turn-popup {
  color: #e5b5b5;
}

#player-image.player-hit {
  animation: player-hit-shake 0.34s linear, player-hit-flash 0.34s ease-out;
}

#fireball-effect,
#icepike-effect,
#poison-effect {
  position: absolute;
  z-index: 6;
  top: 43%;
  left: 50%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#fireball-effect {
  width: clamp(130px, 14vw, 190px);
  height: clamp(130px, 14vw, 190px);
  filter: sepia(1) saturate(8) hue-rotate(330deg) drop-shadow(0 0 15px orange) drop-shadow(0 0 30px red);
}

#icepike-effect {
  width: clamp(100px, 11vw, 150px);
  height: clamp(170px, 20vw, 230px);
  filter: sepia(1) saturate(4) hue-rotate(155deg) brightness(1.4) drop-shadow(0 0 8px #bdefff) drop-shadow(0 0 18px #69c9ff);
}

#poison-effect {
  width: clamp(125px, 13vw, 180px);
  height: clamp(125px, 13vw, 180px);
}

#damage-number {
  position: absolute;
  z-index: 7;
  top: 29%;
  left: 50%;
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: clamp(2rem, 3vw, 3rem);
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  white-space: pre-line;
  text-align: center;
  text-shadow: 0 0 4px #000, 0 0 9px #000;
  transform: translate(-50%, -50%);
}

#damage-number.target-player {
  top: 55%;
  left: 20%;
  color: #ffd1d1;
}

#fireball-effect.fireball-active {
  opacity: 1;
  animation: fireball-burst 0.6s ease-out forwards;
}

#icepike-effect.icepike-active {
  opacity: 1;
  animation: icepike-strike 0.45s ease-in forwards;
}

#poison-effect.poison-active {
  opacity: 1;
  animation: poison-burst 0.7s ease-out forwards;
}

#damage-number.damage-active {
  animation: damage-popup 0.7s ease-out forwards;
}

#damage-number.damage-critical {
  color: #ffd86a;
  font-size: clamp(2.6rem, 4.2vw, 4.2rem);
  text-shadow: 0 0 4px #000, 0 0 10px #8a240f, 0 0 18px rgba(255, 207, 72, 0.72);
}

#damage-number.damage-fatal {
  color: #ff4a3f;
  font-size: clamp(3rem, 5vw, 5rem);
  letter-spacing: 0.06em;
  text-shadow: 0 0 5px #000, 0 0 12px #300, 0 0 24px rgba(255, 25, 15, 0.9);
}

.battle-floating-number {
  position: absolute;
  z-index: 8;
  top: var(--effect-y, 35%);
  left: var(--effect-x, 60%);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: clamp(2rem, 3vw, 3rem);
  font-weight: 900;
  pointer-events: none;
  white-space: pre-line;
  text-align: center;
  text-shadow: 0 0 4px #000, 0 0 9px #000;
  animation: damage-popup 0.7s ease-out forwards;
}

.battle-floating-number.battle-floating-heal {
  color: #87f6a2;
  text-shadow: 0 0 4px #000, 0 0 10px rgba(28, 120, 55, 0.9), 0 0 18px rgba(90, 255, 130, 0.55);
}

.battle-floating-number.battle-floating-critical {
  color: #ffd86a;
  font-size: clamp(2.6rem, 4.2vw, 4.2rem);
}

.battle-floating-number.battle-floating-fatal {
  color: #ff4a3f;
  font-size: clamp(3rem, 5vw, 5rem);
  letter-spacing: 0.06em;
}

#enemy-image.hit-flash {
  animation: fire-hit-shake 0.18s linear, fire-hit-flash 0.28s ease-out;
}

#enemy-image.ice-hit {
  animation: ice-hit-shake 0.15s linear, ice-hit-flash 0.22s ease-out;
}

#enemy-image.punch-hit {
  animation: punch-hit-shake 0.14s linear;
}

@keyframes fireball-burst {
  0% { transform: translate(-50%, -50%) scale(0.15); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.5; }
  50% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
  80% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.25); opacity: 0; }
}

@keyframes icepike-strike {
  0% { transform: translate(-82%, -50%) scale(0.5); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes poison-burst {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  25% { opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -65%) scale(1); opacity: 0; }
}

@keyframes damage-popup {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

@keyframes fire-hit-shake {
  0%, 100% { translate: 0 0; }
  20%, 60% { translate: -5px 0; }
  40%, 80% { translate: 5px 0; }
}

@keyframes fire-hit-flash {
  0%, 100% { filter: brightness(1); }
  20% { filter: brightness(3.2) contrast(1.3) drop-shadow(0 0 18px #ffd27a) drop-shadow(0 0 32px #ff6a00); }
  55% { filter: brightness(1.8) drop-shadow(0 0 20px #d93600); }
}

@keyframes ice-hit-shake {
  0%, 100% { translate: 0 0; }
  20%, 60% { translate: -4px 0; }
  40%, 80% { translate: 4px 0; }
}

@keyframes ice-hit-flash {
  0%, 100% { filter: brightness(1); }
  25% { filter: brightness(3) contrast(1.2) drop-shadow(0 0 18px #bdefff) drop-shadow(0 0 30px #70d8ff); }
  60% { filter: brightness(1.8) drop-shadow(0 0 14px #9eeaff); }
}

@keyframes punch-hit-shake {
  0%, 100% { translate: 0 0; }
  20%, 60% { translate: -4px 0; }
  40%, 80% { translate: 4px 0; }
}

@keyframes player-hit-shake {
  0%, 100% { translate: 0 0; }
  18%, 54% { translate: -7px 0; }
  36%, 72% { translate: 7px 0; }
}

@keyframes player-hit-flash {
  0%, 100% { filter: brightness(1); }
  28% { filter: drop-shadow(0 0 14px rgba(190, 45, 45, 0.95)) brightness(2.4) sepia(0.55) saturate(2.4); }
  62% { filter: drop-shadow(0 0 8px rgba(140, 30, 30, 0.75)) brightness(1.35); }
}

@keyframes turn-popup {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.82); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  76% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.06); }
}

/* Desktop 4:3 and narrower desktop windows */

@media (max-aspect-ratio: 4/3) {
  #battle-screen {
    grid-template-rows: 52px minmax(0, 1fr) 132px;
  }

  #enemy-image {
    width: clamp(260px, 39vw, 420px);
    height: min(57vh, 500px);
  }

  .party-stage {
    right: 1%;
    left: 1%;
    height: 65%;
  }

  #player-image {
    left: 49%;
    width: clamp(190px, 27vw, 290px);
    height: min(39vh, 360px);
  }

  .character-hud {
    bottom: 21%;
    width: clamp(150px, 18vw, 185px);
  }

  .enemy-hud {
    top: 8%;
    bottom: auto;
    left: calc(50% - clamp(240px, 29vw, 320px));
  }

  .player-status-list {
    bottom: 21%;
    left: calc(clamp(150px, 18vw, 185px) + 6px);
  }

  .enemy-status-list {
    top: 8%;
    left: calc(50% - clamp(50px, 10vw, 125px));
  }

  #battle-menu {
    bottom: 27%;
    left: 70%;
    width: clamp(350px, 44vw, 430px);
  }

  .battle-log-frame {
    width: min(780px, 82vw);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  #battle-screen {
    min-height: 640px;
  }

  #turn-indicator {
    min-width: 130px;
  }

  #turn-indicator .eyebrow {
    display: none;
  }

  .party-stage {
    grid-template-columns: 1fr;
  }

  .enemy-hud {
    left: 4%;
  }

  .enemy-status-list {
    top: 8%;
    left: calc(4% + 194px);
  }

  #battle-menu {
    left: 48%;
    width: min(94vw, 420px);
  }

  .battle-log-frame {
    width: calc(100vw - 28px);
  }
}

/* Town map blockout development scene */

#map-blockout-screen {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  background: #12130f;
  color: #f3efe4;
  font-family: Arial, sans-serif;
}

#map-blockout-screen[hidden] {
  display: none;
}

.map-blockout-header {
  z-index: 20;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(16px, 2.2vw, 36px);
  border-bottom: 2px solid #7b786d;
  background: #090a08;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  flex-wrap: wrap;
}

.map-blockout-header h1 {
  margin: 2px 0 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: clamp(1.25rem, 2.2vw, 2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-blockout-header p {
  margin: 0;
  color: #c7c2b5;
  font-size: clamp(0.68rem, 1vw, 0.84rem);
  letter-spacing: 0.05em;
  text-align: right;
}

.map-blockout-header .map-blockout-role {
  max-width: 520px;
  margin-top: 4px;
  color: #aaa598;
  text-align: left;
}

.map-blockout-header-tools {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: min(100%, 520px);
}

.map-blockout-node-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.map-blockout-node-tab {
  padding: 6px 9px;
  border: 1px solid #777367;
  background: #181916;
  color: #c9c4b7;
  font-family: Arial, sans-serif;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-blockout-node-tab[aria-pressed="true"] {
  border-color: #e1bd72;
  background: #4b3b24;
  color: #fff3cf;
}

.map-blockout-current-spawn {
  color: #86c4df;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-blockout-kicker {
  color: #d6aa67;
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.map-blockout-exit {
  padding: 8px 12px;
  border: 1px solid #bcb6a8;
  color: #eee9dd;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.map-blockout-exit:hover,
.map-blockout-exit:focus-visible {
  border-color: #f1d36d;
  color: #f1d36d;
}

.map-blockout-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 42px max(36px, calc((100vw - 1536px) / 2));
  overflow: auto;
  outline: 0;
  background: #22231d;
  scrollbar-color: #817d70 #0c0d0a;
}

.map-blockout-viewport:focus-visible {
  box-shadow: inset 0 0 0 3px #d6aa67;
}

.map-blockout-canvas {
  position: relative;
  margin: 0 auto;
  border: 4px solid #d0cabd;
  background: #34362e;
  box-shadow: 16px 18px 0 rgba(0, 0, 0, 0.42);
  opacity: 1;
  transition: opacity 140ms linear;
}

.map-blockout-canvas.is-fading {
  opacity: 0;
}

.map-blockout-layer,
.map-blockout-grid {
  position: absolute;
  inset: 0;
}

#map-blockout-district-layer { z-index: 1; }
#map-blockout-road-layer,
#map-blockout-environment-layer { z-index: 2; }
#map-blockout-wall-layer { z-index: 3; }
#map-blockout-building-layer { z-index: 4; }
#map-blockout-interactable-layer { z-index: 5; }
#map-blockout-npc-layer { z-index: 6; }

#map-blockout-zone-layer { z-index: 1; }
#map-blockout-path-layer { z-index: 2; }
#map-blockout-footprint-layer { z-index: 3; }
#map-blockout-marker-layer { z-index: 4; }
#map-blockout-spawn-layer { z-index: 5; }
#map-blockout-warp-layer { z-index: 6; }

.map-blockout-grid {
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(var(--blockout-columns), var(--blockout-cell-size));
  grid-template-rows: repeat(var(--blockout-rows), var(--blockout-cell-size));
  pointer-events: none;
}

.map-blockout-grid:not(.grid-visible) {
  visibility: hidden;
}

.map-blockout-grid-cell {
  display: block;
  border-right: 1px solid rgba(245, 241, 226, 0.28);
  border-bottom: 1px solid rgba(245, 241, 226, 0.28);
}

.map-blockout-object {
  position: absolute;
  top: var(--blockout-top);
  left: var(--blockout-left);
  display: grid;
  place-items: center;
  width: var(--blockout-width);
  height: var(--blockout-height);
  padding: 4px;
  overflow: visible;
  border: 2px solid rgba(245, 241, 226, 0.72);
  background: rgba(80, 80, 73, 0.7);
  color: #fffdf6;
  text-align: center;
}

button.map-blockout-object {
  margin: 0;
  font: inherit;
}

.map-blockout-object-label {
  position: relative;
  z-index: 2;
  max-width: 100%;
  padding: 2px 4px;
  background: rgba(5, 6, 5, 0.82);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.map-blockout-group-districts {
  align-items: start;
  justify-items: start;
  border: 2px dashed rgba(216, 208, 190, 0.28);
  background: transparent;
}

.map-blockout-group-districts .map-blockout-object-label {
  margin: 6px;
  color: #c9c1af;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

.map-blockout-type-forest-zone {
  border-color: rgba(112, 151, 90, 0.58);
  background: rgba(53, 85, 48, 0.15);
}

.map-blockout-group-roads {
  border-color: rgba(232, 229, 218, 0.44);
  background: rgba(190, 188, 179, 0.34);
}

.map-blockout-type-side-street { background: rgba(173, 170, 162, 0.28); }
.map-blockout-type-alley { border-style: dashed; background: rgba(142, 140, 134, 0.23); }
.map-blockout-type-town-square,
.map-blockout-type-open-road { border-style: dashed; background: rgba(205, 201, 187, 0.3); }
.map-blockout-type-dirt-road,
.map-blockout-type-forest-path { border-color: rgba(201, 175, 127, 0.66); background: rgba(143, 111, 65, 0.34); }

.map-blockout-group-walls {
  border-color: #aba69a;
  background: rgba(24, 25, 23, 0.9);
}

.map-blockout-type-gate {
  border-color: #f0d396;
  background: rgba(92, 73, 48, 0.94);
}

.map-blockout-type-watchtower,
.map-blockout-type-gatehouse {
  border: 3px double #c8c1b2;
  background: rgba(36, 36, 32, 0.96);
}

.map-blockout-group-buildings {
  border-color: rgba(224, 202, 168, 0.86);
  background: rgba(132, 96, 62, 0.68);
}

.map-blockout-type-important-building {
  border: 3px double #f0cc83;
  background: rgba(151, 108, 58, 0.88);
  color: #fff4d6;
}

.map-blockout-type-small-building,
.map-blockout-type-utility-building { background: rgba(115, 91, 68, 0.65); }
.map-blockout-type-empty-lot { border-style: dashed; background: rgba(110, 105, 87, 0.22); }

.map-blockout-group-interactables {
  border: 2px dashed #f1d36d;
  background: rgba(41, 38, 24, 0.66);
  color: #fff0a9;
}

.map-blockout-group-npcs {
  place-items: start center;
  padding: 38px 0 0;
  border: 0;
  background: transparent;
}

.map-blockout-group-npcs::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #63a7c8;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.52);
  transform: translateX(-50%);
}

.map-blockout-group-npcs .map-blockout-object-label {
  width: max-content;
  max-width: 96px;
  font-size: 0.52rem;
}

.map-blockout-type-guard-npc::before { background: #cf6055; }
.map-blockout-type-quest-npc::before { background: #e0c95f; }
.map-blockout-type-merchant-npc::before,
.map-blockout-type-shopkeeper-npc::before { background: #b47bc0; }
.map-blockout-type-adventurer-npc::before,
.map-blockout-type-guild-npc::before { background: #5d83c1; }
.map-blockout-type-wandering-npc::before { background: #8e8b80; }

.map-blockout-group-environment {
  border-color: rgba(128, 173, 98, 0.7);
  background: rgba(64, 107, 57, 0.38);
  color: #e4f2d8;
}

.map-blockout-type-grass { border-style: dashed; background: rgba(67, 108, 58, 0.23); }
.map-blockout-type-tree { border: 3px solid #6f985c; border-radius: 50%; background: rgba(46, 79, 42, 0.72); }
.map-blockout-type-bush { border-radius: 45%; background: rgba(66, 111, 54, 0.72); }
.map-blockout-type-rock { border-color: #a5a39a; background: rgba(91, 91, 86, 0.75); }
.map-blockout-type-forest-edge { border-width: 3px 0 0; background: rgba(34, 68, 32, 0.84); }
.map-blockout-type-encounter-zone { border: 2px dashed #c7554d; background: rgba(121, 41, 36, 0.34); color: #ffd8d4; }

.map-blockout-group-zones {
  align-items: start;
  justify-items: start;
  border-width: 2px;
}

.map-blockout-group-zones .map-blockout-object-label {
  margin: 4px;
  font-size: 0.52rem;
}

.map-blockout-type-walkable {
  border-color: #65bb78;
  background: rgba(42, 106, 59, 0.27);
  color: #dff8e5;
}

.map-blockout-type-blocked {
  border: 3px dashed #c76060;
  background: rgba(116, 39, 39, 0.42);
  color: #ffd9d9;
}

.map-blockout-group-paths {
  border-color: rgba(226, 220, 199, 0.75);
  background: rgba(158, 139, 102, 0.52);
}

.map-blockout-type-secondary-path,
.map-blockout-type-alley {
  border-style: dashed;
  background: rgba(150, 133, 100, 0.38);
}

.map-blockout-group-footprints {
  border-color: #b8b6af;
  background: rgba(91, 91, 88, 0.82);
  color: #f1efea;
}

.map-blockout-type-important-building {
  border: 3px double #f0cc62;
  background: rgba(134, 104, 42, 0.88);
}

.map-blockout-type-wall {
  background: rgba(39, 40, 38, 0.96);
}

.map-blockout-group-markers {
  border: 2px dashed #a6a29a;
  background: rgba(74, 75, 72, 0.7);
}

.map-blockout-type-important {
  border-color: #f0cc62;
  background: rgba(116, 89, 33, 0.7);
  color: #fff0b8;
}

.map-blockout-type-reserved {
  border-color: #c76060;
  background: rgba(104, 44, 44, 0.52);
}

.map-blockout-type-npc-marker {
  border-radius: 50%;
  background: rgba(105, 88, 128, 0.82);
}

.map-blockout-group-spawns {
  border: 3px solid #e6d35f;
  background: rgba(114, 99, 31, 0.76);
  color: #fff5b8;
}

.map-blockout-group-warps {
  border: 3px solid #4da9dc;
  background: rgba(26, 88, 126, 0.88);
  color: #dcf4ff;
  cursor: pointer;
}

.map-blockout-group-warps:hover:not(:disabled),
.map-blockout-group-warps:focus-visible:not(:disabled) {
  border-color: #bceaff;
  background: rgba(35, 122, 171, 0.96);
  outline: 3px solid rgba(188, 234, 255, 0.38);
  outline-offset: 2px;
}

.map-blockout-group-warps:disabled {
  border-style: dashed;
  border-color: #777;
  background: rgba(51, 55, 58, 0.9);
  color: #aaa;
  cursor: not-allowed;
}

.map-blockout-legend {
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 8px 16px;
  gap: clamp(10px, 2vw, 28px);
  overflow-x: auto;
  border-top: 2px solid #7b786d;
  background: #090a08;
  color: #d6d0c2;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.map-blockout-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.map-blockout-legend i {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid #d8d3c6;
  background: rgba(80, 80, 73, 0.8);
}

.map-blockout-legend .legend-walkable { border-color: #65bb78; background: #2f6f3d; }
.map-blockout-legend .legend-blocked { border-style: dashed; border-color: #c76060; background: #6f3030; }
.map-blockout-legend .legend-warp { border-color: #4da9dc; background: #235f82; }
.map-blockout-legend .legend-important { border-color: #f0cc83; background: rgba(151, 108, 58, 0.95); }
.map-blockout-legend .legend-footprint { background: #5b5b58; }
.map-blockout-legend .legend-marker { border-style: dashed; background: #4a4b48; }
.map-blockout-legend .legend-spawn { border-color: #e6d35f; background: #72631f; }

@media (max-width: 760px) {
  .map-blockout-header {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  .map-blockout-header p { text-align: left; }
  .map-blockout-header-tools { justify-items: start; }
  .map-blockout-node-tabs { justify-content: start; }
  .map-blockout-viewport { padding: 26px 24px; }
  .map-blockout-legend { justify-content: start; }
}

/* End town map blockout development scene */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Data-driven formations, isolated world camera, and entity HUD layer */

#battlefield {
  overflow: visible;
}

.battle-camera,
.battle-hud,
.formation-layer,
.entity-hud-layer {
  position: absolute;
  inset: 0;
}

.battle-camera {
  z-index: 1;
  transform: translate(var(--camera-x, 0), var(--camera-y, 0)) scale(var(--camera-scale, 1));
  transform-origin: 50% 50%;
  transition: transform 0.28s ease-in-out;
  will-change: transform;
}

.battle-world-background {
  position: absolute;
  z-index: 0;
  inset: -24vh -12vw -24vh;
  overflow: hidden;
  background-image: var(--battle-background-image, none);
  background-position: center;
  background-size: cover;
  filter: none;
  transition: filter 0.28s ease, opacity 0.28s ease;
}

.battle-world-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 7, 8, 0.12) 0%, rgba(5, 7, 8, 0.06) 42%, rgba(5, 7, 8, 0.58) 100%),
    radial-gradient(circle at 50% 43%, transparent 18%, rgba(3, 4, 5, 0.23) 88%);
  pointer-events: none;
}

#battle-screen[data-camera-mode="player-focus"] .battle-world-background {
  filter: blur(2px) contrast(0.92);
  opacity: 0.88;
}

#battle-screen[data-camera-mode="player-focus"] .enemy-slot .combatant-sprite {
  filter: blur(1.3px) contrast(0.88) opacity(0.82);
}

.battle-hud {
  z-index: 8;
  contain: layout style;
  pointer-events: none;
  transform: none !important;
  transform-origin: initial !important;
  transition: none !important;
  will-change: auto;
}

.battle-hud .entity-hud-layer {
  transform: none !important;
}

.formation-slot {
  position: absolute;
  top: calc(var(--slot-y) * 1%);
  left: calc(var(--slot-x) * 1%);
  z-index: var(--slot-layer, 2);
  width: clamp(150px, 16vw, 270px);
  height: min(48vh, 440px);
  pointer-events: none;
  transform: translateX(-50%);
}

.formation-slot.enemy-slot {
  width: clamp(180px, 19vw, 330px);
  height: min(49vh, 470px);
}

.formation-slot.is-defeated {
  visibility: hidden;
  pointer-events: none;
}

.combatant-sprite,
.enemy-target {
  width: 100%;
  height: 100%;
}

.combatant-sprite {
  position: relative;
  z-index: 2;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  translate: var(--frame-offset-x, 0px) var(--frame-offset-y, 0px);
  filter: none;
  transform-origin: 50% 75%;
}

.combatant-foot-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 1.5%;
  width: clamp(52px, 38%, 112px);
  height: clamp(12px, 4.5%, 22px);
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.58) 0%,
    rgba(0, 0, 0, 0.38) 46%,
    rgba(0, 0, 0, 0.13) 72%,
    transparent 100%
  );
  filter: blur(2px);
  transform: translate(-50%, 35%) scaleY(0.72);
  transform-origin: center;
}

.enemy-foot-shadow {
  width: clamp(58px, 36%, 118px);
  opacity: 0.9;
}

.player-foot-shadow {
  width: clamp(52px, 34%, 102px);
  opacity: 0.82;
}

.enemy-target {
  position: relative;
  z-index: 2;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  pointer-events: none;
}

.combatant-frame-blend {
  position: absolute;
  z-index: 3;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

#battle-screen[data-input-mode="target"] .enemy-target:not(:disabled) {
  cursor: crosshair;
  pointer-events: auto;
}

/*
 * Nine-frame enemy idle smoothing:
 * keep authored frames sharp, then blend only the outgoing frame for a few
 * milliseconds so frame boundaries read less like hard image swaps.
 */
.map-enemy-frame-blend.is-frame-blending,
.combatant-frame-blend.is-frame-blending {
  animation: enemy-idle-frame-blend-out 58ms linear both;
}

@keyframes enemy-idle-frame-blend-out {
  from { opacity: 0.72; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .map-enemy-frame-blend.is-frame-blending,
  .combatant-frame-blend.is-frame-blending {
    animation: none;
    opacity: 0;
  }
}

.active-turn-marker {
  position: absolute;
  z-index: 5;
  top: -8px;
  left: 50%;
  display: none;
  color: #d5231d;
  font-family: Arial, sans-serif;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1;
  text-shadow: 0 0 3px #000, 0 0 9px rgba(213, 35, 29, 0.74);
  transform: translateX(-50%);
}

.formation-slot.awaiting-command .active-turn-marker {
  display: block;
  animation: active-marker-bob 0.85s ease-in-out infinite;
}

.formation-marker {
  position: absolute;
  z-index: 9;
  right: 4px;
  bottom: 4px;
  display: none;
  padding: 2px 5px;
  border: 1px dashed #d5231d;
  background: rgba(0, 0, 0, 0.78);
  color: #ff645c;
  font-family: Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 900;
}

#battle-screen.show-formation-markers .formation-marker {
  display: block;
}

.formation-slot.empty-slot {
  visibility: hidden;
}

.character-hud-anchor {
  position: absolute;
  z-index: 1;
  top: var(--hud-anchor-y, 40%);
  left: var(--hud-anchor-x, 50%);
  width: 1px;
  height: 1px;
  pointer-events: none;
  opacity: 0;
}

#battle-screen.show-formation-markers .formation-slot.empty-slot {
  visibility: visible;
  border: 1px dashed rgba(213, 35, 29, 0.45);
}

.enemy-target.is-selected-target .combatant-sprite {
  animation: selected-target-pulse 0.82s ease-in-out infinite;
}

.entity-hud-group {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: clamp(178px, 14vw, 224px);
  min-height: 60px;
  pointer-events: none;
  transition: none;
}

.entity-hud-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  width: 100%;
  min-height: 60px;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.34);
}

#party-hud-layer {
  inset: clamp(92px, 14vh, 142px) auto auto clamp(14px, 2vw, 34px);
  display: flex;
  flex-direction: column;
  width: clamp(190px, 15vw, 240px);
  gap: 58px;
}

.player-entity-hud {
  position: relative;
  top: auto;
  left: auto;
  width: 100%;
  transform: none;
}

.enemy-entity-hud[data-hud-anchor="above-head"] {
  width: clamp(158px, 12vw, 196px);
  transform: translate3d(
    calc(var(--hud-screen-x, -9999px) - 50%),
    calc(var(--hud-screen-y, -9999px) - 100% - var(--hud-offset-y, 0px)),
    0
  );
  transform-origin: 50% 100%;
  will-change: transform;
}

.entity-hud-group.is-defeated {
  display: none;
}

.portrait-placeholder {
  width: 44px;
  height: 44px;
  min-height: 44px;
  overflow: hidden;
  align-self: center;
  border-right: 1px solid var(--line-muted);
  background: #fff;
}

.portrait-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entity-hud-content {
  min-width: 0;
  padding: 5px 6px;
}

.entity-hud-card .hud-title-row {
  margin-bottom: 4px;
  padding: 0 1px 3px;
}

.entity-hud-card .hud-title-row h2 {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  font-size: clamp(0.76rem, 1vw, 0.96rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-hud-card .hud-side-label {
  margin-right: auto;
  margin-bottom: 0;
  font-size: 0.43rem;
}

.entity-hud-card .hud-bar {
  height: 8px;
}

.entity-hud-card .hud-values p {
  margin-top: 3px;
  font-size: clamp(0.54rem, 0.72vw, 0.7rem);
}

.entity-hud-group > .status-list {
  top: calc(100% + 6px);
  right: auto;
  bottom: auto;
  left: 0;
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 4px;
  flex-wrap: wrap;
}

.entity-hud-group > .status-list:not([hidden]) {
  pointer-events: auto;
}

.enemy-entity-hud .status-list {
  top: calc(100% + 6px);
  right: auto;
  bottom: auto;
  left: 0;
  width: 100%;
  max-width: 100%;
}

.enemy-entity-hud .entity-hud-content {
  padding-right: 6px;
}

.entity-hud-group .status-icon {
  width: 23px;
  height: 23px;
}

.entity-hud-group .status-icon {
  cursor: help;
  pointer-events: auto;
}

#status-tooltip {
  position: fixed;
  z-index: 40;
  top: var(--tooltip-top, 8px);
  left: var(--tooltip-left, 8px);
  width: min(240px, calc(100vw - 16px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(5, 6, 7, 0.98);
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
  line-height: 1.35;
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.48);
  pointer-events: none;
}

#status-tooltip strong {
  display: block;
  margin-bottom: 5px;
  color: #f2e7bf;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

#status-tooltip p {
  margin: 2px 0;
}

.entity-hud-group.active-combatant .turn-pip {
  background: #d8ec67;
  box-shadow: 0 0 0 1px var(--line), 0 0 9px rgba(216, 236, 103, 0.8);
}

#battle-menu {
  position: absolute;
  top: 0;
  bottom: auto;
  left: 0;
  display: block;
  width: clamp(190px, 15vw, 240px);
  transform: translate3d(var(--action-screen-x, -9999px), var(--action-screen-y, -9999px), 0);
  transition: none;
  will-change: transform;
}

#command-box-header {
  min-height: clamp(40px, 4vw, 52px);
}

#command-category-title {
  font-size: clamp(1.05rem, 1.7vw, 1.55rem);
  line-height: 1.05;
}

#menu-content {
  min-height: 102px;
  padding: 4px 6px;
}

.command-row {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 5px;
  min-height: 32px;
  padding: 4px 6px;
  font-size: clamp(0.67rem, 0.82vw, 0.82rem);
  line-height: 1.1;
}

.command-row.keyboard-selected:not(:disabled) {
  background: #292a2a !important;
  box-shadow: inset 3px 0 0 #d5231d;
  color: #fff;
}

.command-row.keyboard-selected:disabled {
  box-shadow: inset 3px 0 0 #5d2724;
}

.command-icon {
  width: 18px;
  font-size: 0.78rem;
}

.action-cost {
  margin-left: 4px;
  font-size: 0.52rem;
  line-height: 1;
  text-align: right;
}

#battle-screen[data-battle-state="finished"] .active-turn-marker,
#battle-screen[data-turn="enemy"] .active-turn-marker {
  display: none !important;
}

#fireball-effect,
#icepike-effect,
#poison-effect,
#damage-number {
  top: var(--effect-y, 35%);
  left: var(--effect-x, 60%);
}

.combatant-sprite.hit-flash {
  animation: fire-hit-shake 0.18s linear, fire-hit-flash 0.28s ease-out;
}

.combatant-sprite.ice-hit {
  animation: ice-hit-shake 0.15s linear, ice-hit-flash 0.22s ease-out;
}

.combatant-sprite.punch-hit {
  animation: punch-hit-shake 0.14s linear;
}

.combatant-sprite.player-hit {
  animation: player-hit-shake 0.34s linear, player-hit-flash 0.34s ease-out;
}

.combatant-sprite.healing-pulse {
  animation: battle-healing-pulse 0.62s ease-out;
}

@keyframes battle-healing-pulse {
  0%, 100% {
    filter: brightness(1);
  }
  32% {
    filter:
      brightness(1.35)
      drop-shadow(0 0 10px rgba(113, 242, 145, 0.72))
      drop-shadow(0 0 22px rgba(72, 190, 106, 0.42));
  }
  62% {
    filter:
      brightness(1.12)
      drop-shadow(0 0 12px rgba(113, 242, 145, 0.34));
  }
}

@keyframes active-marker-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 9px); }
}

@keyframes selected-target-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: grayscale(1) brightness(3.1) contrast(0.48) drop-shadow(0 0 16px rgba(255, 255, 255, 0.88)); }
}

/* Post-battle placeholder and battle-entry transition */

#battle-summary {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 56px);
  background: rgba(2, 3, 4, 0.9);
  pointer-events: auto;
}

.battle-summary-panel {
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto;
  gap: 14px;
  width: min(720px, 88vw);
  min-height: min(520px, 76vh);
  padding: clamp(18px, 3vw, 34px);
  border: 3px double var(--line);
  background: rgba(8, 9, 10, 0.97);
  box-shadow: 12px 14px 0 rgba(0, 0, 0, 0.48);
}

.battle-summary-reward {
  margin: 0;
  color: #f0d08a;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.battle-summary-progression {
  display: grid;
  gap: 16px;
  width: min(560px, 90%);
}

.battle-summary-meter-card {
  position: relative;
  padding: 14px 16px 15px;
  overflow: hidden;
  border: 1px solid rgba(169, 144, 96, 0.42);
  background: linear-gradient(180deg, rgba(39, 35, 29, 0.72), rgba(13, 13, 14, 0.82));
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.4);
}

.battle-summary-meter-card::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 12%, rgba(255, 236, 184, 0.2) 48%, transparent 78%);
  transform: translateX(-120%);
}

.battle-summary-meter-card.is-promotion {
  animation: battle-summary-promotion-pulse 620ms ease-out;
}

.battle-summary-meter-card.is-promotion::after {
  animation: battle-summary-promotion-sweep 620ms ease-out;
}

.battle-summary-meter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.battle-summary-meter-label {
  color: #9f927b;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.battle-summary-meter-value {
  color: #eee2ca;
  font-family: Georgia, serif;
  font-size: clamp(1.05rem, 2vw, 1.32rem);
  letter-spacing: 0.04em;
}

.battle-summary-meter-track {
  position: relative;
  height: 12px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(201, 173, 113, 0.45);
  background: rgba(0, 0, 0, 0.62);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.8);
}

.battle-summary-meter-track::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 38px,
    rgba(255, 255, 255, 0.065) 38px 39px
  );
}

.battle-summary-meter-fill {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  overflow: hidden;
  transition: width 850ms cubic-bezier(0.18, 0.82, 0.25, 1);
}

.battle-summary-exp .battle-summary-meter-fill {
  background: linear-gradient(90deg, #72582d, #c69d4f 72%, #f0d58a);
  box-shadow: 0 0 12px rgba(213, 171, 87, 0.38);
}

.battle-summary-rank .battle-summary-meter-fill {
  background: linear-gradient(90deg, #633a32, #a96b50 70%, #dfae76);
  box-shadow: 0 0 12px rgba(193, 111, 79, 0.35);
}

.battle-summary-meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 0 38%, rgba(255, 255, 255, 0.46) 50%, transparent 62%);
  transform: translateX(-120%);
  animation: battle-summary-meter-shine 760ms linear infinite;
}

.battle-summary-meter-detail {
  display: block;
  margin-top: 7px;
  color: #a99f8e;
  font-size: 0.75rem;
  letter-spacing: 0.045em;
  text-align: right;
}

.battle-summary-breakdown {
  width: min(590px, 92%);
  margin: 0;
  color: #a99f8e;
  font-size: 0.82rem;
  line-height: 1.5;
}

@keyframes battle-summary-meter-shine {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

@keyframes battle-summary-promotion-pulse {
  0%, 100% {
    border-color: rgba(169, 144, 96, 0.42);
    transform: scale(1);
  }
  45% {
    border-color: rgba(239, 208, 138, 0.92);
    transform: scale(1.018);
    box-shadow: 0 0 24px rgba(220, 177, 91, 0.28), inset 0 0 24px rgba(132, 100, 43, 0.14);
  }
}

@keyframes battle-summary-promotion-sweep {
  0% { opacity: 0; transform: translateX(-120%); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateX(120%); }
}


.battle-summary-panel h1 {
  margin: 5px 0 0;
  font-size: clamp(1.65rem, 4vw, 3rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#battle-summary-content {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line-muted);
  background: rgba(0, 0, 0, 0.28);
  color: #77736d;
  text-align: center;
}

#battle-summary-next {
  justify-self: end;
  min-width: 150px;
  padding: 10px 22px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

#battle-summary-next:hover,
#battle-summary-next:focus-visible {
  background: #fff;
  box-shadow: 0 0 0 2px #111, 0 0 0 4px var(--line);
}

#battle-intro-overlay {
  position: absolute;
  z-index: 50;
  inset: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.88);
  pointer-events: auto;
}

#battle-intro-overlay::before,
#battle-intro-overlay::after {
  content: "";
  position: absolute;
  inset: -12%;
  opacity: 1;
  transform: translateX(0) skewX(0);
}

#battle-intro-overlay::before {
  background: rgba(15, 14, 12, 0.94);
}

#battle-intro-overlay::after {
  inset: 0;
  background:
    linear-gradient(105deg, transparent 0 34%, rgba(138, 35, 29, 0.24) 46%, transparent 58%),
    rgba(0, 0, 0, 0.24);
}

/*
 * Continue the Map encounter wipe into Battle instead of opening with a
 * separate top/bottom curtain. The dark diagonal panel moves onward to the
 * right, revealing the battlefield as one continuous encounter transition.
 */
#battle-intro-overlay.is-revealing {
  animation: battle-encounter-reveal-backdrop 520ms ease-out forwards;
}

#battle-intro-overlay.is-revealing::before {
  animation: battle-encounter-reveal-wipe 520ms cubic-bezier(0.65, 0, 0.32, 1) forwards;
}

#battle-intro-overlay.is-revealing::after {
  animation: battle-encounter-reveal-flash 520ms ease-out forwards;
}

@keyframes battle-encounter-reveal-wipe {
  0% { opacity: 0.94; transform: translateX(0) skewX(0); }
  58% { opacity: 0.94; }
  100% { opacity: 0; transform: translateX(115%) skewX(-10deg); }
}

@keyframes battle-encounter-reveal-flash {
  0% { opacity: 0.22; transform: translateX(0) skewX(0); }
  34% { opacity: 0.72; }
  100% { opacity: 0; transform: translateX(115%) skewX(-10deg); }
}

@keyframes battle-encounter-reveal-backdrop {
  0%, 34% { background: rgba(0, 0, 0, 0.88); }
  100% { background: rgba(0, 0, 0, 0); }
}

@media (max-aspect-ratio: 4/3) {
  .title-illustration-stage {
    left: -15%;
    width: 68vw;
    opacity: 0.76;
  }

  .title-interface {
    right: 4%;
    width: 58vw;
  }

  #title-game-name {
    font-size: clamp(4rem, 12vw, 8rem);
  }

  .title-menu-item {
    grid-template-columns: minmax(40px, 0.75fr) minmax(0, 5fr) minmax(40px, 0.75fr);
    font-size: clamp(2.3rem, 7vw, 5.2rem);
  }

  .formation-slot {
    width: clamp(130px, 20vw, 220px);
    height: min(43vh, 380px);
  }

  .formation-slot.enemy-slot {
    width: clamp(160px, 23vw, 260px);
    height: min(44vh, 400px);
  }

  .entity-hud-group {
    width: clamp(166px, 21vw, 204px);
  }

  #battle-menu {
    left: 0;
    width: clamp(184px, 24vw, 220px);
  }

  #party-hud-layer {
    width: clamp(176px, 22vw, 212px);
  }
}

@media (max-width: 760px) {
  #title-screen {
    min-height: 480px;
  }

  .title-illustration-stage {
    right: -18%;
    left: auto;
    width: 86vw;
    opacity: 0.26;
  }

  .title-interface {
    top: 13%;
    right: 5%;
    left: 5%;
    width: 90%;
    height: 74%;
  }

  #title-game-name {
    font-size: clamp(3.7rem, 18vw, 7rem);
  }

  .title-menu-item {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    min-height: clamp(58px, 10vh, 82px);
    font-size: clamp(2.45rem, 13vw, 4.6rem);
  }

  .title-menu-arrow-left {
    border-top-width: 19px;
    border-right-width: 38px;
    border-bottom-width: 19px;
  }

  .title-menu-arrow-right {
    border-top-width: 19px;
    border-bottom-width: 19px;
    border-left-width: 38px;
  }

  .entity-hud-group {
    width: 166px;
  }

  #battle-menu {
    left: 0;
    width: min(208px, 42vw);
  }

  #party-hud-layer {
    inset: 82px auto auto 10px;
    width: min(180px, 39vw);
    gap: 54px;
  }
}


/* Title screen responsive polish */
@media (max-aspect-ratio: 4/3) {
  .title-background {
    background-position: 48% 55%;
  }

  .title-illustration-stage {
    bottom: -2%;
    left: -7%;
    width: 62vw;
    height: 91%;
    opacity: 0.9;
  }

  .title-interface {
    top: 14%;
    right: 3%;
    width: 58vw;
    height: 75%;
  }

  #title-game-name {
    font-size: clamp(4rem, 11.5vw, 7.9rem);
  }

  .title-menu {
    width: min(100%, 620px);
  }

  .title-menu-item {
    grid-template-columns: minmax(44px, 0.8fr) minmax(0, 4.9fr) minmax(44px, 0.8fr);
    min-height: clamp(58px, 8.2vh, 74px);
    font-size: clamp(2.35rem, 6.25vw, 4.65rem);
  }
}

@media (max-width: 760px) {
  #title-screen {
    min-height: 480px;
  }

  .title-background {
    background-position: 43% 50%;
    filter: sepia(0.18) saturate(0.48) contrast(1.08) brightness(0.68);
  }

  .title-background-sketch {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.34)),
      linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 30%, rgba(0, 0, 0, 0.34));
  }

  .title-illustration-stage {
    right: -17%;
    bottom: -3%;
    left: auto;
    width: 88vw;
    height: 85%;
    opacity: 0.3;
  }

  .title-interface {
    top: 13%;
    right: 5%;
    left: 5%;
    width: 90%;
    height: 76%;
  }

  #title-game-name {
    font-size: clamp(3.45rem, 17vw, 6.6rem);
  }

  .title-menu {
    width: min(100%, 560px);
  }

  .title-menu-item {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    min-height: clamp(54px, 9.2vh, 74px);
    font-size: clamp(2.25rem, 12vw, 4.3rem);
  }

  .title-menu-arrow-left {
    border-top-width: 18px;
    border-right-width: 36px;
    border-bottom-width: 18px;
  }

  .title-menu-arrow-right {
    border-top-width: 18px;
    border-bottom-width: 18px;
    border-left-width: 36px;
  }

  .title-studio-label {
    font-size: clamp(0.9rem, 4vw, 1.2rem);
  }

  .title-version {
    font-size: clamp(0.78rem, 3.4vw, 1rem);
  }
}


/* Litania X typography system
 * - Decorative gothic display only for the game logo
 * - Cinzel for battle names and dramatic headings
 * - Oswald for fast-reading menus, labels, and combat commands
 */
body {
  font-family: var(--font-body);
}

#title-game-name {
  font-family: var(--font-title);
  font-size: clamp(3.8rem, 7.15vw, 8.5rem);
  font-weight: 900;
  letter-spacing: 0.055em;
  line-height: 0.94;
  text-transform: uppercase;
  text-shadow:
    -2px -2px 0 #050505,
    2px -2px 0 #050505,
    -2px 2px 0 #050505,
    2px 2px 0 #050505,
    0 0 2px rgba(255, 255, 255, 0.35),
    7px 9px 0 rgba(0, 0, 0, 0.92);
}

.title-menu-item,
.title-studio-label,
.title-version,
.title-menu-status {
  font-family: var(--font-ui);
}

.title-menu-item {
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.title-studio-label,
.title-version {
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.eyebrow,
#turn-text,
.active-character-label,
.hud-side-label,
.hud-values p,
#enemy-hp,
.status-icon,
.battle-log-label,
.command-row,
.action-cost,
.command-tab-arrow,
#battle-summary-next,
.formation-marker,
.active-turn-marker,
#status-tooltip {
  font-family: var(--font-ui);
}

.hud-title-row h2,
#enemy-name,
#command-category-title,
#turn-popup,
#status-tooltip strong,
.battle-summary-panel h1 {
  font-family: var(--font-display);
}

.hud-title-row h2,
#enemy-name {
  font-weight: 700;
  letter-spacing: 0.035em;
}

#command-category-title {
  font-weight: 800;
  letter-spacing: 0.075em;
}

.command-row {
  font-weight: 500;
  letter-spacing: 0.025em;
}

#turn-text,
.eyebrow,
.hud-side-label,
.battle-log-label,
.action-cost {
  letter-spacing: 0.12em;
}

#turn-popup {
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#battle-log {
  font-family: var(--font-body);
}

#battle-log p:last-child {
  font-weight: 700;
}

.battle-summary-panel h1 {
  font-weight: 800;
}

@media (max-aspect-ratio: 4/3) {
  #title-game-name {
    font-size: clamp(3.6rem, 8.4vw, 7rem);
    letter-spacing: 0.045em;
  }

  .title-menu-item {
    font-size: clamp(2.15rem, 5.85vw, 4.35rem);
  }
}

@media (max-width: 760px) {
  #title-game-name {
    font-size: clamp(3rem, 13.5vw, 5.5rem);
    letter-spacing: 0.035em;
  }

  .title-menu-item {
    font-size: clamp(2.05rem, 10.8vw, 3.9rem);
  }
}


/* Title illustration integration polish
 * Ground the goddess into the old-city background so the PNG reads as part
 * of the scene instead of a cutout floating above it.
 */
.title-illustration-stage {
  bottom: -3.4vh;
}

.title-illustration-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 12%;
  right: 4%;
  bottom: -1.2%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.52) 0%,
    rgba(0, 0, 0, 0.26) 45%,
    transparent 76%
  );
  filter: blur(13px);
  opacity: 0.72;
  transform: scaleX(1.08);
  pointer-events: none;
}

.title-illustration {
  opacity: 0.93;
  filter:
    sepia(0.1)
    saturate(0.72)
    contrast(0.96)
    brightness(0.9)
    drop-shadow(8px 11px 10px rgba(0, 0, 0, 0.34));
}

@media (max-aspect-ratio: 4/3) {
  .title-illustration-stage {
    bottom: -3.6%;
  }

  .title-illustration {
    opacity: 0.88;
  }
}

@media (max-width: 760px) {
  .title-illustration-stage {
    bottom: -4%;
  }

  .title-illustration-stage::before {
    opacity: 0.5;
  }

  .title-illustration {
    opacity: 0.26;
    filter:
      sepia(0.12)
      saturate(0.62)
      contrast(0.92)
      brightness(0.82)
      drop-shadow(5px 8px 8px rgba(0, 0, 0, 0.26));
  }
}


/* Title menu single selection cursor
 * Use one larger cursor tucked close to the selected label.
 */
.title-menu-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}

.title-menu-label {
  grid-column: 2;
  display: block;
  width: auto;
  text-align: center;
}

.title-menu-arrow-right {
  display: none;
}

.title-menu-arrow-left {
  position: static;
  grid-column: 1;
  justify-self: end;
  width: 0;
  height: 0;
  margin-right: clamp(9px, 1vw, 14px);
  border: 0;
  border-top: clamp(12px, 1.45vw, 18px) solid transparent;
  border-bottom: clamp(12px, 1.45vw, 18px) solid transparent;
  border-left: clamp(22px, 2.35vw, 32px) solid #e44742;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.85));
  opacity: 0;
  transform: translateX(-7px);
  transition:
    opacity 110ms ease,
    transform 140ms ease,
    filter 140ms ease;
}

.title-menu-item.is-selected:not(:disabled) .title-menu-arrow-left,
.title-menu-item:hover:not(:disabled) .title-menu-arrow-left,
.title-menu-item:focus-visible:not(:disabled) .title-menu-arrow-left {
  opacity: 1;
  transform: translateX(0);
  filter:
    drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.85))
    drop-shadow(0 0 5px rgba(228, 71, 66, 0.24));
}

@media (max-aspect-ratio: 4/3) {
  .title-menu-arrow-left {
    margin-right: 9px;
    border-top-width: 13px;
    border-bottom-width: 13px;
    border-left-width: 23px;
  }
}

@media (max-width: 760px) {
  .title-menu-arrow-left {
    margin-right: 7px;
    border-top-width: 11px;
    border-bottom-width: 11px;
    border-left-width: 20px;
  }
}


/* Battle command selection typography
 * Mirror the title-menu feedback without changing command row dimensions.
 */
.command-name {
  display: inline-block;
  font-size: 1em;
  line-height: 1;
  transition:
    font-size 110ms ease,
    filter 110ms ease,
    letter-spacing 110ms ease;
}

.command-row.keyboard-selected:not(:disabled) .command-name,
.command-row.selected-action:not(:disabled) .command-name,
.command-row:hover:not(:disabled) .command-name,
.command-row:focus-visible:not(:disabled) .command-name {
  font-size: 1.07em;
  filter: brightness(1.08);
  letter-spacing: 0.04em;
}

.command-row.keyboard-selected:not(:disabled) .action-cost,
.command-row.selected-action:not(:disabled) .action-cost,
.command-row:hover:not(:disabled) .action-cost,
.command-row:focus-visible:not(:disabled) .action-cost {
  filter: brightness(1.08);
}

.action-cost {
  transition: filter 110ms ease;
}


/* Enemy HUD threat marker and extended name bar */
.enemy-entity-hud[data-hud-anchor="above-head"] {
  width: clamp(230px, 16vw, 320px);
}

.enemy-entity-hud .entity-hud-card {
  grid-template-columns: 48px minmax(0, 1fr);
}

.enemy-entity-hud .portrait-placeholder,
.enemy-threat-marker {
  display: grid;
  place-items: center;
  width: 48px;
  height: 100%;
  min-height: 60px;
  border-right: 1px solid var(--line-muted);
  background: #050505;
  color: #f4f1e9;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
  line-height: 1;
  text-shadow: 0 0 5px currentColor;
}

.enemy-threat-marker.threat-standard {
  color: #f4f1e9;
}

.enemy-threat-marker.threat-elite {
  color: #e8842f;
  text-shadow:
    0 0 4px rgba(232, 132, 47, 0.72),
    0 0 9px rgba(232, 132, 47, 0.24);
}

.enemy-threat-marker.threat-boss {
  color: #d83b34;
  text-shadow:
    0 0 4px rgba(216, 59, 52, 0.82),
    0 0 10px rgba(216, 59, 52, 0.34);
}

.enemy-entity-hud .entity-hud-content {
  min-width: 0;
  padding-right: 8px;
}

.enemy-entity-hud .hud-title-row {
  gap: 6px;
}

.enemy-entity-hud .hud-title-row h2 {
  max-width: none;
  overflow: visible;
  font-size: clamp(0.76rem, 0.9vw, 0.94rem);
  letter-spacing: 0.025em;
  text-overflow: clip;
  white-space: nowrap;
}

.enemy-entity-hud .hud-bar {
  width: 100%;
}

@media (max-aspect-ratio: 4/3) {
  .enemy-entity-hud[data-hud-anchor="above-head"] {
    width: clamp(215px, 27vw, 285px);
  }

  .enemy-entity-hud .hud-title-row h2 {
    font-size: clamp(0.7rem, 1.2vw, 0.86rem);
  }
}

@media (max-width: 760px) {
  .enemy-entity-hud[data-hud-anchor="above-head"] {
    width: clamp(205px, 58vw, 270px);
  }

  .enemy-entity-hud .entity-hud-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .enemy-entity-hud .portrait-placeholder,
  .enemy-threat-marker {
    width: 44px;
    font-size: 1.35rem;
  }
}


/* Map movement test ------------------------------------------------------- */
#map-screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #11110d;
  color: #eee8da;
}

#map-screen[hidden] {
  display: none;
}

.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #20221d;
}

.map-world {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  transform-origin: 0 0;
  will-change: transform;
}


/* Exploration atmosphere -------------------------------------------------
 * Viewport-space CSS weather, intentionally independent from map assets.
 * Front Forest + towns get light moving cloud cover.
 * Deep Forest gets cloud shadow + mid fog + low ground mist.
 */
.map-weather-layer {
  position: absolute;
  inset: -18%;
  display: none;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  will-change: transform, opacity;
}

.map-cloud-shadow-layer {
  z-index: 780;
  background:
    radial-gradient(ellipse at 12% 34%, rgba(22, 28, 25, 0.22) 0 9%, rgba(22, 28, 25, 0.1) 18%, transparent 34%),
    radial-gradient(ellipse at 42% 62%, rgba(18, 24, 22, 0.18) 0 11%, rgba(18, 24, 22, 0.08) 20%, transparent 38%),
    radial-gradient(ellipse at 73% 28%, rgba(25, 31, 28, 0.2) 0 10%, rgba(25, 31, 28, 0.08) 19%, transparent 36%),
    radial-gradient(ellipse at 92% 72%, rgba(18, 23, 21, 0.16) 0 9%, rgba(18, 23, 21, 0.07) 18%, transparent 34%);
  background-size: 64% 62%, 72% 68%, 68% 64%, 58% 58%;
  filter: blur(30px);
  mix-blend-mode: multiply;
  animation: mapCloudShadowDrift 46s linear infinite alternate;
}

.map-cloud-shadow-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 26% 28%, rgba(255, 248, 218, 0.13) 0 8%, transparent 30%),
    radial-gradient(ellipse at 74% 58%, rgba(255, 248, 220, 0.1) 0 10%, transparent 34%);
  mix-blend-mode: screen;
  opacity: 0.4;
}

.map-mid-fog-layer {
  z-index: 820;
  background:
    radial-gradient(ellipse at 16% 42%, rgba(205, 213, 208, 0.26) 0 11%, rgba(205, 213, 208, 0.12) 25%, transparent 47%),
    radial-gradient(ellipse at 54% 34%, rgba(190, 201, 195, 0.2) 0 13%, rgba(190, 201, 195, 0.09) 29%, transparent 52%),
    radial-gradient(ellipse at 88% 62%, rgba(207, 214, 210, 0.22) 0 10%, rgba(207, 214, 210, 0.08) 26%, transparent 48%);
  background-size: 78% 54%, 86% 60%, 72% 52%;
  filter: blur(26px);
  animation: mapMidFogDrift 34s linear infinite alternate;
}

.map-ground-mist-layer {
  z-index: 860;
  top: 42%;
  bottom: -22%;
  background:
    radial-gradient(ellipse at 10% 76%, rgba(222, 226, 221, 0.28) 0 10%, rgba(222, 226, 221, 0.11) 28%, transparent 52%),
    radial-gradient(ellipse at 42% 64%, rgba(210, 217, 212, 0.24) 0 13%, rgba(210, 217, 212, 0.09) 30%, transparent 55%),
    radial-gradient(ellipse at 76% 82%, rgba(224, 228, 224, 0.25) 0 11%, rgba(224, 228, 224, 0.09) 29%, transparent 53%);
  background-size: 74% 58%, 82% 62%, 70% 56%;
  filter: blur(22px);
  animation: mapGroundMistDrift 26s ease-in-out infinite alternate;
}

/* Bright outdoor mood: moving cloud shade only. */
#map-screen[data-map-node-id="front-forest"] .map-cloud-shadow-layer,
#map-screen[data-map-node-id="town-south"] .map-cloud-shadow-layer,
#map-screen[data-map-node-id="town-north"] .map-cloud-shadow-layer {
  display: block;
  opacity: 0.14;
  filter: blur(36px);
}

#map-screen[data-map-node-id="front-forest"] .map-cloud-shadow-layer::after,
#map-screen[data-map-node-id="town-south"] .map-cloud-shadow-layer::after,
#map-screen[data-map-node-id="town-north"] .map-cloud-shadow-layer::after {
  opacity: 0.72;
}


/* Town sunlight: reuse the otherwise-idle mid layer as warm moving sunlight.
 * This keeps Front Forest light and breezy while making both town maps feel
 * distinctly brighter without introducing image assets. */
#map-screen[data-map-node-id="town-south"] .map-mid-fog-layer,
#map-screen[data-map-node-id="town-north"] .map-mid-fog-layer {
  display: block;
  opacity: 0.24;
  background:
    radial-gradient(ellipse at 18% 24%, rgba(255, 244, 188, 0.34) 0 9%, rgba(255, 238, 173, 0.16) 22%, transparent 46%),
    radial-gradient(ellipse at 56% 48%, rgba(255, 248, 211, 0.28) 0 11%, rgba(255, 241, 188, 0.12) 25%, transparent 49%),
    radial-gradient(ellipse at 86% 72%, rgba(255, 236, 166, 0.24) 0 8%, rgba(255, 231, 151, 0.1) 21%, transparent 44%);
  background-size: 70% 58%, 82% 64%, 64% 54%;
  filter: blur(34px);
  mix-blend-mode: screen;
  animation: mapTownSunDrift 42s ease-in-out infinite alternate;
}

#map-screen[data-map-node-id="town-south"],
#map-screen[data-map-node-id="town-north"] {
  --map-ground-saturation: 0.7;
  --map-ground-brightness: 0.78;
  --map-ground-contrast: 1.03;
}

/* Deep Forest mood: darker moving cloud cover + layered fog. */
#map-screen[data-map-node-id="deep-forest"] .map-cloud-shadow-layer {
  display: block;
  opacity: 0.42;
  filter: blur(28px) saturate(0.72);
}

#map-screen[data-map-node-id="deep-forest"] .map-cloud-shadow-layer::after {
  opacity: 0.13;
}

#map-screen[data-map-node-id="deep-forest"] .map-mid-fog-layer {
  display: block;
  opacity: 0.34;
}

#map-screen[data-map-node-id="deep-forest"] .map-ground-mist-layer {
  display: block;
  opacity: 0.42;
}

/* Keep the F2 blueprint clean and readable. */
#map-screen.map-debug-visible .map-weather-layer {
  opacity: 0 !important;
}

@keyframes mapCloudShadowDrift {
  from { transform: translate3d(-8%, -3%, 0) scale(1.03); }
  to { transform: translate3d(10%, 5%, 0) scale(1.08); }
}

@keyframes mapMidFogDrift {
  from { transform: translate3d(-12%, 2%, 0) scale(1.04); }
  to { transform: translate3d(13%, -4%, 0) scale(1.12); }
}

@keyframes mapGroundMistDrift {
  from { transform: translate3d(-8%, 3%, 0) scale(1.08); }
  to { transform: translate3d(11%, -2%, 0) scale(1.14); }
}

@keyframes mapTownSunDrift {
  from { transform: translate3d(-7%, -2%, 0) scale(1.04); }
  to { transform: translate3d(9%, 4%, 0) scale(1.1); }
}

.map-node-base,
.map-node-ground-layer,
.map-node-forest-layer,
.map-node-vegetation-layer,
.map-node-town-layer,
.map-node-layout-layer,
.map-node-grid-layer {
  position: absolute;
  inset: 0;
}

.map-node-base {
  z-index: 0;
  overflow: hidden;
  background-color: #34372f;
  background-image: var(--map-ground-base-image, none);
  background-repeat: repeat;
  background-position: var(--map-ground-base-position, 0 0);
  background-size: var(--map-ground-base-size, 560px 560px);
  filter:
    saturate(var(--map-ground-saturation, 0.72))
    brightness(var(--map-ground-brightness, 0.78))
    contrast(var(--map-ground-contrast, 1.04));
}

/* A low-opacity, larger repeat breaks up obvious base-tile repetition without
 * stretching the source artwork. */
.map-node-base::after {
  content: "";
  position: absolute;
  inset: -8%;
  background-image: var(--map-ground-base-image, none);
  background-repeat: repeat;
  background-position: var(--map-ground-overlay-position, 170px -115px);
  background-size: var(--map-ground-overlay-size, 820px 820px);
  mix-blend-mode: soft-light;
  opacity: var(--map-ground-overlay-opacity, 0.14);
  pointer-events: none;
  transform: scale(1.02);
}

/*
 * Rough ground-asset integration.
 * Keep the authored source proportions intact: these surfaces are cropped or
 * repeated, never stretched independently on X/Y. This lets the three current
 * ground images cover the blockout while the final tile set is still pending.
 */
#map-screen {
  --ground-grass-image: url("assets/images/map/ground/grass/ground_grass_01.png");
  --ground-dirt-image: url("assets/images/map/ground/dirt/ground_dirt_01.png");
  --ground-stone-image: url("assets/images/map/ground/stone/ground_stone_01.png");
  --map-ground-base-image: var(--ground-grass-image);
  --map-ground-base-size: 560px 560px;
  --map-ground-overlay-size: 860px 860px;
  --map-ground-saturation: 0.64;
  --map-ground-brightness: 0.68;
  --map-ground-contrast: 1.08;
}

#map-screen[data-map-node-id="front-forest"] {
  --map-ground-base-image: var(--ground-grass-image);
  --map-ground-base-size: 580px 580px;
  --map-ground-overlay-size: 890px 890px;
  --map-ground-overlay-position: 160px -120px;
  --map-ground-base-position: 28px 14px;
  --map-ground-saturation: 0.62;
  --map-ground-brightness: 0.70;
}

#map-screen[data-map-node-id="deep-forest"] {
  --map-ground-base-image: var(--ground-grass-image);
  --map-ground-base-size: 520px 520px;
  --map-ground-overlay-size: 810px 810px;
  --map-ground-overlay-position: -145px 105px;
  --map-ground-base-position: -42px 20px;
  --map-ground-saturation: 0.52;
  --map-ground-brightness: 0.58;
  --map-ground-contrast: 1.12;
}

#map-screen[data-map-node-id="town-south"],
#map-screen[data-map-node-id="town-north"] {
  --map-ground-base-image: var(--ground-dirt-image);
  --map-ground-base-size: 545px 545px;
  --map-ground-overlay-size: 840px 840px;
  --map-ground-overlay-position: 190px 125px;
  --map-ground-saturation: 0.48;
  --map-ground-brightness: 0.66;
  --map-ground-contrast: 1.08;
}

/* Exploration integration baseline: map-specific floor plus gameplay entities.
 * Decorative authored layers remain available in data for a later art pass. */
#map-screen[data-map-visual-mode="minimal-ground"] {
  --map-ground-base-image: var(--ground-grass-image);
  --map-ground-base-size: 580px 580px;
  --map-ground-overlay-size: 890px 890px;
  --map-ground-overlay-position: 160px -120px;
  --map-ground-base-position: 28px 14px;
  --map-ground-saturation: 0.62;
  --map-ground-brightness: 0.70;
  --map-ground-contrast: 1.06;
}

.map-node-ground-layer {
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.map-node-ground-patch {
  position: absolute;
  overflow: hidden;
  border-radius: 46% 54% 42% 58% / 52% 44% 56% 48%;
  background-color: rgba(77, 69, 51, 0.28);
  background-repeat: repeat;
  background-position: var(--ground-background-x, 0) var(--ground-background-y, 0);
  background-size: var(--ground-background-size, 320px) var(--ground-background-size, 320px);
  box-shadow:
    inset 0 0 34px rgba(25, 23, 18, 0.12),
    0 0 18px rgba(17, 16, 13, 0.08);
  filter: saturate(0.7) brightness(0.8) contrast(1.03);
  opacity: var(--ground-stamp-opacity, 0.8);
  transform: rotate(var(--ground-stamp-rotation, 0deg));
  transform-origin: center;
}

.map-node-ground-patch-outer {
  z-index: 0;
  filter: saturate(0.72) brightness(0.82) contrast(1.02);
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.9) 0 38%,
    rgba(0, 0, 0, 0.5) 62%,
    rgba(0, 0, 0, 0.16) 79%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.9) 0 38%,
    rgba(0, 0, 0, 0.5) 62%,
    rgba(0, 0, 0, 0.16) 79%,
    transparent 100%
  );
}

.map-node-ground-patch-transition {
  z-index: 1;
  filter: saturate(0.72) brightness(0.79) contrast(1.03);
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    #000 0 46%,
    rgba(0, 0, 0, 0.76) 67%,
    rgba(0, 0, 0, 0.3) 84%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse at center,
    #000 0 46%,
    rgba(0, 0, 0, 0.76) 67%,
    rgba(0, 0, 0, 0.3) 84%,
    transparent 100%
  );
}

.map-node-ground-patch-edge {
  z-index: 2;
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    #000 0 55%,
    rgba(0, 0, 0, 0.92) 69%,
    rgba(0, 0, 0, 0.52) 84%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse at center,
    #000 0 55%,
    rgba(0, 0, 0, 0.92) 69%,
    rgba(0, 0, 0, 0.52) 84%,
    transparent 100%
  );
}

.map-node-ground-patch-core {
  z-index: 3;
  border-radius: 22px 27px 20px 25px;
  box-shadow:
    inset 0 0 18px rgba(28, 24, 17, 0.2),
    inset 0 0 0 1px rgba(220, 204, 166, 0.04);
  filter: saturate(0.68) brightness(0.76) contrast(1.04);
}

.map-node-ground-patch[data-ground-variant="1"] {
  border-radius: 53% 47% 58% 42% / 43% 57% 46% 54%;
  background-position: 38% 56%;
  filter: saturate(0.68) brightness(0.75) contrast(1.05);
}

.map-node-ground-patch[data-ground-variant="2"] {
  border-radius: 43% 57% 48% 52% / 58% 42% 55% 45%;
  background-position: 62% 44%;
  filter: saturate(0.76) brightness(0.8) contrast(1.03);
}

.map-node-ground-patch[data-ground-variant="3"] {
  border-radius: 57% 43% 45% 55% / 47% 53% 59% 41%;
  background-position: 48% 68%;
  filter: saturate(0.64) brightness(0.73) contrast(1.07);
}

.map-node-ground-patch-town {
  border-radius: 32% 38% 30% 40% / 35% 30% 42% 33%;
}

/* Town roads are composed globally by layer. Every edge sits below every
 * opaque road core, so crossing streets join without dark stacked seams. */
.map-node-ground-patch-town.map-node-ground-patch-outer,
.map-node-ground-patch-town.map-node-ground-patch-transition {
  display: none;
}

.map-node-ground-patch-town.map-node-ground-patch-edge {
  border-radius: 24px 18px 26px 20px;
  box-shadow: none;
  filter: saturate(0.74) brightness(0.82) contrast(1.04);
  opacity: 0.94;
}

.map-node-ground-patch-town.map-node-ground-patch-core {
  border-radius: 12px 15px 11px 16px;
  box-shadow: none;
  filter: saturate(0.66) brightness(0.78) contrast(1.04);
  opacity: 1;
}

.map-node-ground-patch-public-square.map-node-ground-patch-town {
  border-radius: 22px 18px 25px 20px;
}

.map-node-ground-patch-public-square.map-node-ground-patch-core {
  box-shadow: none;
  filter: saturate(0.64) brightness(0.78) contrast(1.04);
}

.map-node-ground-patch-forest.map-node-ground-patch-core {
  border-radius: 22px 27px 20px 25px;
  filter: saturate(0.68) brightness(0.76) contrast(1.04);
}

#map-screen[data-map-node-id="deep-forest"] .map-node-ground-patch-edge {
  filter: saturate(0.58) brightness(0.65) contrast(1.08);
}

#map-screen[data-map-node-id="town-south"] .map-node-ground-patch-edge,
#map-screen[data-map-node-id="town-north"] .map-node-ground-patch-edge {
  filter: saturate(0.62) brightness(0.73) contrast(1.06);
}

/* Front Forest test: one static region represents each blocked forest wall.
 * Illustrated PNG trees remain above this layer at exposed edges and Y-sort
 * points; the mass supplies distant canopy, shared shade, and visual density. */
.map-node-forest-layer {
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.forest-mass {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  background-color: #273127;
  background-image:
    radial-gradient(circle at 13% 18%, rgba(82, 91, 57, 0.54) 0 7%, transparent 7.6%),
    radial-gradient(circle at 37% 43%, rgba(54, 67, 43, 0.72) 0 10%, transparent 10.8%),
    radial-gradient(circle at 66% 23%, rgba(70, 80, 49, 0.58) 0 9%, transparent 9.8%),
    radial-gradient(circle at 84% 61%, rgba(43, 57, 39, 0.78) 0 12%, transparent 12.8%),
    radial-gradient(circle at 27% 82%, rgba(63, 73, 46, 0.56) 0 11%, transparent 11.8%);
  border-radius: 18% 26% 21% 16% / 14% 20% 17% 24%;
  opacity: 0.96;
}

.forest-mass::before {
  content: "";
  position: absolute;
  inset: 4% 3%;
  background:
    radial-gradient(ellipse at 18% 32%, rgba(97, 104, 65, 0.28) 0 11%, transparent 12%),
    radial-gradient(ellipse at 52% 16%, rgba(75, 86, 55, 0.33) 0 13%, transparent 14%),
    radial-gradient(ellipse at 73% 52%, rgba(20, 29, 23, 0.32) 0 17%, transparent 18%),
    radial-gradient(ellipse at 41% 78%, rgba(33, 43, 31, 0.38) 0 15%, transparent 16%);
  border-radius: 24% 17% 28% 21% / 20% 27% 18% 25%;
  opacity: 0.9;
}

.forest-shadow {
  box-shadow:
    inset 0 -30px 0 rgba(15, 21, 17, 0.27),
    inset 0 0 0 2px rgba(16, 22, 17, 0.2);
}

/* This pseudo-element is the broken foliage edge between the mass and path.
 * It uses static shapes only: no blur, per-frame animation, or CSS filter. */
.forest-edge::after {
  content: "";
  position: absolute;
  background-color: #354234;
  background-image:
    radial-gradient(circle at 14% 44%, #586044 0 8%, transparent 9%),
    radial-gradient(circle at 39% 66%, #424e38 0 12%, transparent 13%),
    radial-gradient(circle at 68% 31%, #687050 0 9%, transparent 10%),
    radial-gradient(circle at 88% 72%, #303d31 0 11%, transparent 12%);
  border-radius: 44% 56% 38% 62% / 58% 42% 61% 39%;
  opacity: 0.88;
}

.forest-edge-east::after,
.forest-edge-west::after {
  top: 4%;
  bottom: 4%;
  width: 38px;
  background-size: 44px 108px;
}

.forest-edge-east::after { right: -14px; }
.forest-edge-west::after { left: -14px; }

.forest-edge-north::after,
.forest-edge-south::after {
  left: 4%;
  right: 4%;
  height: 38px;
  background-size: 112px 42px;
}

.forest-edge-north::after { top: -14px; }
.forest-edge-south::after { bottom: -14px; }

.forest-mass[data-forest-variant="1"] {
  border-radius: 25% 14% 22% 29% / 19% 27% 15% 23%;
  background-position: 41px -23px, -17px 31px, 66px 18px, 24px 72px, -38px 9px;
}

.forest-mass[data-forest-variant="2"] {
  border-radius: 15% 27% 18% 24% / 27% 16% 25% 13%;
  background-position: -31px 24px, 38px -16px, 12px 54px, -46px 37px, 71px -28px;
}

.forest-mass[data-forest-variant="3"] {
  border-radius: 28% 19% 25% 14% / 16% 24% 13% 29%;
  background-position: 19px 46px, -42px 8px, 57px -19px, 8px 63px, -26px -31px;
}

.map-node-vegetation-layer {
  overflow: hidden;
  pointer-events: none;
}

.map-node-vegetation {
  position: absolute;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* A small feathered terrain decal visually seats roots in the same ground
 * palette. It is independent of the shadow so engine-side lighting can later
 * replace the shadow without changing tree placement. */
.map-node-vegetation::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: -9px;
  width: calc(var(--vegetation-height, 180px) * 0.54);
  height: calc(var(--vegetation-height, 180px) * 0.19);
  border-radius: 50%;
  background-image: var(--vegetation-base-image, none);
  background-position: center 62%;
  background-size: 190% auto;
  mix-blend-mode: multiply;
  opacity: 0.26;
  transform: translateX(-50%);
  -webkit-mask-image: radial-gradient(ellipse, #000 0 38%, rgba(0, 0, 0, 0.7) 58%, transparent 82%);
  mask-image: radial-gradient(ellipse, #000 0 38%, rgba(0, 0, 0, 0.7) 58%, transparent 82%);
}

.map-node-vegetation::after {
  content: none;
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: calc(var(--vegetation-height, 180px) * 0.34);
  height: calc(var(--vegetation-height, 180px) * 0.085);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.24) 0 42%, rgba(0, 0, 0, 0.1) 62%, transparent 78%);
  opacity: var(--vegetation-opacity, 1);
  transform: translateX(-50%);
}

.tree-shadow::after {
  content: "";
}

.map-node-vegetation img {
  position: absolute;
  left: 50%;
  bottom: var(--vegetation-root-offset, -8px);
  width: auto;
  max-width: none;
  height: var(--vegetation-height, 180px);
  object-fit: contain;
  object-position: center bottom;
  opacity: var(--vegetation-opacity, 1);
  transform:
    translateX(-50%)
    rotate(var(--vegetation-rotation, 0deg))
    scaleX(var(--vegetation-flip, 1));
  transform-origin: center bottom;
  user-select: none;
}

.map-node-vegetation-tree img {
  filter:
    saturate(0.72)
    brightness(0.76)
    contrast(1.05)
    drop-shadow(0 4px 3px rgba(0, 0, 0, 0.24));
}

/* Front Forest trees share the region shadow instead of paying for a
 * drop-shadow filter on every PNG. Only selected .tree-shadow nodes retain a
 * small, unblurred contact ellipse at their footpoint. */
#map-screen[data-map-node-id="front-forest"] .uses-shared-forest-shadow img {
  filter: saturate(0.72) brightness(0.76) contrast(1.05);
}

.tree,
.ground-decoration {
  pointer-events: none;
}

#map-screen[data-map-node-id="deep-forest"] .map-node-vegetation-tree img {
  filter:
    saturate(0.62)
    brightness(0.66)
    contrast(1.08)
    drop-shadow(0 5px 4px rgba(0, 0, 0, 0.28));
}

.map-node-vegetation-grass::after {
  bottom: -1px;
  width: calc(var(--vegetation-height, 42px) * 0.62);
  height: calc(var(--vegetation-height, 42px) * 0.12);
  opacity: 0.42;
}

.map-node-vegetation-grass::before {
  bottom: -5px;
  width: calc(var(--vegetation-height, 42px) * 1.05);
  height: calc(var(--vegetation-height, 42px) * 0.36);
  opacity: 0.24;
}

.map-node-vegetation-grass img {
  filter:
    saturate(0.68)
    brightness(0.76)
    contrast(1.04)
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
}

#map-screen[data-map-node-id="town-south"] .map-node-vegetation img,
#map-screen[data-map-node-id="town-north"] .map-node-vegetation img {
  filter:
    saturate(0.58)
    brightness(0.74)
    contrast(1.04)
    drop-shadow(0 8px 6px rgba(0, 0, 0, 0.22));
}

.map-node-town-layer {
  overflow: visible;
  pointer-events: none;
}

.map-town-prop {
  position: absolute;
  width: 1px;
  height: 1px;
  isolation: isolate;
  pointer-events: none;
}

.map-town-prop::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -6px;
  width: var(--town-contact-width, 96px);
  height: var(--town-contact-depth, 12px);
  border-radius: 50%;
  background: radial-gradient(
    ellipse,
    rgba(20, 18, 14, 0.34) 0 38%,
    rgba(20, 18, 14, 0.17) 58%,
    transparent 78%
  );
  transform: translateX(-50%);
  pointer-events: none;
}

.map-town-prop img {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: var(--town-prop-root-offset, 0px);
  width: auto;
  max-width: none;
  height: var(--town-prop-height, 220px);
  object-fit: contain;
  object-position: center bottom;
  image-rendering: auto;
  opacity: 0.98;
  transform: translateX(-50%) scaleX(var(--town-prop-flip, 1));
  transform-origin: center bottom;
  filter:
    saturate(0.82)
    brightness(0.82)
    contrast(1.04)
    drop-shadow(0 9px 5px rgba(0, 0, 0, 0.24));
  user-select: none;
}

.map-town-prop[data-size-mode="width"] img {
  width: var(--town-prop-width, 320px);
  height: auto;
}

.map-town-prop-wall-x img,
.map-town-prop-wall-y img {
  filter:
    saturate(0.68)
    brightness(0.72)
    contrast(1.08)
    drop-shadow(0 6px 4px rgba(0, 0, 0, 0.22));
}

.map-town-prop-gate img {
  filter:
    saturate(0.76)
    brightness(0.78)
    contrast(1.08)
    drop-shadow(0 8px 5px rgba(0, 0, 0, 0.25));
}

.map-town-prop-market img {
  filter:
    saturate(0.88)
    brightness(0.84)
    contrast(1.03)
    drop-shadow(0 5px 3px rgba(0, 0, 0, 0.22));
}

.map-town-prop-barrel img {
  filter:
    saturate(0.74)
    brightness(0.78)
    contrast(1.05)
    drop-shadow(0 3px 2px rgba(0, 0, 0, 0.2));
}

#map-screen[data-map-node-id="town-south"] .map-node-base,
#map-screen[data-map-node-id="town-north"] .map-node-base {
  filter:
    saturate(var(--map-ground-saturation, 0.56))
    brightness(var(--map-ground-brightness, 0.72))
    contrast(var(--map-ground-contrast, 1.06));
}

.map-node-layout-layer {
  z-index: 2;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

#map-screen.map-debug-visible .map-node-layout-layer {
  visibility: visible;
  opacity: 1;
}

.map-node-grid-layer {
  z-index: 10;
  background-image:
    repeating-linear-gradient(to right, rgba(246, 241, 224, 0.22) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(to bottom, rgba(246, 241, 224, 0.22) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(to right, rgba(222, 188, 112, 0.32) 0 2px, transparent 2px 320px),
    repeating-linear-gradient(to bottom, rgba(222, 188, 112, 0.32) 0 2px, transparent 2px 320px);
  background-size: 64px 64px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

#map-screen[data-map-node-id="town-south"] .map-node-grid-layer,
#map-screen[data-map-node-id="town-north"] .map-node-grid-layer {
  opacity: 0.56;
}

#map-screen.map-debug-visible .map-node-grid-layer,
#map-screen.map-grid-visible .map-node-grid-layer {
  visibility: visible;
  opacity: 1;
}

.map-node-object {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 4px;
  overflow: hidden;
  border: 2px solid rgba(222, 218, 205, 0.68);
  background: rgba(77, 78, 73, 0.68);
  color: #fffdf4;
  text-align: center;
}

.map-node-object-label {
  max-width: 100%;
  padding: 2px 4px;
  background: rgba(7, 8, 7, 0.82);
  font-family: Arial, sans-serif;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

/* Replaced blockout geometry stays in the DOM as an editable blueprint, but
 * no longer paints over finished ground/tree assets during normal play. */
.map-node-object.is-asset-dressed {
  opacity: 0.055;
}

.map-node-object.is-asset-dressed .map-node-object-label {
  opacity: 0;
}

#map-screen.map-debug-visible .map-node-object.is-asset-dressed,
#map-screen.map-debug-visible .map-node-object.is-asset-dressed .map-node-object-label {
  opacity: 1;
}

.map-node-group-zones { z-index: 1; }
.map-node-group-paths { z-index: 2; }
.map-node-group-footprints { z-index: 3; }
.map-node-group-markers { z-index: 4; }
.map-node-group-spawns { z-index: 5; }
.map-node-group-warps { z-index: 6; }

.map-node-type-walkable {
  align-items: start;
  justify-items: start;
  border-color: rgba(101, 185, 120, 0.56);
  background: rgba(44, 104, 58, 0.08);
}

.map-node-type-blocked {
  align-items: start;
  justify-items: start;
  border: 3px dashed rgba(196, 93, 93, 0.82);
  background:
    linear-gradient(rgba(58, 25, 25, 0.38), rgba(58, 25, 25, 0.38));
  color: #ffdddd;
}

.map-node-group-paths {
  border-color: rgba(216, 201, 159, 0.42);
  background-color: rgba(101, 84, 57, 0.16);
  background-image:
    linear-gradient(rgba(40, 35, 26, 0.06), rgba(40, 35, 26, 0.06));
  background-repeat: repeat;
  background-position: center;
  background-size: 300px 300px;
  background-blend-mode: multiply;
  box-shadow:
    inset 0 0 20px rgba(34, 29, 22, 0.42),
    0 0 0 1px rgba(25, 22, 17, 0.12);
}

.map-node-type-secondary-path {
  border-style: dashed;
  background-size: 260px 260px;
  filter: saturate(0.72) brightness(0.86);
}

.map-node-type-alley {
  border-style: dashed;
  background-color: rgba(66, 57, 43, 0.12);
  background-image: none;
  filter: none;
}

/*
 * Real ground art now lives one layer below the blockout markers. Keep road
 * and public-space geometry readable without painting over the mixed assets.
 */
#map-screen[data-map-node-id="town-south"] .map-node-group-paths:not(.map-node-type-alley),
#map-screen[data-map-node-id="town-north"] .map-node-group-paths:not(.map-node-type-alley) {
  background-color: rgba(82, 78, 68, 0.1);
  background-image: none;
  filter: none;
}

#map-screen[data-map-node-id="town-south"] [data-map-object-id="south-public-space"],
#map-screen[data-map-node-id="town-north"] [data-map-object-id="north-square"] {
  background-color: rgba(90, 86, 75, 0.08);
  background-image: none;
}

.map-node-group-footprints {
  border-color: #b8b5ab;
  background: rgba(82, 83, 79, 0.9);
}

.map-node-type-important-building,
.map-node-type-important {
  border: 3px double #efca63;
  background: rgba(132, 101, 41, 0.9);
  color: #fff1bd;
}

.map-node-type-wall {
  background: rgba(38, 39, 37, 0.96);
}

.map-node-group-markers {
  border-style: dashed;
  border-color: #aaa69d;
  background: rgba(69, 71, 67, 0.74);
}

.map-node-type-reserved {
  border-color: #c45d5d;
  background: rgba(101, 42, 42, 0.68);
}

.map-node-type-npc-marker {
  border-radius: 50%;
  background: rgba(104, 86, 128, 0.86);
}

.map-node-group-spawns {
  border: 3px solid #e4d05c;
  background: rgba(112, 96, 29, 0.82);
  color: #fff5b7;
}

.map-node-group-warps {
  border: 3px solid #4ca7d8;
  background: rgba(25, 87, 124, 0.9);
  color: #ddf5ff;
}

.map-node-type-warp-reserved {
  border-style: dashed;
  border-color: #777;
  background: rgba(51, 54, 57, 0.92);
  color: #aaa;
}

.map-node-transition-overlay {
  position: absolute;
  z-index: 6500;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  color: #e8e2d5;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.6vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
  transition: opacity 180ms linear;
}

.map-node-transition-overlay[hidden] {
  display: none;
}

.map-node-transition-overlay.is-active {
  opacity: 1;
}

.map-ground {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 30%, rgba(44, 57, 34, 0.22) 0 10%, transparent 28%),
    radial-gradient(circle at 81% 66%, rgba(35, 48, 29, 0.20) 0 12%, transparent 30%),
    repeating-linear-gradient(72deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 10px),
    #777057;
}

.map-road {
  position: absolute;
  z-index: 1;
  top: -120px;
  left: 655px;
  width: 420px;
  height: 1460px;
  background:
    linear-gradient(90deg, transparent, rgba(67, 60, 46, 0.18) 10%, rgba(118, 105, 78, 0.9) 24%, rgba(126, 113, 84, 0.94) 50%, rgba(114, 100, 74, 0.88) 76%, rgba(66, 59, 45, 0.16) 90%, transparent);
  transform: rotate(-18deg);
  transform-origin: center;
  filter: saturate(0.66);
}

.map-field {
  position: absolute;
  z-index: 2;
  border: 1px solid rgba(38, 39, 27, 0.38);
  background:
    repeating-linear-gradient(
      102deg,
      rgba(63, 72, 38, 0.52) 0 9px,
      rgba(105, 97, 57, 0.38) 9px 15px,
      rgba(44, 52, 32, 0.48) 15px 24px
    );
  opacity: 0.72;
}

.map-field-left {
  left: 45px;
  top: 805px;
  width: 565px;
  height: 300px;
  transform: rotate(-18deg);
  transform-origin: center;
}

.map-field-right {
  left: 1110px;
  top: 95px;
  width: 565px;
  height: 300px;
  transform: rotate(-18deg);
  transform-origin: center;
}

.map-obstacle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-obstacle {
  position: absolute;
  box-sizing: border-box;
  transform: rotate(var(--map-object-angle, 0deg));
  transform-origin: center;
}

.map-building {
  border: 2px solid rgba(25, 24, 20, 0.76);
  border-radius: 6px 6px 2px 2px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent 32%),
    repeating-linear-gradient(90deg, #4f4638 0 28px, #453d32 28px 31px);
  box-shadow:
    0 16px 22px rgba(0, 0, 0, 0.30),
    inset 0 0 0 7px rgba(23, 21, 17, 0.2);
}

.map-building::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  top: -27%;
  height: 40%;
  border: 2px solid rgba(22, 20, 17, 0.78);
  background:
    repeating-linear-gradient(100deg, #3a322b 0 17px, #2f2924 17px 21px);
  clip-path: polygon(50% 0, 100% 58%, 94% 100%, 6% 100%, 0 58%);
}

.map-building::after {
  content: "";
  position: absolute;
  left: 44%;
  bottom: 0;
  width: 18%;
  height: 46%;
  background: #211e19;
  border: 1px solid rgba(180, 160, 120, 0.18);
}

.chapel-ruin {
  background:
    linear-gradient(100deg, rgba(86, 86, 76, 0.9), rgba(52, 53, 48, 0.9)),
    #5b5b52;
}

.chapel-ruin::before {
  background:
    repeating-linear-gradient(94deg, #55534a 0 24px, #46443e 24px 29px);
  clip-path: polygon(0 42%, 18% 14%, 34% 32%, 49% 0, 66% 31%, 83% 12%, 100% 43%, 100% 100%, 0 100%);
}

.map-tree-clump {
  border-radius: 46% 54% 52% 48%;
  background:
    radial-gradient(circle at 22% 42%, #37412e 0 20%, transparent 21%),
    radial-gradient(circle at 48% 28%, #424b32 0 26%, transparent 27%),
    radial-gradient(circle at 70% 48%, #303a2a 0 25%, transparent 26%),
    radial-gradient(circle at 47% 70%, #293225 0 28%, transparent 29%);
  filter: drop-shadow(0 14px 8px rgba(0, 0, 0, 0.28));
}

.map-fence {
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, #4d4434 0 12px, transparent 12px 44px),
    linear-gradient(#4a4132 0 7px, transparent 7px 16px, #40392d 16px 23px, transparent 23px);
  filter: drop-shadow(5px 7px 3px rgba(0, 0, 0, 0.25));
}

/*
 * Exploration perspective lock:
 * all man-made ground geometry follows one mild 3/4 diagonal axis.
 * Character movement remains true 8-direction world-space movement.
 */
.map-road,
.map-field,
.map-building,
.map-fence {
  backface-visibility: hidden;
}

.map-player {
  position: absolute;
  z-index: 700;
  width: 66px;
  height: 96px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  will-change: left, top;
}

/*
 * Exploration scale target:
 * keep characters deliberately smaller than map architecture, then use the
 * camera zoom for readability. The feet remain the world/collision anchor.
 */
.map-player-sprite {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: auto;
  max-width: none;
  height: clamp(76px, 8vh, 92px);
  translate: var(--frame-offset-x, 0px) var(--frame-offset-y, 0px);
  transform: translateX(-50%) scaleX(var(--map-facing, 1));
  transform-origin: center bottom;
  filter: drop-shadow(0 7px 4px rgba(0, 0, 0, 0.3));
  transition: filter 90ms ease;
  backface-visibility: hidden;
}

.map-player-3d-canvas {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -3px;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 7px 4px rgba(0, 0, 0, 0.3));
}

.map-player-footpoint {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 18px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.24);
  filter: blur(2px);
  z-index: -1;
}

.map-test-hud {
  position: absolute;
  z-index: 5000;
  top: 18px;
  left: 18px;
  display: grid;
  gap: 3px;
  min-width: 245px;
  padding: 11px 14px;
  border: 1px solid rgba(231, 223, 205, 0.26);
  background: rgba(6, 6, 5, 0.74);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  pointer-events: none;
}

#map-screen:not(.map-debug-visible) .map-test-hud {
  visibility: hidden;
  opacity: 0;
}

.map-campaign-hud {
  position: absolute;
  z-index: 24;
  top: clamp(16px, 2.2vw, 30px);
  left: 50%;
  width: min(620px, calc(100vw - 32px));
  padding: 10px 18px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(214, 188, 128, 0.48);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(18, 18, 22, 0.9), rgba(9, 10, 13, 0.78));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38);
  color: #eee7d6;
  text-align: center;
  pointer-events: none;
}

.map-campaign-hud strong,
.map-campaign-hud span { display: block; }
.map-campaign-hud strong { color: #d8bd7d; font-family: var(--font-display); letter-spacing: 0.16em; }
.map-campaign-hud span { margin-top: 4px; font-size: 0.82rem; }

.map-test-hud strong {
  margin-bottom: 2px;
  color: #f2ede1;
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.07em;
}

#map-screen[data-map-visual-mode="minimal-ground"] {
  --map-ground-base-image: var(--ground-grass-image);
}

#map-screen[data-map-visual-mode="minimal-ground"] :is(
  .map-node-forest-layer,
  .map-node-vegetation-layer,
  .map-node-town-layer,
  .map-weather-layer,
  .map-screen-grain,
  .map-screen-vignette
) {
  display: none;
}

.settings-panel {
  position: absolute;
  z-index: 80;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(430px, calc(100% - 40px));
  padding: 28px 32px;
  border: 1px solid rgba(205, 176, 119, 0.72);
  background: rgba(12, 13, 15, 0.97);
  box-shadow: 0 25px 70px #000;
  color: #eee4cf;
  font-family: var(--font-ui);
}
.settings-panel[hidden] { display: none; }
.settings-panel h2 { margin: 0 0 20px; color: #ddc17f; font-family: var(--font-display); }
.settings-panel label { display: grid; grid-template-columns: 1fr auto; gap: 8px 15px; margin: 16px 0; align-items: center; }
.settings-panel input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: #ae8c50; }
.settings-panel .settings-toggle { grid-template-columns: auto 1fr; justify-content: start; }
.settings-panel select,
.settings-panel button { padding: 8px 12px; border: 1px solid #8d7449; background: #26221c; color: #f2e8d3; }
.settings-panel button { width: 100%; margin-top: 12px; cursor: pointer; }

/* Vertical-slice exploration content */
.map-interaction-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.map-world-actor,
.map-world-interactive {
  position: absolute;
  width: 52px;
  height: 86px;
  transform: translate(-50%, -100%);
  display: grid;
  place-items: end center;
  color: #f4e6c4;
  text-shadow: 0 2px 4px #000;
  pointer-events: auto;
  border: 0;
  appearance: none;
  background-color: transparent;
  padding: 0;
  cursor: pointer;
}

.map-world-actor:not([data-has-sprite="true"])::before {
  content: "";
  width: 30px;
  height: 54px;
  border: 1px solid rgba(226, 205, 165, 0.74);
  border-radius: 45% 45% 30% 30%;
  background: linear-gradient(#3c3a3b 0 24%, #23272b 25% 100%);
  box-shadow: 0 8px 10px rgba(0, 0, 0, 0.45);
}

.map-world-actor-sprite {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: auto;
  max-width: none;
  height: clamp(72px, 7.5vh, 88px);
  transform: translateX(-50%);
  transform-origin: center bottom;
  pointer-events: none;
  filter: drop-shadow(0 7px 4px rgba(0, 0, 0, 0.3));
}

.map-world-actor > span,
.map-world-interactive > span {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  min-width: max-content;
  padding: 3px 7px;
  border-radius: 2px;
  background: rgba(12, 12, 14, 0.76);
  font: 600 10px/1.2 Georgia, serif;
  letter-spacing: 0.05em;
}

.map-world-actor[data-marker]::after {
  content: attr(data-marker);
  position: absolute;
  top: -43px;
  left: 50%;
  transform: translateX(-50%);
  color: #e6c771;
  font: 800 22px/1 Georgia, serif;
}

.map-world-interactive {
  width: 42px;
  height: 46px;
  border: 1px dashed rgba(224, 200, 143, 0.55);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(187, 154, 90, 0.25), transparent 68%);
}

.map-interaction-prompt {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: 17%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid rgba(214, 190, 144, 0.68);
  background: rgba(10, 11, 13, 0.9);
  color: #f3e8ce;
  font: 600 13px Georgia, serif;
}

.map-interaction-prompt[hidden],
.map-dialogue[hidden],
.map-dialogue-portrait-stage[hidden],
.map-inventory[hidden],
.map-equipment[hidden],
.map-skill-menu[hidden],
.map-shop[hidden],
.vertical-slice-end[hidden] { display: none; }

.map-interaction-prompt kbd {
  padding: 3px 7px;
  border: 1px solid #8f7b58;
  background: #28241f;
  color: #efd9a6;
}

.map-skill-menu {
  position: absolute;
  z-index: 8200;
  inset: clamp(16px, 3.5vh, 42px) clamp(20px, 4vw, 72px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #ded4c0;
  border: 1px solid #7e6b49;
  background:
    radial-gradient(circle at 51% 45%, rgba(45, 55, 59, .28), transparent 42%),
    linear-gradient(145deg, rgba(22, 22, 22, .985), rgba(10, 11, 12, .99));
  box-shadow: 0 24px 80px #000, inset 0 0 80px rgba(153, 120, 66, .04);
}

.map-skill-menu::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border: 1px solid rgba(205, 178, 123, .12);
}

.map-skill-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 13px 22px;
  border-bottom: 1px solid rgba(181, 154, 103, .28);
  background: linear-gradient(90deg, rgba(89, 70, 40, .12), transparent 42%, rgba(38, 46, 48, .18));
}

.map-skill-title-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #cfb36f;
  border: 1px solid #776442;
  transform: rotate(45deg);
}

.map-skill-title-mark::first-letter { transform: rotate(-45deg); }
.map-skill-header span { color: #9e8c69; font-size: 9px; letter-spacing: .22em; text-transform: uppercase; }
.map-skill-header h2 { margin: 3px 0 2px; color: #e1c987; font: 700 26px/1 Georgia, serif; letter-spacing: .03em; }
.map-skill-header p { margin: 0; color: #837d72; font: 11px/1.2 Georgia, serif; }
.map-skill-header button { padding: 8px 11px; border: 1px solid #756341; background: #211f1b; color: #ddd1b9; cursor: pointer; }
.map-skill-header kbd { margin-left: 5px; color: #c9ad70; font: inherit; }

.map-skill-category-tabs {
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid #4b4233;
  background: rgba(8, 9, 10, .72);
}

.map-skill-category-tabs button {
  min-height: 38px;
  color: #746e63;
  border: 0;
  border-right: 1px solid rgba(97, 84, 62, .45);
  background: transparent;
  font: 700 11px Georgia, serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.map-skill-category-tabs button[data-selected="true"] { color: #e2c77f; background: linear-gradient(180deg, rgba(165, 129, 67, .18), rgba(165, 129, 67, .04)); box-shadow: inset 0 -2px #b69454; }
.map-skill-category-tabs small { margin-left: 6px; color: #57534d; font: 8px sans-serif; letter-spacing: .04em; }

.map-skill-body { min-height: 0; display: grid; grid-template-columns: minmax(150px, 18%) minmax(410px, 1fr) minmax(220px, 25%); }
.map-skill-characters { min-width: 0; border-right: 1px solid rgba(103, 89, 65, .55); background: rgba(13, 14, 15, .75); }
.map-skill-characters > header { display: flex; justify-content: space-between; padding: 13px 14px 10px; color: #a18d66; border-bottom: 1px solid rgba(82, 72, 56, .42); font: 9px sans-serif; letter-spacing: .18em; text-transform: uppercase; }
.map-skill-characters > header small { color: #656058; font-size: 8px; }
.map-skill-party-tabs { display: grid; align-content: start; gap: 4px; padding: 9px; }
.map-skill-character { min-width: 0; display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 9px; padding: 8px; color: #938b7d; border: 1px solid transparent; background: rgba(29, 29, 28, .58); text-align: left; cursor: pointer; }
.map-skill-character[data-selected="true"] { color: #ead59e; border-color: #8f774a; background: linear-gradient(90deg, rgba(140, 107, 53, .22), rgba(40, 38, 32, .55)); box-shadow: inset 2px 0 #c4a05c; }
.map-skill-portrait { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; color: #c7ad73; border: 1px solid #75613e; border-radius: 50%; background: radial-gradient(circle, #343433, #171819); font: 700 11px Georgia, serif; }
.map-skill-portrait img { width: 100%; height: 100%; object-fit: cover; }
.map-skill-character-copy { min-width: 0; display: grid; gap: 3px; }
.map-skill-character-copy strong { overflow: hidden; font: 700 12px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.map-skill-character-copy small { color: #716c62; font: 9px sans-serif; letter-spacing: .08em; text-transform: uppercase; }

.map-skill-graph-panel { min-width: 0; min-height: 0; position: relative; overflow: hidden; border-right: 1px solid rgba(103, 89, 65, .55); background: radial-gradient(ellipse at center, rgba(44, 57, 60, .25), rgba(13, 15, 16, .82) 68%); }
.map-skill-graph-heading { position: absolute; z-index: 4; top: 11px; left: 14px; display: grid; pointer-events: none; }
.map-skill-graph-heading span { color: #a99161; font: 700 9px sans-serif; letter-spacing: .18em; text-transform: uppercase; }
.map-skill-graph-heading small { margin-top: 3px; color: #5f5e59; font: 9px Georgia, serif; }
.map-skill-tree { position: absolute; inset: 0; overflow: hidden; }
.map-skill-connectors { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.map-skill-connector { stroke: #455158; stroke-width: .55; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 2px rgba(48, 75, 85, .6)); }
.map-skill-connector.is-unlocked { stroke: #b49654; stroke-width: .8; filter: drop-shadow(0 0 3px rgba(194, 151, 73, .6)); }
.map-skill-root { position: absolute; z-index: 2; display: grid; justify-items: center; gap: 2px; transform: translate(-50%, -35%); color: #bca46d; }
.map-skill-root-glyph { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid #9b7e48; border-radius: 50%; background: #25241f; box-shadow: 0 0 13px rgba(178, 137, 66, .25); }
.map-skill-root small { color: #756b58; font: 8px Georgia, serif; white-space: nowrap; }

.map-skill-node { position: absolute; z-index: 3; width: clamp(48px, 4.5vw, 64px); height: clamp(48px, 4.5vw, 64px); padding: 0; border: 0; border-radius: 50%; transform: translate(-50%, -50%); color: #858c8c; background: transparent; cursor: pointer; transition: filter .15s ease, transform .15s ease; }
.map-skill-node-ring { position: absolute; inset: 5px; display: grid; place-items: center; border: 2px solid #556067; border-radius: 50%; background: radial-gradient(circle, #293034 0, #16191b 67%); box-shadow: inset 0 0 0 3px rgba(116, 131, 137, .1), 0 0 0 1px #22292c; font: 700 clamp(16px, 1.7vw, 22px) Georgia, serif; }
.map-skill-node-label { position: absolute; top: calc(100% + 2px); left: 50%; width: 112px; transform: translateX(-50%); color: #85827a; font: 700 9px/1.1 Georgia, serif; text-align: center; text-shadow: 0 1px 3px #000; }
.map-skill-node.is-locked { opacity: .46; filter: saturate(.45); }
.map-skill-node.is-available { color: #b8d3d5; filter: drop-shadow(0 0 5px rgba(121, 176, 184, .38)); }
.map-skill-node.is-available .map-skill-node-ring { border-color: #91b5b8; }
.map-skill-node.is-unlocked { color: #ead28d; filter: drop-shadow(0 0 6px rgba(204, 159, 75, .46)); }
.map-skill-node.is-unlocked .map-skill-node-ring { border-color: #c1a05b; background: radial-gradient(circle, #4a4028, #201d18 69%); }
.map-skill-node[data-selected="true"] { transform: translate(-50%, -50%) scale(1.08); filter: drop-shadow(0 0 9px rgba(230, 202, 132, .72)); }
.map-skill-node[data-selected="true"] .map-skill-node-ring { outline: 1px solid #eee0b6; outline-offset: 4px; }
.map-skill-node[data-selected="true"] .map-skill-node-label { color: #f0dca8; }
.map-skill-node:focus-visible { outline: none; }

.map-skill-detail { min-width: 0; overflow: auto; padding: 19px 18px; background: linear-gradient(145deg, rgba(28, 27, 25, .92), rgba(15, 16, 17, .95)); }
.map-skill-detail-empty { display: grid; min-height: 100%; place-items: center; color: #69655e; font: italic 12px/1.6 Georgia, serif; text-align: center; }
.map-skill-detail-type { display: inline-block; padding: 4px 7px; color: #aa9466; border: 1px solid #625537; font: 8px sans-serif; letter-spacing: .16em; text-transform: uppercase; }
.map-skill-detail h3 { margin: 11px 0 8px; color: #e2c985; font: 700 21px/1.1 Georgia, serif; }
.map-skill-detail-description { min-height: 42px; margin: 0 0 15px; color: #a69d8c; font: 12px/1.5 Georgia, serif; }
.map-skill-requirements { display: grid; margin: 0; border-top: 1px solid #403a31; }
.map-skill-requirements div { display: grid; grid-template-columns: 46% 54%; padding: 8px 0; border-bottom: 1px solid #35322c; }
.map-skill-requirements dt { color: #716b60; font: 8px sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.map-skill-requirements dd { margin: 0; color: #c4b99f; font: 10px/1.25 Georgia, serif; text-align: right; }
.map-skill-requirements dd[data-skill-status="unlocked"] { color: #d7bd77; }
.map-skill-requirements dd[data-skill-status="available"] { color: #a6c9ca; }
.map-skill-effect { margin-top: 15px; padding: 11px; border: 1px solid rgba(117, 96, 58, .55); background: rgba(126, 99, 52, .08); }
.map-skill-effect span { color: #9b824f; font: 8px sans-serif; letter-spacing: .17em; text-transform: uppercase; }
.map-skill-effect p { margin: 5px 0 0; color: #c4b89d; font: 11px/1.45 Georgia, serif; }

.map-skill-footer { z-index: 5; min-height: 44px; display: grid; grid-template-columns: auto minmax(90px, 1fr) auto; align-items: center; gap: 17px; padding: 7px 16px; border-top: 1px solid #504530; background: rgba(11, 12, 13, .96); }
.map-skill-resources, .map-skill-controls { display: flex; align-items: center; gap: 13px; }
.map-skill-resources strong { color: #e0c47e; font: 700 11px Georgia, serif; }
.map-skill-resources span, .map-skill-controls span { color: #766f63; font: 8px sans-serif; letter-spacing: .06em; white-space: nowrap; }
.map-skill-status { min-height: 14px; margin: 0; color: #d6bb7c; font: 10px Georgia, serif; text-align: center; }

@media (max-width: 1050px), (max-height: 700px) {
  .map-skill-menu { inset: 12px 18px; }
  .map-skill-header { min-height: 58px; padding-block: 8px; }
  .map-skill-header p, .map-skill-category-tabs small { display: none; }
  .map-skill-body { grid-template-columns: 145px minmax(390px, 1fr) 215px; }
  .map-skill-character { grid-template-columns: 33px minmax(0, 1fr); padding: 5px; }
  .map-skill-portrait { width: 31px; height: 31px; }
  .map-skill-detail { padding: 13px; }
  .map-skill-controls { gap: 8px; }
}

.map-interaction-prompt kbd.space-key {
  min-width: 38px;
  padding: 3px 10px 5px;
  border-radius: 4px;
  font-size: 17px;
  line-height: 1;
  text-align: center;
}

.map-dialogue,
.map-shop,
.vertical-slice-end {
  position: absolute;
  z-index: 60;
  color: #efe6d2;
  background: linear-gradient(150deg, rgba(19, 20, 23, 0.97), rgba(8, 9, 11, 0.98));
  border: 1px solid rgba(199, 174, 125, 0.7);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6), inset 0 0 32px rgba(152, 119, 66, 0.06);
}

.map-dialogue {
  left: clamp(24px, 4.5vw, 86px);
  bottom: 4.5%;
  transform: none;
  width: min(680px, 55vw);
  min-height: 126px;
  padding: 20px 25px;
}

.map-dialogue strong { color: #d8bc7b; font: 700 17px Georgia, serif; }
.map-dialogue p { margin: 10px 0 16px; font: 16px/1.55 Georgia, serif; }
.map-dialogue > span { color: #978b75; font: 10px/1.2 sans-serif; letter-spacing: 0.12em; }

.map-dialogue-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(420px, 100%);
  margin: 4px 0 14px;
  gap: 8px;
}

.map-dialogue-choices:empty {
  display: none;
}

.map-dialogue-choice {
  padding: 10px 14px;
  border: 1px solid rgba(147, 126, 88, 0.55);
  background: rgba(31, 29, 26, 0.88);
  color: #d8ceb9;
  font: 700 13px/1.2 Georgia, serif;
  text-align: left;
  cursor: pointer;
}

.map-dialogue-choice[data-selected="true"],
.map-dialogue-choice:hover,
.map-dialogue-choice:focus-visible {
  border-color: #dfbd73;
  outline: none;
  background: linear-gradient(90deg, rgba(104, 77, 40, 0.76), rgba(42, 37, 31, 0.92));
  color: #fff0c9;
}

.map-dialogue-choice[data-choice="attack"][data-selected="true"],
.map-dialogue-choice[data-choice="attack"]:hover,
.map-dialogue-choice[data-choice="attack"]:focus-visible {
  border-color: rgba(180, 74, 57, 0.88);
  background: linear-gradient(90deg, rgba(104, 42, 34, 0.82), rgba(46, 31, 29, 0.94));
  color: #ffd3c9;
}

.map-dialogue-portrait-stage {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  width: clamp(430px, 40vw, 780px);
  height: min(84vh, 910px);
  margin: 0;
  overflow: hidden;
  pointer-events: none;
}

.map-dialogue-portrait {
  position: absolute;
  top: 0;
  left: 50%;
  width: clamp(620px, 50vw, 980px);
  height: auto;
  max-width: none;
  transform: translateX(-50%);
  transform-origin: top center;
  filter: drop-shadow(-18px 18px 18px rgba(0, 0, 0, 0.42));
}

.map-dialogue-portrait-stage[data-portrait-kind="enemy"] {
  width: clamp(560px, 52vw, 980px);
  height: min(94vh, 1040px);
  overflow: hidden;
}

.map-dialogue-portrait-stage[data-portrait-kind="enemy"] .map-dialogue-portrait {
  top: auto;
  right: -4vw;
  bottom: max(-390px, -34vh);
  left: auto;
  width: auto;
  height: min(132vh, 1320px);
  max-height: none;
  object-fit: contain;
  object-position: center bottom;
  transform: none;
  transform-origin: center bottom;
  filter: drop-shadow(-22px 22px 20px rgba(0, 0, 0, 0.48));
}

.map-inventory {
  position: fixed;
  z-index: 75;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(940px, calc(100vw - 112px));
  max-height: min(680px, calc(100vh - 96px));
  overflow: hidden;
  border: 1px solid rgba(205, 177, 123, 0.75);
  background:
    linear-gradient(135deg, rgba(24, 25, 28, 0.965), rgba(8, 9, 11, 0.95)),
    radial-gradient(circle at 70% 35%, rgba(158, 119, 59, 0.13), transparent 48%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.82), inset 0 0 46px rgba(180, 143, 76, 0.04);
  color: #eee5d1;
  font-family: var(--font-ui);
}

.map-inventory > header,
.map-inventory > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-color: rgba(181, 154, 103, 0.3);
}

.map-inventory > header { border-bottom: 1px solid rgba(181, 154, 103, 0.3); }
.map-inventory > footer { border-top: 1px solid rgba(181, 154, 103, 0.3); color: #a89d88; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.map-inventory header span { color: #9e8c69; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }
.map-inventory h2 { margin: 3px 0 0; color: #dfc383; font: 700 27px/1 Georgia, serif; }
.map-inventory header button { padding: 8px 11px; border: 1px solid #756341; background: rgba(31, 29, 25, 0.8); color: #ddd1b9; cursor: pointer; }
.map-inventory kbd { margin-left: 6px; color: #f0d89f; font: inherit; }

.map-inventory-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid rgba(181, 154, 103, 0.28);
  background: rgba(8, 8, 9, 0.5);
}

.map-inventory-tabs button {
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  border-right: 1px solid rgba(181, 154, 103, 0.2);
  background: rgba(28, 27, 25, 0.62);
  color: #958a76;
  font: 800 11px/1.2 sans-serif;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-inventory-tabs button:last-child { border-right: 0; }

.map-inventory-tabs button[data-selected="true"],
.map-inventory-tabs button:hover,
.map-inventory-tabs button:focus-visible {
  outline: none;
  background: linear-gradient(180deg, rgba(96, 73, 41, 0.74), rgba(44, 38, 30, 0.72));
  color: #efd59d;
  box-shadow: inset 0 -2px 0 #c9a866;
}

.map-progression-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(181, 154, 103, 0.24);
  background: rgba(9, 9, 10, 0.38);
}

.map-progression-card {
  padding: 12px 14px;
  border: 1px solid rgba(158, 137, 99, 0.28);
  background: rgba(38, 35, 31, 0.48);
}

.map-progression-card > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.map-progression-card span {
  color: #9e8c69;
  font-size: 10px;
  letter-spacing: 0.18em;
}

.map-progression-card strong {
  color: #ead39b;
  font: 700 19px/1 Georgia, serif;
}

.map-progression-card small {
  display: block;
  margin-top: 8px;
  color: #aaa08e;
  font-size: 11px;
}

.map-progression-bar {
  height: 5px;
  margin-top: 9px;
  overflow: hidden;
  border: 1px solid rgba(154, 129, 83, 0.38);
  background: rgba(0, 0, 0, 0.45);
}

.map-progression-bar > i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #80663e, #d4b56f);
  transition: width 180ms ease-out;
}

.map-inventory-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(350px, 1.25fr);
  min-height: 350px;
  max-height: min(470px, calc(100vh - 300px));
}

.map-inventory-list {
  padding: 18px;
  overflow-y: auto;
  border-right: 1px solid rgba(181, 154, 103, 0.24);
  background: rgba(0, 0, 0, 0.2);
}

.map-inventory-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 54px;
  margin: 0 0 8px;
  padding: 9px 12px;
  gap: 8px;
  border: 1px solid rgba(158, 137, 99, 0.3);
  background: rgba(39, 38, 37, 0.56);
  color: #e9dfcb;
  text-align: left;
  cursor: pointer;
}

.map-inventory-item[data-selected="true"],
.map-inventory-item:hover,
.map-inventory-item:focus-visible {
  border-color: #c5a66b;
  outline: none;
  background: linear-gradient(90deg, rgba(109, 83, 45, 0.55), rgba(47, 43, 36, 0.72));
}

.map-inventory-item > span { color: #dec179; font-size: 22px; text-align: center; }
.map-inventory-item-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
}
.map-inventory-item-icon-image {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}
.map-inventory-item > strong { font: 600 14px/1.2 Georgia, serif; }
.map-inventory-item > small { color: #b9ab91; font-size: 12px; }
.map-inventory-empty { padding: 28px 12px; color: #8f8779; text-align: center; }

.map-inventory-detail {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  padding: clamp(28px, 4vw, 54px);
  overflow-y: auto;
}

.map-inventory-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 24px; border: 1px solid #806e4c; background: rgba(120, 91, 45, 0.16); color: #e1c57f; font-size: 34px; }
.map-inventory-detail-icon-image {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}
.map-inventory-detail > span { color: #9d8b69; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; }
.map-inventory-detail h3 { margin: 8px 0 18px; color: #f0e3c8; font: 700 clamp(24px, 3vw, 36px)/1.05 Georgia, serif; }
.map-inventory-detail p { max-width: 48ch; margin: 0 0 26px; color: #c9c0ae; font: 15px/1.65 Georgia, serif; }
.map-inventory-detail strong { color: #d6bb7c; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.map-inventory-detail small { margin-top: auto; padding-top: 24px; color: #817a6e; font-size: 11px; }

.map-inventory-targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  margin-top: 20px;
  gap: 8px;
}

.map-inventory-target {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  overflow: visible;
  border: 1px solid rgba(151, 130, 92, 0.38);
  background: rgba(27, 27, 28, 0.72);
  color: #e8deca;
  text-align: left;
  cursor: pointer;
}

.map-inventory-target[data-selected="true"] {
  border-color: #d4b36c;
  background: rgba(89, 68, 38, 0.62);
  box-shadow: inset 0 0 16px rgba(210, 170, 92, 0.08);
}

.map-inventory-target:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-inventory-target strong {
  color: #ead6a4;
  font: 700 13px/1.2 Georgia, serif;
}

.map-inventory-target small {
  margin: 0;
  padding: 0;
  color: #a99f8d;
  font: 11px/1.3 sans-serif;
}

.map-inventory-use {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid #9b8357;
  background: #342b20;
  color: #f3e5c8;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-inventory-use:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.map-inventory-status {
  min-height: 1.3em;
  margin: 9px 0 0 !important;
  color: #c8b681 !important;
  font: 12px/1.4 sans-serif !important;
}

.map-equipment {
  position: fixed;
  z-index: 76;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(980px, calc(100vw - 96px));
  max-height: min(760px, calc(100vh - 72px));
  overflow: hidden;
  border: 1px solid rgba(205, 177, 123, 0.78);
  background:
    linear-gradient(135deg, rgba(24, 25, 28, 0.975), rgba(8, 9, 11, 0.965)),
    radial-gradient(circle at 25% 30%, rgba(140, 105, 55, 0.12), transparent 48%);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.84), inset 0 0 48px rgba(180, 143, 76, 0.04);
  color: #eee5d1;
  font-family: var(--font-ui);
}

.map-equipment > header,
.map-equipment > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
}

.map-equipment > header {
  border-bottom: 1px solid rgba(181, 154, 103, 0.3);
}

.map-equipment > footer {
  border-top: 1px solid rgba(181, 154, 103, 0.3);
  color: #a89d88;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-equipment > header span {
  color: #9e8c69;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.map-equipment h2 {
  margin: 3px 0 0;
  color: #dfc383;
  font: 700 29px/1 Georgia, serif;
}

.map-equipment > header button,
.map-equipment-unequip {
  padding: 9px 13px;
  border: 1px solid #756341;
  background: rgba(31, 29, 25, 0.86);
  color: #ddd1b9;
  cursor: pointer;
}

.map-equipment > header button:hover,
.map-equipment-unequip:hover:not(:disabled) {
  border-color: #c4a566;
  background: #3a3125;
}

.map-equipment kbd {
  margin-left: 6px;
  color: #f0d89f;
  font: inherit;
}

.map-equipment-party-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(181, 154, 103, 0.24);
  background: rgba(10, 10, 11, 0.5);
}

.map-equipment-party-tab {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-right: 1px solid rgba(181, 154, 103, 0.22);
  background: rgba(28, 27, 25, 0.58);
  color: #918673;
  font: 800 12px/1.2 sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-equipment-party-tab[data-selected="true"],
.map-equipment-party-tab:hover,
.map-equipment-party-tab:focus-visible {
  outline: none;
  background: linear-gradient(180deg, rgba(89, 68, 38, 0.78), rgba(42, 37, 31, 0.84));
  color: #f0d8a5;
  box-shadow: inset 0 -2px 0 #d0ae69;
}

.map-equipment-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(390px, 1.15fr);
  min-height: 470px;
  max-height: min(560px, calc(100vh - 250px));
}

.map-equipment-layout > section {
  padding: 22px;
  overflow-y: auto;
  border-right: 1px solid rgba(181, 154, 103, 0.24);
  background: rgba(0, 0, 0, 0.18);
}

.map-equipment-kicker {
  margin: 0 0 12px;
  color: #98896e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.map-equipment-slots {
  display: grid;
  gap: 9px;
}

.map-equipment-slot {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 13px;
  border: 1px solid rgba(151, 130, 92, 0.34);
  background: rgba(35, 34, 32, 0.66);
  color: #e8deca;
  text-align: left;
  cursor: pointer;
}

.map-equipment-slot[data-selected="true"],
.map-equipment-slot:hover,
.map-equipment-slot:focus-visible {
  border-color: #caa765;
  outline: none;
  background: linear-gradient(90deg, rgba(93, 69, 39, 0.66), rgba(44, 39, 32, 0.76));
  box-shadow: inset 3px 0 0 #d1b06b;
}

.map-equipment-slot > span {
  color: #dfbf77;
  font-size: 27px;
  text-align: center;
}

.map-equipment-slot > div {
  display: grid;
  gap: 5px;
}

.map-equipment-slot small {
  color: #918573;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.map-equipment-slot strong {
  color: #efe3ca;
  font: 700 15px/1.2 Georgia, serif;
}

.map-equipment-detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px 32px;
  overflow-y: auto;
}

.map-equipment-member-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 20px;
  padding: 10px 12px;
  border: 1px solid rgba(181, 154, 103, 0.22);
  background: rgba(0, 0, 0, 0.2);
  color: #d5bd86;
  font: 700 10px/1.4 sans-serif;
  letter-spacing: 0.04em;
}

.map-equipment-member-bar button {
  padding: 7px 9px;
  border: 1px solid #756341;
  background: rgba(31, 29, 25, 0.86);
  color: #ddd1b9;
  cursor: pointer;
}

.map-equipment-party-tab[data-active="false"] {
  opacity: 0.62;
}

.map-equipment-option:disabled {
  opacity: 0.5;
  cursor: default;
}

.map-equipment-detail > span {
  color: #9d8b69;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.map-equipment-detail h3 {
  margin: 8px 0 14px;
  color: #f0e3c8;
  font: 700 clamp(24px, 3vw, 34px)/1.05 Georgia, serif;
}

.map-equipment-detail > p {
  margin: 0 0 18px;
  color: #c5bcab;
  font: 14px/1.55 Georgia, serif;
}

.map-equipment-unequip {
  align-self: flex-start;
  margin-bottom: 24px;
}

.map-equipment-unequip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.map-equipment-options-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(181, 154, 103, 0.22);
}

.map-equipment-options-header strong {
  color: #d5bd86;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-equipment-options-header small {
  color: #81796c;
  font-size: 10px;
}

.map-equipment-options {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.map-equipment-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(151, 130, 92, 0.32);
  background: rgba(34, 33, 31, 0.65);
  color: #e8deca;
  text-align: left;
  cursor: pointer;
}

.map-equipment-option:hover,
.map-equipment-option:focus-visible {
  border-color: #caaa68;
  outline: none;
  background: rgba(79, 61, 37, 0.7);
}

.map-equipment-option > span {
  color: #dfbf77;
  font-size: 22px;
  text-align: center;
}

.map-equipment-option > div {
  display: grid;
  gap: 3px;
}

.map-equipment-option strong {
  font: 700 13px/1.2 Georgia, serif;
}

.map-equipment-option small {
  color: #9a9081;
  font-size: 10px;
}

.map-equipment-option b {
  color: #d8bd78;
  font-size: 11px;
  text-transform: uppercase;
}

.map-equipment-empty {
  margin: 0;
  padding: 16px 12px;
  border: 1px dashed rgba(151, 130, 92, 0.24);
  color: #857d70;
  font-size: 12px;
  text-align: center;
}

.map-equipment-status {
  min-height: 1.3em;
  margin: 14px 0 0 !important;
  color: #cdbb89 !important;
  font: 12px/1.4 sans-serif !important;
}

.map-inventory-heal-pop {
  position: absolute;
  z-index: 5;
  top: 2px;
  right: 12px;
  color: #87f6a2;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 0 4px #000, 0 0 10px rgba(28, 120, 55, 0.9);
  pointer-events: none;
  animation: map-item-heal-pop 780ms ease-out forwards;
}

.map-inventory-target.is-field-healing {
  animation: map-item-heal-pulse 600ms ease-out;
}

.map-inventory-target.is-field-cured {
  animation: map-item-cure-pulse 600ms ease-out;
}

@keyframes map-item-heal-pop {
  0% { opacity: 0; transform: translateY(8px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-24px) scale(1); }
}

@keyframes map-item-heal-pulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(92, 222, 129, 0); }
  45% { box-shadow: inset 0 0 26px rgba(92, 222, 129, 0.28), 0 0 14px rgba(92, 222, 129, 0.18); }
}

@keyframes map-item-cure-pulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(198, 224, 157, 0); }
  45% { box-shadow: inset 0 0 24px rgba(198, 224, 157, 0.25), 0 0 12px rgba(198, 224, 157, 0.14); }
}

.map-shop,
.vertical-slice-end {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 40px));
  padding: 30px;
  text-align: center;
}

.map-shop {
  width: min(620px, calc(100% - 40px));
  padding: 24px;
  text-align: left;
}

.map-shop > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(181, 154, 103, 0.28);
}

.map-shop > header span {
  color: #9c8a68;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.map-shop > header p {
  margin: 0;
  color: #cbbd9f;
  white-space: nowrap;
}

.map-shop-list {
  display: grid;
  max-height: min(430px, 55vh);
  margin: 16px 0;
  gap: 8px;
  overflow-y: auto;
}

.map-shop .map-shop-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(151, 130, 92, 0.34);
  background: rgba(33, 32, 30, 0.74);
  color: #eee2c9;
  text-align: left;
  cursor: pointer;
}

.map-shop .map-shop-item[data-selected="true"],
.map-shop .map-shop-item:hover:not(:disabled),
.map-shop .map-shop-item:focus-visible:not(:disabled) {
  border-color: #d3b16b;
  outline: none;
  background: linear-gradient(90deg, rgba(92, 69, 38, 0.7), rgba(40, 37, 32, 0.76));
}

.map-shop .map-shop-item:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.map-shop .map-shop-item > span {
  color: #d7ba73;
  font-size: 24px;
  text-align: center;
}

.map-shop .map-shop-item-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
}

.map-shop .map-shop-item-icon-image {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.map-shop .map-shop-item > div {
  display: grid;
  gap: 4px;
}

.map-shop .map-shop-item strong {
  color: #f0e2c6;
  font: 700 14px/1.2 Georgia, serif;
}

.map-shop .map-shop-item small {
  color: #9e9585;
  font-size: 11px;
  line-height: 1.35;
}

.map-shop .map-shop-item b {
  color: #d8bd78;
  font-size: 12px;
  white-space: nowrap;
}

.map-shop > footer {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 38px;
  padding-top: 8px;
  border-top: 1px solid rgba(181, 154, 103, 0.2);
}

.map-shop > footer p {
  flex: 1;
  margin: 0;
  color: #c7b480;
  font-size: 12px;
}

.map-shop h2,
.vertical-slice-end h1 { margin: 4px 0 14px; color: #e0c27c; font-family: Georgia, serif; }
.map-shop button,
.vertical-slice-end button {
  margin: 8px 4px 0;
  padding: 10px 16px;
  border: 1px solid #9b8357;
  background: #24221f;
  color: #f2e7ce;
  cursor: pointer;
}
.map-shop button:hover,
.vertical-slice-end button:hover { background: #3a3125; }
.vertical-slice-end > span { color: #9c8a68; text-transform: uppercase; letter-spacing: 0.2em; font-size: 11px; }

.map-screen-grain,
.map-screen-vignette {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}
.map-screen-grain { opacity: 0.11; background-image: repeating-radial-gradient(circle at 20% 30%, #fff 0 0.4px, transparent 0.8px 3px); mix-blend-mode: soft-light; }
.map-screen-vignette { background: radial-gradient(ellipse at center, transparent 48%, rgba(3, 4, 5, 0.52) 100%); }
#map-screen[data-film-grain="off"] .map-screen-grain { display: none; }
#map-screen[data-screen-effects="low"] .map-weather-layer { animation: none !important; opacity: 0.18; }
#map-screen[data-environment="deep-dark"] .map-viewport { filter: saturate(0.7) brightness(0.78) contrast(1.08); }
#map-screen[data-environment="town-overcast"] .map-viewport { filter: saturate(0.84) sepia(0.08); }

@media (prefers-reduced-motion: reduce) {
  .map-weather-layer,
  .map-screen-grain { animation: none !important; }
}

.map-test-hud span {
  color: #bdb6a6;
}

.map-coordinates {
  margin-top: 4px;
  color: #d9744b !important;
}

@media (max-width: 760px) {
  .map-test-hud {
    top: 10px;
    left: 10px;
    min-width: 0;
    max-width: calc(100vw - 20px);
    font-size: 0.68rem;
  }

  .map-player {
    width: 62px;
    height: 90px;
  }

  .map-player-sprite {
    width: auto;
    height: clamp(72px, 12vh, 86px);
  }

  .map-dialogue { left: 18px; width: calc(100% - 36px); }
  .map-dialogue-portrait-stage { right: -18%; width: 70vw; opacity: 0.72; }
  .map-dialogue-portrait { width: 86vw; }
  .map-inventory { width: calc(100vw - 30px); max-height: calc(100vh - 30px); }
  .map-inventory-layout { grid-template-columns: 1fr; min-height: 0; max-height: calc(100vh - 160px); overflow-y: auto; }
  .map-inventory-list { max-height: 36vh; border-right: 0; border-bottom: 1px solid rgba(181, 154, 103, 0.24); }
  .map-inventory-detail { min-height: 260px; padding: 24px; }
  .map-equipment { width: calc(100vw - 30px); max-height: calc(100vh - 30px); }
  .map-equipment-layout { grid-template-columns: 1fr; min-height: 0; max-height: calc(100vh - 180px); overflow-y: auto; }
  .map-equipment-layout > section { border-right: 0; border-bottom: 1px solid rgba(181, 154, 103, 0.24); }
  .map-equipment-detail { min-height: 320px; padding: 24px; }
  .map-equipment > footer { display: none; }
}


/* Map encounters --------------------------------------------------------- */
.map-encounter-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-enemy {
  position: absolute;
  width: 66px;
  height: 96px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  will-change: left, top;
}

.map-enemy::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 32px;
  height: 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(168, 48, 39, 0.38);
  border-radius: 50%;
  background: rgba(95, 20, 17, 0.15);
  box-shadow: 0 0 14px rgba(125, 31, 25, 0.16);
}

.map-enemy-sprite {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: auto;
  max-width: none;
  height: clamp(74px, 7.8vh, 90px);
  translate: var(--frame-offset-x, 0px) var(--frame-offset-y, 0px);
  transform: translateX(-50%) scaleX(var(--map-enemy-facing, 1));
  transform-origin: center bottom;
  image-rendering: auto;
  backface-visibility: hidden;
  z-index: 2;
  filter:
    saturate(0.82)
    brightness(0.9);
}

.map-enemy-frame-blend {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

.map-enemy-footpoint {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -2px;
  width: 34px;
  height: 11px;
  transform: translateX(-50%) scaleY(0.72);
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(0, 0, 0, 0.3) 52%,
    transparent 100%
  );
  filter: blur(1.5px);
}


.map-encounter-overlay {
  position: absolute;
  z-index: 7000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
}

.map-encounter-overlay[hidden] {
  display: none;
}

.map-encounter-overlay::before,
.map-encounter-overlay::after {
  content: "";
  position: absolute;
  inset: -12%;
  opacity: 0;
  transform: translateX(-115%) skewX(-10deg);
}

.map-encounter-overlay::before {
  background: rgba(15, 14, 12, 0.94);
}

.map-encounter-overlay::after {
  inset: 0;
  background:
    linear-gradient(105deg, transparent 0 34%, rgba(138, 35, 29, 0.24) 46%, transparent 58%),
    rgba(0, 0, 0, 0.24);
}

.map-encounter-overlay span {
  position: relative;
  z-index: 2;
  color: #f1ede3;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.2vw, 4.8rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-shadow:
    0 3px 0 #050505,
    0 0 12px rgba(166, 46, 38, 0.32);
  opacity: 0;
  transform: scale(1.08);
}

.map-encounter-overlay.is-active {
  animation: map-encounter-backdrop 520ms ease-in forwards;
}

.map-encounter-overlay.is-active::before {
  animation: map-encounter-wipe 520ms cubic-bezier(0.65, 0, 0.32, 1) forwards;
}

.map-encounter-overlay.is-active::after {
  animation: map-encounter-flash 520ms ease-out forwards;
}

.map-encounter-overlay.is-active span {
  animation: map-encounter-label 420ms ease-out forwards;
}

#map-screen[data-encounter-state="triggered"] .map-world {
  filter: saturate(0.72) contrast(1.08) brightness(0.76);
  transition: filter 180ms ease;
}

@keyframes map-encounter-wipe {
  0% { opacity: 0; transform: translateX(-115%) skewX(-10deg); }
  38% { opacity: 0.94; }
  100% { opacity: 1; transform: translateX(0) skewX(0); }
}

@keyframes map-encounter-flash {
  0% { opacity: 0; }
  30% { opacity: 0.9; }
  100% { opacity: 0.22; }
}

@keyframes map-encounter-label {
  0% { opacity: 0; transform: scale(1.08); }
  34% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes map-encounter-backdrop {
  0% { background: rgba(0, 0, 0, 0); }
  100% { background: rgba(0, 0, 0, 0.88); }
}

@media (max-width: 760px) {
  .map-enemy {
    width: 82px;
    height: 118px;
  }

  .map-enemy-sprite {
    height: clamp(100px, 16.5vh, 114px);
  }
}


/* Exported Map Editor layout -------------------------------------------- */

.map-runtime-ground-surface {
  position: absolute;
  z-index: 0;
  overflow: hidden;
  background-repeat: repeat;
  background-position: var(--runtime-ground-x, 0) var(--runtime-ground-y, 0);
  background-size:
    var(--runtime-ground-texture-size, 320px)
    var(--runtime-ground-texture-size, 320px);
  transform-origin: center;
  pointer-events: none;
  box-shadow:
    inset 0 0 18px rgba(20, 18, 14, 0.1),
    0 0 18px rgba(38, 33, 25, 0.1);
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-runtime-ground-surface {
  filter: saturate(0.76) brightness(0.88) contrast(1.02);
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-runtime-ground-surface[data-runtime-ground-id="dirt"] {
  filter: saturate(0.68) brightness(0.9) contrast(1.01);
}


.map-runtime-ground-cell {
  position: absolute;
  z-index: 0;
  overflow: hidden;
  background-color: rgba(70, 68, 59, 0.2);
  background-repeat: repeat;
  background-position: var(--runtime-ground-x, 0) var(--runtime-ground-y, 0);
  background-size:
    var(--runtime-ground-texture-size, 256px)
    var(--runtime-ground-texture-size, 256px);
  image-rendering: auto;
  pointer-events: none;
}

.map-runtime-ground-ground {
  filter: saturate(0.82) brightness(0.9) contrast(1.02);
}

.map-runtime-ground-mix {
  opacity: 0.94;
  filter: saturate(0.78) brightness(0.88) contrast(1.02);
}

.map-runtime-ground-edge {
  opacity: 0.92;
  filter: saturate(0.76) brightness(0.87) contrast(1.02);
}

.map-runtime-layout-object {
  position: absolute;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.map-runtime-layout-object img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  height: auto;
  user-select: none;
  pointer-events: none;
  image-rendering: auto;
}

.map-runtime-layout-edge img {
  transform-origin: 50% 50%;
  filter:
    saturate(0.82)
    brightness(0.88)
    contrast(1.03)
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.14));
}

.map-runtime-layout-prop {
  isolation: isolate;
}

.map-runtime-layout-prop img {
  transform-origin: 50% 100%;
  filter:
    saturate(0.9)
    brightness(0.93)
    contrast(1.025)
    drop-shadow(0 7px 4px rgba(0, 0, 0, 0.2));
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-node-base {
  filter:
    saturate(0.74)
    brightness(0.79)
    contrast(1.035);
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-node-base::after {
  opacity: 0.07;
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-runtime-layout-edge img {
  opacity: 0.88;
  filter:
    saturate(0.78)
    brightness(0.92)
    contrast(1.02)
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

#map-screen[data-map-node-id="town-south"][data-map-visual-source="map-editor-json"] .map-runtime-layout-prop img {
  filter:
    saturate(0.9)
    brightness(0.94)
    contrast(1.02)
    drop-shadow(0 7px 4px rgba(0, 0, 0, 0.2));
}

/* Class progression uses the existing skill panel and parchment palette. */
.class-progression-view { position: absolute; inset: 42px 0 0; overflow-y: auto; padding: 16px; color: #c9bea8; font: 13px/1.5 Georgia, serif; }
.class-progression-view h3, .class-progression-view h4 { color: #e2c985; margin: 4px 0 8px; }
.class-progression-view p { margin: 6px 0 10px; }
.class-progression-card { border: 1px solid #625537; background: #1c1b19; padding: 12px; margin: 12px 0; }
.class-progression-view button, .class-progression-view select { color: #e2c985; background: #24221d; border: 1px solid #8b794b; padding: 8px 12px; font: inherit; margin-top: 8px; }
.class-progression-view button:disabled { opacity: .5; }
.class-progression-view button:focus-visible, .class-progression-view select:focus-visible { outline: 2px solid #e2c985; outline-offset: 3px; }
.class-choice { display: grid; gap: 5px; margin: 12px 0; }
.command-page { max-height: min(55vh, 460px); overflow-y: auto; }
.map-skill-category-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.map-skill-menu[data-progression-view]:not([data-progression-view="general"]) .map-skill-body { grid-template-columns: minmax(110px, 18%) minmax(0, 1fr); }
.map-skill-menu[data-progression-view]:not([data-progression-view="general"]) .map-skill-detail { display: none; }
@media (max-width: 760px) {
  .map-skill-category-tabs button { font-size: 9px; letter-spacing: .05em; }
  .map-skill-menu[data-progression-view]:not([data-progression-view="general"]) .map-skill-footer { display: block; }
  .map-skill-menu[data-progression-view]:not([data-progression-view="general"]) .map-skill-controls { display: none; }
  .map-skill-resources { flex-wrap: wrap; gap: 8px; }
}

.lane-exploration #map-viewport { background:#202d28; overflow:hidden; }
.lane-world {position:absolute;inset:0 auto auto 0;width:3200px;height:900px;transform-origin:0 0;isolation:isolate;pointer-events:none;}
.lane-scenery {position:absolute;object-fit:fill;pointer-events:none;}
.lane-actor {position:absolute!important;width:110px;height:145px;object-fit:contain;transform-origin:50% 100%;pointer-events:none;}
.lane-interactable {position:absolute;transform:translate(-50%,-100%);padding:8px 12px;background:#18251ee6;border:1px solid #bca773;border-radius:4px;color:#ffe6b7;font:16px Georgia;white-space:nowrap;}
.lane-interactable img {display:block;height:110px;max-width:110px;object-fit:contain;margin:auto;}
.lane-debug {position:absolute;inset:0;z-index:100;pointer-events:none;}
.lane-debug[hidden] {display:none;}
.lane-debug-zone {position:absolute;height:28px;border:3px solid;background:#15121c99;font:bold 15px monospace;white-space:nowrap;}
.lane-exploration #map-interaction-prompt {z-index:200;}
.lane-exploration .map-test-hud {display:flex!important;position:absolute;left:24px;top:24px;bottom:auto;z-index:110;gap:5px;background:#15211dd9;padding:12px 16px;border:1px solid #bca77355;pointer-events:none;}
.lane-exploration .map-test-hud span {display:block;}
.lane-exploration .map-coordinates:empty {display:none;}
.lane-actor[hidden] {display:none!important;}
#map-screen.lane-exploration .map-test-hud {visibility:visible;opacity:1;flex-direction:column;}

/* Exploration traversal greybox. World positions live at actor feet; only the ground is projected. */
.greybox-exploration #map-viewport { background: #000; overflow: hidden; }
.greybox-exploration .map-weather-layer,
.greybox-exploration .map-screen-grain,
.greybox-exploration .map-screen-vignette { display: none !important; }
.greybox-world { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; isolation: isolate; pointer-events: none; }
.exploration-environment-image { position: absolute; z-index: 0; display: block; max-width: none; object-fit: contain; pointer-events: none; user-select: none; }
.exploration-environment-debug { --exploration-debug-opacity: .58; }
.exploration-environment-debug .greybox-surface { opacity: .62; }
.exploration-foreground-layer { position: absolute; left: 0; top: 0; z-index: 29000; width: 1px; height: 1px; pointer-events: none; }
.exploration-exit-presentation-layer,
.exploration-actor-shadow-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.exploration-exit-presentation-layer { z-index: 70; }
.exploration-actor-shadow-layer { z-index: 90; }
.exploration-warp-circle { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.exploration-warp-circle-visual {
  position: absolute;
  inset: 0;
  display: block;
  border: 1.5px solid var(--warp-ring, #d3b36c);
  border-radius: 50%;
  opacity: var(--warp-opacity, .56);
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--warp-glow, #e2c887) 16%, transparent) 0 40%, transparent 72%);
  box-shadow:
    0 0 5px color-mix(in srgb, var(--warp-glow, #e2c887) 46%, transparent),
    inset 0 0 6px color-mix(in srgb, var(--warp-dust, #a98b51) 35%, transparent);
  animation: explorationWarpBreathe 4.8s ease-in-out infinite;
}
.exploration-warp-circle-visual::after {
  content: '';
  position: absolute;
  inset: 18% 10%;
  border: 1px dotted color-mix(in srgb, var(--warp-ring, #d3b36c) 55%, transparent);
  border-radius: 50%;
}
.exploration-actor-shadow {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: rgba(0, 0, 0, .78);
  filter: blur(4px);
  transform-origin: 50% 50%;
  pointer-events: none;
}
.exploration-actor-shadow-player {
  background: rgba(0, 0, 0, .66);
  filter: blur(2.5px);
}
.exploration-actor-shadow[hidden] { display: none !important; }
@keyframes explorationWarpBreathe {
  0%, 100% { opacity: calc(var(--warp-opacity, .56) * .78); transform: scale(.96); }
  50% { opacity: var(--warp-opacity, .56); transform: scale(1.03); }
}
#map-screen[data-screen-effects="low"] .exploration-warp-circle-visual { animation-duration: 6.8s; }
@media (prefers-reduced-motion: reduce) {
  .exploration-warp-circle-visual { animation: none; }
}
.greybox-surface { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.greybox-surface[hidden] { display: none !important; }
.greybox-ground-layer { z-index: 1; }
.greybox-background-structures { z-index: 50; }
.greybox-foreground-occluders { z-index: 30000; }
.greybox-grid-base { fill: rgba(107, 42, 145, var(--exploration-debug-opacity, 1)); }
.greybox-grid-line { fill: none; stroke: #ff3048; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.greybox-walkable { stroke: #ff3048; stroke-width: 5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.greybox-transition-walkable { fill: rgba(255, 170, 0, .45) !important; stroke: #ffb020; stroke-dasharray: 10 7; }
.greybox-structure-bottom,
.greybox-structure-side,
.greybox-structure-top { stroke: #ff3048; stroke-width: 4px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.greybox-structure-bottom { fill: rgba(20, 104, 255, .88); }
.greybox-structure-side { fill: rgba(6, 20, 43, .35); }
.greybox-structure-top { fill: #1378f5; }
.greybox-exit { fill: rgba(20, 104, 255, .88); stroke: #8fd0ff; stroke-width: 4px; vector-effect: non-scaling-stroke; }
.greybox-arrival-marker { fill: #fff; stroke: #22e6c3; stroke-width: 4px; vector-effect: non-scaling-stroke; }
.greybox-player-anchor { fill: #fff; stroke: #ff3048; stroke-width: 4px; vector-effect: non-scaling-stroke; }
.greybox-actor { position: absolute !important; width: var(--exploration-actor-width, 110px); height: var(--exploration-actor-height, 145px); object-fit: contain; transform-origin: 50% 100%; pointer-events: none; }
.greybox-enemy { width: auto; max-width: none; height: var(--exploration-unit-visual-height, 112px); }
.greybox-follower { width: 76px; height: var(--exploration-unit-visual-height, 112px); }
.greybox-interactable { position: absolute; min-width: 34px; min-height: 34px; padding: 5px 8px; transform-origin: 50% 100%; color: #c9e7ff; background: #083e74; border: 3px solid #45adff; font: bold 12px/1.2 monospace; white-space: nowrap; pointer-events: none; }
.greybox-interactable img { display: block; width: auto; max-width: none; height: var(--exploration-unit-visual-height, 112px); object-fit: contain; }
.greybox-interactable-sign {
  min-width: 0;
  min-height: 0;
  width: 0;
  height: 0;
  padding: 0;
  color: transparent;
  background: transparent;
  border: 0;
}
.greybox-world:not(.greybox-debug-visible) .greybox-interactable-npc {
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}
.greybox-marker-glyph { display: grid; min-width: 22px; min-height: 22px; place-items: center; }
.greybox-interactable-label { display: block; }
.greybox-world:not(.greybox-debug-visible) .greybox-interactable:not(.greybox-interactable-npc),
.greybox-world:not(.greybox-debug-visible) .greybox-interactable-label { display: none; }
.greybox-exploration #map-interaction-prompt { z-index: 30000; }
.greybox-exploration .map-test-hud { display: flex !important; position: absolute; left: 20px; top: 20px; bottom: auto; z-index: 30010; flex-direction: column; gap: 4px; padding: 10px 14px; color: #fff; background: rgba(0,0,0,.76); border: 1px solid #70429a; pointer-events: none; }
#map-screen.greybox-exploration .map-test-hud { visibility: visible; opacity: 1; }
.greybox-exploration .map-coordinates:empty { display: none; }
.greybox-actor[hidden] { display: none !important; }
