:root {
  color-scheme: dark;
  --text: #fff1dc;
  --muted: #c4b3c9;
  --edge: #483652;
  --amber: #ffe39c;
  --night: #171122;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--night);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #fff1ce; outline-offset: 3px; }
[hidden] { display: none !important; }

.mine {
  width: min(100%, 490px);
  margin-inline: auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.masthead {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

h1, h2, p { margin: 0; }
h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .025em;
}
.lede { margin-top: 6px; color: var(--muted); font-size: 13px; }
.mode { margin-bottom: 5px; color: #efd4a9; font-size: 11px; letter-spacing: .10em; }

.wallet {
  min-width: 88px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  color: #ffe2a5;
  border: 1px solid #5e4358;
  border-radius: 12px;
  background: #281b34;
}

.wallet-gem {
  display: block;
  flex: 0 0 16px;
  height: 22px;
  clip-path: polygon(50% 0, 94% 30%, 82% 69%, 47% 100%, 9% 68%, 0 30%);
  background: conic-gradient(from 24deg at 50% 45%, #ffead4 0 48deg, #e58cff 48deg 136deg,
    #8151c8 136deg 220deg, #ad6beb 220deg 292deg, #f3ccff 292deg);
}
.wallet-label { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; }
.wallet strong { font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }

.well {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 360 / 408;
  isolation: isolate;
  border: 1px solid #654978;
  border-radius: 18px;
  background: #23162d;
  box-shadow: 0 15px 35px #100a1b50, inset 0 0 60px #100a1b60;
}
#stage { display: block; width: 100%; height: 100%; }
.aim-display, .motion {
  position: absolute;
  top: 10px;
  border: 1px solid #856084;
  color: #fff0d7;
  background: #21172c;
}
.aim-display {
  min-height: 28px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  pointer-events: none;
}
.aim-indicator { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.motion { right: 10px; min-height: 44px; padding: 6px 9px; border-radius: 8px; font-size: 11px; }

.operations { display: grid; gap: 17px; padding-top: 11px; }
.aim-controls {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-bottom: 8px;
}
.aim-controls button {
  min-height: 44px;
  border-radius: 9px;
  color: var(--amber);
  border: 1px solid var(--edge);
  background: #261a33;
  font-size: 28px;
  line-height: 1;
}
.aim-controls button:disabled { color: #987eab; }
#aim-text { font-size: 13px; text-align: center; color: var(--muted); }

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #fff1ce;
  border-radius: 10px;
  background: linear-gradient(160deg, #ffedb7, #ffd37e 65%, #efb762);
  color: #332017;
  box-shadow: 0 3px 0 #a77343, 0 6px 16px #110a1b70;
  font-weight: 800;
  letter-spacing: .03em;
  text-align: center;
}
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #a77343; }
.primary:disabled { background: #3e2c49; color: #dcc5df; border-color: #775985; box-shadow: 0 3px 0 #201526; }
.status { margin-top: 11px; min-height: 18px; font-size: 12px; line-height: 1.55; text-align: center; color: var(--muted); }

.finds { border-top: 1px solid var(--edge); padding: 13px 0 0; }
.finds h2 { font-size: 12px; font-weight: 600; color: #e8cfae; }
.finds-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.finds-list li { display: grid; justify-items: center; gap: 1px; font-size: 11px; color: var(--muted); }
.finds-list canvas { width: 40px; height: 38px; }

.reward {
  width: min(calc(100% - 36px), 350px);
  max-height: calc(100% - 36px);
  overflow: auto;
  margin: auto;
  padding: 15px 21px 20px;
  background: radial-gradient(ellipse at 50% 20%, #5c376c, #2a1d3b 57%, #21162f);
  color: var(--text);
  border: 1px solid #a377a4;
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 22px 85px #0b0711;
}
.reward::backdrop { background: #100a1bd9; }
.reward-art {
  display: grid;
  place-items: center;
  width: 130px;
  height: 105px;
  margin: 0 auto;
  background: radial-gradient(ellipse, #ffde8945, #e494ff20 53%, transparent 69%);
}
.reward-art canvas { width: 110px; height: 100px; }
.reward-caption { margin: 1px 0 6px; color: var(--amber); font-size: 12px; }
.reward h2 { font-size: 25px; overflow-wrap: anywhere; }
#reward-description { margin: 7px 0 18px; color: var(--muted); font-size: 13px; }
.reward-link {
  display: block;
  width: fit-content;
  margin: 0 auto 10px;
  padding: 12px;
  color: var(--amber);
  font-size: 13px;
}

@media (min-width: 820px) {
  body { background: radial-gradient(ellipse at 36% 19%, #2c1d3b, #171122 73%); }
  .mine { width: min(100%, 990px); padding: 40px 34px; }
  .masthead { margin-bottom: 25px; }
  h1 { font-size: 56px; }
  .lede { margin-top: 9px; font-size: 14px; }
  .wallet { padding: 10px 15px; }
  .play { display: grid; align-items: start; grid-template-columns: 1.47fr 1fr; gap: 26px; }
  .operations {
    padding: 23px 20px;
    gap: 19px;
    border: 1px solid var(--edge);
    border-radius: 18px;
    background: #20172be6;
  }
}

@media (max-width: 374px) {
  .mine { padding-inline: max(12px, env(safe-area-inset-left)); }
  .masthead { margin-bottom: 12px; }
}

.vault, .gift-actions { display: flex; gap: 12px; justify-content: space-between; align-items: center; }
.vault p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
#gift-form { text-align: left; margin-top: 12px; }
#recipient { display: block; width: 100%; min-height: 44px; margin-top: 7px; padding: 10px; border-radius: 8px; border: 1px solid #77648b; background: #241a30; color: #fff; }
.gift-actions .primary, .gift-actions .reward-link { flex: 1 1 0; }
dialog:not([open]) { display: none; }
.fallback-dialog-active { overflow: hidden; }
.fallback-dialog-active::before { content: ""; position: fixed; inset: 0; z-index: 9; background: #120b1bc9; }
.reward.fallback-dialog { position: fixed; inset: 0; z-index: 10; margin: auto; height: max-content; overflow: auto; max-height: calc(100vh - 20px); }
