:root {
  --gold: #ffd76a;
  --gold-soft: rgba(255, 215, 106, 0.52);
  --jade: #7fffd4;
  --cyan: #5ee8ff;
  --crimson: #ff5a6e;
  --violet: #9a7cff;
  --ink: #080611;
  --ink-2: #120c23;
  --panel: rgba(10, 7, 18, 0.68);
  --line: rgba(255, 232, 174, 0.26);
  --muted: #cbb8ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0a1e;
  touch-action: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at center, transparent 34%, rgba(3, 2, 10, 0.2) 72%, rgba(3, 2, 10, 0.52)),
    linear-gradient(180deg, rgba(3, 2, 12, 0.15), transparent 22%, transparent 74%, rgba(3, 2, 12, 0.38));
}

#c {
  position: fixed;
  inset: 0;
  display: block;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#realmBanner {
  position: absolute;
  top: 12px;
  left: 50%;
  min-width: 290px;
  padding: 6px 22px 10px;
  border: 1px solid rgba(255, 215, 106, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 215, 106, 0.08), transparent),
    rgba(7, 4, 16, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  transform: translateX(-50%);
}

#realmBanner::before,
#realmBanner::after {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--gold-soft));
}

#realmBanner::before {
  right: 100%;
}

#realmBanner::after {
  left: 100%;
  transform: scaleX(-1);
}

#realmName {
  color: #fff8de;
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 6px;
  line-height: 1.1;
  text-shadow: 0 0 12px rgba(255, 79, 216, 0.85), 0 0 28px rgba(255, 215, 106, 0.36);
}

#realmSub {
  margin-top: 3px;
  color: #d9cdfd;
  font-size: 11px;
  letter-spacing: 3px;
  opacity: 0.92;
}

#vitalPanel {
  position: absolute;
  top: 18px;
  left: 18px;
  display: grid;
  width: min(360px, 34vw);
  gap: 8px;
}

.gauge {
  padding: 8px 10px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(8, 5, 18, 0.64);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.gaugeTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  color: #f6edff;
  font-size: 11px;
  letter-spacing: 2px;
  text-shadow: 0 1px 4px #000;
}

.gaugeTop span:last-child {
  color: rgba(246, 237, 255, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0;
}

.barWrap {
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
}

.barWrap::after {
  position: absolute;
  inset: 1px;
  border-radius: 5px;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 48%);
}

.barFill {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  transition: width 0.15s ease-out;
}

#hpFill {
  background: linear-gradient(90deg, #e93e59, #ff7a52 54%, #ffc06a);
  box-shadow: 0 0 14px rgba(255, 90, 110, 0.55);
}

.gauge--xp .barWrap {
  height: 7px;
}

#xpFill {
  width: 0%;
  background: linear-gradient(90deg, #53fff0, #8b7cff 52%, #ff4fd8);
  box-shadow: 0 0 14px rgba(94, 232, 255, 0.48);
}

#combatStats {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: min(390px, 34vw);
  gap: 8px;
}

.statChip {
  min-width: 74px;
  padding: 7px 10px;
  border: 1px solid rgba(126, 255, 212, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(126, 255, 212, 0.09), rgba(154, 124, 255, 0.05)),
    rgba(8, 5, 18, 0.62);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #ecfffb;
  font-size: 12px;
  letter-spacing: 1px;
  text-align: center;
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
}

#hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(7, 4, 16, 0.36);
  color: #d8ccff;
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.76;
  text-shadow: 0 1px 3px #000;
  transform: translateX(-50%);
  animation: hintFade 8s ease 5s forwards;
  white-space: nowrap;
}

@keyframes hintFade {
  to {
    opacity: 0.18;
  }
}

.dmg {
  position: absolute;
  color: #ff3b5c;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 18px;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 0 6px rgba(255, 59, 92, 0.8), 0 2px 2px #000;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.dmg.crit {
  color: var(--gold);
  font-size: 24px;
  text-shadow: 0 0 10px rgba(255, 215, 106, 0.9), 0 2px 2px #000;
}

.dmg.heal {
  color: #6dff9c;
}

.dmg.hurt {
  color: #fff;
}

.overlay {
  --overlay-image: none;

  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background-color: #080410;
  background-image:
    radial-gradient(ellipse at center, rgba(24, 12, 45, 0.42), rgba(6, 3, 16, 0.9)),
    linear-gradient(180deg, rgba(6, 3, 16, 0.15), rgba(6, 3, 16, 0.85)),
    var(--overlay-image);
  background-position: center;
  background-size: cover;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(3px);
  transition: opacity 0.25s ease-out;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlayInner {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(760px, 100%);
}

.overlayInner::before {
  position: absolute;
  top: 66px;
  left: 50%;
  width: min(680px, 92vw);
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 215, 106, 0.5), transparent);
  transform: translateX(-50%);
}

