:root {
  --ink: #14303F;
  --teal: #2E8C86;
  --moss: #7FA650;
  --cream: #F4E5C7;
  --coral: #F26B4E;
  --gold: #E9B44C;
  --plum: #7A4A6E;
  --display: "Bevan", Georgia, serif;
  --text: "Hanken Grotesk", "Trebuchet MS", sans-serif;
  --mono: "Azeret Mono", "Courier New", monospace;
  --edge: clamp(8px, 1.4vw, 18px);
  --xp-h: clamp(20px, 2.8vh, 28px);
  --paper-shadow: 5px 5px 0 rgba(20, 48, 63, 0.22);
  --soft-shadow: 3px 3px 0 rgba(20, 48, 63, 0.18);
  --panel-slice: 28;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--cream);
}

body {
  font-family: var(--text);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

#app,
#stage {
  position: fixed;
  inset: 0;
}

#stage {
  background: var(--cream);
}

#stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

#hud.is-ready {
  opacity: 1;
  visibility: visible;
}

#hud::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: url("../assets/paper_grain.png");
  background-size: 192px 192px;
  opacity: 0.14;
}

/* Sun from the upper left, cool shade to the lower right, and a soft vignette.
   Plain gradients: no blend mode, so the field never waits on a composite. */
#grade {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(115% 78% at 16% 2%, rgba(255, 241, 196, 0.28), rgba(255, 241, 196, 0) 56%),
    radial-gradient(95% 68% at 104% 104%, rgba(16, 42, 56, 0.20), rgba(16, 42, 56, 0) 62%),
    linear-gradient(180deg, rgba(20, 48, 63, 0.10), rgba(20, 48, 63, 0) 24%);
}

.panel {
  background-color: var(--cream);
  border: 15px solid transparent;
  border-image: url("../assets/ui_kit_01_panel_frame.webp") 28 / 15px / 0 stretch;
  box-shadow: var(--paper-shadow);
}

/* Keep the panel's inside cream even where border-image leaves a gap. */
.panel {
  background-clip: padding-box;
}

/* ---------- Character card ---------- */

.char-wrap {
  position: absolute;
  left: var(--edge);
  top: var(--edge);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.crest {
  width: clamp(34px, 4.6vw, 58px);
  height: auto;
  margin-right: -16px;
  z-index: 3;
  transform: rotate(-7deg);
  filter: drop-shadow(3px 3px 0 rgba(20, 48, 63, 0.25));
}

.char-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  width: clamp(300px, 31vw, 396px);
  min-height: 132px;
  padding: 10px 13px 10px 20px;
  pointer-events: auto;
}

.portrait {
  flex: 0 0 auto;
  width: clamp(58px, 5.6vw, 76px);
  height: clamp(80px, 8.2vw, 108px);
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.18);
  overflow: hidden;
  position: relative;
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(20, 48, 63, 0.25);
  pointer-events: none;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 22%;
  transform: scale(1.14);
  transform-origin: 50% 20%;
}

.status-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  line-height: 1;
}

.hero-name {
  font-family: var(--display);
  font-size: clamp(17px, 1.65vw, 22px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px 2px;
  border: 2px solid var(--ink);
  background: var(--cream);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.15);
}

.level-chip b {
  font-size: 10px;
}

.class-chip {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  margin-top: 1px;
  padding: 4px 5px 4px 6px;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-left-width: 6px;
  border-left-color: var(--gold);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.22);
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(10px, 0.9vw, 12px);
  letter-spacing: 0.03em;
  color: var(--cream);
  pointer-events: auto;
  white-space: nowrap;
  transition: transform 100ms ease, box-shadow 100ms ease, background 120ms ease;
}

.class-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.class-chip:hover {
  color: var(--cream);
  background: #1D3D4E;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.24);
}

.class-chip:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(20, 48, 63, 0.18);
}

.class-chip #className {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gold);
}

.class-chip .class-dots i {
  border-color: var(--cream);
}

.class-dots {
  display: inline-flex;
  gap: 3px;
}

.class-dots i {
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  display: block;
}

.class-edit {
  display: block;
  width: 100%;
  margin-left: 0;
  padding: 3px 6px 2px;
  text-align: center;
  background: var(--coral);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 7.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.class-key {
  flex: 0 0 auto;
  min-width: 14px;
  padding: 2px 3px;
  border: 1.5px solid var(--cream);
  border-radius: 2px;
  background: rgba(244, 229, 199, 0.14);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 700;
  text-align: center;
  line-height: 1;
}

.class-chip.job-attention {
  animation: job-attention 2.2s ease-in-out infinite;
}

@keyframes job-attention {
  0%, 100% {
    border-left-color: var(--gold);
    box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.22);
  }
  50% {
    border-left-color: var(--coral);
    box-shadow: 5px 5px 0 rgba(232, 169, 63, 0.7);
  }
}

.bar-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 5px;
}

