* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #070b16; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
body { font-family: 'Chakra Petch', sans-serif; color: #e8eefc; }
button { font-family: 'Chakra Petch', sans-serif; cursor: pointer; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; left: 0; top: 0; overflow: hidden; background: #0a1226; }
#stage canvas { display: block; }
#vignette { position: absolute; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 55%, rgba(4,6,16,.55) 100%); }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #fff; z-index: 30; }
.disp { font-family: 'Dela Gothic One', sans-serif; text-transform: uppercase; letter-spacing: -0.02em; }

/* ---------- HUD ---------- */
#hud { position: absolute; pointer-events: none; z-index: 10; }
#hud .side { position: absolute; top: 8px; display: flex; align-items: flex-start; gap: 6px; width: calc(50% - 38px); }
#hud .side.p1 { left: 8px; }
#hud .side.p2 { right: 8px; flex-direction: row-reverse; }
#hud .port { flex: 0 0 auto; width: 44px; height: 44px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--c, #fff); padding: 2px; }
#hud .port img { width: 100%; height: 100%; object-fit: cover; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); display: block; }
#hud .barwrap { flex: 1; min-width: 0; }
#hud .bar { position: relative; height: 18px; background: #1a1220; border: 2px solid #0b0d16; box-shadow: 0 0 0 1px rgba(255,220,150,.35), 0 2px 8px rgba(0,0,0,.6); transform: skewX(-24deg); overflow: hidden; }
#hud .p2 .bar { transform: skewX(24deg); }
#hud .bar .fill, #hud .bar .lag { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transform-origin: left; }
#hud .p2 .bar .fill, #hud .p2 .bar .lag { transform-origin: right; }
#hud .bar .lag { background: #fff4d6; transition: transform .6s ease .25s; }
#hud .bar .fill { background: linear-gradient(180deg, #ffe48a, #ffb21e 55%, #d97a00); }
#hud .bar .fill.mid { background: linear-gradient(180deg, #ffc06a, #ff7a1e 55%, #c44a00); }
#hud .bar .fill.low { background: linear-gradient(180deg, #ff8a7a, #e81e1e 55%, #8a0a0a); }
#hud .nm { font-family: 'Dela Gothic One'; font-size: 13px; margin-top: 3px; letter-spacing: -0.01em; color: #fff; text-shadow: 0 0 6px var(--c), 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud .p2 .nm { text-align: right; }
#hud .pips { display: flex; gap: 5px; margin-top: 2px; }
#hud .p2 .pips { justify-content: flex-end; }
#hud .pips i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #c9d4ff; background: #12182a; box-shadow: 0 0 4px #000; }
#hud .pips i.on { background: radial-gradient(circle, #fff 0, var(--c) 60%); border-color: #fff; box-shadow: 0 0 8px var(--c); }
#timer { position: absolute; left: 50%; top: 4px; width: 60px; height: 52px; transform: translateX(-50%); background: #0d1428; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); display: flex; align-items: center; justify-content: center; }
#timer::before { content: ""; position: absolute; inset: 2px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: linear-gradient(180deg, #1c2a4e, #0a1020); z-index: -1; }
#timer { box-shadow: none; background: linear-gradient(180deg, #9fb7ff, #3b4d86); }
#timer span { font-family: 'Chakra Petch'; font-weight: 700; font-size: 26px; color: #fff; text-shadow: 0 0 8px #7fb3ff; position: relative; }
#timer.warn span { color: #ff6a5a; text-shadow: 0 0 8px #ff3a2a; }
#hud .meter { position: absolute; bottom: 10px; width: 38%; height: 14px; background: rgba(8,10,20,.85); border: 2px solid #0b0d16; box-shadow: 0 0 0 1px rgba(160,200,255,.3); }
#hud .meter.p1 { left: 10px; transform: skewX(-24deg); }
#hud .meter.p2 { right: 10px; transform: skewX(24deg); }
#hud .meter .mfill { position: absolute; inset: 0; background: var(--c); transform-origin: left; transform: scaleX(0); box-shadow: inset 0 0 8px rgba(255,255,255,.7); }
#hud .meter.p2 .mfill { transform-origin: right; }
#hud .meter.full .mfill { animation: mpulse .5s infinite alternate; }
@keyframes mpulse { from { filter: brightness(1); } to { filter: brightness(1.7); } }
#hud .meter b { position: absolute; top: -17px; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: #cfe0ff; text-shadow: 0 0 4px #000; }
#hud .meter.p1 b { left: 4px; } #hud .meter.p2 b { right: 4px; }
#hud .meter.full b { color: #fff; text-shadow: 0 0 6px var(--c), 0 0 2px #000; }
.combo { position: absolute; top: 30%; font-family: 'Dela Gothic One'; font-size: 24px; color: #fff; opacity: 0; text-shadow: 0 0 10px var(--c), 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; transition: opacity .3s; line-height: 1; }
.combo small { display: block; font-size: 12px; font-family: 'Chakra Petch'; font-weight: 700; letter-spacing: .15em; }
#combo1 { left: 12px; } #combo2 { right: 12px; text-align: right; }
.combo.show { opacity: 1; }
.buffs { position: absolute; top: 74px; display: flex; gap: 3px; }
#buffs1 { left: 10px; } #buffs2 { right: 10px; }
.buffs img { width: 16px; height: 23px; border-radius: 2px; box-shadow: 0 0 6px rgba(255,255,255,.4); }
#pauseBtn { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); pointer-events: auto; width: 34px; height: 26px; border-radius: 6px; border: 1px solid rgba(180,200,255,.5); background: rgba(10,16,34,.75); color: #cfe0ff; font-weight: 700; font-size: 12px; }

/* ---------- slams ---------- */
#slam { position: absolute; z-index: 25; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.slamtxt { position: absolute; font-family: 'Dela Gothic One'; text-transform: uppercase; letter-spacing: -0.03em; line-height: .95; text-align: center; white-space: nowrap; color: #fff;
  -webkit-text-stroke: 3px #120a1a; paint-order: stroke fill; filter: drop-shadow(0 0 14px var(--c)) drop-shadow(0 4px 0 #000); }
.slamtxt .half { display: block; }
.slamtxt .inner { background: linear-gradient(180deg, #fff 0%, #fff 35%, var(--c) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0; }
.slam-in { animation: slamIn .18s cubic-bezier(.2,1.4,.4,1) both, shake .28s .18s both; }
@keyframes slamIn { from { transform: scale(1.45); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { translate: 0 0; } 20% { translate: -7px 3px; } 40% { translate: 6px -4px; } 60% { translate: -4px 2px; } 80% { translate: 3px -1px; } }
.slam-out .top { animation: crackT .45s ease-in both; }
.slam-out .bot { animation: crackB .45s ease-in both; }
@keyframes crackT { to { transform: translate(-18px,-16px) rotate(-4deg); opacity: 0; } }
@keyframes crackB { to { transform: translate(18px,16px) rotate(3deg); opacity: 0; } }
.slamtxt .wrap { position: relative; display: inline-block; }
.slamtxt .layer { display: block; }
.slamtxt .layer.top { clip-path: polygon(0 0, 100% 0, 100% 44%, 62% 52%, 40% 47%, 0 58%); }
.slamtxt .layer.bot { position: absolute; inset: 0; clip-path: polygon(0 58%, 40% 47%, 62% 52%, 100% 44%, 100% 100%, 0 100%); }
#movename { position: absolute; z-index: 24; pointer-events: none; font-family: 'Dela Gothic One'; text-transform: uppercase; color: #fff; text-align: center; opacity: 0; letter-spacing: -0.02em; }
#movename.show { animation: mv 1.1s ease-out both; }
@keyframes mv { 0% { opacity: 0; transform: scale(1.3); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#keyhint { position: absolute; z-index: 11; pointer-events: none; text-align: center; font-size: 12px; font-weight: 600; color: #cfe0ff; text-shadow: 0 1px 3px #000; letter-spacing: .04em; }

/* ---------- touch ---------- */
#touch { position: absolute; z-index: 12; left: 0; right: 0; bottom: 0; }
#touch.under { background: linear-gradient(180deg, rgba(4,6,14,0) 0%, rgba(4,6,14,.18) 40%, rgba(4,6,14,.5) 100%); }
#touch button { position: absolute; border: 2px solid rgba(190,210,255,.55); background: rgba(14,22,46,.72); color: #fff; touch-action: none; font-weight: 700; }
#touch button.on { background: rgba(120,170,255,.5); border-color: #fff; }
#dpad { position: absolute; }
#dpad .dp { width: 33.3%; height: 33.3%; border-radius: 12px; font-size: 18px; }
#dpad .up { left: 33.3%; top: 0; } #dpad .down { left: 33.3%; bottom: 0; }
#dpad .left { left: 0; top: 33.3%; } #dpad .right { right: 0; top: 33.3%; }
#btns { position: absolute; }
#btns .ab { border-radius: 50%; display: flex; align-items: center; justify-content: center; }
#btns .ab b { font-size: 10px; letter-spacing: .04em; line-height: 1.05; text-align: center; pointer-events: none; }
#btns .p { border-color: #ffd27a; } #btns .k { border-color: #ff9b6a; }
#btns .s1, #btns .s2 { border-color: var(--c, #7fd); }
#btns .su { border-color: #fff; background: rgba(60,40,90,.7); }
#btns .su.ready { background: var(--c); box-shadow: 0 0 16px var(--c); animation: mpulse .5s infinite alternate; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; }
#title { justify-content: center; gap: 18px; background: radial-gradient(ellipse at 50% 40%, rgba(10,16,40,.15), rgba(4,6,14,.75)); }
#logo { width: min(92vw, 760px); filter: drop-shadow(0 0 24px rgba(255,120,40,.35)) drop-shadow(0 0 30px rgba(80,180,255,.3)); animation: logoIn .7s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes logoIn { from { transform: scale(1.4); opacity: 0; } }
.tag { font-weight: 700; letter-spacing: .18em; font-size: clamp(11px, 2.6vw, 15px); color: #cfe0ff; text-shadow: 0 2px 6px #000; text-align: center; padding: 0 12px; }
button.big { font-family: 'Dela Gothic One'; font-size: 22px; padding: 12px 38px; border: 0; color: #fff; background: linear-gradient(90deg, #ff6a1f, #ff3d6a 50%, #3fb4ff); clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%); text-shadow: 0 2px 0 #000; letter-spacing: -0.01em; }
button.big:active { filter: brightness(1.3); }
button.ghost { font-weight: 700; font-size: 15px; letter-spacing: .1em; padding: 10px 20px; color: #cfe0ff; background: rgba(10,16,34,.7); border: 1px solid rgba(160,190,255,.5); border-radius: 4px; }
.howto { font-size: 13px; color: #b8c8ee; text-align: center; max-width: 520px; padding: 0 16px; line-height: 1.5; text-shadow: 0 1px 3px #000; }
.howto b { color: #fff; }

#select { background: linear-gradient(180deg, rgba(5,8,20,.78), rgba(5,8,20,.55) 40%, rgba(5,8,20,.85)); padding: 10px 8px 12px; justify-content: space-between; }
.selhead { font-family: 'Dela Gothic One'; font-size: clamp(18px, 4.6vw, 30px); text-shadow: 0 0 12px #4fa0ff, 2px 2px 0 #000; text-align: center; }
.selbody { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.preview { display: flex; align-items: flex-end; gap: 10px; width: 100%; max-width: 640px; flex: 1; min-height: 0; justify-content: center; }
.pfig { height: 100%; max-height: 360px; flex: 0 0 48%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.pfig::after { content: ""; position: absolute; bottom: -4px; left: 15%; right: 15%; height: 18px; border-radius: 50%; background: radial-gradient(ellipse, var(--c) 0, transparent 70%); opacity: .6; }
.pfig img { max-height: 100%; max-width: 100%; object-fit: contain; filter: drop-shadow(0 0 10px var(--c)); position: relative; z-index: 1; }
.pinfo { flex: 1; min-width: 0; background: rgba(8,14,32,.82); border: 1px solid var(--c); box-shadow: 0 0 14px -4px var(--c); padding: 10px 12px; border-radius: 4px; align-self: center; }
.pname { font-family: 'Dela Gothic One'; font-size: clamp(16px, 4.4vw, 26px); color: #fff; line-height: 1; text-shadow: 0 0 10px var(--c), 2px 2px 0 #000; }
.pelem { color: var(--c); font-weight: 700; font-size: 13px; margin-top: 6px; letter-spacing: .06em; text-transform: uppercase; }
.pstyle { font-weight: 700; font-size: 13px; margin-top: 2px; letter-spacing: .06em; text-transform: uppercase; color: #e8eefc; }
.ppow { list-style: none; padding: 0; margin: 8px 0 0; }
.ppow li { font-size: 12.5px; line-height: 1.25; margin: 5px 0; padding-left: 16px; position: relative; color: #c8d6f6; }
.ppow li b { color: #fff; display: block; font-size: 13px; }
.ppow li::before { content: ""; position: absolute; left: 0; top: 3px; width: 9px; height: 9px; transform: rotate(45deg); background: var(--c); box-shadow: 0 0 6px var(--c); }
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 4px; width: 100%; max-width: 900px; padding: 8px 0 2px; }
.card { width: clamp(52px, 14.5vw, 76px); aspect-ratio: 3/4; position: relative; border-radius: 5px; transition: transform .15s, box-shadow .15s; box-shadow: 0 0 0 2px var(--c), 0 4px 10px rgba(0,0,0,.7); cursor: pointer; background: #000; }
.card img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; }
.card span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 8.5px; font-weight: 700; text-align: center; background: linear-gradient(0deg, rgba(0,0,0,.9), transparent); padding: 6px 1px 2px; letter-spacing: .02em; border-radius: 0 0 4px 4px; }
.card.cur { transform: translateY(-9px) rotate(0deg) scale(1.1) !important; box-shadow: 0 0 0 2px #fff, 0 0 18px 4px var(--c); z-index: 2; }
.card.p1pick::after, .card.p2pick::after { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.card.p1pick::after { content: "P1"; background: #ff7a1f; }
.card.p2pick::after { content: "CPU"; background: #3fa8ff; }
.selfoot { display: flex; gap: 12px; align-items: center; justify-content: center; }

#powerup { background: rgba(4,6,16,.66); justify-content: center; gap: 14px; padding: 12px; }
.puhead { font-family: 'Dela Gothic One'; font-size: clamp(18px, 5vw, 30px); padding: 6px 22px; border: 1px solid #8fb0ff; background: rgba(8,14,32,.85); clip-path: polygon(4% 0, 96% 0, 100% 50%, 96% 100%, 4% 100%, 0 50%); text-shadow: 0 0 10px #4fa0ff; }
.pucards { display: flex; gap: clamp(8px, 3vw, 24px); justify-content: center; }
.pucard { width: clamp(96px, 28vw, 180px); position: relative; transform: translateY(120vh); transition: transform .5s cubic-bezier(.2,1.2,.4,1); cursor: pointer; }
.pucard.in { transform: translateY(0); }
.pucard:hover, .pucard.cur { filter: brightness(1.18) drop-shadow(0 0 14px var(--c)); }
.pucard img { width: 100%; display: block; }
.pucard .lbl { position: absolute; left: 8%; right: 8%; bottom: 9%; text-align: center; background: rgba(6,8,18,.78); padding: 4px 2px; border-top: 1px solid var(--c); }
.pucard .lbl b { display: block; font-family: 'Dela Gothic One'; font-size: clamp(11px, 3.2vw, 17px); line-height: 1.05; }
.pucard .lbl i { display: block; font-style: normal; font-weight: 700; font-size: clamp(8px, 2.3vw, 12px); color: #dfe8ff; margin-top: 3px; letter-spacing: .03em; }
.pufoot { font-size: 13px; color: #cfe0ff; text-align: center; min-height: 18px; }
.shard { position: absolute; z-index: 45; pointer-events: none; background-size: cover; }

#result { justify-content: center; gap: 14px; background: rgba(4,6,16,.6); }
.rtitle { font-family: 'Dela Gothic One'; font-size: clamp(30px, 9vw, 64px); text-shadow: 0 0 18px var(--c), 3px 3px 0 #000; text-align: center; }
.rsub { font-size: 15px; color: #cfe0ff; text-align: center; padding: 0 16px; }
.rbtns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#pause { background: rgba(4,6,16,.88); justify-content: center; gap: 12px; padding: 14px; overflow-y: auto; }
.ptitle { font-family: 'Dela Gothic One'; font-size: 32px; text-shadow: 0 0 12px #4fa0ff; }
.moves { max-width: 520px; width: 100%; font-size: 13.5px; line-height: 1.45; background: rgba(12,20,44,.8); border: 1px solid rgba(140,170,255,.4); padding: 10px 14px; border-radius: 4px; }
.moves h4 { margin: 6px 0 2px; font-family: 'Dela Gothic One'; font-weight: 400; font-size: 15px; color: var(--c, #fff); }
.moves .row { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.07); padding: 2px 0; }
.moves .row span:last-child { color: #ffd27a; font-weight: 700; text-align: right; white-space: nowrap; }
#loading { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(4,6,16,.8); font-weight: 700; letter-spacing: .2em; }
.spin { width: 26px; height: 26px; border: 3px solid #3fa8ff; border-top-color: #ff7a1f; border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
#soundBtn { position: absolute; z-index: 70; right: 8px; bottom: 8px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(160,190,255,.5); background: rgba(10,16,34,.75); color: #cfe0ff; font-size: 11px; font-weight: 700; }
body.fighting #soundBtn { top: 60px; bottom: auto; right: auto; left: calc(50% + 24px); width: 34px; height: 26px; border-radius: 6px; font-size: 10px; }

body.touchside #hud .meter { bottom: auto; top: 76px; width: 30%; height: 10px; }
body.touchside #hud .meter b { top: 10px; font-size: 9px; }
body.touchside .buffs { top: 100px; }
body.touchside #touch button { background: rgba(14,22,46,.42); }