.ovKicker {
  margin-bottom: 5px;
  color: var(--jade);
  font-size: 12px;
  letter-spacing: 4px;
  text-shadow: 0 0 14px rgba(127, 255, 212, 0.55);
}

.ovTitle {
  margin-bottom: 8px;
  color: var(--gold);
  font-family: "KaiTi", "STKaiti", "楷体", serif;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 8px;
  text-shadow: 0 0 22px rgba(255, 215, 106, 0.62);
}

.ovTitle--danger {
  color: #ff6d82;
  text-shadow: 0 0 22px rgba(255, 90, 110, 0.62);
}

.ovSub {
  margin-bottom: 26px;
  color: #dacdff;
  font-size: 13px;
  letter-spacing: 2px;
}

#cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 192px));
  gap: 16px;
  justify-content: center;
  width: 100%;
}

.upgradeCard {
  position: relative;
  min-height: 258px;
  padding: 0;
  border: none;
  appearance: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: transform 0.14s ease-out;
}

.upgradeCard:hover,
.upgradeCard:focus-visible {
  outline: none;
  transform: translateY(-5px);
}

.cardFrame {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 258px;
  padding: 14px 13px 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 106, 0.38);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 215, 106, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(31, 24, 48, 0.92), rgba(8, 5, 18, 0.9));
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.cardFrame::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  pointer-events: none;
  content: "";
}

.cardFrame::after {
  position: absolute;
  inset: auto 18px 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(126, 255, 212, 0.62), transparent);
  opacity: 0.7;
}

.upgradeCard:hover .cardFrame,
.upgradeCard:focus-visible .cardFrame {
  border-color: rgba(255, 215, 106, 0.82);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.58), 0 0 24px rgba(255, 215, 106, 0.18);
}

.cardMeta {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 6px;
  margin-bottom: 11px;
}

.cardRank,
.cardType {
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #dffefa;
  font-size: 10px;
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.22);
}

.cardRank {
  color: #ffe9a4;
  border-color: rgba(255, 215, 106, 0.22);
}

.card .ic,
.upgradeCard .ic {
  display: grid;
  align-items: center;
  justify-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 12px;
  font-size: 32px;
  margin-inline: auto;
}

.cardIcon {
  display: block;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(255, 215, 106, 0.24);
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 0 24px rgba(255, 215, 106, 0.2), 0 0 34px rgba(94, 232, 255, 0.08);
}

.card .nm,
.upgradeCard .nm {
  margin-bottom: 7px;
  color: var(--gold);
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
}

.card .ds,
.upgradeCard .ds {
  color: #e1d8fb;
  font-size: 12px;
  line-height: 1.55;
}

.cardHint {
  margin-top: auto;
  padding-top: 13px;
  color: rgba(203, 184, 255, 0.72);
  font-size: 10px;
  letter-spacing: 1px;
}

.bigBtn {
  margin-top: 8px;
  padding: 13px 54px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe17d, #ff9a3d);
  box-shadow: 0 0 24px rgba(255, 180, 60, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: #311300;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 6px;
  pointer-events: auto;
}

.bigBtn:active {
  transform: scale(0.96);
}

#deathStats {
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 5, 18, 0.58);
  color: #e8ddff;
  font-size: 13px;
  letter-spacing: 1px;
  line-height: 2;
  text-align: center;
}

#joy {
  position: fixed;
  z-index: 8;
  display: none;
  width: 110px;
  height: 110px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126, 255, 212, 0.1), rgba(255, 255, 255, 0.04));
  box-shadow: 0 0 22px rgba(94, 232, 255, 0.14);
}

#joyKnob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.16);
  transform: translate(-50%, -50%);
}

@media (max-width: 860px) {
  #realmBanner {
    min-width: 250px;
    padding-inline: 16px;
  }

  #realmName {
    font-size: 25px;
    letter-spacing: 4px;
  }

  #vitalPanel {
    top: 76px;
    left: 50%;
    width: min(390px, 88vw);
    transform: translateX(-50%);
  }

  #combatStats {
    top: 158px;
    left: 50%;
    right: auto;
    justify-content: center;
    width: min(420px, 92vw);
    transform: translateX(-50%);
  }

  .statChip {
    min-width: 68px;
    padding-inline: 8px;
    font-size: 11px;
  }

  #cards {
    grid-template-columns: minmax(220px, 320px);
    max-height: 58vh;
    overflow-y: auto;
    padding: 0 4px 6px;
  }

  .upgradeCard,
  .cardFrame {
    min-height: 218px;
  }
}

@media (max-width: 520px) {
  .overlay {
    padding: 18px 12px;
  }

  .ovTitle {
    font-size: 31px;
    letter-spacing: 6px;
  }

  .ovSub {
    margin-bottom: 18px;
  }

  #hint {
    max-width: calc(100vw - 28px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .gaugeTop {
    font-size: 10px;
  }
}
