:root {
  --bg1: #0b1430; --bg2: #24103f; --gold: #ffd36b; --ink: #1d2233; --panel: rgba(16, 22, 48, .78);
  --line: rgba(255, 255, 255, .14); --txt: #eef2ff; --mute: #9aa6c8; --red: #ff5a5a; --green: #45d98a; --blue: #5aa9ff;
  --cardw: 112px; --cardh: 156px;
  --thick: 0 1px 0 #e4dccb, 0 2px 0 #cfc5ae, 0 3px 0 #b8ad93, 0 4px 0 #9c9178;
  --thick-back: 0 1px 0 #e9e1ca, 0 2px 0 #d3c8aa, 0 3px 0 #b9ad8c, 0 4px 0 #9b8f6e;
}
.ic { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.28em; line-height: 0; }
.ic svg { width: 100%; height: 100%; display: block; overflow: visible; }
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050816; color: var(--txt);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif; }
button { font-family: inherit; cursor: pointer; }

#viewport { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1b2a66 0%, var(--bg1) 45%, #04060f 100%); }
#stage { position: relative; flex-shrink: 0; width: 1280px; height: 800px; transform-origin: center center; overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(120, 90, 255, .25), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(255, 120, 80, .18), transparent 45%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
#stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255, 255, 255, .5) 1px, transparent 1.4px); background-size: 38px 38px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }

/* ---------- 頂部列 ---------- */
#topbar { position: absolute; left: 0; right: 0; top: 0; height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .45), transparent); z-index: 20; }
#topbar .logo { font-weight: 900; font-size: 19px; letter-spacing: 1px; background: linear-gradient(90deg, #ffe58a, #ff9b6b, #ff6bd0);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 6px rgba(255, 150, 80, .4)); }
#topbar .info { color: var(--mute); font-size: 13px; margin-left: 8px; }
#topbar .sp { flex: 1; }
.tbtn { background: rgba(255, 255, 255, .08); color: var(--txt); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; font-size: 13px; }
.tbtn:hover { background: rgba(255, 255, 255, .16); }

/* ---------- 桌面 ---------- */
#table { position: absolute; left: 150px; top: 70px; width: 980px; height: 520px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 45%, #1f6b5a 0%, #134a43 55%, #0b2d2c 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .55), 0 0 0 10px #3a2614, 0 0 0 14px #5b3c1e, 0 20px 50px rgba(0, 0, 0, .55); }
#table::after { content: ""; position: absolute; inset: 26px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .12); }

