:root {
  --ink: #1c2418;
  --leaf: #3d6b4a;
  --gold: #d4b06a;
  --gold-2: #f0d48a;
  --paper: #f4ead4;
  --paper-2: #e8dcc0;
  --purple: #5c4a78;
  --purple-2: #3a2f52;
  --cta: #e8a03a;
  --cinnabar: #d4452a;
  --line: #c4a574;
  --safe: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #0e1210;
  color: #2a2118;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button {
  font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
button:active:not(.walk-layer):not(.hud-ico):not(.menu-flower):not(.gift-float) { transform: scale(.96); }
[hidden] { display: none !important; }

#desk {
  height: 100%;
  height: 100dvh;
  display: grid;
  place-items: stretch;
  padding: 0;
  gap: 0;
}
.desk-panel { display: none; max-width: 300px; color: #e8dcc0; }
.desk-kicker { margin: 0; font-size: 11px; letter-spacing: .16em; color: var(--gold); }
.desk-panel h1 { font-family: "Songti SC", "STSong", "Noto Serif SC", serif; font-size: 44px; font-weight: 700; margin: 8px 0; color: #f4ead4; }
.desk-panel p { line-height: 1.65; font-size: 14px; color: #cbbda6; }
.desk-url { color: var(--gold-2) !important; word-break: break-all; }

#phone {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #2d4a38;
}

#game { position: absolute; inset: 0; }

.world {
  position: absolute; inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  background: #2d4a38;
}
.walk-layer {
  position: absolute; z-index: 3;
  inset: 0;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}
.tap-mark {
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 42px;
  object-fit: contain;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transform: translate(-50%, -50%);
}
.tap-mark.show {
  animation: tapPing 1.15s ease-out;
}
@keyframes tapPing {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(.55); }
  35% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}
.hero {
  position: absolute; z-index: 3;
  left: 50%; top: 58%;
  width: 58px; height: auto;
  transform: translate(-50%, -88%);
  transition: left .45s ease, top .45s ease;
  pointer-events: none;
  filter: drop-shadow(0 6px 4px rgb(0 0 0 / .4));
}
.hero.flip { transform: translate(-50%, -88%) scaleX(-1); }
.hero.walk { animation: bob .45s ease; }
@keyframes bob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -6px; }
}

