:root {
  --paper: #fff9e9;
  --card: #fffdf6;
  --ink: #292139;
  --muted: #655d72;
  --purple: #6b46ce;
  --lilac: #ece4ff;
  --yellow: #ffe06a;
  --outline: 2px solid var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: radial-gradient(circle, #dfd3b4 0.8px, transparent 0.9px) 0 0 / 15px 15px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #6b46ce; outline-offset: 4px; }
button:disabled { cursor: default; }
canvas { display: block; image-rendering: pixelated; }
[data-icon] { display: inline-block; flex: 0 0 auto; width: 20px; height: 20px; vertical-align: middle; }
[data-icon] canvas { width: 100%; height: 100%; }
.topbar { background: var(--card); border-bottom: var(--outline); }
.topbar-inner { max-width: 1168px; min-height: 76px; margin: auto; padding: 11px 28px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 11px; justify-self: start; padding: 0; border: 0; background: none; text-align: left; font-size: 21px; font-weight: 900; line-height: 1.14; }
.brand-icon { display: grid; place-items: center; width: 44px; height: 44px; border: var(--outline); background: #cbb5ff; border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); }
.brand-icon canvas { width: 33px; height: 33px; }
.brand small { display: block; margin-top: 4px; color: var(--purple); font: 800 11px/1 ui-monospace, monospace; letter-spacing: .11em; }
.nav { display: flex; gap: 4px; padding: 4px; border: 1px solid #e0d8ee; border-radius: 12px; background: #f5efff; }
.nav button { display: flex; align-items: center; gap: 7px; padding: 8px 15px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #554a67; font-size: 14px; font-weight: 800; white-space: nowrap; }
.nav button[aria-current] { background: #e2d2ff; border-color: #bfa9e9; color: #392369; }
.nav button:hover { background: #ebe0ff; }
.top-score { display: flex; align-items: center; gap: 6px; justify-self: end; border: var(--outline); border-radius: 10px; background: #fff0ae; box-shadow: 2px 2px 0 var(--ink); padding: 7px 12px; font-size: 14px; white-space: nowrap; }
.top-score b { font: 900 18px/1 ui-monospace, monospace; }
.shell { max-width: 1168px; margin: auto; padding: 33px 28px 0; }
.intro { margin: 0 0 28px; text-align: center; }
.eyebrow { display: inline-flex; gap: 6px; align-items: center; border: var(--outline); border-radius: 100px; padding: 5px 13px; background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); font-size: 14px; font-weight: 900; }
.eyebrow i { width: 15px; height: 15px; }
h1 { margin: 7px 0 5px; font-size: clamp(44px, 6vw, 76px); line-height: 1.15; font-weight: 1000; letter-spacing: -.075em; }
h1 em { color: var(--purple); font-style: normal; }
h1 em span { margin-left: .04em; }
.intro p { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1.86fr) minmax(300px, 1fr); align-items: stretch; gap: 19px; }
.game-panel, .card { border: var(--outline); box-shadow: 4px 4px 0 var(--ink); border-radius: 18px; background: var(--card); }
.game-panel { padding: 12px; }
.stage { position: relative; display: grid; place-items: center; overflow: hidden; height: 274px; isolation: isolate; border: var(--outline); border-radius: 12px; background: #cdb9fb; }
.stage-grid { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 43%, #f7edffa0 2%, transparent 67%), linear-gradient(#f3e9ff61 1px, transparent 1px) 50% 50% / 21px 21px, linear-gradient(90deg, #f3e9ff61 1px, transparent 1px) 50% 50% / 21px 21px; z-index: -3; }
.stage-floor { position: absolute; inset: auto 0 0; height: 24%; border-top: 2px solid #9c7bd0; background: repeating-conic-gradient(#bda0f2 0 25%, #c8adf4 0 50%) 50% 0 / 42px 26px; z-index: -2; }
.stage-corner { position: absolute; inset: 9px; border: 1px dashed #9b79d78c; border-radius: 6px; pointer-events: none; z-index: -1; }
.stage-tag, .stage-time { position: absolute; top: 14px; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--ink); border-radius: 6px; background: #fcf7ff; box-shadow: 2px 2px 0 #423065; font-size: 13px; }
.stage-tag { left: 15px; }
.stage-tag > span { width: 8px; height: 8px; background: #8057df; border: 1px solid #4e2f91; }
.stage-time { right: 15px; font: 900 16px/1 ui-monospace, monospace; }
.stage-time i { width: 16px; height: 16px; }
.mascot { position: absolute; left: 50%; bottom: 29px; width: 212px; height: 212px; transform: translateX(-50%); }
.mascot canvas { position: relative; width: 100%; height: 100%; animation: bounce 2.8s ease-in-out infinite; }
.mascot-shadow { position: absolute; z-index: -1; width: 72%; height: 13px; bottom: 13px; left: 14%; background: #8562be60; clip-path: polygon(8% 0, 92% 0, 92% 20%, 100% 20%, 100% 80%, 92% 80%, 92% 100%, 8% 100%, 8% 80%, 0 80%, 0 20%, 8% 20%); }
.twinkles { position: absolute; inset: 0; pointer-events: none; }
.twinkles i { position: absolute; width: 30px; height: 30px; }
.twinkles i:nth-child(1) { left: 25%; top: 30%; }
.twinkles i:nth-child(2) { left: 15%; top: 58%; width: 15px; height: 15px; }
.twinkles i:nth-child(3) { right: 23%; top: 27%; width: 35px; height: 35px; }
.twinkles i:nth-child(4) { right: 14%; top: 56%; width: 17px; height: 17px; }
.twinkles i:nth-child(5) { right: 33%; top: 59%; width: 18px; height: 18px; }
@keyframes bounce { 50% { transform: translateY(-7px); } }
.stage[data-state="active"] .mascot canvas { animation: bounce 550ms ease-in-out infinite; }
.stage[data-state="active"] .stage-tag > span { background: #8fe29e; border-color: #357147; }
#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #211932; transform: scaleX(-1); }
.stage-meter { position: absolute; z-index: 2; bottom: 14px; left: 15px; right: 15px; height: 12px; border: 1px solid var(--ink); border-radius: 4px; overflow: hidden; background: #f5edff; }
#progress { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: repeating-linear-gradient(90deg, #7950dc 0 12px, #9068eb 12px 14px); }
.controls { padding: 14px 0 1px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
.button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; min-height: 49px; border: var(--outline); border-radius: 10px; box-shadow: 3px 3px 0 var(--ink); font-weight: 900; transition: transform .12s, box-shadow .12s, background .12s; }
.button:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.button:not(:disabled):active, .button[data-pressed] { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button:disabled { opacity: .55; }
.primary { background: var(--yellow); }
.secondary { background: #e9ddff; }
#hold { touch-action: none; user-select: none; -webkit-user-select: none; }
.game-hint { grid-column: 1 / -1; margin: 1px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }
.side { display: grid; grid-template-rows: auto 1fr; gap: 14px; }
.card { padding: 17px 18px; }
.card h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 19px; font-weight: 900; }
.card h2 i { width: 22px; height: 22px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 13px; }
.stats > div { display: grid; gap: 3px; place-items: center; min-width: 0; padding: 8px 3px 7px; border-radius: 8px; border: 1px solid #e5d8f2; background: #f3ebff; }
.stats strong { font: 900 clamp(19px, 2.4vw, 28px)/1.1 ui-monospace, monospace; color: #51359d; overflow-wrap: anywhere; }
.stats strong small { font-size: .53em; }
.stats span { color: #5e5072; font-size: 13px; white-space: nowrap; }
.instructions ol { padding: 0; margin: 13px 0 0; list-style: none; display: grid; gap: 10px; }
.instructions li { display: flex; align-items: flex-start; gap: 9px; }
.instructions li > span { min-width: 24px; height: 24px; border: 1px solid var(--ink); border-radius: 6px; background: #fff0ab; text-align: center; font: 900 14px/22px ui-monospace, monospace; }
.instructions li div { display: grid; gap: 2px; }
.instructions li strong { font-size: 14px; }
.instructions li small { font-size: 13px; color: var(--muted); line-height: 1.35; }
.preview { margin-top: 19px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.text-button { border: 0; background: transparent; color: #5935b4; font-size: 14px; font-weight: 900; padding: 4px 0; }
.text-button:hover { text-decoration: underline; }
.loot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.loot { --loot-bg: #f9ebd8; --loot-edge: #e1c19a; display: flex; align-items: center; gap: 9px; padding: 8px; min-width: 0; border: 1px solid var(--loot-edge); border-radius: 10px; background: var(--loot-bg); }
[data-rarity="rare"] { --loot-bg: #e5f2ff; --loot-edge: #b3d1f2; }
[data-rarity="epic"] { --loot-bg: #f0e4ff; --loot-edge: #d4b7f6; }
[data-rarity="legendary"] { --loot-bg: #fff0bd; --loot-edge: #e5c761; }
.loot-art { flex: 0 0 auto; position: relative; display: grid; place-items: center; background: #ffffff9e; border: 1px solid var(--loot-edge); border-radius: 8px; width: 48px; height: 43px; }
.loot-art canvas { width: 38px; height: 38px; }
.loot-info { display: grid; gap: 3px; min-width: 0; }
.loot-info strong { font-size: 14px; line-height: 1.28; }
.loot-info small { font-size: 12px; color: #534862; }
.full-collection { max-width: 920px; margin: auto; }
.full-collection .loot { flex-direction: column; align-items: stretch; padding: 11px; }
.full-collection .loot-art { width: 100%; height: 114px; }
.full-collection .loot-art canvas { width: 100px; height: 100px; }
.full-collection .loot-info { padding: 4px 2px; gap: 6px; }
.full-collection .loot-info strong { font-size: 17px; }
.full-collection .loot-info small, .drop-note { font-size: 14px; }
.drop-note { color: var(--muted); margin: 16px 0 1px; }
.history-card { max-width: 850px; margin: auto; }
.empty { margin: 0; color: var(--muted); padding: 35px 10px; text-align: center; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid #eadff2; }
.history-row:last-child { border-bottom: 0; }
.history-row div { display: grid; gap: 4px; }
.history-row small { color: var(--muted); font-size: 13px; }
.history-row > span { text-align: right; }
footer { display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--muted); padding: 20px 0 16px; font-size: 13px; text-align: center; }
footer i { width: 15px; height: 15px; }
.result { width: min(380px, calc(100% - 34px)); padding: 20px; border: var(--outline); border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); color: var(--ink); background: var(--card); text-align: center; }
.result::backdrop { background: #2c193b8a; }
.result-art { --loot-bg: #e9ddff; --loot-edge: #d1b9f4; display: grid; place-items: center; border: 1px solid var(--loot-edge); border-radius: 12px; background: var(--loot-bg); }
.result-art canvas { width: 116px; height: 116px; }
.result h2 { margin: 14px 0 8px; }
.result p { color: var(--muted); margin: 0 0 14px; }
.result .button { width: 100%; }
@media (max-width: 760px) {
  .shell { padding: 26px 17px 0; }
  .topbar-inner { padding: 10px 17px; gap: 12px; grid-template-columns: 1fr 1fr; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .nav button { flex: 1; justify-content: center; }
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto; }
  .loot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 510px) {
  .side { grid-template-columns: minmax(0, 1fr); }
  .stage { height: 234px; }
  .mascot { width: 174px; height: 174px; bottom: 25px; }
  .twinkles i:nth-child(1) { left: 17%; }
  .twinkles i:nth-child(3) { right: 15%; }
  .twinkles i:nth-child(5) { display: none; }
  .card { padding: 14px; }
  .intro { margin-bottom: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .mascot canvas, .stage[data-state="active"] .mascot canvas { animation: none; }
  .button { transition: none; }
}