/* 中央 */
#center { position: absolute; left: 470px; top: 215px; width: 340px; height: 200px; z-index: 5; }
.pile { position: absolute; width: var(--cardw); height: var(--cardh); }
#deckPile { left: 30px; top: 10px; }
#discardPile { left: 196px; top: 10px; }
.pile .cnt { position: absolute; bottom: -24px; left: 0; right: 0; text-align: center; font-size: 12px; color: #cfe; text-shadow: 0 1px 2px #000; }
.pile .stack { position: absolute; inset: 0; }
.pile .stack .back { position: absolute; inset: 0; }
.pile.empty { border: 2px dashed rgba(255, 255, 255, .25); border-radius: 10px; }
#weatherBox { position: absolute; left: 148px; top: 52px; width: 44px; height: 70px; text-align: center; font-size: 26px; }
#weatherBox small { display: block; font-size: 11px; color: #cfe; }
#phaseBox { position: absolute; left: 0; right: 0; top: 190px; text-align: center; font-size: 13px; color: #d8fff0; text-shadow: 0 1px 3px #000; }

#ticker { position: absolute; left: 400px; top: 455px; width: 480px; height: 64px; overflow: hidden; z-index: 6;
  font-size: 12.5px; line-height: 16px; color: #e8fff7; text-align: center; text-shadow: 0 1px 2px #000;
  mask-image: linear-gradient(180deg, transparent 0%, #000 35%); }
#ticker div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 座位 ---------- */
.seat { position: absolute; width: 214px; transform: translate(-50%, -50%); z-index: 8; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 7px 8px 8px; backdrop-filter: blur(6px); transition: box-shadow .3s, opacity .4s; }
.seat.turn { box-shadow: 0 0 0 2px var(--gold), 0 0 26px rgba(255, 211, 107, .6); }
.seat.dead { opacity: .55; filter: grayscale(.7); }
.seat.targetable { box-shadow: 0 0 0 3px #6ff, 0 0 24px #6ff; cursor: pointer; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px #6ff, 0 0 8px #6ff; } }
.seat-head { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; margin-bottom: 5px; }
.seat-head .ava { font-size: 20px; line-height: 0; }
.seat-head .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbadge { font-size: 11.5px; padding: 2px 7px; border-radius: 999px; background: #39415e; color: #fff; white-space: nowrap; }
.rbadge.leader { background: linear-gradient(90deg, #ff6a4d, #e8553e); }
.rbadge.guard { background: linear-gradient(90deg, #f6c64a, #d9a21f); color: #3b2a00; }
.rbadge.challenger { background: linear-gradient(90deg, #8b9db0, #5d6d80); }
.rbadge.rocket { background: linear-gradient(90deg, #44445a, #1d1d29); border: 1px solid #b33; }
.rbadge.unk { background: #2d3350; color: #aab; }
.seat-body { display: flex; gap: 6px; align-items: stretch; }
.seat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; font-size: 12px; color: var(--mute); }
.handbacks { display: flex; align-items: center; }
.handbacks i { display: inline-block; width: 12px; height: 17px; margin-left: -4px; border-radius: 2px; border: 1px solid #fff8;
  background: var(--back-card) center/100% 100%; box-shadow: 0 1px 0 #d8cfb6, 0 2px 3px #0008; }
.handbacks b { margin-left: 6px; color: #fff; }

/* 迷你靈獸 */
.mini { position: relative; flex: 1; border-radius: 10px; padding: 4px 6px 5px; color: #fff; cursor: pointer; min-height: 74px; overflow: hidden;
  background: linear-gradient(160deg, var(--e1), var(--e2)); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); }
.mini.benchm { flex: 0 0 66px; opacity: .9; }
.mini .mm-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #0009; }
.mini .mm-art { height: 46px; display: flex; justify-content: center; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.mini.benchm .mm-art { height: 34px; }
.mini .mm-art svg { height: 100%; width: auto; }
.mini .mm-name { font-size: 11px; text-align: center; font-weight: 700; text-shadow: 0 1px 2px #000a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mm-icons { position: absolute; right: 3px; top: 16px; display: flex; flex-direction: column; gap: 1px; font-size: 12px; }
.mini.fainted { filter: grayscale(1) brightness(.6); }
.mini.fainted::after { content: "昏厥"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; color: #fff; background: rgba(0, 0, 0, .45); }
.mini.facedown { background: var(--back-mon) center/auto 94% no-repeat, linear-gradient(160deg, #1d6f5c, #0f4a3c); }
.mini.facedown > * { visibility: hidden; }
.hpbar { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .45); overflow: hidden; margin-top: 3px; }
.hpbar > div { height: 100%; background: linear-gradient(90deg, #5cf08f, #2bc46b); transition: width .4s; }
.hpbar.mid > div { background: linear-gradient(90deg, #ffd35c, #f3a623); }
.hpbar.low > div { background: linear-gradient(90deg, #ff6b6b, #e23b3b); }
.hptxt { font-size: 10.5px; text-align: center; margin-top: 1px; text-shadow: 0 1px 2px #000; }

/* ---------- 玩家區 ---------- */
#me { position: absolute; left: 0; right: 0; bottom: 0; height: 238px; z-index: 12; }
#meInfo { position: absolute; left: 14px; bottom: 14px; width: 150px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
#meInfo .who { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; }
#meInfo .rolecard { margin-top: 8px; border-radius: 10px; padding: 8px; cursor: pointer; text-align: center; font-weight: 800; font-size: 15px; }
#meInfo .rolecard small { display: block; font-weight: 400; font-size: 11px; margin-top: 4px; opacity: .9; line-height: 1.35; }
#meInfo .status { margin-top: 8px; font-size: 12px; color: var(--mute); line-height: 1.5; }
#meInfo.turn { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(255, 211, 107, .55); }
#meInfo.targetable { box-shadow: 0 0 0 3px #6ff, 0 0 24px #6ff; }

#meMons { position: absolute; left: 176px; bottom: 10px; display: flex; gap: 10px; align-items: flex-end; }
#hand { position: absolute; left: 560px; right: 150px; bottom: 12px; height: 200px; }
#hand .pcard { position: absolute; bottom: 0; transition: transform .18s, box-shadow .18s; cursor: pointer; }
#hand .pcard:hover { transform: translateY(-26px) scale(1.06) !important; z-index: 50; box-shadow: inset 0 0 0 3px #d8d2c4, var(--thick), 0 18px 26px rgba(0, 0, 0, .5); }
#hand .pcard.sel { transform: translateY(-30px) !important; box-shadow: 0 0 0 3px #6ff, 0 0 20px #6ff; }
#actions { position: absolute; right: 14px; bottom: 14px; width: 126px; display: flex; flex-direction: column; gap: 8px; }
.abtn { border: none; border-radius: 14px; padding: 12px 8px; font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(180deg, #4b8cff, #2a5bd8); box-shadow: 0 4px 0 #1b3a8f, 0 8px 18px rgba(0, 0, 0, .4); }
.abtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b3a8f; }
.abtn.end { background: linear-gradient(180deg, #ff8a4c, #e5532b); box-shadow: 0 4px 0 #9b3014, 0 8px 18px rgba(0, 0, 0, .4); }
.abtn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.abtn.small { padding: 8px 6px; font-size: 13px; }
#phaseTip { font-size: 12px; color: var(--mute); text-align: center; line-height: 1.4; }

/* ---------- 遊戲卡 ---------- */
.pcard { width: var(--cardw); height: var(--cardh); border-radius: 10px; position: relative; overflow: hidden; color: #222;
  background: #f7f4ee; box-shadow: inset 0 0 0 3px #d8d2c4, var(--thick), 0 8px 16px rgba(0, 0, 0, .45); }
.pcard .pc-art { position: absolute; left: 6px; right: 6px; top: 6px; height: 88px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .15); }
.pcard .pc-art svg { width: 100%; height: 100%; display: block; }
.pcard .pc-w { position: absolute; left: 4px; top: 4px; z-index: 3; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.pcard .pc-name { position: absolute; left: 5px; right: 5px; top: 98px; text-align: center; font-weight: 900; font-size: 13px; padding: 3px 2px; border-radius: 5px;
  background: linear-gradient(180deg, #fff, #e9e4da); box-shadow: inset 0 0 0 1px #bbb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .pc-kind { position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%); font-size: 10px; color: #fff; background: #333; padding: 1px 9px; border-radius: 999px; }
.pcard .pc-text { display: none; }
.pcard.k-atk .pc-name { color: #c4261a; font-size: 16px; }
.pcard.k-dodge .pc-name { color: #13805a; font-size: 16px; }
.pcard.k-event .pc-kind { background: #3c4fa8; } .pcard.k-item .pc-kind { background: #8a3fb0; } .pcard.k-tool .pc-kind { background: #6b6b2a; }
.pcard.k-atk .pc-kind { background: #c4261a; } .pcard.k-dodge .pc-kind { background: #13805a; }
.pcard.big { --cardw: 230px; --cardh: 322px; }
.pcard.big .pc-art { height: 170px; }
.pcard.big .pc-w { width: 42px; height: 42px; font-size: 26px; }
.pcard.big .pc-name { top: 182px; font-size: 19px; }
.pcard.big .pc-text { display: block; position: absolute; left: 10px; right: 10px; top: 216px; bottom: 26px; font-size: 12.5px; line-height: 1.45; color: #333; overflow: auto; }
.pcard.big .pc-kind { font-size: 12px; }

/* 卡背 */
.back { width: var(--cardw); height: var(--cardh); border-radius: 10px; position: relative;
  background: var(--back-card) center/100% 100%; box-shadow: var(--thick-back), 0 7px 12px rgba(0, 0, 0, .45); }
.back::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .22) 45%, transparent 60%); }
.back.mon { background-image: var(--back-mon); }
.back.role { background-image: var(--back-role); }
/* 牌堆厚度 */
.pile .edge { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0 0 10px 10px;
  background: repeating-linear-gradient(180deg, #efe7d2 0 1px, #b9ae92 1px 2px); box-shadow: 0 6px 12px rgba(0, 0, 0, .45); }

/* 靈獸大卡 */
.mcard { width: 186px; height: 222px; border-radius: 14px; position: relative; overflow: hidden; color: #fff; padding: 6px;
  background: linear-gradient(160deg, var(--e1), var(--e2)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55), var(--thick), 0 10px 20px rgba(0, 0, 0, .5); }
.mcard .mc-top { display: flex; align-items: center; gap: 5px; font-weight: 900; }
.mcard .mc-hp { background: #fff; color: #d62e2e; border-radius: 999px; padding: 0 7px; font-size: 13px; box-shadow: 0 1px 3px #0006; }
.mcard .mc-name { flex: 1; font-size: 14.5px; text-shadow: 0 1px 3px #000a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard .mc-lv { font-size: 12px; text-shadow: 0 1px 3px #000a; }
.mcard .mc-art { height: 92px; margin: 4px 0; border-radius: 8px; position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7), 0 2px 0 rgba(0, 0, 0, .2); background: #fff; }
.mcard .mc-art svg.art { width: 100%; height: 100%; display: block; }
.mcard .mc-icons { position: absolute; right: 4px; top: 4px; display: flex; gap: 2px; font-size: 15px; z-index: 2; }
.mcard .mc-type { position: absolute; left: 9px; top: 33px; z-index: 2; font-size: 10px; background: rgba(0, 0, 0, .45); padding: 1px 6px; border-radius: 999px; }
.mcard .mc-ab { font-size: 10.5px; line-height: 1.35; background: rgba(255, 255, 255, .92); color: #222; border-radius: 7px; padding: 3px 5px; max-height: 44px; overflow: hidden; }
.mcard .mc-ab b { color: #7a3ad1; }
.mcard .mc-moves { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.mvbtn { display: flex; align-items: center; gap: 4px; width: 100%; border: none; border-radius: 8px; padding: 4px 6px; font-weight: 800; font-size: 12.5px; text-align: left;
  background: rgba(255, 255, 255, .95); color: #222; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.mvbtn .cost { font-size: 13px; }
.mvbtn .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mvbtn .dmg { color: #d62e2e; font-weight: 900; }
.mvbtn.ok { background: linear-gradient(180deg, #fffbe0, #ffe48a); box-shadow: 0 0 0 2px #ffcf3a, 0 2px 0 rgba(0, 0, 0, .25); animation: glow 1.4s infinite; }
.mvbtn:disabled { opacity: .7; cursor: default; }
@keyframes glow { 50% { box-shadow: 0 0 0 2px #fff3b0, 0 0 12px #ffcf3a; } }
.mcard.activec { width: 200px; height: auto; min-height: 222px; }
.mcard.activec::before { content: "戰鬥區"; position: absolute; right: 9px; top: 33px; font-size: 10px; background: rgba(0, 0, 0, .45); padding: 1px 6px; border-radius: 999px; z-index: 2; }
.mcard.benchc { width: 116px; height: 158px; }
.mcard.benchc .mc-art { height: 62px; }
.mcard.benchc .mc-ab, .mcard.benchc .mc-moves { display: none; }
.mcard.benchc .mc-name { font-size: 12px; }
.mcard .tag { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); font-size: 11px; background: rgba(0, 0, 0, .55); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.mcard.fainted { filter: grayscale(1) brightness(.6); }
.mcard .hpbar { margin-top: 0; }
.mcard.zoom { width: 300px; height: auto; min-height: 400px; padding: 10px; }
.mcard.zoom .mc-art { height: 160px; }
.mcard.zoom .mc-name { font-size: 20px; }
.mcard.zoom .mc-ab { max-height: none; font-size: 13px; padding: 6px 8px; }
.mcard.zoom .mc-type { top: 44px; font-size: 12px; }
.mcard.zoom .mvdesc { font-size: 12px; line-height: 1.4; background: rgba(255, 255, 255, .92); color: #222; border-radius: 7px; padding: 6px 8px; margin-top: 5px; }
.mcard.zoom .mvdesc b { color: #c4261a; }
.abbtn { margin-top: 4px; width: 100%; border: none; border-radius: 8px; padding: 4px; font-size: 12px; font-weight: 800; color: #fff; background: linear-gradient(180deg, #a46cff, #6d3ad1); }

/* 閃卡效果 */
.holo { position: relative; }
.holo::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; mix-blend-mode: color-dodge; opacity: .55;
  background: linear-gradient(115deg, transparent 20%, rgba(255, 120, 200, .55) 36%, rgba(120, 220, 255, .55) 46%, rgba(255, 250, 140, .55) 56%, transparent 72%);
  background-size: 250% 250%; animation: holo 3.2s ease-in-out infinite; }
@keyframes holo { 0% { background-position: 100% 100%; } 50% { background-position: 0% 0%; } 100% { background-position: 100% 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 紀錄 ---------- */
#logPanel { position: absolute; right: 12px; top: 52px; width: 330px; height: 470px; z-index: 30; display: none; background: rgba(8, 12, 30, .94);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; overflow-y: auto; font-size: 12.5px; line-height: 1.55; }
#logPanel.open { display: block; }
#logPanel div { border-bottom: 1px dashed rgba(255, 255, 255, .06); padding: 2px 0; }
.l-turn { color: var(--gold); font-weight: 800; margin-top: 4px; }
.l-dmg { color: #ff9b9b; } .l-heal { color: #8ff0b8; } .l-ko { color: #ff6b6b; font-weight: 800; } .l-move { color: #ffe08a; }
.l-status { color: #e1a6ff; } .l-weather { color: #9fd5ff; } .l-card { color: #b8c7ff; } .l-sys { color: #6ff; } .l-level { color: #ffd36b; }

/* ---------- FX ---------- */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
.fxc { position: absolute; left: 0; top: 0; will-change: transform; }
.flip3d { perspective: 900px; }
.flipper { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
.flipper > .face, .flipper > .backface { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipper > .face { transform: rotateY(180deg); }
.flipper.flipped { transform: rotateY(180deg); }
.rays { position: absolute; width: 640px; height: 640px; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 240, 180, .55) 0 7deg, transparent 7deg 20deg);
  mask-image: radial-gradient(circle, #000 15%, transparent 65%); animation: spinc 6s linear infinite; transition: opacity .3s; }
@keyframes spinc { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
.rays.on { opacity: 1; }
.rays.rare { background: repeating-conic-gradient(from 0deg, rgba(255, 140, 240, .6) 0 6deg, rgba(120, 220, 255, .5) 6deg 12deg, transparent 12deg 22deg); }
.spark { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px 3px #ffe58a; }
.dmgnum { position: absolute; font-weight: 900; font-size: 34px; color: #ff4b4b; -webkit-text-stroke: 2px #fff; text-shadow: 0 4px 10px rgba(0, 0, 0, .6); transform: translate(-50%, -50%); }
.dmgnum.heal { color: #2fd27a; }
.poptxt { position: absolute; font-weight: 900; font-size: 22px; transform: translate(-50%, -50%); white-space: nowrap; -webkit-text-stroke: 1px #000; text-shadow: 0 3px 8px #000; }
.mvlabel { position: absolute; transform: translate(-50%, -50%); background: linear-gradient(90deg, #ff6a3c, #ffb03c); color: #fff; font-weight: 900; font-size: 20px;
  padding: 6px 18px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); white-space: nowrap; -webkit-text-stroke: .5px #8a2a00; }
.proj { position: absolute; font-size: 40px; transform: translate(-50%, -50%); filter: drop-shadow(0 0 10px #fff); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-7px) rotate(-2deg); } 40% { transform: translateX(7px) rotate(2deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }
.dodgeAnim { animation: dodgeA .5s; }
@keyframes dodgeA { 40% { transform: translateX(34px) skewX(-10deg); opacity: .5; } }
.hitflash { animation: hitf .35s; }
@keyframes hitf { 30% { filter: brightness(2.2) saturate(.2); } }
.healglow { animation: healg .8s; }
@keyframes healg { 40% { filter: brightness(1.4) drop-shadow(0 0 14px #5f8); } }

#banner { position: absolute; left: 0; right: 0; top: 330px; text-align: center; z-index: 70; pointer-events: none; opacity: 0; }
#banner span { display: inline-block; padding: 12px 60px; font-size: 30px; font-weight: 900; color: #fff;
  background: linear-gradient(90deg, transparent, rgba(20, 30, 80, .92) 15%, rgba(50, 30, 90, .92) 85%, transparent); text-shadow: 0 2px 8px #000; letter-spacing: 2px; }

/* 洗牌區 */
#shuffleZone { position: absolute; left: 640px; top: 300px; z-index: 65; pointer-events: none; }
#shuffleZone .back { position: absolute; left: calc(var(--cardw) / -2); top: calc(var(--cardh) / -2); }
#shuffleLabel { position: absolute; left: 0; top: 108px; transform: translateX(-50%); white-space: nowrap; font-weight: 800; color: #fff; text-shadow: 0 2px 6px #000; font-size: 16px; }

/* ---------- 彈窗 ---------- */
#modal { position: absolute; inset: 0; z-index: 92; display: none; align-items: center; justify-content: center; background: rgba(3, 6, 20, .6); backdrop-filter: blur(3px); }
#modal.open { display: flex; }
#modal.top { align-items: flex-start; padding-top: 70px; }
.mbox { min-width: 380px; max-width: 980px; max-height: 720px; overflow: auto; background: linear-gradient(180deg, #1c2550, #141a3a); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 20px; padding: 18px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: pop .25s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.mbox h2 { margin: 0 0 6px; font-size: 21px; }
.mbox p { margin: 6px 0 10px; color: #cdd6f5; font-size: 14px; line-height: 1.55; }
.mcards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 10px 0; }
.mcards .pick { cursor: pointer; transition: transform .15s; border-radius: 12px; }
.mcards .pick:hover { transform: translateY(-6px); }
.mcards .pick.sel { box-shadow: 0 0 0 4px #6ff, 0 0 24px #6ff; transform: translateY(-8px); }
.mbtns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.mbtn { border: none; border-radius: 12px; padding: 10px 20px; font-weight: 800; font-size: 15px; color: #fff; background: linear-gradient(180deg, #4b8cff, #2a5bd8); box-shadow: 0 3px 0 #1b3a8f; }
.mbtn.alt { background: linear-gradient(180deg, #5c6488, #3c4366); box-shadow: 0 3px 0 #262a44; }
.mbtn.warn { background: linear-gradient(180deg, #ff8a4c, #e5532b); box-shadow: 0 3px 0 #9b3014; }
.mbtn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.pbtn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 120px; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: rgba(255, 255, 255, .06); color: #fff; }
.pbtn:hover { background: rgba(255, 255, 255, .14); }
.pbtn .ava { font-size: 28px; } .pbtn small { color: var(--mute); }
.pbtn.sel { box-shadow: 0 0 0 3px #6ff; }
.monpick { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.monpick .owner { font-size: 12px; color: #cde; }
.monpick .mini { width: 120px; flex: none; min-height: 92px; }
.monpick.sel .mini { box-shadow: 0 0 0 3px #6ff, 0 0 18px #6ff; }
.tagpick { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: #ffcf3a; color: #3b2a00; font-weight: 900; font-size: 12px; padding: 2px 10px; border-radius: 999px; z-index: 3; white-space: nowrap; }

/* 標題畫面 */
#titleScreen { position: absolute; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(255, 180, 90, .25), transparent 50%), linear-gradient(160deg, #0b1430, #2a1047); }
#titleScreen h1 { margin: 0; font-size: 64px; font-weight: 900; letter-spacing: 4px; background: linear-gradient(90deg, #ffe58a, #ff9b6b, #ff6bd0, #8fd0ff);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 18px rgba(255, 120, 120, .45)); }
#titleScreen .sub { font-size: 20px; color: #ffe9c4; margin: 4px 0 16px; letter-spacing: 6px; }
.tfan { position: relative; height: 196px; width: 600px; margin-bottom: 0; }
.tfan > div { position: absolute; left: 50%; top: -66px; transform-origin: 50% 160%; }
.opts { display: grid; grid-template-columns: 110px auto; gap: 9px 14px; align-items: center; background: rgba(0, 0, 0, .28); padding: 18px 26px; border-radius: 18px; border: 1px solid var(--line); }
.opts label { color: #cfd8ff; font-weight: 700; text-align: right; }
.seg { display: flex; gap: 6px; }
.seg button { border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: #fff; border-radius: 10px; padding: 8px 16px; font-weight: 700; }
.seg button.on { background: linear-gradient(180deg, #ffcf5a, #f29c2b); color: #3b2200; border-color: #ffd36b; }
.opts input { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 15px; width: 200px; -webkit-user-select: text; user-select: text; }
.startbtn { margin-top: 16px; border: none; border-radius: 18px; padding: 16px 70px; font-size: 24px; font-weight: 900; color: #fff; letter-spacing: 4px;
  background: linear-gradient(180deg, #ff9b4c, #e5532b); box-shadow: 0 6px 0 #9b3014, 0 14px 30px rgba(0, 0, 0, .5); animation: breathe 2s infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }
.hint { font-size: 12.5px; color: var(--mute); margin-top: 12px; }

.rules { max-width: 860px; font-size: 13.5px; line-height: 1.7; color: #dfe6ff; }
.rules h3 { color: var(--gold); margin: 14px 0 4px; font-size: 16px; }
.rules table { border-collapse: collapse; margin: 6px 0; }
.rules td, .rules th { border: 1px solid rgba(255, 255, 255, .18); padding: 4px 10px; }

.toast { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); z-index: 95; background: rgba(20, 20, 40, .95); border: 1px solid #ff8a8a; color: #ffd0d0;
  padding: 8px 18px; border-radius: 999px; font-size: 14px; pointer-events: none; animation: pop .2s; }

/* 手動抽牌 */
#deckPile.drawable { cursor: grab; z-index: 7; }
#deckPile.drawable .topcard { animation: deckGlow 1.1s ease-in-out infinite; }
#deckPile.drawable:hover .topcard { filter: brightness(1.12); }
@keyframes deckGlow { 50% { box-shadow: var(--thick-back), 0 0 0 3px #ffe58a, 0 0 30px 6px #ffd36b; } }
#drawTip { position: absolute; left: 556px; top: 150px; transform: translateX(-50%); z-index: 66; pointer-events: none; text-align: center; white-space: nowrap;
  background: linear-gradient(180deg, #ffe58a, #f6b93b); color: #3b2600; border-radius: 14px; padding: 6px 16px; font-size: 14px; font-weight: 800;
  box-shadow: 0 4px 0 #b97a10, 0 10px 20px rgba(0, 0, 0, .45); animation: tipBob 1.2s ease-in-out infinite; }
#drawTip b { display: block; font-size: 17px; letter-spacing: 2px; }
#drawTip small { display: block; font-size: 11.5px; font-weight: 700; opacity: .8; }
#drawTip::after { content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); border: 9px solid transparent; border-bottom: 0; border-top-color: #f6b93b; }
@keyframes tipBob { 50% { transform: translateX(-50%) translateY(-6px); } }
.drawghost { z-index: 70; box-shadow: var(--thick-back), 0 0 0 3px #ffe58a, 0 18px 30px rgba(0, 0, 0, .55); }
#titleScreen h1, #titleScreen .sub { position: relative; z-index: 2; }

/* 選牌視窗：查看卡片說明 */
.mbox { position: relative; }
.infobtn { position: absolute; right: -8px; top: -8px; z-index: 4; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; padding: 5px;
  background: linear-gradient(180deg, #5aa9ff, #2a5bd8); color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.infobtn svg { width: 100%; height: 100%; display: block; }
.infobtn:hover { transform: scale(1.15); }
.detailov { position: absolute; inset: 0; z-index: 20; border-radius: inherit; background: rgba(6, 10, 30, .82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer; perspective: 900px; }
.detailtip { font-size: 13px; color: #cfe; }
#discardPile { cursor: pointer; }
#discardPile:not(.empty):hover .pcard { filter: brightness(1.08); box-shadow: inset 0 0 0 3px #d8d2c4, var(--thick), 0 0 0 3px #8fd0ff, 0 0 20px #8fd0ff; }
.detailov { position: absolute; inset: 0; z-index: 90; }

/* ================= 觸控裝置 ================= */
html, body { touch-action: manipulation; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
#deckPile, .drawghost { touch-action: none; }
@media (hover: none) {
  #hand .pcard:hover { transform: none; }
  .mcards .pick:hover { transform: none; }
  .infobtn { width: 36px; height: 36px; right: -10px; top: -10px; }
}
/* 直向提示 */
#rotateHint { position: fixed; inset: 0; z-index: 999; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 30px; text-align: center;
  background: radial-gradient(circle at 50% 40%, #2a1d5a, #070a1c); color: #fff; font-size: 18px; font-weight: 800; }
#rotateHint.show { display: flex; }
#rotateHint .ph { width: 70px; height: 116px; border: 5px solid #ffd36b; border-radius: 14px; position: relative; animation: rotPhone 2.2s ease-in-out infinite; }
#rotateHint .ph::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 16px; height: 4px; border-radius: 2px; background: #ffd36b; transform: translateX(-50%); }
@keyframes rotPhone { 0%, 25% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
#rotateHint small { font-size: 13px; font-weight: 400; color: #cdd6f5; line-height: 1.6; }
#rotateHint button { border: none; border-radius: 12px; padding: 10px 22px; font-weight: 800; font-size: 15px; color: #fff; background: linear-gradient(180deg, #5c6488, #3c4366); }

/* ================= 手機橫向精簡版面（480 高） ================= */
#stage.compact #topbar { height: 34px; gap: 6px; padding: 0 8px; }
#stage.compact #topbar .logo { font-size: 14px; }
#stage.compact #topbar .info { font-size: 11px; margin-left: 2px; }
#stage.compact .tbtn { padding: 4px 9px; font-size: 12px; }
#stage.compact #table { left: 70px; top: 44px; width: calc(var(--SW) - 140px); height: 300px; }
#stage.compact .seat { transform: translate(-50%, -50%) scale(.8); }
#stage.compact #center { left: calc(var(--SW) / 2 - 170px); top: 112px; transform: scale(.72); }
#stage.compact #ticker { left: calc(var(--SW) / 2 - 220px); top: 286px; width: 440px; height: 52px; font-size: 12px; line-height: 15px; }
#stage.compact #me { height: 300px; pointer-events: none; }
#stage.compact #me > * { pointer-events: auto; }
#stage.compact #meInfo { left: 6px; bottom: 6px; width: 150px; transform: scale(.86); transform-origin: bottom left; }
#stage.compact #meInfo .rolecard small { display: none; }
#stage.compact #meMons { left: 140px; bottom: 6px; transform: scale(.74); transform-origin: bottom left; }
#stage.compact #hand { left: 372px; right: auto; bottom: 4px; transform: scale(.82); transform-origin: bottom left; }
#stage.compact #actions { right: 6px; bottom: 6px; width: 116px; gap: 6px; }
#stage.compact .abtn { padding: 10px 6px; font-size: 15px; }
#stage.compact .abtn.small { padding: 7px 5px; font-size: 13px; }
#stage.compact #phaseTip { font-size: 12px; }
#stage.compact #logPanel { top: 38px; height: 400px; width: 340px; font-size: 13px; }
#stage.compact .mbox { max-height: 464px; padding: 12px 16px; border-radius: 16px; }
#stage.compact .mbox h2 { font-size: 19px; margin-bottom: 2px; }
#stage.compact .mbox p { margin: 4px 0 6px; font-size: 14px; line-height: 1.45; }
#stage.compact .mcards { margin: 6px 0; gap: 10px; }
#stage.compact .mbtns { margin-top: 8px; }
#stage.compact .mbtn { padding: 10px 20px; font-size: 16px; }
#stage.compact #modal.top { padding-top: 10px; }
#stage.compact #rcard { transform: scale(.8); margin: -32px 0; }
#stage.compact .dmgnum { font-size: 40px; }
#stage.compact .poptxt { font-size: 24px; }
#stage.compact #banner span { font-size: 26px; padding: 8px 40px; }
#stage.compact .toast { top: 40px; font-size: 15px; }
/* 標題畫面：精簡版改為左右兩欄 */
#stage.compact #titleScreen { flex-direction: row; flex-wrap: wrap; align-content: center; column-gap: 28px; row-gap: 0; }
#stage.compact #titleScreen .tfan { display: none; }
#stage.compact #titleScreen .tleft { display: flex; flex-direction: column; align-items: center; }
#stage.compact #titleScreen h1 { font-size: 46px; }
#stage.compact #titleScreen .sub { font-size: 16px; margin-bottom: 10px; }
#stage.compact .opts { gap: 7px 10px; padding: 12px 18px; }
#stage.compact .seg button { padding: 7px 13px; }
#stage.compact .startbtn { margin-top: 12px; padding: 12px 56px; font-size: 22px; }
#titleScreen .tleft { display: contents; }
#titleScreen h1 { order: 1; } #titleScreen .sub { order: 2; } #titleScreen .opts { order: 3; } #titleScreen .startbtn { order: 4; } #titleScreen .hint { order: 5; }
#stage.compact #titleScreen .tleft { order: 1; }
#stage.compact #titleScreen .opts { order: 2; }

/* AI 個性與對話 */
.pchip { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; white-space: nowrap; background: #3b4470; color: #dfe6ff; }
.pc-righteous { background: #2f6fd8; color: #fff; } .pc-cunning { background: #7b4fd0; color: #fff; } .pc-treacherous { background: #5a2a3a; color: #ffb3c0; }
.pc-smart { background: #1f8a78; color: #fff; } .pc-hot { background: #e5532b; color: #fff; } .pc-careful { background: #8a7a3a; color: #fff; }
.bubble { position: absolute; z-index: 75; transform: translate(-50%, -100%); max-width: 220px; padding: 7px 12px; border-radius: 14px; background: #fff; color: #23203a;
  font-size: 14px; font-weight: 800; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .45); pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); border: 8px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble.below::after { bottom: auto; top: -8px; border-top: 0; border-bottom: 8px solid #fff; }
#stage.compact .bubble { font-size: 15px; }

/* 規則：分頁與卡牌介紹 */
.rtabs { display: flex; gap: 8px; margin: 4px 0 10px; position: sticky; top: -18px; z-index: 3; padding: 6px 0; background: #1a2249; }
.rtabs button { border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: #fff; border-radius: 10px; padding: 8px 18px; font-weight: 800; font-size: 14px; }
.rtabs button.on { background: linear-gradient(180deg, #ffcf5a, #f29c2b); color: #3b2200; border-color: #ffd36b; }
.rules .ctable { width: 100%; }
.rules .ctable td { vertical-align: top; font-size: 13px; }
.rules .ctable .cname { white-space: nowrap; }
.rules .ctable .ccnt { text-align: center; font-weight: 800; color: var(--gold); }
.rules .ctable .cw { white-space: nowrap; }
.rules .knote { font-size: 12.5px; color: var(--mute); margin-bottom: 4px; }
.gsamples { display: flex; gap: 14px; justify-content: center; margin: 12px 0 6px; flex-wrap: wrap; }
.gsample { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; color: #fff; }
.kt { display: inline-block; padding: 1px 9px; border-radius: 999px; color: #fff; font-size: 12.5px; }
.kt.k-atk { background: #c4261a; } .kt.k-dodge { background: #13805a; } .kt.k-event { background: #3c4fa8; } .kt.k-item { background: #8a3fb0; } .kt.k-tool { background: #6b6b2a; }
.mguide { display: flex; gap: 18px; align-items: flex-start; }
.mguide .mgcard { flex: none; }
.mguide > div:last-child { line-height: 1.75; }
#stage.compact .mguide { flex-direction: column; align-items: center; }
#stage.compact .rtabs { top: -12px; }
.rules .ctable th { white-space: nowrap; }
