:root {
  color-scheme: dark;
  --bg: #0c0e12;
  --text: #e7e4dc;
  --muted: #9a9386;
  --gold: #e8c56b;
  --gold-deep: #8a6a2f;
  --line: rgba(232, 197, 107, 0.35);
  --panel: #141820;
  --blue: #5e98d9;
  --purple: #8847ff;
  --pink: #d32ce6;
  --red: #eb4b4b;
  --rare-gold: #ffd700;
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "Microsoft JhengHei UI", sans-serif;
  --font-mono:
    "JetBrains Mono", "Iosevka", "Cascadia Code", ui-monospace, SFMono-Regular,
    Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  overflow-x: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(880px 380px at 50% -12%, rgba(232, 197, 107, 0.16), transparent 62%),
    linear-gradient(180deg, #141820 0%, var(--bg) 42%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}
main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}
h1, h2, p { margin: 0; }
button, a { font: inherit; }
a { color: inherit; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
}
h1 {
  font-size: 34px;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.account {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 8.5rem;
}
.balance-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.balance strong {
  font-family: var(--font-mono);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.balance small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.who {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 16rem;
}
.who img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
}
.who span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1b160d;
  color: var(--gold);
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.14);
}
.btn:focus-visible,
.pull:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(235, 75, 75, 0.45);
  border-radius: 8px;
  background: rgba(235, 75, 75, 0.1);
  color: #ffd0d0;
}

.case-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #10141b;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    0 18px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.case-frame::before,
.case-frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold);
  z-index: 4;
  pointer-events: none;
}
.case-frame::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.case-frame::after { right: 8px; bottom: 8px; border-left: 0; border-top: 0; }
.marker {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
  z-index: 3;
  pointer-events: none;
}
.marker::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--gold);
}
.viewport {
  overflow: hidden;
  height: 176px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%),
    #0d1016;
}
.viewport::before,
.viewport::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 64px;
  z-index: 2;
  pointer-events: none;
}
.viewport::before { left: 0; background: linear-gradient(90deg, #10141b, transparent); }
.viewport::after { right: 0; background: linear-gradient(270deg, #10141b, transparent); }
.viewport.flash-blue { box-shadow: inset 0 0 48px rgba(94, 152, 217, 0.55); }
.viewport.flash-purple { box-shadow: inset 0 0 48px rgba(136, 71, 255, 0.55); }
.viewport.flash-pink { box-shadow: inset 0 0 48px rgba(211, 44, 230, 0.5); }
.viewport.flash-red { box-shadow: inset 0 0 48px rgba(235, 75, 75, 0.55); }
.viewport.flash-gold { box-shadow: inset 0 0 56px rgba(255, 215, 0, 0.55); }
.reel {
  display: flex;
  gap: 8px;
  width: max-content;
  padding: 26px 0;
  will-change: transform;
}
.reel.idle { margin: 0 auto; }
.case-frame.mode-ten .viewport {
  height: auto;
  overflow: hidden;
  padding: 16px;
}
.case-frame.mode-ten .marker,
.case-frame.mode-ten .viewport::before,
.case-frame.mode-ten .viewport::after { display: none; }
.reel.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  padding: 0;
  gap: 8px;
}

.card {
  width: 124px;
  height: 124px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.28));
  position: relative;
  overflow: hidden;
}
.reel.grid .card { width: 100%; max-width: 100%; min-width: 0; height: 118px; }
.card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--tone, var(--blue));
}
.rarity-blue { --tone: var(--blue); }
.rarity-purple { --tone: var(--purple); }
.rarity-pink { --tone: var(--pink); }
.rarity-red { --tone: var(--red); }
.rarity-gold { --tone: var(--rare-gold); }
.gem {
  width: 28px;
  height: 28px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), var(--tone));
  box-shadow: 0 0 16px color-mix(in srgb, var(--tone) 70%, transparent);
}
.card .rarity,
.card .name,
.card .gain {
  max-width: 100%;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.card .rarity,
.card .gain {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.card .name { font-weight: 750; font-size: 14px; }
.card.is-hit .name { color: #fff; }
.card.pending { opacity: 0; transform: translateY(8px) scale(0.96); }
.card.show { animation: pop 0.35s ease; }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.status, .fine {
  color: var(--muted);
  margin-top: 12px;
  font-size: 14px;
}
.fine { margin-top: 8px; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.pull {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}
.pull.single {
  background: #1a2230;
  border: 1px solid #3d4f6a;
  color: #d5e4f7;
}
.pull.ten {
  background: linear-gradient(180deg, #3a3118, #221c0e);
  border: 1px solid #c6a15a;
  color: #f6ead0;
}
.pull-name { font-size: 18px; font-weight: 750; letter-spacing: 0.06em; }
.pull-cost {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.pull:disabled { opacity: 0.45; cursor: not-allowed; }

.summary {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.results, .stats { margin-top: 22px; }
.results h2, .stats h2 {
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 10px;
}
#result-list, #stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
#result-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
#stat-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.result, .stat {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 3px solid var(--tone, #3d4f6a);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
}
.result b, .stat b { display: block; }
.result span, .stat span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(232, 197, 107, 0.16);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 720px) {
  main { width: min(100% - 20px, 920px); padding-top: 18px; }
  .top { flex-direction: column; align-items: stretch; }
  .account { justify-content: space-between; }
  .balance { align-items: flex-start; }
  h1 { font-size: 28px; }
  .reel.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions { grid-template-columns: 1fr; }
  .pull { min-height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .reel { transition: none !important; }
  .card.show { animation: none; }
}
