:root {
  --orange: #FF8A3D;
  --orange-deep: #E96318;
  --gold: #F6C87A;
  --gold-bright: #FFE3AE;
  --cream: #FFF4DE;
  --jade: #7FD6B4;
  --jade-deep: #1F7D68;
  --ink: #071F24;
  --ink-2: #0D3333;
  --muted: rgba(255, 244, 222, .46);
  --muted-2: rgba(255, 244, 222, .3);
  --line: rgba(246, 200, 122, .18);
  --panel: linear-gradient(160deg, rgba(20, 58, 52, .9), rgba(6, 27, 28, .94));
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  background: #04171b;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--cream);
  font-family: var(--sans);
  background: #04171b;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid rgba(255, 224, 160, .9);
  outline-offset: 3px;
}

img { -webkit-user-drag: none; user-select: none; }

/* ---------- scene ---------- */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: #0a2529 url("assets/bg-mountains.svg") center top / cover no-repeat;
  transform: translateZ(0);
}

.bg-veil {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(120% 55% at 50% 0%, rgba(5, 20, 26, .16), transparent 62%),
    linear-gradient(180deg, rgba(4, 19, 25, .18) 0%, rgba(4, 19, 25, .06) 34%, rgba(3, 17, 19, .42) 66%, rgba(2, 13, 15, .84) 100%);
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#moteCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(30px + var(--safe-bottom));
}

