:root {
  color-scheme: light;
  --ink: #2b2340;
  --ink-2: #5b5274;
  --paper: #fffaf0;
  --paper-2: #f5ecd9;
  --line: #3a2f4a;
  --jade: #3fb49a;
  --jade-2: #2c8f7a;
  --rose: #ff7aa8;
  --gold: #ffcf4a;
  --sky: #7cc8f0;
  --hp: #ff5d73;
  --mp: #4f9dff;
  --xp: #ffc83a;
  --panel-shadow: 0 10px 30px rgba(30, 20, 50, 0.35);
  --r-normal: #e9e6f2;
  --r-fine: #7fe08c;
  --r-rare: #6cb8ff;
  --r-heroic: #c88cff;
  --r-legendary: #ffb347;
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #1c1830;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
kbd {
  font: 800 10px/1 ui-monospace, monospace;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(43, 35, 64, 0.12);
}

.wb {
  position: fixed;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  background: #1c1830;
}

/* ---------- shared window look (classic RPG panel, pastel hanji) */
.win,
.hud-player,
.hud-map,
.tracker,
.log,
.panel,
.dialog,
.hotbar,
.menu-bar {
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.94), rgba(245, 236, 217, 0.94));
  border: 2px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), 0 4px 0 rgba(30, 20, 50, 0.25);
}

/* ---------- HUD */
.hud-player {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 236px;
  padding: 7px 9px 8px;
  z-index: 5;
}
.hp-name {
  font-weight: 900;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-title {
  color: #b77a00;
  font-size: 12px;
}
.hp-line {
  font-size: 11px;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.bar {
  position: relative;
  height: 14px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: #3a3350;
  overflow: hidden;
  margin-top: 3px;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 6px;
  transition: width 0.15s linear;
}
.bar span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 10px;
  line-height: 11px;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.bar-hp i {
  background: linear-gradient(180deg, #ff8a9a, var(--hp));
}
.bar-mp i {
  background: linear-gradient(180deg, #8ac2ff, var(--mp));
}
.bar-xp {
  height: 9px;
}
.bar-xp i {
  background: linear-gradient(180deg, #ffe08a, var(--xp));
}
.bar-xp span {
  font-size: 8px;
  line-height: 6px;
}
.party {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.party .pm {
  flex: 1;
  min-width: 0;
  font-size: 10px;
}
.party .pm .bar {
  height: 7px;
  margin-top: 1px;
}
.buffs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.buffs span {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: #fff1b8;
  border: 1px solid #d8b24a;
}

.hud-map {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 5px;
  z-index: 5;
  text-align: center;
}
.map-name {
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 3px;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#minimap {
  display: block;
  width: 150px;
  height: 110px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: #2b2340;
  image-rendering: pixelated;
  cursor: pointer;
}
.gold {
  margin-top: 4px;
  font-size: 12px;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
}
.coin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #f0b429 60%, #b47a0a);
  box-shadow: inset 0 0 0 3px transparent;
  position: relative;
}
.coin::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: #b47a0a;
  border-radius: 1px;
}

.tracker {
  position: absolute;
  right: 10px;
  top: 172px;
  width: 226px;
  max-height: 40%;
  overflow: auto;
  padding: 7px 9px;
  z-index: 4;
  font-size: 12px;
}
.tracker h3 {
  margin: 0 0 3px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--jade-2);
}
.tq {
  margin-bottom: 6px;
}
.tq b {
  display: block;
  font-size: 12px;
}
.tq.main b {
  color: #b35a00;
}
.tq .ob {
  color: var(--ink-2);
  font-size: 11px;
}
.tq .ob.ok {
  color: var(--jade-2);
  text-decoration: line-through;
}
.tq.ready b::after {
  content: " ✔";
  color: var(--jade);
}

.log {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(430px, calc(50% - 262px));
  height: 118px;
  padding: 5px 8px;
  z-index: 4;
  background: rgba(30, 24, 48, 0.72);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: none;
}
.log-lines {
  height: 100%;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.35;
  color: #f4f0ff;
  scrollbar-width: thin;
}
.log-lines p {
  margin: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.log-lines .c-xp {
  color: #ffe38a;
}
.log-lines .c-loot {
  color: #aef0b8;
}
.log-lines .c-quest {
  color: #8fe8ff;
}
.log-lines .c-warn,
.log-lines .c-bad {
  color: #ffa0b0;
}
.log-lines .c-good {
  color: #ffd36b;
}
.log-lines .c-map {
  color: #d0c4ff;
}
.log-lines .c-herald {
  color: #ffb347;
  font-weight: 900;
}

.menu-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 4px;
  z-index: 5;
}
.menu-bar button {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 11px;
  min-width: 46px;
}
.menu-bar button:hover {
  background: #eafff8;
}
.menu-bar button kbd {
  font-size: 9px;
}
.menu-bar button.alert span::after {
  content: "•";
  color: var(--rose);
  margin-left: 2px;
}

.hotbar {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  z-index: 5;
}
.hk {
  position: relative;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #d8d0e8 center / 32px 32px no-repeat;
  padding: 0;
  image-rendering: pixelated;
}
.hk.empty {
  background: #ece6f4;
  opacity: 0.6;
}
.hk .key {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px #000, 0 0 2px #000;
}
.hk .cd {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 50, 0.6);
  transform-origin: bottom;
  border-radius: 5px;
  pointer-events: none;
}
.hk .cnt {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px #000, 0 0 2px #000;
}
.hk.nomp {
  filter: saturate(0.3) brightness(0.8);
}
.hk.pot {
  border-color: #8a5a3a;
}

/* ---------- touch */
.touch {
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  z-index: 6;
}
.dpad {
  position: absolute;
  left: 12px;
  bottom: 14px;
  width: 132px;
  height: 132px;
}
.dp {
  position: absolute;
  width: 46px;
  height: 46px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 240, 0.85);
  touch-action: none;
}
.dp::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border: 9px solid transparent;
}
.dp.up {
  left: 43px;
  top: 0;
}
.dp.up::after {
  border-bottom-color: var(--line);
  border-top-width: 0;
}
.dp.down {
  left: 43px;
  bottom: 0;
}
.dp.down::after {
  border-top-color: var(--line);
  border-bottom-width: 0;
}
.dp.left {
  left: 0;
  top: 43px;
}
.dp.left::after {
  border-right-color: var(--line);
  border-left-width: 0;
}
.dp.right {
  right: 0;
  top: 43px;
}
.dp.right::after {
  border-left-color: var(--line);
  border-right-width: 0;
}
.dp.on,
.act.on {
  background: #bff5e6;
}
.acts {
  position: absolute;
  right: 12px;
  bottom: 14px;
  width: 150px;
  height: 132px;
}
.act {
  position: absolute;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.9);
  font-weight: 900;
  touch-action: none;
}
.act.atk {
  width: 74px;
  height: 74px;
  right: 0;
  bottom: 0;
  background: rgba(255, 190, 200, 0.95);
  font-size: 15px;
}
.act.talk {
  width: 46px;
  height: 46px;
  right: 82px;
  bottom: 4px;
}
.act.pick {
  width: 46px;
  height: 46px;
  right: 60px;
  bottom: 70px;
}
.act.menu {
  width: 40px;
  height: 40px;
  right: 8px;
  bottom: 84px;
}

