:root {
  --bg: #050718;
  --panel: rgba(12, 18, 47, .72);
  --line: rgba(133, 165, 255, .16);
  --text: #f7f6ff;
  --muted: #8e99bd;
  --cyan: #4deaff;
  --violet: #8d6bff;
  --magenta: #eb65ff;
  --gold: #e7c77d;
  --danger: #ff80a2;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--text); background: radial-gradient(circle at 50% 45%, #101a44 0%, #080b24 36%, var(--bg) 78%); overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

#starCanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .82; }
.cosmic-glow { position: fixed; width: 470px; height: 470px; border-radius: 50%; filter: blur(125px); pointer-events: none; opacity: .14; }
.glow-a { left: -210px; top: 22%; background: #6d3dff; }
.glow-b { right: -220px; bottom: -100px; background: #00d8ff; }

.app-shell { min-height: 100vh; position: relative; z-index: 1; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  min-height: 84px; padding: 14px clamp(20px, 3vw, 54px); display: flex; align-items: center; gap: 15px;
  border-bottom: 1px solid var(--line); background: rgba(4, 7, 22, .7); backdrop-filter: blur(18px);
}
.brand-seal { width: 48px; height: 48px; display: grid; place-items: center; position: relative; border: 1px solid rgba(231,199,125,.48); border-radius: 50%; color: var(--gold); background: radial-gradient(circle, rgba(222,195,124,.16), transparent 66%); box-shadow: 0 0 24px rgba(195,158,82,.16); }
.brand-seal::before, .brand-seal::after { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(231,199,125,.22); transform: rotate(45deg); }
.brand-seal span { z-index: 1; font-size: 22px; text-shadow: 0 0 16px var(--gold); }
.title-block { min-width: 0; }
.title-block p { margin: 0 0 3px; color: #7889be; font-size: 11px; letter-spacing: .1em; }
h1 { margin: 0; font-size: clamp(22px, 2vw, 31px); line-height: 1.12; letter-spacing: .08em; }
.header-count { margin-left: clamp(10px, 3vw, 54px); padding-left: clamp(12px, 2.3vw, 38px); border-left: 1px solid var(--line); }
.header-count span, .header-count strong { display: block; }
.header-count span { color: var(--muted); font-size: 10px; margin-bottom: 2px; }
.header-count strong { color: #d9e3ff; font-size: 14px; }
.header-count b { color: var(--cyan); font-size: 24px; line-height: 1; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.sound-button, .button, .text-button { border: 0; color: var(--text); cursor: pointer; transition: transform .18s ease, filter .18s ease, background .18s ease; }
.sound-button { min-height: 43px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); color: #c1c9e2; }
.sound-button[aria-pressed="false"] { color: #697493; }
.button { min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 700; }
.button-primary { background: linear-gradient(125deg, #6652dc, #347ee5 58%, #16b6c8); box-shadow: 0 8px 24px rgba(65,102,231,.23); }
.button-glass { background: rgba(255,255,255,.055); border: 1px solid rgba(164,183,255,.15); }
.button:hover, .sound-button:hover, .text-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.button:active, .sound-button:active, .text-button:active { transform: translateY(1px); }
.button:focus-visible, .sound-button:focus-visible, .text-button:focus-visible, .main-action:focus-visible { outline: 3px solid rgba(77,234,255,.35); outline-offset: 3px; }

main { width: min(1720px, 100%); margin: 0 auto; padding: 0 clamp(16px, 3vw, 52px); min-width: 0; }
.status-strip { min-height: 64px; display: flex; align-items: center; gap: 22px; border-bottom: 1px solid rgba(141,162,225,.09); }
.status-item { display: flex; align-items: center; gap: 8px; color: #9da9ca; font-size: 11px; }
.sample-status { color: #e5c78a; }
.sample-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 11px var(--gold); }
.privacy { color: #66769b; }
.privacy > span:first-child { color: #7c91c6; font-size: 16px; }
.status-actions { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.switch-label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-label > span b, .switch-label > span small { display: block; }
.switch-label b { font-size: 12px; }
.switch-label small { color: #68789e; font-size: 9px; margin-top: 2px; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch-label > i { width: 43px; height: 24px; border-radius: 99px; background: #202a48; position: relative; transition: .2s; box-shadow: inset 0 2px 5px rgba(0,0,0,.35); }
.switch-label > i::after { content: ""; width: 18px; height: 18px; position: absolute; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch-label input:checked + i { background: linear-gradient(90deg, #765be7, #29c6da); }
.switch-label input:checked + i::after { transform: translateX(19px); }
.switch-label input:focus-visible + i { outline: 3px solid rgba(77,234,255,.3); outline-offset: 3px; }
.round-count { padding-left: 18px; border-left: 1px solid var(--line); }
.round-count span { display: block; color: var(--muted); font-size: 9px; }
.round-count strong { font-size: 12px; }
.round-count b { color: #dcceff; font-size: 19px; }
.text-button { min-height: 34px; padding: 0 11px; border-radius: 9px; background: rgba(255,255,255,.035); border: 1px solid var(--line); color: #a7b1cf; font-size: 11px; }

.deck-section { display: flex; flex-direction: column; align-items: center; padding-top: 8px; min-width: 0; }
.section-heading { height: 27px; display: flex; align-items: center; justify-content: center; gap: 11px; color: #7488c1; font-size: 10px; letter-spacing: .14em; }
.section-heading p { margin: 0; }
.section-heading span { width: 38px; height: 1px; background: linear-gradient(90deg, transparent, #697eb6); }
.section-heading span:last-child { transform: scaleX(-1); }

.deck-arena {
  width: min(1180px, 100%); height: clamp(370px, 55vh, 590px); position: relative; display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(119,144,225,.12); border-radius: 28px;
  background: radial-gradient(ellipse at center, rgba(62,76,161,.13), transparent 57%), linear-gradient(145deg, rgba(12,17,50,.48), rgba(6,9,29,.4));
  box-shadow: inset 0 1px rgba(255,255,255,.03), 0 30px 80px rgba(0,0,0,.2);
  perspective: 1400px;
}
.deck-arena::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(179,153,255,.06); border-radius: 21px; pointer-events: none; }
.deck-arena::after { content: "✦"; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 270px; color: rgba(135,109,255,.025); pointer-events: none; }
.energy-ring { position: absolute; left: 50%; top: 50%; border-radius: 50%; pointer-events: none; border: 1px solid rgba(100,180,255,.09); }
.ring-one { width: 70%; height: 70%; transform: translate(-50%,-50%); }
.ring-two { width: 48%; height: 48%; transform: translate(-50%,-50%) rotate(45deg); border-color: rgba(231,199,125,.07); border-radius: 24%; }

.deck-grid {
  width: min(1040px, 94%); max-height: 92%; display: grid; grid-template-columns: repeat(var(--columns, 9), minmax(0, 1fr)); gap: var(--gap, 10px);
  justify-items: center; align-items: center; position: relative; z-index: 2; transform-style: preserve-3d;
}
.mystic-card {
  width: var(--card-width, 88px); aspect-ratio: .64; position: relative; border-radius: calc(var(--card-width, 88px) * .105);
  perspective: 900px; transform-style: preserve-3d; transition: opacity .55s ease, filter .55s ease, transform .8s cubic-bezier(.2,.8,.18,1), left .8s cubic-bezier(.2,.8,.18,1), top .8s cubic-bezier(.2,.8,.18,1);
  will-change: transform; z-index: 2;
}
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.05s cubic-bezier(.16,.82,.17,1); }
.card-face { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-back {
  display: grid; place-items: center; background: linear-gradient(145deg, #181741, #101839 48%, #13102f); border: 1px solid rgba(231,199,125,.58);
  box-shadow: inset 0 0 0 3px rgba(5,8,24,.8), inset 0 0 0 4px rgba(231,199,125,.16), inset 0 0 28px rgba(79,79,196,.25), 0 9px 18px rgba(0,0,0,.3);
}
.card-back::before { content: ""; position: absolute; inset: 9%; border: 1px solid rgba(231,199,125,.32); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.card-back::after { content: ""; width: 34%; aspect-ratio: 1; border: 1px solid rgba(231,199,125,.5); border-radius: 50%; box-shadow: 0 0 0 5px rgba(129,93,255,.08), 0 0 20px rgba(112,85,255,.22); }
.back-symbol { position: relative; z-index: 1; color: var(--gold); font-size: calc(var(--card-width, 88px) * .22); text-shadow: 0 0 12px rgba(231,199,125,.6); }
.corner-mark { position: absolute; color: rgba(231,199,125,.55); font-size: calc(var(--card-width, 88px) * .09); }
.corner-mark.tl { left: 8%; top: 5%; }
.corner-mark.br { right: 8%; bottom: 5%; transform: rotate(180deg); }
.card-front {
  transform: rotateY(180deg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10%;
  background: radial-gradient(circle at 50% 30%, rgba(89,224,255,.24), transparent 34%), linear-gradient(155deg, #1b2e64, #171541 58%, #281342);
  border: 1px solid rgba(108,238,255,.85); box-shadow: inset 0 0 0 3px rgba(6,10,32,.66), inset 0 0 30px rgba(114,84,255,.42), 0 0 30px rgba(56,197,255,.35);
}
.front-symbol { font-size: calc(var(--card-width, 88px) * .29); color: #ffe8a0; text-shadow: 0 0 20px rgba(255,216,105,.75); margin-bottom: 8%; }
.card-front b { width: 100%; color: #fff; font-size: clamp(10px, calc(var(--card-width, 88px) * .155), 24px); line-height: 1.25; overflow-wrap: anywhere; text-shadow: 0 3px 9px rgba(0,0,0,.55); }
.card-front small { position: absolute; bottom: 7%; color: #8defff; font-size: calc(var(--card-width, 88px) * .065); letter-spacing: .12em; }

.deck-grid.is-shuffling .mystic-card { animation: shuffleCard .78s ease-in-out infinite alternate; animation-delay: var(--delay); }
.deck-grid.is-shuffling .mystic-card:nth-child(3n) { animation-name: shuffleCardAlt; }
.deck-grid.is-shuffling .card-back { box-shadow: inset 0 0 0 3px rgba(5,8,24,.8), inset 0 0 0 4px rgba(231,199,125,.18), 0 0 23px rgba(91,104,255,.35); }
.deck-grid.is-revealing .mystic-card:not(.is-winner) { opacity: .16; filter: saturate(.3) blur(.5px); transform: scale(.82) translateZ(-100px); }
.mystic-card.is-winner { position: fixed; z-index: 20; filter: drop-shadow(0 0 35px rgba(88,223,255,.55)); }
.mystic-card.is-winner .card-inner { transform: rotateY(180deg); }
.mystic-card.is-winner::before { content: ""; position: absolute; inset: -20%; border: 1px solid rgba(81,227,255,.25); border-radius: 50%; animation: winnerAura 2.2s ease-in-out infinite; pointer-events: none; }
.mystic-card.is-winner::after { content: ""; position: absolute; inset: -8%; border: 1px solid rgba(231,199,125,.32); border-radius: 16px; animation: winnerAura 2.2s .35s ease-in-out infinite; pointer-events: none; }

.result-console { position: absolute; left: 50%; bottom: 11px; transform: translateX(-50%); z-index: 25; width: min(720px, 92%); text-align: center; animation: consoleUp .55s ease both; }
.result-console[hidden] { display: none; }
.destiny-label { margin: 0 0 2px; color: #69eaff; font-size: 9px; letter-spacing: .18em; }
.result-console h2 { margin: 0; font-size: clamp(25px, 3.2vw, 46px); line-height: 1.2; background: linear-gradient(180deg, white, #a9eaff); color: transparent; background-clip: text; }
.blessing { margin: 2px 0 10px; color: #efd38e; font-size: clamp(14px, 1.5vw, 20px); font-weight: 700; }
.result-actions { display: flex; justify-content: center; gap: 8px; }
.result-actions .button { min-height: 38px; padding-inline: 14px; font-size: 11px; }

.performance-note { min-height: 22px; margin-top: 4px; display: flex; align-items: center; gap: 7px; color: #6e7ca4; font-size: 10px; }
.performance-note[hidden] { visibility: hidden; display: flex; }
.performance-note > span:first-child { color: #9d82ef; }
.main-action-wrap { width: min(430px, 94%); margin-top: 4px; }
.main-action {
  width: 100%; min-height: 66px; padding: 8px 18px; display: grid; grid-template-columns: 43px 1fr 28px; align-items: center;
  border: 1px solid rgba(127,211,255,.5); border-radius: 18px; color: white; cursor: pointer;
  background: linear-gradient(120deg, #4736b6, #644ee2 43%, #237eb8 100%);
  box-shadow: 0 12px 34px rgba(69,64,197,.28), inset 0 1px rgba(255,255,255,.24), 0 0 0 5px rgba(91,86,231,.06);
  transition: transform .2s ease, filter .2s ease, background .25s ease;
}
.main-action:hover { transform: translateY(-2px); filter: brightness(1.1); }
.main-action:active { transform: translateY(1px) scale(.99); }
.main-action.is-shuffling { background: linear-gradient(120deg, #9d3f99, #704ee1 45%, #1e9cb9); }
.main-action:disabled { cursor: wait; filter: saturate(.6); }
.action-icon { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: #ffe9a9; text-shadow: 0 0 12px #ffd672; }
.action-copy { text-align: left; }
.action-copy b, .action-copy small { display: block; }
.action-copy b { font-size: 18px; }
.action-copy small { font-size: 9px; opacity: .72; margin-top: 2px; }
.action-arrow { font-size: 21px; opacity: .8; }

footer { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 8px 4vw 12px; color: #586689; font-size: 10px; letter-spacing: .04em; }
footer p { margin: 0; }
footer span { color: #3e4a6c; font-size: 8px; letter-spacing: .16em; }
.toast { position: fixed; left: 50%; bottom: 27px; z-index: 90; transform: translate(-50%,20px); opacity: 0; pointer-events: none; max-width: min(500px,88vw); padding: 12px 18px; border-radius: 12px; background: rgba(17,23,58,.96); border: 1px solid rgba(80,219,255,.3); box-shadow: 0 15px 40px rgba(0,0,0,.4); text-align: center; font-size: 13px; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { color: #ffd3de; border-color: rgba(255,92,133,.4); }

@keyframes shuffleCard {
  0% { transform: translate3d(0,0,0) rotate(0) scale(1); z-index: 1; }
  45% { transform: translate3d(var(--sx),var(--sy),35px) rotate(var(--sr)) scale(1.06); z-index: 5; }
  100% { transform: translate3d(var(--sx2),var(--sy2),0) rotate(var(--sr2)) scale(.96); z-index: 2; }
}
@keyframes shuffleCardAlt {
  0% { transform: translate3d(0,0,0) rotate(0); }
  50% { transform: translate3d(var(--sx3),var(--sy),55px) rotate(var(--sr3)); }
  100% { transform: translate3d(var(--sx),var(--sy3),0) rotate(var(--sr)); }
}
@keyframes winnerAura { 0%,100% { opacity: .28; transform: scale(.93) rotate(0); } 50% { opacity: .8; transform: scale(1.08) rotate(12deg); } }
@keyframes consoleUp { from { opacity: 0; transform: translate(-50%,18px); } }

@media (max-width: 1050px) {
  .status-strip { flex-wrap: wrap; gap: 8px 18px; padding-block: 7px; }
  .status-actions { width: 100%; justify-content: flex-end; }
  .deck-arena { height: clamp(380px, 54vh, 530px); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 12px 15px; }
  .brand-seal { width: 42px; height: 42px; }
  .title-block p { font-size: 8px; }
  h1 { font-size: 20px; }
  .header-count { margin-left: auto; }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1; }
  .status-strip { align-items: flex-start; }
  .privacy { display: none; }
  .status-actions { justify-content: space-between; gap: 8px; }
  .switch-label > span small { display: none; }
  .round-count { padding-left: 8px; }
  .deck-arena { height: 470px; border-radius: 20px; }
  .result-actions { flex-wrap: wrap; }
  .result-actions .button { flex: 1; min-width: 120px; }
  footer { flex-direction: column; gap: 3px; text-align: center; }
}
@media (max-width: 470px) {
  .header-count { display: none; }
  main { padding-inline: 10px; }
  .status-actions { flex-wrap: wrap; }
  .switch-label { flex: 1; }
  .deck-arena { height: 440px; }
  .main-action { min-height: 61px; }
  .result-console h2 { font-size: 28px; }
}
@media (max-height: 790px) and (min-width: 761px) {
  .topbar { min-height: 69px; padding-block: 9px; }
  .brand-seal { width: 42px; height: 42px; }
  .status-strip { min-height: 50px; }
  .deck-arena { height: min(52vh, 430px); }
  .main-action { min-height: 59px; }
  .main-action-wrap { margin-top: 1px; }
  footer { min-height: 30px; padding-block: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
