* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1530; touch-action: none; overscroll-behavior: none; position: fixed; inset: 0; }
#app { position: fixed; inset: 0; font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Trebuchet MS", system-ui, sans-serif; color: #2b1d2e; overflow: hidden; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
img { image-rendering: pixelated; -webkit-user-drag: none; }
em { color: #e2483a; font-style: normal; }

/* ---------- buttons ---------- */
.btn { font-weight: 900; font-size: 17px; padding: 12px 18px; border-radius: 14px; border: 3px solid #2b1d2e; background: linear-gradient(#ffffff, #e6defa); color: #2b1d2e; box-shadow: 0 4px 0 #2b1d2e; transition: transform .08s, box-shadow .08s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #2b1d2e; }
.btn.go { background: linear-gradient(#fff3a0, #ffc04d 55%, #ff9a3d); }
.btn:disabled { opacity: .45; filter: grayscale(.6); }
.btn small { display: block; font-size: 12px; opacity: .7; }

/* ---------- HUD & controls ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px) 0 calc(env(safe-area-inset-left) + 12px); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; opacity: 0; transition: opacity .4s; z-index: 5; }
#app.playing #hud, #app.playing #controls { opacity: 1; }
#loc { font-weight: 900; color: #fff8e0; background: linear-gradient(#8d5a3b, #6d4326); border: 3px solid #2b1d2e; border-radius: 12px; padding: 6px 14px; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.25); transform: translateX(-130%); }
#loc.show { animation: locIn 3s ease forwards; }
@keyframes locIn { 0% { transform: translateX(-130%); } 12%, 82% { transform: translateX(0); } 100% { transform: translateX(-130%); } }
#menuBtn { pointer-events: auto; width: 46px; height: 46px; border-radius: 14px; border: 3px solid #2b1d2e; background: linear-gradient(#ffffff, #e6defa); box-shadow: 0 3px 0 #2b1d2e; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; }
#menuBtn i { width: 20px; height: 3px; border-radius: 2px; background: #2b1d2e; }
#controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 calc(18px + env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; opacity: 0; transition: opacity .4s; z-index: 6; }
#dpad { pointer-events: auto; width: 150px; height: 150px; position: relative; touch-action: none; }
#dpad span { position: absolute; background: rgba(27, 21, 48, .55); border: 2px solid rgba(255, 255, 255, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#dpad .u { left: 50px; top: 0; width: 50px; height: 52px; border-radius: 14px 14px 4px 4px; border-bottom: none; }
#dpad .d { left: 50px; bottom: 0; width: 50px; height: 52px; border-radius: 4px 4px 14px 14px; border-top: none; }
#dpad .l { left: 0; top: 50px; width: 52px; height: 50px; border-radius: 14px 4px 4px 14px; border-right: none; }
#dpad .r { right: 0; top: 50px; width: 52px; height: 50px; border-radius: 4px 14px 14px 4px; border-left: none; }
#dpad .c { left: 50px; top: 50px; width: 50px; height: 50px; border: none; }
#dpad span::after { content: ''; position: absolute; left: 50%; top: 50%; border: 8px solid transparent; transform: translate(-50%, -50%); }
#dpad .u::after { border-bottom-color: rgba(255,255,255,.85); margin-top: -4px; }
#dpad .d::after { border-top-color: rgba(255,255,255,.85); margin-top: 4px; }
#dpad .l::after { border-right-color: rgba(255,255,255,.85); margin-left: -4px; }
#dpad .r::after { border-left-color: rgba(255,255,255,.85); margin-left: 4px; }
#dpad .c::after { display: none; }
#dpad[data-dir=up] .u, #dpad[data-dir=down] .d, #dpad[data-dir=left] .l, #dpad[data-dir=right] .r { background: rgba(255, 210, 63, .6); }
#ab { display: flex; gap: 14px; align-items: flex-end; pointer-events: auto; }
#ab button { width: 72px; height: 72px; border-radius: 50%; font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); border: 3px solid rgba(255,255,255,.7); box-shadow: 0 5px 0 rgba(20,10,30,.55); touch-action: none; }
#btnA { background: radial-gradient(circle at 35% 30%, #ff9a8a, #e2483a 60%, #a32a20); margin-bottom: 34px; }
#btnB { background: radial-gradient(circle at 35% 30%, #9ad8ff, #2f80ed 60%, #1a4fa0); width: 60px !important; height: 60px !important; font-size: 22px !important; }
#ab button.down { transform: translateY(4px); box-shadow: 0 1px 0 rgba(20,10,30,.55); }

/* ---------- dialog ---------- */
#dialog { position: absolute; left: calc(10px + env(safe-area-inset-left)); right: calc(10px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; }
.d-box { position: relative; background: linear-gradient(#fffaf0, #fff0d0); border: 4px solid #2b1d2e; border-radius: 16px; box-shadow: inset 0 0 0 3px #ffd36b, 0 6px 0 rgba(0,0,0,.35); padding: 22px 18px 20px; min-height: 124px; font-size: 17px; line-height: 1.45; font-weight: 700; }
.d-portrait { position: absolute; left: 12px; bottom: calc(100% - 18px); width: 92px; height: 92px; border: 4px solid #2b1d2e; border-radius: 16px; background: radial-gradient(circle at 50% 30%, #fff, var(--bg, #bde) 70%); box-shadow: 0 4px 0 rgba(0,0,0,.3); overflow: hidden; z-index: 2; }
.d-portrait img { width: 100%; height: 100%; display: block; }
.d-portrait.pop { animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
@keyframes popIn { from { transform: scale(.6) translateY(10px); } to { transform: none; } }
.d-name { position: absolute; top: -18px; left: 116px; background: linear-gradient(#ff8a5a, #e2483a); color: #fff; font-weight: 900; padding: 4px 14px; border: 3px solid #2b1d2e; border-radius: 10px; font-size: 15px; letter-spacing: .3px; }
#dialog .d-portrait[style*="none"] + .d-box .d-name { left: 14px; }
.d-next { position: absolute; right: 16px; bottom: 10px; width: 0; height: 0; border: 7px solid transparent; border-top: 9px solid #e2483a; opacity: 0; }
#dialog.done .d-next { opacity: 1; animation: bob .6s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(4px); } }
#dialog.narr .d-box { background: linear-gradient(#2a2150, #1b1530); color: #fff6dc; box-shadow: inset 0 0 0 3px #ffd36b55, 0 6px 0 rgba(0,0,0,.35); }
#dialog.narr em { color: #ffd23f; }
#dialog.sign .d-box { background: linear-gradient(#f6e6c0, #ead2a0); color: #3a2a1a; box-shadow: inset 0 0 0 3px #c08a52, 0 6px 0 rgba(0,0,0,.35); }
#dialog.sign em { color: #b03a2e; }
.d-choices { position: absolute; right: 0; bottom: calc(100% + 10px); display: flex; flex-direction: column; gap: 8px; }
.d-choice { font-weight: 900; font-size: 16px; padding: 10px 18px; border: 3px solid #2b1d2e; border-radius: 12px; background: #fff; box-shadow: 0 3px 0 #2b1d2e; }
.d-choice.sel { background: #ffe680; }
#app.cine::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, rgba(40,30,90,.75), rgba(10,8,24,.95)); z-index: 15; }

/* ---------- banners / toast / modal / transition ---------- */
#banner { position: absolute; left: 0; right: 0; top: 30%; z-index: 40; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 2.6s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.6); } 12% { opacity: 1; transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.bn-t { font-size: 38px; font-weight: 900; color: #fff8d0; text-shadow: 0 3px 0 #2b1d2e, 3px 0 0 #2b1d2e, -3px 0 0 #2b1d2e, 0 -3px 0 #2b1d2e, 0 8px 12px rgba(0,0,0,.4); }
.bn-s { margin: 10px auto 0; max-width: 84%; font-size: 16px; font-weight: 800; color: #fff; background: rgba(27,21,48,.75); display: inline-block; padding: 6px 14px; border-radius: 10px; }
#toast { position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 70px); transform: translate(-50%, -20px); background: rgba(27,21,48,.9); color: #fff; font-weight: 800; padding: 10px 18px; border-radius: 12px; z-index: 60; opacity: 0; transition: .3s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#trans { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 100; display: none; pointer-events: all; }
.modal { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(15,10,35,.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); padding: calc(env(safe-area-inset-top) + 10px) 14px calc(env(safe-area-inset-bottom) + 10px); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.m-box { background: linear-gradient(#fffaf0, #fff0d0); border: 4px solid #2b1d2e; border-radius: 18px; padding: 18px; max-width: 360px; width: 100%; font-weight: 700; font-size: 17px; line-height: 1.4; box-shadow: 0 8px 0 rgba(0,0,0,.35); max-height: 100%; overflow-y: auto; touch-action: pan-y; animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
.m-box.wide { max-width: 420px; }
.cardmodal .m-box { background: none; border: none; box-shadow: none; padding: 0; display: flex; flex-direction: column; align-items: center; }
.m-btns { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.m-btns .btn { flex: 1; min-width: 96px; }

/* ---------- title ---------- */
.screen { position: absolute; inset: 0; z-index: 50; }
#title { display: flex; align-items: center; justify-content: center; background: linear-gradient(rgba(20,14,50,.55), rgba(20,14,50,.05) 40%, rgba(20,14,50,.1) 60%, rgba(20,14,50,.7)); }
.tt-wrap { text-align: center; padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 20px); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tt-logo { display: flex; flex-direction: column; line-height: .95; font-weight: 900; animation: floaty 4s ease-in-out infinite; filter: drop-shadow(3px 0 0 #2b1d2e) drop-shadow(-3px 0 0 #2b1d2e) drop-shadow(0 3px 0 #2b1d2e) drop-shadow(0 -3px 0 #2b1d2e) drop-shadow(0 7px 0 rgba(0,0,0,.35)); }
.tt-a { font-size: 34px; color: #fff8e0; letter-spacing: 1px; }
.tt-b { font-size: 76px; background: linear-gradient(#fffbd0, #ffd23f 45%, #ff7a3d 80%); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: 2px; }
@keyframes floaty { 50% { transform: translateY(-6px) rotate(-1deg); } }
.tt-cards { display: flex; justify-content: center; height: 140px; margin: 6px 0 0; }
.tt-cards .card { font-size: 9.5px; margin: 0 -14px; transform: rotate(var(--r)); animation: cardbob 3s ease-in-out infinite; }
.tt-cards .card:nth-child(2) { margin-top: -12px; animation-delay: -1s; z-index: 2; }
.tt-cards .card:nth-child(3) { animation-delay: -2s; }
@keyframes cardbob { 50% { translate: 0 -8px; } }
.tt-sub { font-weight: 900; color: #fff; background: rgba(27,21,48,.7); padding: 6px 14px; border-radius: 10px; font-size: 15px; }
.tt-btns { display: flex; flex-direction: column; gap: 12px; width: 230px; margin-top: 14px; }
.tt-btns .btn { font-size: 20px; padding: 14px; }
.tt-foot { color: #fff; opacity: .8; font-size: 12px; font-weight: 700; margin-top: 8px; text-shadow: 0 1px 2px #000; }

/* ---------- menu / binder ---------- */
#menu { display: grid; place-items: center; background: rgba(15,10,35,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.mn-box { width: min(300px, 86vw); display: flex; flex-direction: column; gap: 10px; background: linear-gradient(#fffaf0, #fff0d0); border: 4px solid #2b1d2e; border-radius: 18px; padding: 16px; box-shadow: 0 8px 0 rgba(0,0,0,.35); animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
.mn-h { font-weight: 900; font-size: 22px; text-align: center; margin-bottom: 4px; }
.types p { font-size: 15px; text-align: center; margin: 10px 0 0; }
.ty-ring { display: flex; flex-direction: column; gap: 6px; }
.ty { display: flex; align-items: center; gap: 8px; font-weight: 900; padding: 6px 10px; border-radius: 10px; border: 3px solid #2b1d2e; background: linear-gradient(90deg, var(--c1), var(--c2)); color: #fff; text-shadow: 0 1px 0 #0006; }
.ty img { width: 22px; height: 22px; }
.ty span { margin-left: auto; font-size: 13px; }
#binder { background: linear-gradient(#3a2f6e, #1b1530); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 12px); }
.bd-top { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 10px; }
.bd-h { font-weight: 900; font-size: 24px; }
.bd-dk { font-weight: 900; padding: 4px 10px; border-radius: 10px; margin-right: auto; }
.bd-dk.ok { background: #43a047; } .bd-dk.bad { background: #e2483a; }
.bd-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px 10px; touch-action: pan-y; padding: 4px 2px 20px; align-content: start; justify-items: center; }
.bd-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bd-cell .card { font-size: 9.6px; }
.bd-cnt { display: flex; gap: 6px; font-size: 12px; font-weight: 900; color: #fff; }
.bd-cnt b { color: #ffd23f; }
.bd-tip { color: #fff; opacity: .7; font-size: 12px; font-weight: 700; text-align: center; }
.bd-empty { color: #fff; grid-column: 1/-1; text-align: center; padding: 40px; font-weight: 800; }
.card.unknown { background: linear-gradient(160deg, #5a4d8a, #2b2350) !important; }
.card.unknown .c-in { background: rgba(255,255,255,.08); border-color: #1b1530; align-items: center; justify-content: center; color: #b8a8ff; }
.card.unknown .q { font-size: 4em; font-weight: 900; }
.card.unknown .no { font-weight: 800; font-size: 1em; }
.starter { text-align: center; }
.st-h { font-weight: 900; font-size: 22px; margin-bottom: 14px; }
.st-row { display: flex; gap: 10px; justify-content: center; }
.st-row .card { font-size: 10.4px; }
.st-tip { font-size: 13px; margin-top: 12px; opacity: .7; }
.reveal { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rv-t { font-weight: 900; font-size: 22px; color: #fff8d0; text-align: center; text-shadow: 0 2px 0 #2b1d2e, 2px 0 0 #2b1d2e, -2px 0 0 #2b1d2e, 0 -2px 0 #2b1d2e; z-index: 1; }
.rv-s { color: #fff; font-weight: 800; font-size: 14px; text-align: center; max-width: 280px; z-index: 1; }
.rv-rays { position: absolute; left: 50%; top: 50%; width: 700px; height: 700px; margin: -350px; background: repeating-conic-gradient(rgba(255,240,170,.22) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: spin 14s linear infinite; -webkit-mask: radial-gradient(circle, #000 20%, transparent 65%); mask: radial-gradient(circle, #000 20%, transparent 65%); pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.card.flipin { animation: flipin 1s cubic-bezier(.2,.9,.3,1.2); }
@keyframes flipin { 0% { transform: rotateY(540deg) scale(.2); filter: brightness(4); } 70% { filter: brightness(1.6); } 100% { transform: none; } }

/* ---------- cards ---------- */
.card { position: relative; width: 10em; height: 14em; border-radius: .75em; padding: .42em; flex: none; background: linear-gradient(160deg, var(--c2), var(--c1) 55%, var(--dk)); box-shadow: 0 .3em .6em rgba(0,0,0,.35), inset 0 0 0 .1em rgba(255,255,255,.55); color: #2b1d2e; overflow: hidden; font-size: 10px; transform-style: preserve-3d; }
.card.hand, .card.bench { height: 12.6em; }
.card.full { font-size: min(27px, 6.8vw, 4.4vh); height: auto; min-height: 14em; }
.card.full .c-nm { font-size: .8em; }
.card.full .c-in { gap: .32em; }
.c-in { position: relative; height: 100%; display: flex; flex-direction: column; gap: .28em; padding: .35em; border-radius: .45em; background: linear-gradient(#fffdf6, #f1e7d0); border: .1em solid var(--dk); }
.c-top { display: flex; align-items: center; gap: .25em; font-weight: 900; line-height: 1; }
.c-cost { flex: none; width: 1.55em; height: 1.55em; border-radius: 50%; display: grid; place-items: center; font-size: .95em; background: radial-gradient(circle at 35% 30%, #fffbd0, #ffd23f 45%, #e08a00); border: .1em solid #6a3a00; color: #4a2a00; }
.c-nm { flex: 1; min-width: 0; font-size: .92em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.c-hp { font-size: .95em; color: #c0322a; white-space: nowrap; }
.c-hp small { font-size: .55em; margin-right: .1em; }
.c-art { position: relative; border-radius: .35em; overflow: hidden; border: .14em solid var(--dk); aspect-ratio: 4 / 3; flex: none; box-shadow: inset 0 0 0 .1em rgba(255,255,255,.4); background: #fff; }
.c-art img { width: 100%; height: 100%; display: block; }
.c-band { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(90deg, var(--c1), var(--c2)); border-radius: .3em; padding: .2em .35em; margin-top: auto; border: .08em solid var(--dk); }
.c-band img { width: 1.1em; height: 1.1em; }
.c-rs { color: #fff; font-size: .9em; text-shadow: 0 .08em 0 #0007; }
.c-type { display: flex; align-items: center; gap: .25em; font-size: .62em; font-weight: 900; padding: .25em .4em; border-radius: .35em; background: linear-gradient(90deg, var(--c1), var(--c2)); color: #fff; text-shadow: 0 .08em 0 #0007; }
.c-type img { width: 1.4em; height: 1.4em; }
.c-type { white-space: nowrap; }
.c-weak { margin-left: auto; display: flex; align-items: center; gap: .2em; font-weight: 800; }
.c-abs { display: flex; flex-direction: column; gap: .2em; }
.c-ab { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .3em; font-size: .62em; font-weight: 900; border-bottom: .08em dashed #c8b890; padding-bottom: .2em; }
.c-abn { font-size: 1.1em; }
.c-abd { font-size: 1.35em; color: #2b1d2e; }
.c-abt { grid-column: 1 / -1; font-size: .85em; font-weight: 700; color: #6a5a4a; }
.c-fl { font-size: .5em; font-style: italic; color: #7a6a5a; font-weight: 700; line-height: 1.3; }
.c-ft { margin-top: auto; display: flex; justify-content: space-between; font-size: .5em; font-weight: 900; color: #7a6a5a; }
.pip { display: inline-block; width: .9em; height: .9em; border-radius: 50%; margin-right: .08em; vertical-align: middle; background: radial-gradient(circle at 35% 30%, #fffbd0, #ffd23f 45%, #e08a00); border: .1em solid #6a3a00; }
.pip.off { background: #463a6a; border-color: #2b1d2e; }
.c-bar { height: .7em; border-radius: .4em; background: #3a2a3a; overflow: hidden; border: .08em solid #2b1d2e; margin-top: auto; }
.c-bar i { display: block; height: 100%; background: linear-gradient(#a8ff8a, #43c047); transition: width .4s; }
.c-st { position: absolute; left: .4em; right: .4em; top: 2.2em; display: flex; flex-wrap: wrap; gap: .2em; }
.st { font-size: .62em; padding: .15em .4em; border-radius: .4em; color: #fff; border: .1em solid #2b1d2e; animation: stpulse 1s ease-in-out infinite alternate; }
.st.burn { background: #ff6b3d; } .st.stun { background: #c9a400; } .st.shld { background: #2f80ed; }
@keyframes stpulse { to { transform: scale(1.08); } }
.c-foil { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.r-uncommon .c-foil { background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%); background-size: 300% 100%; animation: foil 5s linear infinite; }
.r-rare .c-foil { background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.75) 46%, rgba(255,240,170,.5) 50%, transparent 64%); background-size: 300% 100%; mix-blend-mode: overlay; animation: foil 3s linear infinite; }
.r-rare { box-shadow: 0 .3em .6em rgba(0,0,0,.35), inset 0 0 0 .14em #fff3b0, 0 0 .6em rgba(255,220,120,.5); }
.r-legendary { background: linear-gradient(135deg, #fff3b0, #ffcf40 25%, #ff9ad5 50%, #9ad8ff 75%, #fff3b0) !important; background-size: 200% 200% !important; animation: holoBg 6s linear infinite; }
.r-legendary .c-foil { background: linear-gradient(115deg, rgba(255,0,128,.3), rgba(255,200,0,.3), rgba(0,255,160,.3), rgba(0,160,255,.3), rgba(180,0,255,.3), rgba(255,0,128,.3)); background-size: 300% 300%; mix-blend-mode: color-dodge; animation: holo 4s linear infinite; }
.r-legendary .c-foil::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.8) 48%, transparent 60%); background-size: 300% 100%; animation: foil 2.6s linear infinite; mix-blend-mode: overlay; }
@keyframes foil { from { background-position: 150% 0; } to { background-position: -150% 0; } }
@keyframes holo { from { background-position: 0% 50%; } to { background-position: 300% 50%; } }
@keyframes holoBg { from { background-position: 0% 0%; } to { background-position: 200% 200%; } }
.cback { display: inline-block; width: 1.6em; height: 2.2em; border-radius: .25em; border: .12em solid #fff; background: radial-gradient(circle, #ffd23f 0 22%, transparent 24%), repeating-conic-gradient(#4a35a0 0 15deg, #2a1d6a 15deg 30deg); box-shadow: 0 .1em .2em #0006; vertical-align: middle; }
.cback.sm { width: 1.1em; height: 1.5em; margin-left: -.45em; }

/* ---------- battle ---------- */
#battle { position: absolute; inset: 0; z-index: 30; overflow: hidden; background: #6cc24a; font-size: 10px; display: block; }
#battle.hidden { display: none; }
.b-bg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.b-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
.b-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; gap: .4em; padding: calc(env(safe-area-inset-top) + .6em) calc(env(safe-area-inset-right) + .8em) calc(env(safe-area-inset-bottom) + .3em) calc(env(safe-area-inset-left) + .8em); }
.b-bar { display: flex; align-items: center; gap: .7em; background: rgba(27,21,48,.78); color: #fff; border-radius: 1.4em; padding: .35em .8em .35em .35em; font-weight: 900; font-size: 1.25em; border: .15em solid rgba(255,255,255,.25); }
.b-av { width: 2.6em; height: 2.6em; border-radius: 50%; overflow: hidden; background: radial-gradient(#fff, #ffe08a); border: .15em solid #fff; flex: none; }
.b-av img { width: 100%; height: 100%; display: block; }
.b-av img.wild { object-fit: cover; transform: scale(1.4); }
.b-nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 8em; }
.b-stars { display: flex; gap: .15em; margin-left: auto; }
.star { width: 1.2em; height: 1.2em; background: #4a3f66; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.star.on { background: linear-gradient(#fffbd0, #ffd23f 50%, #ff9a3d); filter: drop-shadow(0 0 .2em #ffd23f); }
.b-pile { display: flex; align-items: center; gap: .3em; font-size: .9em; }
.b-hc { display: flex; padding-left: .45em; min-width: 1em; }
.b-field { display: flex; justify-content: center; align-items: center; gap: .9em; flex: none; height: 17.2em; }
.slot.act { width: 11.8em; height: 16.6em; display: grid; place-items: center; }
.slot.bench { width: 6.2em; height: 7.8em; display: grid; place-items: center; }
.slot .card.field { font-size: 1.18em; }
.slot .card.bench { font-size: .62em; }
.slot .empty { width: 100%; height: 100%; border: .25em dashed rgba(255,255,255,.6); border-radius: .9em; display: grid; place-items: center; color: rgba(255,255,255,.85); font-weight: 900; font-size: 1.1em; background: rgba(255,255,255,.12); }
.b-field.op .slot.act .card { animation: idleOp 3s ease-in-out infinite; }
.b-field.me .slot.act .card { animation: idleMe 3s ease-in-out infinite; }
@keyframes idleOp { 50% { transform: translateY(-.25em); } }
@keyframes idleMe { 50% { transform: translateY(.25em); } }
.b-mid { height: 3.4em; display: grid; place-items: center; flex: none; }
.b-msg { font-weight: 800; font-size: 1.35em; color: #fff; background: rgba(27,21,48,.8); padding: .35em .9em; border-radius: 1em; text-align: center; max-width: 100%; border: .12em solid rgba(255,255,255,.25); }
.b-msg:empty { display: none; }
.b-msg b { color: #ffd23f; }
.b-msg.pop { animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
.b-acts { display: flex; gap: .6em; height: 5.8em; flex: none; align-items: stretch; }
.ab-btn { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: .4em; text-align: left; background: linear-gradient(#fff, #fff 30%, var(--c2) 31%, var(--c1)); border: .25em solid #2b1d2e; border-radius: 1em; padding: .35em .7em; font-weight: 900; color: #2b1d2e; box-shadow: 0 .35em 0 #2b1d2e; font-size: 1em; animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
.ab-btn:active:not(:disabled) { transform: translateY(.25em); box-shadow: 0 .1em 0 #2b1d2e; }
.ab-btn:disabled { filter: grayscale(.8) brightness(.8); opacity: .7; }
.ab-c { white-space: nowrap; font-size: 1.1em; }
.ab-n { font-size: 1.35em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-d { font-size: 2em; }
.ab-d em { font-size: .5em; color: #c0322a; margin-left: .1em; }
.ab-btn small { grid-column: 1 / -1; font-size: 1.05em; color: #fff; text-shadow: 0 .08em 0 #0008; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-note { flex: 1; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 1.4em; color: #2b1d2e; background: rgba(255,255,255,.85); border-radius: 1em; border: .2em solid #2b1d2e; padding: .3em; }
.ab-note.dim { background: rgba(27,21,48,.7); color: #fff; border-color: transparent; }
.b-en { display: flex; align-items: center; gap: .1em; font-size: 1.05em; }
.b-en span { margin-right: .4em; font-size: .85em; opacity: .85; }
.b-en .pip { width: 1.15em; height: 1.15em; }
.b-bar.me .b-stars { margin-left: auto; }
.b-end { font-size: .95em !important; padding: .4em .9em !important; border-radius: .9em !important; border-width: .18em !important; box-shadow: 0 .25em 0 #2b1d2e !important; }
#battle.myturn .b-end:not(:disabled) { background: linear-gradient(#fff3a0, #ffc04d 55%, #ff9a3d); }
.b-hand { display: flex; justify-content: center; align-items: center; min-height: 11.5em; flex: none; padding-bottom: .2em; touch-action: pan-x; }
.b-hand .card { font-size: .86em; margin: 0 calc(var(--n) * -.3em); transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 3deg)); transform-origin: 50% 120%; transition: transform .15s; filter: brightness(.9); }
.b-hand .card.can { filter: none; box-shadow: 0 0 0 .2em #fff, 0 0 1em .3em rgba(255,230,120,.9); animation: canGlow 1.2s ease-in-out infinite alternate; }
@keyframes canGlow { to { box-shadow: 0 0 0 .2em #fff, 0 0 1.6em .5em rgba(255,230,120,.6); translate: 0 -.5em; } }
.b-ban { position: absolute; left: 0; right: 0; top: 44%; z-index: 9; text-align: center; font-weight: 900; font-size: 3.6em; color: #fff; pointer-events: none; padding: .2em 0; transform: translateX(-110%); text-shadow: 0 .06em 0 #2b1d2e, .06em 0 0 #2b1d2e, -.06em 0 0 #2b1d2e, 0 -.06em 0 #2b1d2e; }
.b-ban.me { background: linear-gradient(90deg, transparent, rgba(47,128,237,.85) 20%, rgba(47,128,237,.85) 80%, transparent); }
.b-ban.op { background: linear-gradient(90deg, transparent, rgba(226,72,58,.85) 20%, rgba(226,72,58,.85) 80%, transparent); }
.b-ban.go { animation: sweep 1s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes sweep { 0% { transform: translateX(-110%); } 30%, 70% { transform: translateX(0); } 100% { transform: translateX(110%); } }
.b-float { position: absolute; z-index: 10; pointer-events: none; font-weight: 900; font-size: 3em; color: #fff; white-space: nowrap; text-shadow: 0 .07em 0 #2b1d2e, .07em 0 0 #2b1d2e, -.07em 0 0 #2b1d2e, 0 -.07em 0 #2b1d2e; }
.b-float.dmg { color: #ff5a4a; } .b-float.weak { font-size: 4em; color: #ffd23f; }
.b-float.heal { color: #8dff9a; }
.b-float.note { font-size: 1.8em; } .b-float.blue { color: #9ad8ff; } .b-float.red { color: #ff9a6a; } .b-float.yel { color: #ffe14d; }
.b-det { position: absolute; inset: 0; z-index: 12; background: rgba(15,10,35,.65); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); display: grid; place-items: center; animation: fadeIn .15s; }
.det-w { display: flex; flex-direction: column; align-items: center; gap: 1.2em; animation: popIn .25s cubic-bezier(.3,1.6,.5,1); }
.det-b { display: flex; flex-wrap: wrap; gap: .8em; justify-content: center; width: 30em; max-width: 92vw; }
.det-b .btn { font-size: 1.6em; padding: .5em 1em; flex: 1; }
.det-n { width: 100%; text-align: center; color: #fff; font-weight: 800; font-size: 1.4em; }
.pips .pip { width: .8em; height: .8em; }
.b-over { position: absolute; inset: 0; z-index: 11; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; background: radial-gradient(circle, rgba(255,240,170,.35), rgba(15,10,35,.75)); animation: fadeIn .4s; }
.b-over.lose { background: radial-gradient(circle, rgba(120,120,160,.3), rgba(15,10,35,.85)); }
.ov-t { font-size: 6em; font-weight: 900; color: #fff8d0; animation: popIn .5s cubic-bezier(.3,1.6,.5,1); text-shadow: 0 .05em 0 #2b1d2e, .05em 0 0 #2b1d2e, -.05em 0 0 #2b1d2e, 0 -.05em 0 #2b1d2e, 0 .12em .2em rgba(0,0,0,.4); }
.b-over.win .ov-t { background: linear-gradient(#fffbd0, #ffd23f 50%, #ff7a3d); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(.04em 0 0 #2b1d2e) drop-shadow(-.04em 0 0 #2b1d2e) drop-shadow(0 .05em 0 #2b1d2e) drop-shadow(0 -.04em 0 #2b1d2e); }
.ov-s { font-size: 1.7em; color: #fff; font-weight: 800; }
.b-over .btn { font-size: 2em; padding: .5em 1.6em; }
@media (min-width: 700px) and (min-height: 600px) { #dialog { left: 50%; right: auto; width: 640px; transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }
