:root {
  --bg: #14110e;
  --bg-2: #231c16;
  --ink: #f6efe4;
  --muted: #b4a794;
  --line: rgba(244, 214, 160, 0.18);
  --gold: #e7b65a;
  --gold-deep: #8a5a18;
  --purple: #c7a6f4;
  --blue: #b7cbe4;
  --danger: #e08b7a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(231, 182, 90, 0.18), transparent 60%),
    radial-gradient(700px 480px at 100% 100%, rgba(120, 78, 168, 0.16), transparent 55%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255, 244, 214, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 70%, rgba(255, 244, 214, 0.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 72% 18%, rgba(255, 244, 214, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 62%, rgba(255, 244, 214, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 88%, rgba(255, 244, 214, 0.35) 50%, transparent 51%);
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid #f2d48a;
  outline-offset: 3px;
}

#app {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.brand { display: flex; gap: 14px; align-items: center; }

.seal {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 4px rgba(231, 182, 90, 0.25);
  color: var(--gold);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 26px;
}

.brand h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand p { margin: 4px 0 0; color: var(--muted); }

.top-actions { display: flex; gap: 10px; align-items: center; }

.balance {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 244, 214, 0.06);
  border: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
}

.balance strong { font-size: 22px; font-variant-numeric: tabular-nums; }

.coin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6d4, var(--gold) 46%, var(--gold-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.panel {
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.045), rgba(255, 248, 236, 0.02));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.picker { padding: 18px; margin-bottom: 16px; }

.picker-head, .section-head, .history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.picker h2, .panel h2, .history h2 { margin: 0; font-size: 18px; }

.hint { margin: 0; color: var(--muted); font-size: 14px; }

.gold-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.gold-option { position: relative; display: block; }

.gold-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.gold-face {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 132px;
  padding: 14px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 236, 196, 0.14), rgba(255, 236, 196, 0.04)),
    #2a2218;
  border: 1px solid rgba(231, 182, 90, 0.28);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.gold-option:hover .gold-face { transform: translateY(-3px); }

.gold-option.is-selected .gold-face {
  background: linear-gradient(180deg, #ffe7ad, #e0aa45 55%, #b47b28);
  color: #2a1c08;
  border-color: transparent;
}

.gold-no {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  font-size: 12px;
  opacity: 0.75;
}

.gold-face strong { font-size: 22px; line-height: 1.2; }

.ribbon {
  align-self: flex-start;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(231, 182, 90, 0.16);
  font-size: 12px;
  font-style: normal;
}

.gold-option.is-selected .ribbon { background: rgba(42, 28, 8, 0.16); }

.dash {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 16px;
}

.pity, .wallet { padding: 18px; }

.pity-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meter { margin: 12px 0; }

.meter span, .meter small { display: flex; justify-content: space-between; gap: 8px; }

.meter small { color: var(--muted); margin-bottom: 6px; }

.track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8d6adf, #d7b4ff);
}

.track.hard i { background: linear-gradient(90deg, #a8742a, #ffe1a0); }

.track.hard.is-ready i { background: linear-gradient(90deg, #ffe1a0, #fff6d8); }

.copy {
  margin: 8px 0 0;
  line-height: 1.55;
  color: #efe4d2;
}

.wallet p { margin: 6px 0 12px; color: var(--muted); line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

.chip, .text-btn, .btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.chip, .btn { padding: 8px 14px; }

.chip:hover, .text-btn:hover, .btn:hover { border-color: rgba(231, 182, 90, 0.55); }

.add-form { display: flex; gap: 8px; }

.add-form input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 14px;
  margin: 16px 0;
}

.btn-pull {
  border: 0;
  border-radius: 20px;
  min-height: 112px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn-pull .kicker { font-size: 28px; font-weight: 700; letter-spacing: 0.06em; }

.btn-pull .cost { font-size: 16px; }

.btn-pull .note { font-size: 13px; opacity: 0.8; }

.btn-single {
  color: #e7f1ff;
  background: linear-gradient(180deg, #3c5674, #1d2c40);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 12px 28px rgba(0, 0, 0, 0.25);
}

.btn-ten {
  color: #2a1c08;
  background: linear-gradient(180deg, #ffe3a4, #e2ae45 42%, #c4892f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 14px 30px rgba(196, 137, 47, 0.28);
}

.btn-pull.is-off { filter: saturate(0.7) brightness(0.86); }

.btn-pull:active { transform: translateY(1px); }

.status-line { margin: 0 0 18px; color: var(--gold); }

.rules { margin-bottom: 18px; color: var(--muted); }

.rules summary { cursor: pointer; color: var(--ink); }

.rules ol { margin: 10px 0 0; padding-left: 18px; line-height: 1.65; }

.history { padding: 18px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }

.filter.is-on {
  background: rgba(231, 182, 90, 0.18);
  border-color: rgba(231, 182, 90, 0.7);
  color: #ffe7b8;
}

.batch-list { display: grid; gap: 12px; max-height: 560px; overflow: auto; padding-right: 4px; }

.batch {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.15);
}

.batch header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
}

.batch ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.reward {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.reward.is-done { opacity: 0.55; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

.dot.purple { background: var(--purple); }
.dot.gold { background: var(--gold); }

.reward .name { font-weight: 650; }
.reward .meta { color: var(--muted); font-size: 12px; }

.linkish {
  background: transparent;
  border: 0;
  color: var(--danger);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty { color: var(--muted); margin: 8px 0 0; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.overlay[hidden] { display: none; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.72);
}

.dialog {
  position: relative;
  width: min(980px, 100%);
  max-height: min(920px, calc(100vh - 28px));
  overflow: auto;
  padding: 18px;
  border-radius: 24px;
  background: #221c16;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.dialog-top, .dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.dialog-actions { justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.text-btn { background: transparent; padding: 6px 8px; }

.result-dialog {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.result-dialog.is-single-dialog { width: min(440px, 100%); }

.result-dialog h2, .confirm-dialog h2, .pool-dialog h2 { margin: 6px 0; }

#resultGrid { overflow: auto; min-height: 0; flex: 1 1 auto; }
.dialog-top, .dialog-actions { flex-shrink: 0; }

#resultSub { margin-top: 0; color: var(--gold); }

.result-grid.is-ten {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.result-grid.is-single { max-width: 280px; margin: 0 auto; }

.flip-inner {
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: transform 0.45s cubic-bezier(0.2, 0.75, 0.2, 1), opacity 0.35s ease;
}

.flip.show .flip-inner {
  opacity: 1;
  transform: none;
}

.flip-front {
  min-height: 168px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}

.flip-back { display: none; }

.result-grid.is-single .flip-front { min-height: 240px; }

.r-normal .flip-front { background: linear-gradient(180deg, #eef3f8, #a9bfd6); color: #1b2836; }
.r-purple .flip-front { background: linear-gradient(180deg, #f4e9ff, #9b74e0); color: #27143f; }
.r-gold .flip-front { background: linear-gradient(180deg, #fff0c4, #e2b04a 48%, #a8742a); color: #2b1c07; }

.flip.show.r-gold .flip-inner { filter: drop-shadow(0 0 14px rgba(231, 182, 90, 0.45)); }

.rarity-tag, .eyebrow {
  font-size: 12px;
  letter-spacing: 0.08em;
}

.flip-front strong { font-size: 18px; line-height: 1.35; }
.result-grid.is-single .flip-front strong { font-size: 28px; }
.flip-front em { font-style: normal; font-size: 12px; opacity: 0.75; }

.btn-solid, .btn-gold, .btn-danger, .btn-ghost { border-radius: 999px; padding: 10px 16px; }

.btn-solid { background: #f3efe7; color: #221c16; border: 0; }
.btn-gold { background: linear-gradient(180deg, #ffe3a4, #d7a441); color: #2a1c08; border: 0; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(224, 139, 122, 0.6); }
.btn-ghost { background: transparent; }

.pool-cols {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.7fr;
  gap: 14px;
}

.pool-cols section {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.pool-cols h3 { margin: 0 0 8px; }
.pool-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pool-cols li { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.pool-cols li span { color: var(--muted); }

.confirm-dialog { width: min(420px, 100%); }
.pool-dialog { width: min(920px, 100%); }

#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff6e4;
  color: #2a1c08;
  transition: 0.2s ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

body.modal-open { overflow: hidden; }

@media (max-width: 860px) {
  .dash, .pool-cols, .actions, .gold-row { grid-template-columns: 1fr; }
  .gold-row { display: flex; overflow-x: auto; padding-bottom: 6px; }
  .gold-option { min-width: 46%; }
  .result-grid.is-ten { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .top-actions { justify-content: space-between; }
  .brand h1 { font-size: 28px; white-space: nowrap; }
  .picker-head, .history-head, .section-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