/* ---------- tip, herald, toasts */
.tip {
  position: absolute;
  left: 50%;
  top: 68px;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: min(560px, 92vw);
  padding: 8px 10px 8px 14px;
  background: #fffbe0;
  border: 2px solid #c79a1a;
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
  font-size: 13px;
  animation: pop 0.25s ease-out;
}
.tip p {
  margin: 0;
}
.tip button {
  border: 2px solid var(--line);
  background: var(--gold);
  border-radius: 8px;
  padding: 3px 10px;
  font-weight: 900;
}
.herald {
  position: absolute;
  top: 124px;
  left: 0;
  right: 0;
  z-index: 9;
  pointer-events: none;
  text-align: center;
}
.herald div {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(90, 40, 0, 0.85), rgba(160, 90, 0, 0.9), rgba(90, 40, 0, 0.85));
  color: #fff3b0;
  font-weight: 900;
  font-size: 14px;
  text-shadow: 0 1px 0 #000;
  border: 2px solid #ffd36b;
  animation: herald 6s ease-in-out forwards;
}
.toasts {
  position: absolute;
  top: 164px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  align-items: center;
}
.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(180deg, #fff8dc, #ffe9a8);
  border: 2px solid #b8860b;
  border-radius: 12px;
  box-shadow: var(--panel-shadow);
  animation: toast 4.2s ease-in-out forwards;
  min-width: 240px;
}
.toast .medal {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #ffd36b 50%, #d89a1a);
  border: 2px solid var(--line);
  flex: none;
}
.toast small {
  display: block;
  color: var(--ink-2);
  font-size: 11px;
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
  }
  8%,
  85% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes herald {
  0% {
    opacity: 0;
    transform: translateX(40px);
  }
  10%,
  85% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateX(-40px);
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.92);
  }
}