/* ---------- HUD ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: linear-gradient(180deg, rgba(4, 19, 25, .82) 0%, rgba(4, 19, 25, .44) 66%, rgba(4, 19, 25, 0) 100%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.hud-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: rgba(6, 28, 29, .55);
  border: 1px solid rgba(246, 200, 122, .15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

.id-seal {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #422306;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 800;
  background: linear-gradient(155deg, #ffeec0 0%, #f4c474 52%, #c88b3d 100%);
  border: 1px solid #ffedc0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 4px 10px rgba(0, 0, 0, .26);
  position: relative;
}

.id-seal::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(82, 43, 9, .32);
  border-radius: 8px;
}

.id-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.id-copy b {
  font-size: 13px;
  font-weight: 700;
  color: #ffedc9;
  letter-spacing: .02em;
  white-space: nowrap;
}

.id-copy span {
  font-size: 9.5px;
  color: rgba(255, 235, 197, .44);
  letter-spacing: .16em;
  margin-top: 2px;
  white-space: nowrap;
}

.hud-res {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.res-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 33px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(6, 28, 29, .62);
  border: 1px solid rgba(246, 200, 122, .16);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .04);
}

.res-pill .mp-icon {
  width: 14px;
  height: 14px;
  color: #ffc272;
  filter: drop-shadow(0 0 5px rgba(255, 154, 66, .45));
}

.res-pill b {
  font-size: 12px;
  font-weight: 700;
  color: #ffe8b9;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

.stone-gem {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 2px;
  transform: rotate(45deg);
  background: linear-gradient(145deg, #eafff2, #7fe0bd 45%, #2f9b7d);
  box-shadow: 0 0 8px rgba(127, 214, 180, .55), inset 0 0 0 1px rgba(255, 255, 255, .4);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: 3px 0 0;
  text-align: center;
}

.scene-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: rgba(255, 227, 174, .74);
  font-size: 10px;
  letter-spacing: .3em;
}

.scene-label i {
  display: block;
  width: 21px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 200, 122, .75));
}

.scene-label i:last-child { transform: scaleX(-1); }

.scene-title {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: clamp(19px, 5.4vw, 22px);
  font-weight: 700;
  letter-spacing: .08em;
  color: #fff1d6;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .48), 0 0 34px rgba(255, 172, 86, .12);
}

.qi-zone {
  position: relative;
  height: clamp(286px, 81vw, 338px);
  margin-top: 0;
  display: grid;
  place-items: center;
}

.core-aura {
  position: absolute;
  width: min(78vw, 306px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 205, 120, .34) 0%, rgba(255, 138, 61, .13) 45%, rgba(255, 138, 61, 0) 72%);
  filter: blur(9px);
  animation: auraPulse 4.2s ease-in-out infinite;
  pointer-events: none;
}

.qi-core {
  position: relative;
  z-index: 2;
  width: min(84vw, 328px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  filter: drop-shadow(0 24px 32px rgba(0, 0, 0, .34));
  transition: transform .13s ease;
}

.qi-core:active { transform: scale(.962); }

.core-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.spin-slow,
.spin-rev,
.orbit-gems,
.orbit-dots,
.orb-wrap,
.float-swords,
.lotus {
  transform-box: view-box;
}

.spin-slow {
  transform-origin: 50% 45.6%;
  animation: spin 52s linear infinite;
}

.spin-rev {
  transform-origin: 50% 45.6%;
  animation: spin 76s linear infinite reverse;
}

.orbit-gems {
  transform-origin: 50% 45.6%;
  animation: spin 34s linear infinite;
}

.orbit-dots {
  transform-origin: 50% 45.6%;
  animation: spin 18s linear infinite;
}

.orb-wrap {
  transform-origin: 50% 45.6%;
  animation: breathe 3.6s ease-in-out infinite;
}

.float-swords {
  transform-origin: 50% 55%;
  animation: swordFloat 6s ease-in-out infinite;
}

.lotus {
  transform-origin: 50% 74%;
  animation: lotusFloat 5.2s ease-in-out infinite;
}

.combo-pill {
  position: absolute;
  top: 4%;
  right: 2%;
  z-index: 5;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .06em;
  color: #ffe4b5;
  background: rgba(255, 138, 61, .14);
  border: 1px solid rgba(255, 177, 95, .45);
  box-shadow: 0 0 18px rgba(255, 122, 36, .16);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(4px) scale(.9);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.combo-pill b {
  font-size: 12.5px;
  font-weight: 800;
  color: #ffc87d;
}

.combo-pill.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.combo-pill.pop { animation: comboPop .24s ease; }

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}

.tap-hint {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: -6px;
  padding: 7px 15px;
  border-radius: 999px;
  color: #ffe7b8;
  font-size: 11.5px;
  letter-spacing: .07em;
  background: rgba(7, 28, 30, .62);
  border: 1px solid rgba(246, 200, 122, .22);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255, 255, 255, .04);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: hintFloat 3.4s ease-in-out infinite;
}

.tap-hint .mp-icon {
  width: 14px;
  height: 14px;
  color: #ffb15f;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 14px 2px 0;
  padding: 10px 0 2px;
  border-top: 1px solid rgba(246, 200, 122, .13);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  border-right: 1px solid rgba(246, 200, 122, .1);
}

.stat:last-child { border-right: 0; }

.stat span {
  font-size: 9.5px;
  letter-spacing: .12em;
  color: rgba(255, 244, 222, .4);
}

.stat b {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: #ffe2ad;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(255, 177, 95, .2);
}

/* ---------- panels ---------- */
.panel {
  position: relative;
  margin-top: 14px;
  padding: 16px;
  border-radius: 23px;
  background: var(--panel);
  border: 1px solid rgba(246, 200, 122, .17);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .055);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -50px;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle, rgba(255, 188, 100, .1), transparent 68%);
  pointer-events: none;
}

.realm-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.realm-seal {
  position: relative;
  flex: 0 0 55px;
  width: 55px;
  height: 55px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #452507;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(155deg, #ffeec3 0%, #f6c978 52%, #c88c3e 100%);
  border: 1px solid #ffefc4;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .65);
}

.realm-seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(82, 43, 9, .34);
  border-radius: 11px;
}

.realm-copy {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.mini-label {
  display: block;
  font-size: 9.5px;
  letter-spacing: .22em;
  color: rgba(255, 231, 184, .48);
}

.realm-copy h2 {
  margin: 3px 0 2px;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: .04em;
  color: #fff0d2;
}

.realm-copy p {
  margin: 0;
  font-size: 10.5px;
  color: rgba(255, 244, 222, .42);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.realm-next {
  flex: 0 0 auto;
  text-align: right;
  padding-left: 10px;
  border-left: 1px solid rgba(246, 200, 122, .14);
}

.realm-next span {
  display: block;
  font-size: 9px;
  letter-spacing: .12em;
  color: rgba(255, 231, 184, .42);
}

.realm-next b {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: #ffd99a;
  white-space: nowrap;
}

.progress-block { margin-top: 14px; }

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 10.5px;
  color: rgba(255, 244, 222, .48);
}

.progress-meta b {
  color: #ffe4b2;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255, 255, 255, .055);
  overflow: hidden;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8a3d, #ffd27d);
  box-shadow: 0 0 14px rgba(255, 138, 61, .55);
  transition: width .32s ease;
}

.progress-glint {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 28%, rgba(255, 255, 255, .33) 47%, transparent 63%);
  transform: translateX(-110%);
  animation: glint 3.1s ease-in-out infinite;
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .08em;
  transition: transform .12s ease, filter .12s ease, box-shadow .2s ease;
}