.bar-label {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.bar-track {
  position: relative;
  height: 14px;
  background-image: url("../assets/ui_kit_03_bar_track.webp");
  background-size: 100% 100%;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  left: 4px;
  top: 4px;
  bottom: 4px;
  width: 50%;
  display: block;
  transition: width 180ms linear;
}

.bar-fill.hp {
  background: var(--coral);
  box-shadow: inset 0 2px 0 rgba(244, 229, 199, 0.32);
}

.bar-fill.sp {
  background: var(--teal);
  box-shadow: inset 0 2px 0 rgba(244, 229, 199, 0.32);
}

.num {
  font-family: var(--mono);
  font-size: 8.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 54px;
  text-align: right;
}

.stat-line {
  display: flex;
  gap: 10px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  color: rgba(20, 48, 63, 0.78);
  line-height: 1;
  margin-top: 1px;
}

.stat-line b {
  color: var(--ink);
}

/* ---------- Minimap and top right ---------- */

.top-right {
  position: absolute;
  top: var(--edge);
  right: var(--edge);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.minimap-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.minimap {
  position: relative;
  width: clamp(94px, 11vw, 148px);
  aspect-ratio: 1;
  filter: drop-shadow(4px 4px 0 rgba(20, 48, 63, 0.22));
}

.minimap-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.minimap canvas {
  position: absolute;
  inset: 13%;
  width: 74%;
  height: 74%;
  border-radius: 50%;
}

.map-label {
  pointer-events: auto;
  cursor: pointer;
  margin-top: -6px;
  padding: 3px 9px 2px;
  background: var(--cream);
  border: 2px solid var(--ink);
  font-family: var(--display);
  font-size: clamp(7px, 0.62vw, 9px);
  letter-spacing: 0.16em;
  line-height: 1.2;
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.16);
}

.zeny-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 2px 5px;
  background: var(--cream);
  border: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: clamp(9px, 0.8vw, 11px);
  font-weight: 700;
  box-shadow: var(--soft-shadow);
  white-space: nowrap;
}

.zeny-chip img {
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.zeny-chip small {
  font-size: 8px;
  font-weight: 400;
  opacity: 0.7;
}

.hud-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  max-width: min(300px, 46vw);
  pointer-events: auto;
}

.paper-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px 5px;
  background: var(--cream);
  border: 2px solid var(--ink);
  box-shadow: var(--soft-shadow);
  font-family: var(--display);
  font-size: clamp(7px, 0.62vw, 9px);
  letter-spacing: 0.08em;
  line-height: 1;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.paper-btn small {
  font-family: var(--mono);
  font-size: 7px;
  opacity: 0.45;
  letter-spacing: 0;
}

.paper-btn.round {
  width: 33px;
  height: 33px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  font-family: var(--display);
}

.paper-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(20, 48, 63, 0.2);
}

.paper-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(20, 48, 63, 0.2);
}

.paper-btn.jobs-btn {
  background: #FFF0C9;
  border-color: var(--ink);
  border-left: 5px solid var(--coral);
  font-weight: 700;
}

.paper-btn.jobs-btn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: inset 0 0 0 2px #ffe6b8;
}

/* ---------- Hint bubble ---------- */

.hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) rotate(-0.35deg);
  width: clamp(292px, 32vw, 430px);
  min-height: 132px;
  pointer-events: none;
  filter: drop-shadow(5px 5px 0 rgba(20, 48, 63, 0.18));
  transition: opacity 220ms ease, transform 220ms ease;
}

.hint[hidden] {
  display: none;
}

.hint.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px) rotate(-0.35deg);
  pointer-events: none;
}

.hint-bubble {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.hint-copy {
  position: relative;
  z-index: 1;
  padding: clamp(14px, 1.5vw, 20px) clamp(21px, 2.2vw, 30px) 28px;
}

.hint-copy b {
  font-family: var(--display);
  font-size: clamp(9px, 0.8vw, 11px);
  letter-spacing: 0.14em;
  color: var(--coral);
}

.hint-copy p {
  margin: 6px 0 4px;
  font-size: clamp(11px, 0.9vw, 13px);
  line-height: 1.3;
  font-weight: 600;
}

.hint-copy span {
  display: block;
  font-size: clamp(9px, 0.76vw, 11px);
  line-height: 1.3;
  color: rgba(20, 48, 63, 0.72);
}

.hint-x {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: 10px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.16);
  pointer-events: auto;
}

/* ---------- Party rail ---------- */

.party-rail {
  position: absolute;
  right: var(--edge);
  top: clamp(300px, 40vh, 360px);
  bottom: calc(var(--xp-h) + 92px);
  width: clamp(88px, 8.4vw, 112px);
  display: flex;
  flex-direction: column;
  pointer-events: none;
  filter: drop-shadow(4px 4px 0 rgba(20, 48, 63, 0.16));
}

.party-cap {
  position: relative;
  height: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.party-cap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0.95;
}

.party-cap span {
  position: relative;
  z-index: 1;
  margin-bottom: 2px;
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--cream);
}

.party-body {
  flex: 1;
  min-height: 90px;
  background-color: var(--cream);
  border: 15px solid transparent;
  border-image: url("../assets/ui_kit_01_panel_frame.webp") 28 / 15px / 0 stretch;
  background-clip: padding-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 10px;
}

.party-seat {
  width: 100%;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  border: 1.5px dashed rgba(20, 48, 63, 0.3);
  border-radius: 2px;
  background: rgba(20, 48, 63, 0.03);
}

.party-seat i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1.5px solid rgba(20, 48, 63, 0.4);
  border-radius: 50%;
}

.party-seat span {
  font-family: var(--mono);
  font-size: 5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(20, 48, 63, 0.42);
  white-space: nowrap;
}

.party-body em {
  margin-top: auto;
  font-size: 7.5px;
  font-style: normal;
  line-height: 1.25;
  text-align: center;
  color: rgba(20, 48, 63, 0.45);
  letter-spacing: 0.04em;
}

/* ---------- Field log ---------- */

.log-panel {
  position: absolute;
  left: var(--edge);
  bottom: calc(var(--xp-h) + 8px);
  width: clamp(300px, 31vw, 410px);
  height: clamp(98px, 17vh, 158px);
  padding: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.log-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 4px;
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.16em;
  border-bottom: 1.5px solid rgba(20, 48, 63, 0.18);
}

.log-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 6.5px;
  letter-spacing: 0.1em;
  color: var(--coral);
}

.log-live i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--coral);
  display: block;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 5px 11px 6px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
}

.log-list li {
  display: flex;
  gap: 5px;
  align-items: baseline;
  font-size: clamp(9.5px, 0.8vw, 11.5px);
  line-height: 1.25;
  letter-spacing: 0.005em;
  animation: log-in 180ms ease both;
}