/* ---------- boss card */
.boss-card {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(60, 10, 40, 0.25), rgba(20, 5, 20, 0.7));
  animation: bossfade 3.2s ease-in-out forwards;
}
.boss-card .bc {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 26px 16px 16px;
  background: linear-gradient(90deg, rgba(40, 10, 30, 0.95), rgba(90, 20, 50, 0.95));
  border: 3px solid #ffb347;
  border-radius: 16px;
  color: #fff;
  box-shadow: 0 0 40px rgba(255, 90, 120, 0.5);
  max-width: 92vw;
}
.boss-card .bc-art {
  width: 130px;
  height: 130px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #ffd36b;
  flex: none;
  background: #2a1a30;
}
.boss-card .bc-art img,
.boss-card .bc-art canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: auto;
}
.boss-card .bc-kick {
  color: #ff9ab0;
  font-size: 13px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}
.boss-card h2 {
  margin: 2px 0;
  font-size: 26px;
  font-weight: 900;
}
@keyframes bossfade {
  0% {
    opacity: 0;
  }
  12%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- panels */
.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(900px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: var(--panel-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 6px 14px;
  border-bottom: 2px solid rgba(58, 47, 74, 0.25);
  background: linear-gradient(180deg, #d8f6ec, #b8ebdc);
  border-radius: 8px 8px 0 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
}
.panel-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.panel-tabs button,
.btn,
.chip-btn {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: 13px;
}
.panel-tabs button[aria-selected="true"] {
  background: var(--jade);
  color: #fff;
}
.btn.primary {
  background: var(--jade);
  color: #fff;
}
.btn.warn {
  background: #ffb0a0;
}
.btn.gold {
  background: var(--gold);
}
.btn.ghost {
  background: transparent;
}
.btn:disabled,
.chip-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.small,
.chip-btn {
  padding: 2px 8px;
  font-size: 12px;
}
.x {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 32px;
  height: 30px;
  font-weight: 900;
}
.panel-body {
  overflow: auto;
  padding: 12px 14px 14px;
  font-size: 13px;
}
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
.cols.wide-left {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
}
.card {
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid rgba(58, 47, 74, 0.35);
  border-radius: 10px;
  padding: 10px;
}
.card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}
.muted {
  color: var(--ink-2);
  font-weight: 600;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row.between {
  justify-content: space-between;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid rgba(58, 47, 74, 0.2);
}
.li .grow {
  flex: 1;
  min-width: 0;
}
.li.done {
  opacity: 0.6;
}
.li.locked {
  filter: grayscale(0.8);
  opacity: 0.6;
}

/* items */
.slots {
  display: grid;
  grid-template-columns: repeat(8, 44px);
  gap: 4px;
}
.eq-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.eq {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--ink-2);
}
.it {
  position: relative;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ece6f4 center / 32px 32px no-repeat;
  padding: 0;
  image-rendering: pixelated;
}
.it[data-r="fine"] {
  border-color: #35a045;
  box-shadow: inset 0 0 0 2px var(--r-fine);
}
.it[data-r="rare"] {
  border-color: #2a70c0;
  box-shadow: inset 0 0 0 2px var(--r-rare);
}
.it[data-r="heroic"] {
  border-color: #7a3ac0;
  box-shadow: inset 0 0 0 2px var(--r-heroic);
}
.it[data-r="legendary"] {
  border-color: #c06a00;
  box-shadow: inset 0 0 0 2px var(--r-legendary), 0 0 8px #ffb347;
}
.it.sel {
  outline: 3px solid var(--gold);
}
.it .enh {
  position: absolute;
  right: 1px;
  top: 0;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px #000, 0 0 2px #000;
}
.it .cnt {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px #000, 0 0 2px #000;
}
.it.empty {
  opacity: 0.5;
}
.detail h3 {
  margin: 0;
  font-size: 16px;
}
.detail .sub {
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.detail ul {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}
.detail li {
  font-size: 13px;
}
.detail .aff {
  color: #2a70c0;
}
.detail .power {
  color: #b35a00;
  font-style: italic;
  font-size: 12px;
}
.up {
  color: #1e9a4a;
}
.down {
  color: #d23a4a;
}
.rname-normal {
  color: #5b5274;
}
.rname-fine {
  color: #1e9a4a;
}
.rname-rare {
  color: #2a70c0;
}
.rname-heroic {
  color: #7a3ac0;
}
.rname-legendary {
  color: #c06a00;
}

/* stats */
.stat-row {
  display: grid;
  grid-template-columns: 60px 50px 1fr;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  font-size: 13px;
}
.kv b {
  text-align: right;
}

/* skills */
.sk-icon {
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  border-radius: 8px;
  image-rendering: pixelated;
  flex: none;
}
select {
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 1px 4px;
}

.prog {
  height: 8px;
  border-radius: 4px;
  background: #ddd4ea;
  overflow: hidden;
  margin-top: 3px;
}
.prog i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--jade), #8fe8c8);
}
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.ach {
  padding: 8px;
  border-radius: 10px;
  border: 1.5px solid rgba(58, 47, 74, 0.25);
  background: rgba(255, 255, 255, 0.6);
}
.ach.done {
  background: linear-gradient(180deg, #fff8dc, #ffeaa8);
  border-color: #b8860b;
}
.ach small {
  display: block;
  color: var(--ink-2);
  font-weight: 600;
}

/* forge */
.forge-view {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 60%, #ffe7b0, #f2d9a8 50%, #d9b88a);
  border: 2px solid var(--line);
  position: relative;
  overflow: hidden;
  min-height: 160px;
}
.forge-view .it {
  width: 64px;
  height: 64px;
  background-size: 48px 48px;
}
.forge-big {
  font-size: 30px;
  font-weight: 900;
}
.forge-chance {
  font-size: 22px;
  font-weight: 900;
  color: var(--jade-2);
}
.forge-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.forge-fx.success {
  animation: fsucc 1.2s ease-out forwards;
  background: radial-gradient(circle, rgba(255, 255, 200, 0.95), rgba(255, 210, 90, 0.5) 40%, transparent 70%);
}
.forge-fx.fail {
  animation: ffail 1.1s ease-out forwards;
  background: radial-gradient(circle, rgba(90, 80, 110, 0.8), transparent 70%);
}
.forge-fx.destroyed {
  animation: ffail 1.6s ease-out forwards;
  background: radial-gradient(circle, rgba(255, 60, 60, 0.85), rgba(40, 0, 0, 0.6) 50%, transparent 80%);
}
.forge-view.shake {
  animation: shake 0.45s;
}
@keyframes fsucc {
  from {
    opacity: 1;
    transform: scale(0.3);
  }
  to {
    opacity: 0;
    transform: scale(2.2);
  }
}
@keyframes ffail {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}
.risk-keep {
  color: var(--jade-2);
}
.risk-down {
  color: #c77a00;
}
.risk-break {
  color: #d23a4a;
}
.pity {
  display: flex;
  gap: 3px;
}
.pity i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #ddd4ea;
  border: 1px solid rgba(58, 47, 74, 0.4);
}
.pity i.on {
  background: #ff9ad8;
}

/* world map */
.wm {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 64vh;
  display: block;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: #e8f4e0;
}

/* dialog */
.dialog {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(780px, calc(100% - 20px));
  display: flex;
  gap: 14px;
  padding: 12px;
  z-index: 18;
  box-shadow: var(--panel-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}
.dlg-portrait,
.portrait {
  width: 128px;
  height: 128px;
  flex: none;
  border-radius: 12px;
  border: 2px solid var(--line);
  overflow: hidden;
  background: linear-gradient(180deg, #e8f6ff, #d8ecf8);
  display: grid;
  place-items: center;
}
.dlg-portrait img,
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.badge {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 44px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.dialog.no-portrait .dlg-portrait {
  display: none;
}
.dlg-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.dlg-head strong {
  font-size: 17px;
}
.dlg-head span {
  color: var(--ink-2);
  font-size: 12px;
  margin-left: 4px;
}
.dlg-text {
  margin: 6px 0 8px;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 600;
  min-height: 3em;
  white-space: pre-wrap;
}
.dlg-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}
.dlg-opts button {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 5px 11px;
  font-weight: 800;
  font-size: 13px;
  text-align: left;
}
.dlg-opts button.q {
  background: #fff4c8;
}
.dlg-opts button.done {
  background: #c9f5e4;
}
.dlg-opts button.primary {
  background: var(--jade);
  color: #fff;
}
.dlg-opts button.danger {
  background: #ffc0cc;
}
.dlg-next {
  font-size: 11px;
  color: var(--ink-2);
  align-self: flex-end;
}

.death {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: grid;
  place-content: center;
  text-align: center;
  color: #fff;
  background: radial-gradient(circle, rgba(60, 0, 20, 0.35), rgba(20, 0, 10, 0.8));
}
.death h2 {
  font-size: 34px;
  margin: 0;
  letter-spacing: 0.08em;
}
.fade {
  position: absolute;
  inset: 0;
  background: #1c1830;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.18s;
}
.fade.on {
  opacity: 1;
  transition: none;
}

/* ---------- title */
.title-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 12px;
}
.title-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #bfe8ff 0%, #fde2f0 55%, #c9f0d8 100%);
}
.title-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.6s;
}
.title-bg img.loaded {
  opacity: 1;
}
.title-card {
  position: relative;
  width: min(760px, 100%);
  text-align: center;
  padding: 18px 20px 16px;
  background: rgba(255, 250, 240, 0.9);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--panel-shadow);
}
.kicker {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.logo {
  margin: 4px 0 0;
  font-size: clamp(38px, 8vw, 64px);
  font-weight: 900;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 3px var(--line);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 #6fd0c0, 0 8px 18px rgba(40, 20, 80, 0.3);
  letter-spacing: 0.02em;
}
.sub {
  margin: 4px 0 12px;
  font-size: 18px;
  font-weight: 900;
  color: var(--jade-2);
}
.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.title-actions .btn {
  font-size: 16px;
  padding: 8px 18px;
}
.title-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
}
.name-field {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}
.name-field input {
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  width: 170px;
  background: #fff;
}
.choose {
  margin: 10px 0 6px;
  font-weight: 900;
}
.paths {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.path {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.path[aria-checked="true"] {
  background: #d8f6ec;
  box-shadow: 0 0 0 3px var(--jade);
}
.path .portrait {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}
.path b {
  font-size: 15px;
}
.path small {
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 600;
  line-height: 1.25;
}
.ng-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
textarea {
  width: 100%;
  min-height: 90px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  font: 600 11px/1.3 ui-monospace, monospace;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
}

@media (max-width: 1040px) and (min-width: 761px) {
  .log {
    bottom: 70px;
    width: min(400px, 46%);
    height: 96px;
  }
}
/* ---------- responsive: phones */
@media (max-width: 760px), (pointer: coarse) and (max-height: 560px) {
  .menu-bar {
    display: none;
  }
}
@media (max-width: 760px) {
  .hud-player {
    width: 168px;
    padding: 5px 7px 6px;
    left: 6px;
    top: 6px;
  }
  .hp-name {
    font-size: 13px;
  }
  .bar {
    height: 12px;
  }
  .bar span {
    font-size: 9px;
    line-height: 9px;
  }
  .hud-map {
    right: 6px;
    top: 6px;
    padding: 4px;
  }
  #minimap {
    width: 104px;
    height: 76px;
  }
  .map-name {
    max-width: 104px;
    font-size: 11px;
  }
  .tracker {
    display: none;
  }
  .log {
    left: 6px;
    right: auto;
    bottom: 154px;
    width: min(62vw, 300px);
    height: 58px;
    padding: 3px 6px;
  }
  .log-lines {
    font-size: 10.5px;
  }
  .hotbar {
    left: auto;
    right: 6px;
    transform: none;
    bottom: 152px;
    display: grid;
    grid-template-columns: repeat(2, 38px);
    gap: 3px;
    padding: 3px;
  }
  .hk {
    width: 38px;
    height: 38px;
    background-size: 26px 26px;
  }
  .tip {
    top: 96px;
  }
  .herald {
    top: 96px;
  }
  .toasts {
    top: 130px;
  }
  .panel {
    width: calc(100% - 8px);
    max-height: calc(100% - 8px);
  }
  .panel-body {
    padding: 8px;
  }
  .cols,
  .cols.wide-left {
    grid-template-columns: 1fr;
  }
  .slots {
    grid-template-columns: repeat(auto-fill, 40px);
  }
  .it {
    width: 40px;
    height: 40px;
  }
  .dialog {
    bottom: 6px;
    padding: 8px;
    gap: 8px;
  }
  .dlg-portrait {
    width: 72px;
    height: 72px;
  }
  .dlg-text {
    font-size: 13.5px;
  }
  .paths {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .path .portrait {
    width: 64px;
  }
  .boss-card .bc-art {
    width: 84px;
    height: 84px;
  }
  .boss-card h2 {
    font-size: 19px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.chk {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 4px 0;
  font-weight: 700;
}
.chk input {
  margin-top: 3px;
  flex: none;
}

/* painted atlas icons (set once the art atlas has loaded) */
.wb.painted .it,
.wb.painted .hk.pot {
  image-rendering: auto;
  background-size: 38px 38px;
}
.wb.painted .forge-view .it {
  background-size: 56px 56px;
}
@media (max-width: 700px) {
  .wb.painted .hk.pot {
    background-size: 30px 30px;
  }
}
