:root {
  --parch: #efe6c9;
  --parch-deep: #e4d4ad;
  --parch-edge: #c9b48a;
  --ink: #3c2f1c;
  --ink-soft: #5a4a32;
  --ink-faint: #7a6a50;
  --gold: #c9a44a;
  --gold-deep: #8a6a22;
  --gold-btn: #d4b85a;
  --line: #8a7350;
  --line-soft: #c4b48c;
  --blue: #1f5f8a;
  --green: #2f6b32;
  --red: #8a2e24;
  --wood: #4a3824;
  --shadow: rgba(28, 18, 8, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Noto Serif", "Times New Roman", serif;
  color: var(--ink);
  background: #0d0c0a;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

#bg,
#bg-next {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.06);
  transition: opacity 0.8s ease;
}

#bg {
  z-index: 0;
  animation: drift 48s ease-in-out infinite alternate;
}

#bg-next {
  z-index: 1;
  opacity: 0;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(8, 6, 3, 0.55) 100%),
    linear-gradient(180deg, rgba(8, 6, 3, 0.28) 0%, transparent 18%, transparent 78%, rgba(8, 6, 3, 0.5) 100%);
}

#grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  position: relative;
  z-index: 4;
  height: 100%;
}

@keyframes drift {
  from { transform: scale(1.04) translate3d(-1.2%, -0.6%, 0); }
  to { transform: scale(1.1) translate3d(1.4%, 0.8%, 0); }
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 7;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px 0;
  gap: 12px;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
}

.hud-right {
  align-items: flex-end;
}

.plate {
  background:
    linear-gradient(180deg, rgba(245, 236, 210, 0.94), rgba(226, 210, 168, 0.92));
  border: 1px solid var(--line);
  outline: 1px solid rgba(90, 70, 36, 0.55);
  box-shadow: 0 2px 0 rgba(255, 248, 226, 0.35) inset, 0 8px 22px var(--shadow);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.sigil {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--gold-deep);
  background:
    radial-gradient(circle at 40% 35%, #f0e2b0, #b89448 55%, #6a4e1c);
  display: grid;
  place-items: center;
  color: #3a2a10;
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 600;
}

.who h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
}

.who .meta {
  font-size: 12px;
  color: var(--ink-soft);
}