.log-list li .dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  transform: translateY(-1px) rotate(45deg);
  background: var(--ink);
  opacity: 0.5;
}

.log-list li .who {
  font-weight: 700;
  white-space: nowrap;
}

.log-list li .msg {
  color: rgba(20, 48, 63, 0.86);
}

.log-list li.rare .msg {
  font-weight: 600;
}

@keyframes log-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Hotbar ---------- */

.hotbar {
  position: absolute;
  right: var(--edge);
  bottom: calc(var(--xp-h) + 8px);
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: auto;
  gap: 5px;
  pointer-events: auto;
  filter: drop-shadow(4px 4px 0 rgba(20, 48, 63, 0.18));
}

.slot {
  position: relative;
  width: clamp(42px, 4.2vw, 56px);
  aspect-ratio: 1;
  background-image: url("../assets/ui_kit_02_inventory_slot.webp");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: grid;
  place-items: center;
  transition: transform 100ms ease;
}

.slot:hover {
  transform: translateY(-2px);
}

.slot img {
  width: 74%;
  height: 74%;
  object-fit: contain;
  pointer-events: none;
}

.slot .key {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0.62;
  pointer-events: none;
}

.slot .count {
  position: absolute;
  left: 4px;
  bottom: 2px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  color: var(--coral);
  pointer-events: none;
}

.slot.empty {
  opacity: 0.44;
}

.slot.empty img {
  filter: grayscale(1);
  opacity: 0.5;
}

.slot.locked::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 9px;
  border: 2px solid rgba(20, 48, 63, 0.55);
  border-radius: 2px;
  background: rgba(244, 229, 199, 0.55);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -20%);
}

.slot.locked::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 2px solid rgba(20, 48, 63, 0.55);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -110%);
}

.slot.locked {
  opacity: 0.5;
}

.slot.locked img {
  display: none;
}

.slot.locked .count,
.slot.locked .key {
  opacity: 0.35;
}

/* ---------- Experience strip ---------- */

.xp-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--xp-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--cream);
  border-top: 3px solid var(--ink);
  box-shadow: 0 -4px 0 rgba(20, 48, 63, 0.12);
  pointer-events: none;
  z-index: 4;
}

.xp-tag,
.xp-next {
  font-family: var(--display);
  font-size: clamp(7px, 0.6vw, 8.5px);
  letter-spacing: 0.14em;
  color: var(--ink);
  white-space: nowrap;
}

.xp-track {
  position: relative;
  flex: 1;
  height: clamp(10px, 1.5vh, 14px);
  background: var(--ink);
  border: 2px solid var(--ink);
  overflow: hidden;
}

.xp-fill {
  position: absolute;
  inset: 1.5px auto 1.5px 1.5px;
  width: 0%;
  background: var(--gold);
  transition: width 220ms linear;
}

.xp-text {
  font-family: var(--mono);
  font-size: clamp(8px, 0.7vw, 10px);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
  color: var(--ink);
}

/* ---------- Touch controls ---------- */

.attack-btn {
  position: absolute;
  right: calc(var(--edge) + 4px);
  bottom: calc(var(--xp-h) + clamp(72px, 9vh, 104px));
  width: clamp(54px, 5.4vw, 68px);
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  box-shadow: var(--paper-shadow);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: auto;
  z-index: 5;
}

.attack-btn img {
  width: 48%;
  height: 48%;
  object-fit: contain;
}

.attack-btn span {
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.attack-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.2);
}

.joystick {
  position: fixed;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border: 3px solid rgba(20, 48, 63, 0.75);
  border-radius: 50%;
  background: rgba(244, 229, 199, 0.55);
  box-shadow: 0 4px 0 rgba(20, 48, 63, 0.15);
  pointer-events: none;
  z-index: 8;
}

.joy-nub {
  position: absolute;
  width: 46px;
  height: 46px;
  left: 50%;
  top: 50%;
  margin: -23px 0 0 -23px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.2);
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  pointer-events: auto;
  padding: 14px;
}

.modal[hidden] {
  display: none;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 48, 63, 0.52);
}

/* The job panel is a quick change, not a full stop: the field stays visible behind it. */
.modal.is-job .modal-scrim {
  background: rgba(20, 48, 63, 0.18);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 94vw);
  max-height: min(86vh, 780px);
  overflow: auto;
  background-color: var(--cream);
  border: 18px solid transparent;
  border-image: url("../assets/ui_kit_01_panel_frame.webp") 28 / 18px / 0 stretch;
  background-clip: padding-box;
  box-shadow: 9px 9px 0 rgba(20, 48, 63, 0.3);
  padding: clamp(14px, 2.4vw, 26px);
  color: var(--ink);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--teal) transparent;
}

.modal-card::-webkit-scrollbar {
  width: 8px;
}

.modal-card::-webkit-scrollbar-thumb {
  background: var(--teal);
}

.modal-x {
  position: sticky;
  float: right;
  top: 0;
  z-index: 5;
  width: 30px;
  height: 30px;
  margin: -4px -4px 0 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.2);
  font-family: var(--mono);
  font-size: 11px;
  display: grid;
  place-items: center;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.modal-head img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: 0 0 auto;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(20px, 2.1vw, 27px);
  letter-spacing: 0.01em;
  line-height: 1;
}

.modal-sub {
  margin: 2px 0 12px;
  font-size: 11px;
  color: rgba(20, 48, 63, 0.68);
  line-height: 1.35;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}

.tab-btn {
  padding: 6px 12px 5px;
  background: var(--cream);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.18);
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.tab-btn.active {
  background: var(--teal);
  color: var(--cream);
}

.market-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1.5px solid rgba(20, 48, 63, 0.25);
  border-left: 5px solid var(--gold);
  margin-bottom: 10px;
  font-size: 10px;
  line-height: 1.3;
}