.hud-top {
  position: absolute; z-index: 4; left: 8px; right: 8px; top: 8px;
  display: flex; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.minimap {
  width: 86px; height: 86px; border-radius: 50%;
  background: #2f5a38 url("../img/ico-minimap.png") center / cover no-repeat;
  border: 3px solid var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 10px; color: #fff; font-size: 10px;
  box-shadow: 0 4px 12px rgb(0 0 0 / .35), inset 0 0 0 2px #8a6a30;
  position: relative; overflow: hidden;
}
.minimap::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(transparent 45%, rgb(20 28 18 / .72));
}
.map-name { font-weight: 700; position: relative; }
.map-xy { position: relative; opacity: .85; }
.top-left { display: flex; flex-direction: row; align-items: flex-start; gap: 4px; }
.hud-end {
  margin-left: auto;
  width: 128px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.party { display: flex; gap: 6px; width: 100%; }
.portrait {
  flex: 1;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  border: 2px solid var(--gold);
  overflow: hidden;
  position: relative;
  background: #1a2418;
}
.portrait img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.portrait em {
  position: absolute; right: 2px; top: 2px;
  font-style: normal; font-size: 10px;
  background: rgb(42 28 16 / .88); color: var(--gold-2); padding: 1px 4px; border-radius: 4px;
  z-index: 1;
}
.portrait i {
  position: absolute; left: 4px; right: 4px; bottom: 4px; height: 4px;
  background: #1a2018; border-radius: 2px; z-index: 1;
}
.portrait i::after {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 78%;
  background: linear-gradient(90deg, #3ec86a, #b8e86a);
  border-radius: 2px;
}
.portrait:nth-child(2) i::after { width: 54%; background: linear-gradient(90deg, #e8a03a, #f0d48a); }
.portrait:active img, .portrait.press img, .portrait.on img { filter: brightness(1.28); }

.left-rail {
  position: absolute; z-index: 4; left: 8px; top: 104px;
  display: flex; flex-direction: column; gap: 6px;
}
.hud-ico, .menu-flower, .gift-float {
  width: 46px; height: 46px;
  min-width: 46px; min-height: 46px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  border: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
  display: block;
}
.hud-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  z-index: 0;
}
.hud-face img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.hud-face em {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  isolation: isolate;
  height: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgb(0 0 0 / .85);
  pointer-events: none;
}
.hud-face em::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 7px;
  background: linear-gradient(to top, rgb(255 248 230 / .45), transparent);
  z-index: -1;
  pointer-events: none;
}
.gift-float, .limit-ico {
  width: 36px; height: 36px;
  min-width: 36px; min-height: 36px;
}
.gift-float em, .limit-ico em {
  height: 14px;
  font-size: 9px;
  padding-bottom: 3px;
}
.limit-ico {
  position: absolute; z-index: 4; right: 10px; top: 186px;
}
.dot {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #f07858 0 22%, #c43022 58%, #7a1810 100%);
  box-shadow:
    0 0 0 1px #d4b06a,
    0 1px 2px rgb(40 12 8 / .55),
    inset 0 1px 1px rgb(255 210 170 / .35);
  pointer-events: none;
  z-index: 4;
}
.hud-ico .dot, .gift-float .dot, .menu-flower .dot {
  top: 1px; right: 1px;
}
.btn-claim .dot, .subtabs .dot, .tile .dot, .chat-rail .dot {
  top: 2px; right: 2px;
}
.hud-ico:active .hud-face, .hud-ico.press .hud-face, .hud-ico.on .hud-face,
.menu-flower:active .hud-face, .menu-flower.press .hud-face, .menu-flower.on .hud-face,
.gift-float:active .hud-face, .gift-float.press .hud-face, .gift-float.on .hud-face,
.chat-mini:active, .chat-mini.press, .chat-mini.on {
  filter: brightness(1.38) saturate(1.06);
}

.quest-panel {
  position: static;
  width: 100%;
  background: rgb(16 20 18 / .62);
  border: 1px solid rgb(212 176 106 / .35);
  border-radius: 8px; color: #f4ead4; font-size: 10px;
  padding: 6px 7px;
  backdrop-filter: blur(6px);
}
.quest-tabs { display: flex; gap: 10px; margin-bottom: 6px; color: #cbbda6; }
.quest-tabs button { color: inherit; min-height: 22px; }
.quest-tabs .on { color: var(--gold-2); }
.quest-panel ul { list-style: none; margin: 0; padding: 0; }
.quest-panel li { margin-bottom: 6px; text-align: left; width: 100%; color: inherit; }
.quest-panel small { display: block; opacity: .75; }

.quest-banner {
  position: absolute; z-index: 4; left: 70px; right: 70px; bottom: 196px;
  text-align: center; font-size: 12px; color: #fff;
  background: rgb(40 28 20 / .58); padding: 7px; border-radius: 8px;
  border: 1px solid rgb(212 176 106 / .3);
}

.hud-bottom {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  padding: 0 6px calc(6px + var(--safe));
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "left . right"
    "chat chat chat";
  align-items: end;
  column-gap: 4px;
  row-gap: 2px;
}
.chat-mini {
  grid-area: chat;
  margin: 0;
  padding: 6px 10px;
  background: rgb(12 16 18 / .72); color: #e8dcc0;
  border-radius: 8px; font-size: 11px;
  border: 1px solid rgb(212 176 106 / .2);
}
.chat-mini .ch { color: var(--gold); margin-right: 6px; }
.chat-mini p { display: inline; margin: 0; }
.corner-left, .corner-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}
.corner-left { grid-area: left; }
.corner-right { grid-area: right; }

#game[data-hand="left"] .left-rail { left: auto; right: 8px; }
#game[data-hand="left"] .top-left { margin-left: auto; align-items: flex-start; }
#game[data-hand="left"] .hud-end { margin-left: 0; margin-right: auto; }
#game[data-hand="left"] .limit-ico { right: auto; left: 10px; }
#game[data-hand="left"] .hud-bottom {
  grid-template-areas:
    "right . left"
    "chat chat chat";
}

.sheet, .chat-sheet, .menu-sheet {
  position: absolute; z-index: 8; inset: 0;
  background:
    radial-gradient(80% 40% at 50% -10%, #5a4a78, transparent),
    linear-gradient(#2a2438f2, #1a1628f6);
  color: var(--paper);
  display: flex; flex-direction: column; padding: 18px 14px 8px;
}
.sheet h2 {
  font-family: "Songti SC", "STSong", serif; font-weight: 700; font-size: 26px; margin: 0 0 8px;
}
.sheet-lead { margin: 0 0 14px; font-size: 12px; color: #cbbda6; }
.role-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.role-head img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 10px; border: 2px solid var(--gold);
}
.role-head strong { display: block; font-size: 18px; }
.role-head span { font-size: 12px; color: #cbbda6; }
.role-money {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 14px;
}
.money-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgb(244 234 212 / .1);
  border: 1px solid #6a5a88;
  border-radius: 12px; padding: 10px 8px 12px;
  color: var(--paper);
}
.money-chip img { width: 44px; height: 44px; object-fit: contain; }
.money-chip b { font-size: 15px; color: var(--gold-2); }
.money-chip small { font-size: 11px; color: #cbbda6; }
.simple-body { margin: 0; line-height: 1.7; font-size: 14px; color: #e8dcc0; }
.claim-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgb(244 234 212 / .1);
  border: 1px solid #6a5a88;
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
}
.claim-card span { display: block; font-size: 12px; color: #cbbda6; margin-top: 4px; }
.btn-claim {
  position: relative;
  min-width: 72px; min-height: 40px;
  background: linear-gradient(#f2c14d, #d4891a);
  color: #3a2208; font-weight: 700; border-radius: 8px;
  box-shadow: 0 2px 0 #8a5a12;
}
.btn-claim.sm { min-width: 44px; min-height: 32px; }
.btn-claim.claimed {
  background: #3a3450; color: #cbbda6; box-shadow: none;
}
.sheet-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding-top: 10px; padding-bottom: var(--safe);
}
.btn-back {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--purple-2); color: #fff; font-size: 12px;
  border: 2px solid #c9a0d8;
}
.subtabs, .play-tabs {
  flex: 1; display: flex; justify-content: space-around; align-items: center;
  font-size: 12px; color: #cbbda6;
}
.subtabs span { position: relative; }
.subtabs .on, .play-tabs .on { color: var(--gold-2); }

.chat-sheet {
  background: transparent;
  padding: 0;
  justify-content: flex-end;
}
.chat-sheet .chat-rail {
  position: absolute; left: 0; top: 34%; bottom: calc(52px + var(--safe));
  width: 72px;
  background: #4a3a68;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 4px;
}
.chat-rail button {
  min-height: 36px; color: #d8cce8; font-size: 12px; border-radius: 6px; position: relative;
}
.chat-rail button.on { background: #6a58a0; color: var(--gold-2); }
.chat-body {
  margin-left: 72px; margin-top: 34%;
  background: rgb(244 234 212 / .94); color: #2a2118;
  border-radius: 12px 0 0 0; padding: 10px;
  min-height: 48%;
}
.mail-row {
  width: 100%; text-align: left; padding: 12px 4px;
  border-bottom: 1px solid #d4c4a8;
  display: flex; flex-direction: column; gap: 4px;
}
.mail-row span { font-size: 12px; color: #6a5e4e; }
.world-box .bubble { margin: 8px 0; font-size: 13px; }
.hist { font-size: 11px; color: #8a7e6e; text-align: center; }
.chat-input {
  margin-top: 12px; background: #ddd4c4; border-radius: 8px; padding: 10px; color: #8a7e6e; font-size: 13px;
}
.chat-back { position: absolute; left: 8px; bottom: calc(8px + var(--safe)); }

.play-sheet { background: linear-gradient(#b7d4c8, #8fb89a); color: #2a2118; }
.exp-bar { font-size: 12px; background: rgb(255 255 255 / .4); padding: 8px 12px; border-radius: 20px; }
.play-map { flex: 1; position: relative; }
.pin {
  position: absolute; background: rgb(255 255 255 / .88); padding: 8px 10px; border-radius: 8px; font-size: 12px;
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.pin:nth-child(1) { left: 18%; top: 42%; }
.pin:nth-child(2) { left: 48%; top: 28%; }
.pin:nth-child(3) { left: 22%; top: 18%; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cell {
  background: var(--paper); color: #2a2118; border-radius: 12px;
  min-height: 100px; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px #d4c4a0;
}
.shop-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.shop-tabs span { padding: 8px 16px; background: #3a3450; border-radius: 8px; }
.shop-tabs .on { background: linear-gradient(#d4b06a, #b8883a); color: #2a1a08; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: rgb(244 234 212 / .12); padding: 14px; border-radius: 10px; margin-bottom: 8px;
}

.bag-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.bag-cell {
  min-height: 72px; border-radius: 10px;
  background: rgb(244 234 212 / .12);
  border: 1px solid #6a5a88;
  color: var(--paper);
}
.bag-cell.on { border-color: var(--gold); background: rgb(212 176 106 / .18); }

.menu-sheet {
  background: transparent; justify-content: flex-end; padding: 0;
}
.menu-grid {
  background: rgb(48 40 72 / .94);
  border-radius: 16px 16px 0 0;
  padding: 16px 12px calc(72px + var(--safe));
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.tile {
  min-height: 56px; background: #4a3e68; color: var(--paper);
  border-radius: 10px; position: relative;
}
.tile.wide { grid-column: span 2; }
.tile.locked { opacity: .4; }
.menu-back { position: absolute; left: 8px; bottom: calc(8px + var(--safe)); z-index: 2; }

.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgb(0 0 0 / .5);
  display: grid; place-items: center; padding: 28px;
}
.modal-card {
  width: 100%; background: #f4ead4; border-radius: 14px;
  padding: 36px 20px 24px; text-align: center; position: relative;
  border: 2px solid var(--gold);
}
.modal-x {
  position: absolute; top: 8px; right: 8px;
  min-width: 40px; min-height: 40px; font-size: 12px; color: #6a5e4e;
}
.modal-card h3 { font-family: "Songti SC", "STSong", serif; font-size: 28px; margin: 8px 0 0; font-weight: 700; }

#toast {
  position: absolute; z-index: 25; left: 50%; bottom: 28%;
  transform: translateX(-50%);
  background: rgb(20 16 12 / .88); color: var(--paper);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  border: 1px solid #8a6a30;
  white-space: nowrap;
}

#fs-gate {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgb(8 10 9 / .72);
  color: #f4ead4;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 24px calc(48px + var(--safe));
  text-align: center;
  gap: 10px;
}
@media (hover: none), (pointer: coarse) {
  #fs-gate:not([hidden]) { display: flex; }
}
body.is-fs #fs-gate,
body.is-standalone #fs-gate { display: none !important; }
#fs-enter {
  min-width: 220px;
  min-height: 56px;
  padding: 0 28px;
  background: linear-gradient(#f2c14d, #d4891a);
  color: #3a2208;
  font-size: 18px;
  font-weight: 700;
  border-radius: 14px;
}
#fs-gate p { margin: 0; font-size: 13px; color: #cbbda6; max-width: 280px; line-height: 1.5; }
#fs-gate .fs-alt { font-size: 11px; color: #8a7e6e; }

#lab { position: absolute; z-index: 30; left: 0; right: 0; bottom: 0; pointer-events: none; }
.lab-toggle {
  pointer-events: auto; position: absolute; right: 52px; bottom: 2px;
  font-size: 10px; color: rgb(244 234 212 / .55);
  min-height: 28px; padding: 0 8px;
}
.lab-toggle-test { right: 6px; }
.lab-body {
  pointer-events: auto; background: #12110f; color: #e8dcc0;
  padding: 10px 10px calc(10px + var(--safe));
  display: grid; gap: 8px;
}
.lab-body select {
  font: inherit; color: #e8dcc0; background: #2a241c;
  border: 1px solid #4a3b2e; border-radius: 8px; min-height: 36px; width: 100%;
}
.lab-note { margin: 0; font-size: 11px; color: #8a7e6e; }

@media (hover: hover) and (pointer: fine) and (min-width: 880px) {
  #fs-gate { display: none !important; }
  #desk {
    place-items: center;
    padding: 20px;
    gap: 28px;
    grid-template-columns: 300px 390px;
    justify-content: center;
  }
  .desk-panel { display: block; }
  #phone {
    width: 390px;
    height: 844px;
    border-radius: 28px;
    border: 8px solid #2a2418;
    box-shadow: 0 20px 60px rgb(0 0 0 / .5);
  }
}