.btn:active { transform: translateY(1px) scale(.99); filter: brightness(.97); }

.btn-primary {
  margin-top: 12px;
  color: #3d1c05;
  background: linear-gradient(180deg, #ffc078 0%, #ff913f 46%, #f0731f 100%);
  border: 1px solid rgba(255, 225, 172, .55);
  box-shadow: 0 9px 20px rgba(240, 115, 31, .28), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -2px 0 rgba(139, 55, 8, .26);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .2);
}

.btn-primary .mp-icon {
  width: 18px;
  height: 18px;
  color: #4f2608;
}

.btn-primary.is-ready {
  animation: readyPulse 1.9s ease-in-out infinite;
}

.btn-primary.is-max {
  color: rgba(255, 244, 222, .48);
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .09);
  box-shadow: none;
  text-shadow: none;
  cursor: default;
}

.btn-primary.is-max .mp-icon { color: rgba(255, 244, 222, .35); }

.panel-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.45;
  letter-spacing: .04em;
  color: rgba(255, 244, 222, .35);
}

/* ---------- battle ---------- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.section-head h2 {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: .06em;
  color: #fff0d2;
}

.kicker {
  margin: 0;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .26em;
  color: rgba(255, 205, 128, .46);
}

.head-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.head-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #ffb15f;
  background: linear-gradient(155deg, rgba(255, 138, 61, .24), rgba(255, 138, 61, .05));
  border: 1px solid rgba(255, 138, 61, .3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}

.head-icon .mp-icon { width: 17px; height: 17px; }

.wave-chip {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  color: #ffd9a3;
  font-size: 10px;
  background: rgba(255, 138, 61, .11);
  border: 1px solid rgba(255, 138, 61, .24);
  white-space: nowrap;
}

.wave-chip b {
  font-size: 13px;
  color: #ffc078;
}

.battle-body {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 12px;
}

.monster-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 144px;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, rgba(255, 106, 40, .2), rgba(0, 0, 0, .28) 70%);
  border: 1px solid rgba(246, 200, 122, .14);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, .35);
}

.monster-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, transparent 42%, rgba(3, 16, 18, .55) 100%);
  pointer-events: none;
}

#monsterImg {
  position: relative;
  z-index: 1;
  display: block;
  width: 116%;
  max-width: none;
  transform: translateY(2%);
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .46));
  animation: monsterIdle 3.8s ease-in-out infinite;
  transition: filter .16s ease, transform .16s ease, opacity .3s ease;
}

.monster-wrap.hit #monsterImg {
  animation: monsterHit .26s ease;
  filter: drop-shadow(0 0 12px rgba(255, 120, 50, .9)) brightness(1.55) saturate(1.3);
}

.monster-wrap.dying #monsterImg {
  animation: monsterDie .55s ease forwards;
}

.monster-lv {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 3;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  color: #ffe3b0;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(246, 200, 122, .23);
  font-variant-numeric: tabular-nums;
}

.ember {
  position: absolute;
  z-index: 2;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ff9b45;
  box-shadow: 0 0 8px #ff7a24;
  opacity: 0;
  pointer-events: none;
}

.ember.e1 { left: 22%; bottom: 18%; animation: emberUp 2.8s ease-out infinite; }
.ember.e2 { left: 72%; bottom: 12%; animation: emberUp 3.4s .9s ease-out infinite; }
.ember.e3 { left: 48%; bottom: 24%; animation: emberUp 3.1s 1.7s ease-out infinite; }

.battle-fx {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.battle-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.monster-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.monster-name-row h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .03em;
  color: #fff0d2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reward-chip {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 9px;
  color: #ffe0a8;
  background: rgba(246, 200, 122, .09);
  border: 1px solid rgba(246, 200, 122, .2);
  white-space: nowrap;
}

.reward-chip b { color: #ffd071; font-weight: 700; }

.hp-meta {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 4px;
  font-size: 9px;
  color: rgba(255, 244, 222, .42);
  font-variant-numeric: tabular-nums;
}

.hp-meta b { color: #ffcf9e; font-weight: 600; }

.hp-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .05);
  overflow: hidden;
}

.hp-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff5b3a, #ffb15f);
  box-shadow: 0 0 12px rgba(255, 91, 58, .55);
  transition: width .16s ease;
}

.btn-attack {
  margin-top: 10px;
  min-height: 45px;
  gap: 6px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 13px;
  letter-spacing: .04em;
  color: #eafff3;
  background: linear-gradient(180deg, #55c3a2 0%, #268e75 55%, #146b58 100%);
  border: 1px solid rgba(168, 240, 210, .4);
  box-shadow: 0 8px 16px rgba(20, 107, 88, .28), inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -2px 0 rgba(4, 53, 42, .28);
  text-shadow: 0 1px 2px rgba(0, 40, 30, .35);
}

.btn-attack .mp-icon { width: 17px; height: 17px; color: #ffe6a8; }

.btn-attack em {
  font-style: normal;
  font-size: 9.5px;
  padding: 2px 5px;
  border-radius: 6px;
  color: #d8fff1;
  background: rgba(0, 0, 0, .2);
  font-variant-numeric: tabular-nums;
}

.btn-attack[disabled] {
  opacity: .5;
  filter: grayscale(.35);
  cursor: default;
}

.battle-info .panel-hint {
  margin-top: 6px;
  font-size: 8.5px;
}

/* ---------- treasures ---------- */
.section-note {
  flex: 0 0 auto;
  max-width: 126px;
  text-align: right;
  font-size: 9px;
  line-height: 1.45;
  letter-spacing: .03em;
  color: rgba(255, 244, 222, .36);
}