.market-note b {
  font-family: var(--mono);
  font-size: 10px;
}

.rows {
  display: flex;
  flex-direction: column;
  border-top: 1.5px solid rgba(20, 48, 63, 0.16);
}

.row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1.5px solid rgba(20, 48, 63, 0.14);
}

.row-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(20, 48, 63, 0.05);
  border: 1.5px solid rgba(20, 48, 63, 0.16);
}

.row-icon img {
  width: 86%;
  height: 86%;
  object-fit: contain;
}

.row-main {
  min-width: 0;
}

.row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.15;
}

.row-meta {
  margin-top: 2px;
  font-size: 9px;
  color: rgba(20, 48, 63, 0.64);
  line-height: 1.3;
}

.row-side {
  display: flex;
  align-items: center;
  gap: 7px;
}

.price {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.price small {
  font-size: 8px;
  font-weight: 400;
  opacity: 0.65;
}

.act {
  padding: 5px 9px 4px;
  background: var(--cream);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.18);
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.act:hover {
  background: var(--gold);
}

.act:disabled {
  opacity: 0.38;
  cursor: default;
  background: var(--cream);
}

.rarity {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rarity .pips {
  display: inline-flex;
  gap: 1.5px;
}

.rarity .pips i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  display: block;
}

.empty-line {
  padding: 18px 6px;
  text-align: center;
  font-size: 11px;
  color: rgba(20, 48, 63, 0.5);
  font-style: italic;
}

/* ---------- Satchel ---------- */

.bag-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.paper-box {
  border: 1.5px solid rgba(20, 48, 63, 0.22);
  background: rgba(20, 48, 63, 0.035);
  padding: 9px 10px;
}

.paper-box h3 {
  margin: 0 0 5px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.gear-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  text-align: center;
  line-height: 1.2;
}

.gear-icon {
  width: 44px;
  height: 44px;
  background-image: url("../assets/ui_kit_02_inventory_slot.webp");
  background-size: 100% 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.paper-box h3 {
  margin-top: 0;
}

.paper-box.grow {
  margin-bottom: 0;
}

.paper-box + .paper-box {
  margin-top: 10px;
}

.beige-em {
  font-style: italic;
  color: rgba(20, 48, 63, 0.55);
}

.gear-bonus {
  font-family: var(--mono);
  font-size: 7px;
  color: var(--teal);
}

/* ---------- Class path ---------- */

.job-tabs {
  display: flex;
  gap: 6px;
  margin: 8px 0 10px;
}

.job-tabs .tab-btn {
  flex: 1 1 0;
  text-align: center;
}

.job-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 10px;
  padding: 7px 10px;
  background: var(--paper, #F7EEDB);
  border: 1.5px solid rgba(20, 63, 84, 0.24);
  border-left: 4px solid var(--gold);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.job-help span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.job-help b {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font-size: 7px;
}

.job-help .job-help-free {
  margin-left: auto;
  padding: 3px 6px;
  background: var(--teal);
  color: var(--cream);
  font-weight: 700;
}

.class-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  line-height: 1.3;
  margin-bottom: 10px;
  padding: 7px 10px;
  border-left: 5px solid var(--gold);
  border: 1.5px solid rgba(20, 48, 63, 0.25);
  border-left-width: 5px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 7px;
}

.class-opt {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 9px;
  border: 2px solid var(--ink);
  background: var(--cream);
  text-align: left;
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.15);
  min-height: 58px;
}

.class-opt:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.17);
}

.class-opt.picked {
  background: var(--ink);
  color: var(--cream);
}

.class-opt.picked .co-bonus,
.class-opt.picked .co-blurb {
  color: rgba(244, 229, 199, 0.7);
}

.co-swatch {
  flex: 0 0 auto;
  width: 13px;
  height: 34px;
  border: 1.5px solid var(--ink);
}

.class-opt.picked .co-swatch {
  border-color: var(--cream);
}

.co-body {
  min-width: 0;
}

.co-name {
  display: block;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.co-blurb {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  line-height: 1.2;
  color: rgba(20, 48, 63, 0.62);
}

.co-bonus {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 6.5px;
  color: var(--teal);
  line-height: 1.2;
}

.combo-preview {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.combo-preview.single {
  grid-template-columns: 1fr;
}

.combo-card {
  position: relative;
  background-image: url("../assets/ui_kit_08_tooltip_frame.webp");
  background-size: 100% 100%;
  padding: 18px 20px 22px;
  min-height: 175px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.combo-kicker {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.14em;
  color: var(--coral);
  text-transform: uppercase;
}

.combo-name {
  font-family: var(--display);
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1;
  margin: 4px 0 5px;
}

.combo-blurb {
  font-size: 10px;
  line-height: 1.3;
  color: rgba(20, 48, 63, 0.75);
  max-width: 260px;
}

.combo-bonuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 7px;
  margin-top: 8px;
}

.bonus-chip {
  font-family: var(--mono);
  font-size: 7.5px;
  padding: 3px 5px;
  border: 1.5px solid var(--ink);
  background: rgba(244, 229, 199, 0.72);
  white-space: nowrap;
}

.combo-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.all-note {
  font-size: 9px;
  line-height: 1.35;
  color: rgba(20, 48, 63, 0.62);
}

.combo-side .all-note {
  font-size: 9px;
  line-height: 1.35;
  color: rgba(20, 48, 63, 0.62);
}

.weave-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 118px;
  overflow: auto;
  padding-right: 3px;
}

.weave-chip {
  font-size: 8px;
  padding: 3px 6px;
  border: 1.5px solid rgba(20, 48, 63, 0.4);
  background: var(--cream);
  white-space: nowrap;
}

.weave-chip:hover,
.weave-chip.active {
  background: var(--teal);
  color: var(--cream);
  border-color: var(--ink);
}

.cta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.cta {
  padding: 9px 16px 7px;
  background: var(--coral);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.2);
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.cta:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(20, 48, 63, 0.22);
}