label.meta {
  display: block;
  margin: 12px 0 6px;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.xpwrap {
  padding: 7px 10px 8px;
}

.xpwrap .lbl {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.bar {
  height: 9px;
  background: #c8b48a;
  border: 1px solid #6a5434;
  position: relative;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(180deg, #6aa8d4, #1f5f8a);
}

.bar.gold > i {
  background: linear-gradient(180deg, #e2c66a, #8a6a22);
}

.bar.green > i {
  background: linear-gradient(180deg, #7cbc6a, #2f6b32);
}

.bar.red > i {
  background: linear-gradient(180deg, #d4846a, #8a2e24);
}

.bar.purple > i {
  background: linear-gradient(180deg, #b49ad4, #5a3a7a);
}

.coins {
  display: flex;
  gap: 8px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  font-size: 13px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #5a4010;
  background: radial-gradient(circle at 35% 30%, #f2e08a, #b8862a);
}

.dot.teal {
  background: radial-gradient(circle at 35% 30%, #b8f0d4, #2a7a58);
  border-color: #1a4a34;
}

.dot.copper {
  background: radial-gradient(circle at 35% 30%, #f0c090, #8a4a18);
  border-color: #5a3010;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 640px;
}

.nav button,
.gold,
.ghost,
.tab {
  cursor: pointer;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #ead58a, #b8943a);
  color: #3a2a10;
  padding: 5px 10px;
  font-size: 13px;
  box-shadow: 0 1px 0 rgba(255, 244, 200, 0.55) inset;
}

.nav button.active,
.tab.active {
  background: linear-gradient(180deg, #fff0b0, #d4a83a);
  outline: 1px solid #8a2418;
}

.ghost {
  background: linear-gradient(180deg, #efe4c4, #d4c49a);
  color: var(--ink);
}

.gold:disabled,
.nav button:disabled {
  opacity: 0.45;
  cursor: default;
}

.stage {
  position: absolute;
  inset: 128px 22px 22px;
  z-index: 4;
  display: flex;
  align-items: stretch;
  justify-content: center;
  pointer-events: none;
}

.stage > * {
  pointer-events: auto;
}

.window {
  position: relative;
  width: min(1080px, 100%);
  background:
    linear-gradient(180deg, rgba(246, 238, 214, 0.96), rgba(228, 212, 172, 0.95));
  border: 1px solid #6e5736;
  outline: 2px solid rgba(42, 30, 14, 0.45);
  box-shadow:
    0 0 0 1px #d8c89a inset,
    0 18px 40px rgba(10, 6, 2, 0.45);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.window.dragging .whead {
  cursor: grabbing;
}

.window.moved {
  position: absolute;
  margin: 0;
}

.window.narrow {
  width: min(420px, 100%);
}

.window.mid {
  width: min(760px, 100%);
}

.whead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 10px 7px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255, 248, 226, 0.55), transparent);
  cursor: grab;
}

.whead h2 {
  grid-column: 2;
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 4px;
}

.x {
  justify-self: end;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  background: #efe4c4;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 12px;
}

.wbody {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
  flex: 1;
}

.wbody.one {
  grid-template-columns: 1fr;
}

.list {
  border-right: 1px solid var(--line-soft);
  overflow: auto;
  padding: 8px 0 12px;
}

.ch {
  padding: 7px 14px 4px;
  font-size: 12px;
  color: var(--gold-deep);
  letter-spacing: 0.03em;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.qcopy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.qmini {
  flex: 0 0 52px;
  width: 52px;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #cbb888;
}

.qmini img {
  width: 100%;
  height: 124%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
}

.qpay {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  font-style: normal;
}

.qpay .xp,
.reward .xp {
  color: var(--blue);
}

.qpay .ess,
.reward .ess {
  color: var(--gold-deep);
}

.qpay .coin,
.reward .coin {
  color: #8a4a18;
}

.row:hover {
  background: rgba(180, 150, 80, 0.16);
}

.row.on {
  background: rgba(90, 110, 130, 0.18);
}

.mark {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 1px solid var(--line);
  background: #f4ead0;
}

.mark.ok {
  background: #3d8a3d;
  border-color: #245224;
}

.scroll {
  margin: 12px 14px 14px;
  padding: 14px 18px 16px;
  background:
    linear-gradient(180deg, rgba(255, 250, 234, 0.75), rgba(236, 222, 184, 0.7));
  border: 1px solid var(--line-soft);
  box-shadow: 0 10px 18px rgba(60, 40, 16, 0.08);
  overflow: auto;
  min-height: 0;
}

.scroll h3 {
  font-family: "Cormorant Garamond", serif;
  font-size: 24px;
  text-align: center;
  margin-bottom: 10px;
}

.reward {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  font-weight: 600;
}

.reward .xp {
  color: var(--blue);
}

.reward .ess {
  color: var(--gold-deep);
}

.npc {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.55;
}

.npc b {
  color: var(--gold-deep);
}

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.need {
  font-size: 12px;
  color: var(--ink-faint);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.skill {
  padding: 8px 10px;
}

.skill .top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
}

.statline {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(138, 115, 80, 0.28);
  font-size: 14px;
}

.statline .num {
  color: var(--blue);
}

.slots {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  gap: 8px;
  margin: 10px 0 14px;
}

.slot {
  width: 64px;
  height: 74px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f6eed4, #ddd0a8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
}

.slot .ico {
  width: 28px;
  height: 28px;
  border: 1px solid var(--gold-deep);
  background: #c9a44a;
  margin-bottom: 4px;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.slot .frac {
  font-size: 11px;
}

.slot .frac.bad {
  color: var(--red);
}

.slot .frac.ok {
  color: var(--green);
}

.mixer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mixrow {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.mixrow button {
  width: 26px;
  height: 22px;
  border: 1px solid var(--line);
  background: #efe4c4;
  cursor: pointer;
}

.tick {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 4px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.tick input {
  width: 16px;
  height: 16px;
  accent-color: #c9a44a;
}

.field {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: 1px solid var(--line);
  background: #f7f0d8;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.45;
}

.field.short {
  min-height: 0;
  height: 34px;
}

.mapwrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 10px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #c4b48a;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.mapstage {
  position: relative;
  width: fit-content;
  height: fit-content;
  line-height: 0;
}

.mapstage > img {
  display: block;
  max-width: 100cqi;
  max-height: 100cqh;
  width: auto;
  height: auto;
  pointer-events: none;
}

.pin {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -100%);
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #3a2a10;
  text-align: center;
}

.zpin {
  z-index: 4;
}


.pin .bang {
  width: 22px;
  height: 22px;
  margin: 0 auto 3px;
  border-radius: 50%;
  background: #e6c44a;
  border: 2px solid #5a4010;
  color: #3a2a10;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.zpin .gate {
  width: 16px;
  height: 16px;
  margin: 0 auto 4px;
  border-radius: 50%;
  background: #6a4a1a;
  border: 2px solid #f0e0a8;
  box-shadow: 0 0 0 1px #3a2a10;
}

.qpin {
  z-index: 3;
}

.qhero {
  height: 210px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #cbb888;
}

.qhero img {
  width: 100%;
  height: 122%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
}

.pin.on .gate {
  outline: 2px solid #8a2418;
  background: #8a2418;
}

.pin small {
  display: block;
  padding: 2px 6px;
  background: rgba(246, 236, 210, 0.88);
  border: 1px solid var(--line);
  font-size: 11px;
  white-space: nowrap;
}

.qpin small {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.locbar {
  position: absolute;
  left: 18px;
  bottom: 16px;
  z-index: 6;
  padding: 8px 12px;
  max-width: 320px;
}

.locbar h3 {
  font-family: "Cormorant Garamond", serif;
  font-size: 20px;
}

.locbar p {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin: 4px 0 8px;
}

.minimap {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 5;
  width: 170px;
  padding: 6px;
}

.minimap .thumb {
  height: 88px;
  background: #cbb888 center/cover;
  border: 1px solid var(--line);
}

.minimap .cap {
  font-size: 11px;
  text-align: center;
  margin-top: 4px;
  color: var(--ink-soft);
}

.splash {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.banner {
  padding: 18px 36px 16px;
  min-width: min(560px, 92vw);
}

.banner .kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.banner h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 48px;
  font-weight: 600;
  line-height: 1;
  margin: 6px 0 8px;
}

.banner p {
  font-size: 15px;
  color: var(--ink-soft);
  max-width: 420px;
  margin: 0 auto 16px;
  line-height: 1.45;
}

.toast {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 8px 16px;
  font-size: 14px;
  pointer-events: none;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: rgba(10, 7, 4, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hint {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.chip {
  font-size: 12px;
  padding: 3px 7px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 250, 230, 0.6);
}

.diary-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(138, 115, 80, 0.25);
}

.diary-item time {
  display: block;
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.saves {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.reset {
  background: none;
  border: 0;
  color: rgba(246, 236, 210, 0.7);
  text-decoration: underline;
  font-size: 12px;
  cursor: pointer;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #8a7350;
  border: 1px solid #5a4428;
}

::-webkit-scrollbar-track {
  background: #d8c89a;
}

@media (max-width: 860px) {
  .wbody {
    grid-template-columns: 1fr;
  }
  .list {
    max-height: 180px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .hud-left,
  .hud-right {
    min-width: 0;
  }
  .nav {
    max-width: 220px;
  }
  .banner h1 {
    font-size: 34px;
  }
  .slots {
    grid-template-columns: repeat(4, 64px);
  }
}