.treasure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
}

.treasure-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 163px;
  padding: 9px 10px 11px;
  border-radius: 18px;
  text-align: left;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .012));
  border: 1px solid rgba(246, 200, 122, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
}

.treasure-card::before {
  content: "";
  position: absolute;
  top: -44px;
  right: -44px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 197, 105, .16), transparent 68%);
  pointer-events: none;
}

.treasure-card:active { transform: scale(.982); }

.t-art {
  position: relative;
  display: grid;
  place-items: center;
  height: 80px;
  margin-bottom: 2px;
}

.t-art::after {
  content: "";
  position: absolute;
  width: 62px;
  height: 12px;
  bottom: 5px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 186, 92, .22), transparent 70%);
  filter: blur(3px);
}

.t-art img {
  position: relative;
  z-index: 1;
  width: 76px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 7px 9px rgba(0, 0, 0, .36));
  transition: transform .24s ease, filter .24s ease, opacity .24s ease;
}

.treasure-card:not(.owned) .t-art img {
  filter: grayscale(.55) brightness(.76) drop-shadow(0 7px 9px rgba(0, 0, 0, .4));
  opacity: .88;
}

.treasure-card.can-buy:not(.owned) .t-art img {
  filter: grayscale(.18) brightness(.95) drop-shadow(0 7px 11px rgba(0, 0, 0, .36));
  opacity: 1;
}

.t-name {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: .03em;
  color: #fff0d6;
}

.t-effect {
  position: relative;
  z-index: 1;
  min-height: 24px;
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.35;
  color: rgba(255, 244, 222, .4);
}

.t-cost {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 5px;
  margin-top: auto;
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  color: #ffdca3;
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(246, 200, 122, .13);
  font-variant-numeric: tabular-nums;
}

.t-cost .stone-gem {
  width: 7px;
  height: 7px;
}

.treasure-card.owned {
  border-color: rgba(127, 214, 180, .34);
  background: linear-gradient(165deg, rgba(127, 214, 180, .11), rgba(255, 255, 255, .015));
  box-shadow: inset 0 0 24px rgba(84, 189, 155, .06);
}