.cta:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.2);
}

/* ---------- AI traveller card ---------- */

.ai-top {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.ai-portrait {
  width: 84px;
  height: 106px;
  background: rgba(20, 48, 63, 0.05);
  border: 2px solid var(--ink);
  display: grid;
  place-items: end center;
  overflow: hidden;
  box-shadow: 3px 3px 0 rgba(20, 48, 63, 0.16);
}

.ai-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 88%;
  transform: scale(1.06);
}

.ai-name {
  font-family: var(--display);
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1;
}

.ai-class {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--teal);
}

.ai-blurb {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.3;
  color: rgba(20, 48, 63, 0.7);
}

.ai-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 8px;
}

.ai-stats b {
  color: var(--ink);
}

.chat-box {
  margin-top: 10px;
  border: 1.5px solid rgba(20, 48, 63, 0.22);
  background: rgba(20, 48, 63, 0.035);
  padding: 9px 10px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 90px;
  overflow: auto;
  margin-bottom: 7px;
  font-size: 10px;
  line-height: 1.3;
}

.chat-log .you {
  color: var(--teal);
  font-weight: 700;
}

.chat-log .them {
  color: var(--plum);
  font-weight: 700;
}

.chat-form {
  display: flex;
  gap: 6px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid var(--ink);
  background: var(--cream);
  font-family: var(--text);
  font-size: 11px;
  color: var(--ink);
  outline: none;
}

.chat-form input:focus {
  background: var(--cream);
}

.chat-form button {
  padding: 6px 11px 5px;
  border: 2px solid var(--ink);
  background: var(--teal);
  color: var(--cream);
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.05em;
}

/* ---------- Toast ---------- */

