:root { --bg: #1c1e2e; --panel: #262a40; --ink: #f4f4f4; --soft: #9aa3c7; --red: #e5484d; --blue: #4c8fe0; --gold: #f5c542;
  --sab: env(safe-area-inset-bottom, 0px); font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

#homeLink { position: fixed; z-index: 4; left: calc(8px + env(safe-area-inset-left, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); width: 38px; height: 38px;
  border-radius: 50%; background: #0009; box-shadow: 0 0 0 2px #ffffff40; display: grid; place-items: center; color: #fff; }
#homeLink:active { scale: .92; }
#homeLink svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#app { height: 100%; display: flex; flex-direction: column; align-items: center; }
#stage { position: relative; flex: 1; min-height: 0; aspect-ratio: 135 / 240; max-width: 100%; }
#cv { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#title { position: absolute; left: 50px; right: 50px; top: 1.5%; height: 10%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-weight: 900; line-height: 1.15; font-size: clamp(13px, 4.6cqw, 34px); text-shadow: 0 2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 0 -2px 0 #000; pointer-events: none; }
#stage { container-type: inline-size; }
#title em { font-style: normal; color: var(--gold); }
#result { position: absolute; left: 0; right: 0; top: 42%; text-align: center; font-weight: 900; font-size: clamp(28px, 13cqw, 90px);
  text-shadow: 0 3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 -3px 0 #fff; pointer-events: none; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
#result small { display: block; font-size: 38%; color: #fff; text-shadow: 0 2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 0 -2px 0 #000; margin-top: 2%; }
#result.red { color: var(--red); } #result.blue { color: var(--blue); } #result.draw { color: #666; }
@keyframes pop { from { scale: .3; opacity: 0; } }
#topbar { position: absolute; left: 3%; right: 3%; bottom: 2.5%; display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
#topbar #btnBack { margin-right: auto; }
.pill { padding: 5px 11px; border-radius: 99px; background: #0008; font-size: 13px; font-weight: 700; }
#coins::before { content: "● "; color: var(--gold); }

#panel { width: min(100%, 520px); padding: 8px 10px calc(10px + var(--sab)); background: var(--panel); border-radius: 16px 16px 0 0; }
.view { display: flex; flex-direction: column; gap: 8px; }
.two { display: flex; gap: 8px; } .two > * { flex: 1; }
.big { height: 50px; border-radius: 12px; background: #3a4062; font-size: 18px; font-weight: 800; box-shadow: 0 4px 0 #0006; }
.big:active, .tab:active, .card button:active { translate: 0 2px; box-shadow: none; }
.big.red { background: var(--red); } .big.blue { background: var(--blue); } .big.gold { background: var(--gold); color: #3a2a00; }
.big:disabled { opacity: .45; }
.big.picked { outline: 3px solid #fff; }
.note { margin: 0; text-align: center; font-size: 13px; color: var(--soft); min-height: 18px; }

#ver { opacity: .6; margin-left: 6px; }
.tabs { display: flex; gap: 6px; }
.tab { flex: 1; height: 34px; border-radius: 10px; background: #3a4062; font-size: 13px; font-weight: 700; opacity: .7; }
.tab.on { opacity: 1; outline: 2px solid #fff; } .tab.red { background: var(--red); } .tab.blue { background: var(--blue); }
.strip { display: flex; align-items: stretch; gap: 4px; }
.arrow { flex: 0 0 30px; border-radius: 10px; background: #3a4062; font-size: 24px; font-weight: 800; line-height: 1; }
.arrow:active { translate: 0 2px; }
.arrow:disabled { opacity: .25; }
#cards { flex: 1; min-width: 0; cursor: grab; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; touch-action: pan-x; }
#cards::-webkit-scrollbar, #infoCards::-webkit-scrollbar { display: none; }
.card.has { outline: 2px solid var(--gold); outline-offset: -2px; }
.card { flex: 0 0 76px; background: #1c1e2e; border-radius: 10px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; }
.card canvas { width: 52px; height: 52px; image-rendering: pixelated; }
.card .n { font-size: 16px; font-weight: 800; }
.card .pm { display: flex; gap: 4px; } .card .pm button { width: 30px; height: 28px; border-radius: 8px; background: #3a4062; font-weight: 800; font-size: 16px; }
.card.locked canvas { filter: brightness(0); opacity: .6; }
.card .buy { width: 64px; height: 28px; border-radius: 8px; background: var(--gold); color: #3a2a00; font-weight: 800; font-size: 12px; }
.card .buy:disabled { background: #3a4062; color: var(--soft); }

#info { position: fixed; inset: 0; z-index: 5; background: #0b0d18d9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
#infoCards { display: flex; gap: 10px; max-width: 100%; overflow-x: auto; touch-action: pan-x; padding-bottom: 4px; scrollbar-width: none; }
.mon { flex: 0 0 min(300px, 82vw); background: var(--panel); border-radius: 16px; padding: 14px; border-top: 5px solid #3a4062; }
.mon.red { border-top-color: var(--red); } .mon.blue { border-top-color: var(--blue); }
.mon .head { display: flex; align-items: center; gap: 10px; } .mon .head img { width: 78px; height: 78px; image-rendering: pixelated; }
.mon h3 { margin: 0; font-size: 20px; } .mon .kind { font-size: 12px; color: var(--gold); font-weight: 700; }
.mon dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; text-align: center; }
.mon dl div { background: #1c1e2e; border-radius: 8px; padding: 5px 2px; } .mon dt { font-size: 11px; color: var(--soft); } .mon dd { margin: 0; font-weight: 800; font-size: 15px; }
.mon p { margin: 0; font-size: 13px; line-height: 1.5; color: #d5dbf5; }
#infoClose { width: min(300px, 82vw); flex: none; }
.card canvas, .card .nm { cursor: pointer; }

@media (min-aspect-ratio: 1/1) {
  #app { flex-direction: row; justify-content: center; align-items: stretch; gap: 12px; }
  #stage { flex: none; height: 100%; }
  #panel { align-self: center; border-radius: 16px; width: 420px; }
}