.treasure-card.owned .t-name { color: #d9ffee; }

.treasure-card.owned .t-cost {
  color: #9fe8cd;
  border-color: rgba(127, 214, 180, .22);
  background: rgba(31, 125, 104, .16);
}

.t-owned {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #0b3a30;
  background: linear-gradient(180deg, #b5f5da, #63c9a5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.treasure-card.can-buy {
  border-color: rgba(255, 177, 95, .36);
  box-shadow: inset 0 0 22px rgba(255, 138, 61, .055);
}

.treasure-card.just-bought { animation: bought .65s ease; }

/* ---------- footer ---------- */
.foot {
  padding: 26px 0 8px;
  text-align: center;
  color: rgba(255, 231, 184, .3);
  font-size: 9.5px;
  letter-spacing: .16em;
}

.foot-orn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 6px;
}

.foot-orn i {
  display: block;
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 200, 122, .32));
}

.foot-orn i:last-child { transform: scaleX(-1); }

.foot-orn b {
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3em;
  color: rgba(255, 231, 184, .56);
}

.foot p { margin: 0; }

/* ---------- floating numbers ---------- */
.float-num {
  position: absolute;
  z-index: 7;
  left: 0;
  top: 0;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--sans);
  font-weight: 800;
  font-size: 17px;
  color: #ffe6ac;
  text-shadow: 0 2px 9px rgba(0, 0, 0, .6), 0 0 16px rgba(255, 177, 95, .45);
  animation: floatUp .9s cubic-bezier(.18, .8, .28, 1) forwards;
}

.float-num.crit {
  font-size: 23px;
  color: #ffb15f;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .65), 0 0 22px rgba(255, 122, 36, .8);
}

.float-num.stone {
  font-size: 13px;
  color: #a8f0d2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6), 0 0 16px rgba(84, 189, 155, .6);
}

.float-num.dmg {
  font-size: 18px;
  color: #ffd2a4;
}

.float-num.dmg.crit {
  font-size: 24px;
  color: #ff9a55;
}

.qi-ripple {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 220, 155, .75);
  pointer-events: none;
  animation: ripple .62s ease-out forwards;
}

.slash {
  position: absolute;
  z-index: 5;
  width: 54px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff6dc, transparent);
  box-shadow: 0 0 10px rgba(255, 230, 170, .9);
  pointer-events: none;
  animation: slash .3s ease-out forwards;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 200;
  max-width: calc(100vw - 48px);
  padding: 10px 18px;
  border-radius: 999px;
  text-align: center;
  line-height: 1.4;
  font-size: 12px;
  color: #ffeccb;
  background: rgba(7, 27, 29, .95);
  border: 1px solid rgba(246, 200, 122, .32);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .46), inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .22s ease, transform .22s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- breakthrough overlay ---------- */
.bt-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.bt-overlay.show { opacity: 1; }

.bt-flash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 229, 171, .62), rgba(255, 138, 61, .26) 28%, rgba(4, 20, 25, .6) 68%),
    rgba(3, 16, 18, .35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.bt-card {
  position: relative;
  text-align: center;
  padding: 30px 44px 28px;
  border-radius: 28px;
  background: linear-gradient(165deg, rgba(29, 69, 60, .93), rgba(7, 24, 25, .96));
  border: 1px solid rgba(255, 224, 160, .48);
  box-shadow: 0 0 70px rgba(255, 177, 95, .38), 0 24px 50px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12);
  transform: scale(.82);
  opacity: 0;
}

.bt-overlay.show .bt-card {
  animation: btPop .72s cubic-bezier(.18, .9, .24, 1.28) forwards;
}

.bt-kicker {
  display: block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .34em;
  color: rgba(255, 205, 128, .55);
}

.bt-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 9px 0 8px;
  border-radius: 50%;
  color: #4b2707;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .05em;
  background: linear-gradient(155deg, #ffedbe, #e6ac56 60%, #b9772f);
  border: 1px solid #fff0c8;
  box-shadow: 0 0 26px rgba(255, 214, 150, .5);
}

.bt-card h2 {
  margin: 4px 0 6px;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .12em;
  color: #fff3d8;
  text-shadow: 0 0 22px rgba(255, 200, 120, .55);
}

.bt-card p {
  margin: 0;
  font-size: 10px;
  letter-spacing: .18em;
  color: rgba(255, 235, 197, .55);
}