.toast-wrap {
  position: fixed;
  top: calc(var(--edge) + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 90;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 6px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-left-width: 7px;
  box-shadow: 4px 4px 0 rgba(20, 48, 63, 0.2);
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.05em;
  animation: toast-in 220ms ease both;
  max-width: 86vw;
}

.toast.out {
  animation: toast-out 260ms ease both;
}

.toast img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.toast .t-sub {
  display: block;
  font-family: var(--mono);
  font-size: 6.5px;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

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

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

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  :root {
    --edge: 8px;
  }

  .party-rail {
    display: none;
  }

  .crest {
    width: 28px;
    margin-right: -10px;
  }

  .char-panel {
    width: calc(100vw - 136px);
    max-width: 330px;
    min-height: 96px;
    gap: 7px;
    padding: 7px 9px 7px 14px;
  }

  .portrait {
    width: 48px;
    height: 68px;
  }

  .hero-name {
    font-size: 15px;
  }

  .class-chip {
    font-size: 9px;
    gap: 4px;
    min-width: 0;
  }

  .class-edit {
    display: inline-block;
    flex: 0 0 auto;
    font-size: 6.5px;
    padding: 2px 4px 1px;
    letter-spacing: 0.05em;
  }

  .class-key {
    font-size: 6px;
    min-width: 12px;
  }

  .bar-track {
    height: 12px;
  }

  .bar-fill {
    left: 3px;
    top: 3px;
    bottom: 3px;
  }

  .stat-line {
    font-size: 7px;
    gap: 7px;
  }

  .top-right {
    gap: 4px;
  }

  .minimap {
    width: 88px;
  }

  .map-label {
    font-size: 6.5px;
    padding: 2px 6px 1px;
  }

  .zeny-chip {
    font-size: 9px;
    padding: 2px 7px 1px 4px;
  }

  .zeny-chip img {
    width: 16px;
    height: 16px;
  }

  .paper-btn {
    padding: 5px 7px 4px;
    font-size: 6.5px;
    gap: 4px;
  }

  .paper-btn small {
    display: none;
  }

  .paper-btn.round {
    width: 27px;
    height: 27px;
    font-size: 12px;
  }

  .hint {
    top: 200px;
    width: 76vw;
    min-height: 112px;
  }

  .hint-copy {
    padding: 12px 20px 22px;
  }

  .hint-copy p {
    font-size: 10.5px;
  }

  .hint-copy span {
    font-size: 9px;
  }

  .party-rail {
    top: 300px;
    bottom: calc(var(--xp-h) + 112px);
    width: 26px;
  }

  .party-cap {
    height: 30px;
  }

  .party-cap span {
    display: none;
  }

  .party-body {
    border-width: 8px;
    border-image-slice: 28;
    padding: 4px 3px 8px;
    min-height: 60px;
    gap: 5px;
  }

  .party-seat {
    height: 16px;
    justify-content: center;
    padding: 0;
    border: 0;
    background: none;
  }

  .party-seat span {
    display: none;
  }

  .party-seat i {
    width: 9px;
    height: 9px;
    border-color: rgba(20, 48, 63, 0.3);
  }

  .party-body em {
    display: none;
  }

  .log-panel {
    width: 48vw;
    height: 82px;
    bottom: calc(var(--xp-h) + 8px);
    border-width: 9px;
  }

  .log-head {
    padding: 3px 8px 2px;
    font-size: 6.5px;
  }

  .log-list {
    padding: 3px 7px 4px;
    gap: 2px;
  }

  .log-list li {
    font-size: 8.5px;
  }

  .log-list li .dot {
    width: 4px;
    height: 4px;
  }

  .hotbar {
    grid-auto-flow: row;
    grid-template-columns: repeat(4, auto);
    grid-template-rows: repeat(2, auto);
    gap: 4px;
    bottom: calc(var(--xp-h) + 8px);
  }

  .slot {
    width: clamp(34px, 9vw, 42px);
  }

  .attack-btn {
    display: flex;
    right: 10px;
    bottom: calc(var(--xp-h) + 92px);
    width: 54px;
  }

  .xp-strip {
    padding: 0 7px;
    gap: 5px;
  }

  .xp-next {
    display: none;
  }

  .modal-card {
    width: 96vw;
    max-height: 93vh;
    border-width: 11px;
    padding: 12px;
  }

  .class-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .combo-preview {
    grid-template-columns: 1fr;
  }

  .combo-card {
    min-height: 155px;
  }

  .bag-top {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 38px 1fr auto;
    gap: 7px;
  }

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

  .row-name {
    font-size: 11px;
  }

  .act {
    padding: 4px 7px 3px;
    font-size: 7px;
  }

  .ai-top {
    grid-template-columns: 62px 1fr;
  }

  .ai-portrait {
    width: 62px;
    height: 82px;
  }
}

@media (pointer: coarse) {
  .attack-btn {
    display: flex;
  }
}

@media (max-height: 560px) and (min-width: 700px) {
  .party-rail {
    display: none;
  }

  .modal-card {
    max-height: 94vh;
    padding: 10px 12px;
  }

  .modal-head img {
    width: 28px;
    height: 28px;
  }

  .modal-head h2 {
    font-size: 20px;
  }

  .modal-sub {
    font-size: 9px;
    margin-bottom: 6px;
  }

  .class-intro {
    font-size: 9px;
    padding: 5px 8px;
    margin-bottom: 6px;
  }

  .job-help {
    padding: 5px 8px;
    gap: 4px 10px;
    margin-bottom: 6px;
    font-size: 7px;
  }

  .job-help b {
    width: 12px;
    height: 12px;
    font-size: 6.4px;
  }

  .class-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .modal.is-job .class-grid {
    gap: 4px;
  }

  .class-opt {
    min-height: 0;
    padding: 6px 7px;
    gap: 5px;
  }

  .co-blurb {
    font-size: 7.8px;
  }

  .co-bonus {
    font-size: 6.2px;
  }

  .class-cta {
    margin-top: 8px;
    padding-top: 7px;
  }

  .modal.is-job .modal-sub {
    display: none;
  }

  .modal.is-job .class-intro {
    margin-bottom: 6px;
    padding: 5px 8px;
  }

  .modal.is-job .job-help {
    display: none;
  }

  .modal.is-job .class-opt {
    padding: 4px 6px;
  }

  .modal.is-job .special-wrap {
    margin-top: 2px;
  }

  .modal.is-job .special-wrap .co-blurb {
    display: none;
  }

  .party-rail {
    top: 210px;
  }

  .char-panel {
    min-height: 98px;
    width: clamp(280px, 28vw, 350px);
    padding: 7px 10px 7px 16px;
  }

  .portrait {
    width: 50px;
    height: 70px;
  }

  .stat-line {
    display: none;
  }

  .log-panel {
    height: 82px;
  }

  .party-rail {
    top: 166px;
    bottom: calc(var(--xp-h) + 72px);
  }

  .minimap {
    width: 96px;
  }

  .hint {
    width: 34vw;
    min-height: 106px;
    top: 8px;
  }

  .hint-copy {
    padding: 11px 16px 20px;
  }

  .hint-copy p {
    font-size: 10px;
  }

  .hint-copy span {
    display: none;
  }

  .hotbar {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-template-rows: none;
  }

  .slot {
    width: 38px;
  }
}

@media (max-width: 380px) {
  .char-panel {
    width: calc(100vw - 118px);
  }

  .minimap {
    width: 76px;
  }

  .stat-line {
    display: none;
  }

  .log-panel {
    width: 47vw;
    height: 72px;
  }

  .log-list li {
    font-size: 8px;
  }

  .paper-btn {
    font-size: 6px;
  }
}

/* ---------- Loader ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--cream);
  transition: opacity 500ms ease, visibility 500ms ease;
}

#loader.is-done {
  opacity: 0;
  visibility: hidden;
}

#loader img {
  width: clamp(72px, 9vw, 112px);
  height: auto;
  animation: loader-bob 2.4s ease-in-out infinite;
  filter: drop-shadow(4px 4px 0 rgba(20, 48, 63, 0.2));
}

#loader h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(26px, 4.2vw, 52px);
  letter-spacing: 0.04em;
  line-height: 1;
}

#loader h1 span {
  color: var(--coral);
  font-size: 0.48em;
  letter-spacing: 0.16em;
  vertical-align: middle;
}

#loader p {
  margin: 0;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--teal);
}

@keyframes loader-bob {
  0%,
  100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

/* ---------- Identity ---------- */

.kind-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -1px;
  line-height: 1;
}

.kind-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px 1px;
  border: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  white-space: nowrap;
}

.kind-badge.human {
  background: var(--teal);
  color: var(--cream);
}

.kind-badge.ai {
  background: var(--plum);
  color: var(--cream);
}

.kind-badge.you {
  background: var(--gold);
  color: var(--ink);
}

.account-name {
  font-family: var(--mono);
  font-size: 7px;
  color: rgba(20, 48, 63, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.realm-chip {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 2px;
  background: var(--cream);
  border: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.16);
  pointer-events: auto;
  white-space: nowrap;
}

.realm-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  display: block;
}

.realm-chip.local::before {
  background: var(--gold);
}

.realm-chip.connecting::before {
  background: var(--coral);
}

.realm-chip:hover {
  background: var(--gold);
}

/* ---------- Boss bar ---------- */

.boss-bar {
  position: absolute;
  top: clamp(142px, 20vh, 176px);
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 62vw);
  padding: 8px 12px 7px;
  background: rgba(244, 229, 199, 0.97);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 rgba(20, 48, 63, 0.25);
  pointer-events: none;
  z-index: 6;
}

.boss-bar[hidden] {
  display: none;
}

.boss-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  line-height: 1;
}

#bossName {
  font-family: var(--display);
  font-size: clamp(10px, 1vw, 13px);
  letter-spacing: 0.06em;
  color: var(--ink);
}

.boss-meta {
  font-family: var(--mono);
  font-size: 6.5px;
  color: var(--teal);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.boss-track {
  position: relative;
  height: 14px;
  margin-top: 5px;
  background: var(--ink);
  border: 1.5px solid var(--ink);
  overflow: hidden;
}

.boss-fill {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 100%;
  background: var(--coral);
  transition: width 220ms linear;
}

.boss-sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 7px;
  line-height: 1.3;
  color: rgba(20, 48, 63, 0.66);
}

.boss-resp {
  color: var(--plum);
  white-space: nowrap;
}

/* ---------- Skill slots ---------- */

.slot.skill {
  background-image: url("../assets/ui_kit_02_inventory_slot.webp");
}

.slot.skill .skill-glyph {
  font-family: var(--display);
  font-size: clamp(15px, 1.4vw, 20px);
  color: var(--ink);
  line-height: 1;
  pointer-events: none;
}

.slot.skill .skill-name {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  text-align: center;
  font-family: var(--mono);
  font-size: 5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(20, 48, 63, 0.7);
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

.slot.skill .cooldown {
  position: absolute;
  inset: 3px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 48, 63, 0.72);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--cream);
  pointer-events: none;
}

.slot.skill.cooling .cooldown {
  display: flex;
}

.slot.skill .key {
  right: 3px;
  bottom: 2px;
}

/* ---------- Lore ---------- */

.lore-entry {
  padding: 9px 11px;
  border: 1.5px solid rgba(20, 48, 63, 0.2);
  border-left: 5px solid var(--gold);
  margin-bottom: 7px;
}

.lore-entry h4 {
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.lore-entry .lore-term {
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
  color: var(--coral);
  text-transform: uppercase;
}

.lore-entry p {
  margin: 4px 0 0;
  font-size: 10px;
  line-height: 1.38;
  color: rgba(20, 48, 63, 0.78);
}

/* ---------- Shared reef modal ---------- */

.realm-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1.5px solid rgba(20, 48, 63, 0.25);
  border-left: 6px solid var(--teal);
  margin-bottom: 10px;
  font-size: 10px;
  line-height: 1.3;
}

.realm-status.local {
  border-left-color: var(--gold);
}

.realm-status.connecting {
  border-left-color: var(--coral);
}

.realm-status b {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.realm-status .small {
  font-family: var(--mono);
  font-size: 7px;
  color: rgba(20, 48, 63, 0.55);
  white-space: nowrap;
}

.online-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1.5px solid rgba(20, 48, 63, 0.12);
}

.online-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 700;
}

.online-meta {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 7.5px;
  color: rgba(20, 48, 63, 0.58);
}

.online-side {
  font-family: var(--mono);
  font-size: 8px;
  text-align: right;
  color: rgba(20, 48, 63, 0.6);
  line-height: 1.3;
}

@media (max-width: 900px) {
  .boss-bar {
    top: 230px;
    width: 80vw;
    padding: 6px 9px 6px;
    border-width: 2px;
  }

  #bossName {
    font-size: 9px;
  }

  .boss-meta {
    font-size: 5.5px;
  }

  .boss-track {
    height: 11px;
  }

  .boss-sub {
    font-size: 6px;
  }

  .realm-chip {
    font-size: 5.5px;
    padding: 2px 5px 1px;
  }

  .kind-badge {
    font-size: 6px;
    padding: 1px 4px 1px;
  }

  .account-name {
    font-size: 6px;
    max-width: 90px;
  }

  .slot.skill .skill-glyph {
    font-size: 14px;
  }

  .slot.skill .skill-name {
    font-size: 4.5px;
  }
}

@media (max-height: 560px) and (min-width: 700px) {
  .boss-bar {
    top: 8px;
    left: 56%;
    transform: translateX(-50%);
    width: 36vw;
    padding: 5px 8px 5px;
  }

  .boss-sub {
    font-size: 5.5px;
  }
}

@media (max-width: 380px) {
  .boss-bar {
    top: 230px;
    width: 78vw;
  }

  .kind-badge {
    display: none;
  }
}

/* ---------- Special path ---------- */

.special-wrap {
  margin-top: 10px;
  padding: 9px 10px;
  border: 2px solid var(--gold);
  background: rgba(233, 180, 76, 0.09);
}

.special-title {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--coral);
}

.class-opt.special-opt {
  width: 100%;
  min-height: 64px;
}

.class-opt.compact {
  min-height: 0;
  padding: 5px 7px;
  gap: 6px;
  align-items: center;
}

.class-opt.compact .co-icon {
  width: 30px;
  height: 30px;
}

.class-opt.compact .co-name {
  font-size: 9.5px;
}

.class-opt.compact .co-blurb {
  display: none;
}

.class-opt.compact .co-bonus {
  margin-top: 1px;
  font-size: 6.2px;
}

.current-path {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 0 0 auto;
  padding: 5px 9px 4px;
  border: 1.5px dashed rgba(20, 48, 63, 0.35);
  background: rgba(20, 48, 63, 0.04);
  font-family: var(--mono);
  line-height: 1.1;
}

.current-path b {
  font-size: 7px;
  letter-spacing: 0.08em;
  color: var(--teal);
}

.current-path small {
  font-size: 7px;
  color: rgba(20, 48, 63, 0.7);
}

.combo-subtitle {
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin: -1px 0 4px;
  text-transform: uppercase;
}

.combo-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.skill-pill {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 3px 6px;
  border: 1.5px solid var(--ink);
  background: rgba(244, 229, 199, 0.8);
  font-family: var(--mono);
  font-size: 7px;
  white-space: nowrap;
}