/* ---------- animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

@keyframes auraPulse {
  0%, 100% { transform: scale(.96); opacity: .55; }
  50% { transform: scale(1.06); opacity: .82; }
}

@keyframes swordFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes lotusFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

@keyframes hintFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes glint {
  0%, 18% { transform: translateX(-110%); }
  58%, 100% { transform: translateX(110%); }
}

@keyframes comboPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes readyPulse {
  0%, 100% { box-shadow: 0 9px 20px rgba(240, 115, 31, .28), 0 0 0 0 rgba(255, 177, 95, .28), inset 0 1px 0 rgba(255, 255, 255, .5); }
  50% { box-shadow: 0 9px 22px rgba(240, 115, 31, .38), 0 0 0 5px rgba(255, 177, 95, .06), inset 0 1px 0 rgba(255, 255, 255, .5); }
}

@keyframes monsterIdle {
  0%, 100% { transform: translateY(2%) scale(1); }
  50% { transform: translateY(0) scale(1.018); }
}

@keyframes monsterHit {
  0% { transform: translate(0, 2%) scale(1); }
  25% { transform: translate(-4px, 1%) scale(1.02) rotate(-1.5deg); }
  55% { transform: translate(4px, 3%) scale(.99) rotate(1.5deg); }
  100% { transform: translate(0, 2%) scale(1); }
}

@keyframes monsterDie {
  0% { opacity: 1; transform: translateY(2%) scale(1); }
  40% { opacity: .9; transform: translateY(-2%) scale(1.08); filter: brightness(2) saturate(1.4); }
  100% { opacity: 0; transform: translateY(8%) scale(.86) rotate(3deg); filter: brightness(.7); }
}

@keyframes emberUp {
  0% { opacity: 0; transform: translate(0, 0) scale(.6); }
  18% { opacity: .9; }
  100% { opacity: 0; transform: translate(8px, -74px) scale(1.1); }
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.72); }
  18% { opacity: 1; transform: translate(-50%, -45%) scale(1.04); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

@keyframes ripple {
  0% { opacity: .9; transform: scale(.35); }
  100% { opacity: 0; transform: scale(4.4); }
}

@keyframes slash {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(.2) rotate(-28deg); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.2) rotate(-28deg); }
}

@keyframes bought {
  0% { box-shadow: 0 0 0 0 rgba(127, 214, 180, .55), inset 0 0 24px rgba(84, 189, 155, .1); }
  55% { box-shadow: 0 0 0 7px rgba(127, 214, 180, .08), inset 0 0 30px rgba(84, 189, 155, .22); }
  100% { box-shadow: inset 0 0 24px rgba(84, 189, 155, .06); }
}

@keyframes btPop {
  0% { opacity: 0; transform: scale(.82); }
  55% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.shake { animation: shakeX .32s ease; }

/* ---------- responsive ---------- */
@media (max-width: 374px) {
  .app { padding-left: 13px; padding-right: 13px; }
  .hud { margin-left: -13px; margin-right: -13px; padding-left: 13px; padding-right: 13px; }
  .id-copy span { display: none; }
  .res-pill { padding: 0 9px; }
  .battle-body { grid-template-columns: 114px minmax(0, 1fr); gap: 10px; }
  .monster-wrap { min-height: 136px; }
  .btn-attack { font-size: 12px; }
  .section-note { display: none; }
  .treasure-card { min-height: 156px; }
  .t-art { height: 72px; }
  .t-art img { width: 68px; height: 68px; }
}

@media (min-width: 520px) {
  body { background: #021013; }
  .bg-scene { background-position: center top; }
  .app {
    max-width: 460px;
    padding-bottom: 42px;
    box-shadow: 0 0 90px rgba(0, 0, 0, .6);
  }
  .hud { margin-left: -16px; margin-right: -16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .progress-glint { display: none; }
}

@media (hover: hover) {
  .treasure-card:hover { border-color: rgba(246, 200, 122, .3); }
  .treasure-card:hover .t-art img { transform: translateY(-2px) scale(1.04); }
  .qi-core:hover { filter: drop-shadow(0 26px 38px rgba(255, 150, 64, .16)); }
  .btn-primary:not(.is-max):hover { filter: brightness(1.04); }
  .btn-attack:not([disabled]):hover { filter: brightness(1.06); }
}