.skill-pill b {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  background: var(--ink);
  color: var(--cream);
  font-size: 7px;
}

#soundBtn {
  display: none !important;
}

/* ---------- Painted class emblems ---------- */

.class-dots {
  gap: 2px;
}

.class-dots img,
.class-mini {
  width: 13px;
  height: 13px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(1px 1px 0 rgba(20, 48, 63, 0.18));
}

.co-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(2px 2px 0 rgba(20, 48, 63, 0.18));
}

.class-opt.special-opt .co-icon {
  width: 44px;
  height: 44px;
}

.combo-icons {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.combo-icons img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(2px 2px 0 rgba(20, 48, 63, 0.16));
}

.path-icons {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
}

.path-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(2px 2px 0 rgba(20, 48, 63, 0.16));
}

.ai-class .class-mini {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 2px;
}

@media (max-width: 900px) {
  .class-dots img,
  .class-mini {
    width: 11px;
    height: 11px;
  }

  .co-icon {
    width: 30px;
    height: 30px;
  }

  .class-opt.special-opt .co-icon {
    width: 36px;
    height: 36px;
  }

  .combo-icons img {
    width: 26px;
    height: 26px;
  }

  .path-icon {
    width: 30px;
    height: 30px;
  }
}


.co-sub {
  display: block;
  font-family: var(--mono);
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-top: 1px;
}

@media (max-width: 900px) {
  .toast-wrap {
    top: 290px;
  }
}

@media (max-width: 700px) {
  .class-intro {
    flex-wrap: wrap;
  }

  .class-intro > span {
    flex: 1 1 100%;
  }
}

@media (max-height: 560px) and (min-width: 700px) {
  .toast-wrap {
    top: 270px;
  }
}


/* ---------- Market plaque and auto slot ---------- */

.market-plaque {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0 0 6px;
  padding: 3px 4px;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(20, 48, 63, 0.16);
  font-family: var(--mono);
  font-size: 5px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
}

.market-plaque img {
  width: 15px;
  height: 15px;
  object-fit: contain;
  flex: 0 0 auto;
}

.market-plaque span {
  display: block;
}

.slot.auto {
  background-image: url("../assets/ui_kit_02_inventory_slot.webp");
}

.slot.auto .auto-glyph {
  font-family: var(--display);
  font-size: clamp(8px, 0.8vw, 10px);
  color: var(--ink);
  letter-spacing: 0.04em;
  line-height: 1;
  pointer-events: none;
}

.slot.auto .auto-state {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  text-align: center;
  font-family: var(--mono);
  font-size: 5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1;
  pointer-events: none;
}

.slot.auto.on .auto-state {
  color: var(--teal);
}

.slot.auto.off .auto-state {
  color: rgba(20, 48, 63, 0.45);
}

.slot.auto.off .auto-glyph {
  opacity: 0.45;
}

.slot.auto .key {
  right: 3px;
  bottom: 2px;
}

@media (max-width: 900px) {
  .market-plaque {
    display: none;
  }
}

@media (max-height: 560px) {
  .market-plaque {
    display: none;
  }
}

/* ---------- Quest tracker and quests modal ---------- */

button.map-label {
  cursor: pointer;
  color: var(--ink);
}

.quest-track {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 12px);
  margin: 5px 6px 0;
  padding: 4px 6px;
  border: 1.5px solid var(--ink);
  background: rgba(255, 249, 235, 0.72);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
}

.quest-track .qt-kicker {
  flex: none;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  color: var(--coral);
}

.quest-track .qt-name {
  font-family: var(--body);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quest-track .qt-goal {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--teal);
  flex: none;
}

.quest-row {
  border: 1.5px solid rgba(20, 48, 63, 0.24);
  border-left: 4px solid var(--gold);
  background: rgba(255, 249, 235, 0.62);
  padding: 7px 8px;
  margin-bottom: 6px;
}

.quest-row.active {
  border-left-color: var(--teal);
}

.quest-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.quest-name {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.quest-progress {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--teal);
  flex: none;
}

.quest-trackline {
  height: 6px;
  margin: 4px 0;
  border: 1.5px solid var(--ink);
  background: rgba(20, 48, 63, 0.12);
}

.quest-trackline i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.quest-row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.map-town {
  border: 2px solid var(--ink);
  background: rgba(255, 249, 235, 0.68);
  padding: 9px;
}

.map-town-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px dashed rgba(20, 48, 63, 0.3);
}

.map-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 7px;
}

.map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px;
  border: 1.5px solid rgba(20, 48, 63, 0.22);
  background: rgba(255, 249, 235, 0.58);
}

.map-row > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.map-row > div:first-child .row-meta {
  overflow-wrap: anywhere;
}

.map-row .act {
  flex: 0 0 auto;
}

.map-row.here {
  border-color: var(--teal);
  background: rgba(46, 140, 134, 0.12);
}

.map-row-name {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.boss-tag {
  display: inline-block;
  padding: 1px 5px;
  background: var(--plum);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.08em;
}

@media (max-width: 560px) {
  .quest-track .qt-goal {
    font-size: 7px;
  }
  .map-town-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .map-label {
    max-width: 124px;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    font-size: 6px;
    letter-spacing: 0.12em;
  }
  .hud-actions {
    max-width: 190px;
  }
  .hud-actions .paper-btn {
    padding: 5px 6px 4px;
  }
}

#talkBtn {
  border-left-width: 5px;
  border-left-color: var(--teal);
}

@media (pointer: coarse) {
  #talkBtn {
    min-width: 52px;
    min-height: 30px;
  }
}

/* The bind action sits after the last card, so it never covers the list. */
.class-cta {
  margin-top: 12px;
  padding: 10px 0 16px;
}

.class-top-cta {
  flex: 0 0 auto;
  padding: 7px 10px 5px;
  font-size: 9px;
}
