/* PvP arena (systems/pvp/): stats, tabs, team picker, opponents, the battle replay. */

.pvp-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.pvp-stat { display: grid; gap: 1px; padding: 6px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); min-width: 84px; }
.pvp-stat span { color: var(--muted); font-size: 0.72rem; }
.pvp-stat b { font-family: var(--pixel); font-size: 1.1rem; }
.pvp-stat.gold b { color: var(--accent); }

.pvp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pvp-tab {
  padding: 7px 16px; border-radius: 9px; border: 1px solid var(--line); background: #0b1424;
  color: var(--muted); font-family: var(--pixel); font-size: 0.95rem; cursor: pointer;
}
.pvp-tab:hover { color: var(--text); background: #14223b; }
.pvp-tab.on { background: var(--card-2); border-color: var(--accent); color: var(--accent); }

.pvp-body { display: grid; gap: 12px; }
.pvp-card { display: grid; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.pvp-card h3, .pvp-fight-title { font-family: var(--pixel); font-size: 1.05rem; }
.pvp-actions { display: flex; justify-content: flex-end; }
.pvp-flash { margin-bottom: 10px; padding: 8px 12px; border-radius: 8px; background: #2a3550; font-size: 0.9rem; }

/* the team picker */
.pp { display: grid; gap: 10px; }
.pp-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pp-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; }
.pp-chip {
  position: relative; display: grid; justify-items: center; gap: 1px; min-width: 96px; padding: 6px 8px 8px;
  border-radius: 10px; border: 1px solid var(--line); background: #0b1424; color: var(--text); font: inherit; cursor: pointer;
}
.pp-chip:hover { border-color: var(--accent); }
.pp-chip.on { border-color: var(--accent); background: #2a2610; }
.pp-empty { border-style: dashed; cursor: default; min-height: 82px; align-content: center; }
.pp-empty:hover { border-color: var(--line); }
.pp-order { position: absolute; top: 4px; left: 6px; font-family: var(--pixel); font-size: 0.75rem; color: var(--accent); }
.pp-name { font-family: var(--pixel); font-size: 0.8rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-sub { font-size: 0.68rem; color: var(--muted); }

/* opponents: name + elo on top, the details under them, the team, and the action(s) at the end;
   a narrow card puts the actions on their own row instead of squeezing the rest */
.pvp-opps { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.pvp-opp {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 10px; align-items: center;
  padding: 10px 12px; border-radius: 10px; background: #0b1424; border: 1px solid var(--line);
}
.pvp-opp:hover { border-color: #3b4f7a; }
.pvp-opp.leader { border-color: #3b4f7a; }
/* an arena card: who on the first row, the team and "Atacar" on the second */
.pvp-opp:not(.duel) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who who" "team act"; }
.pvp-opp:not(.duel) > .pvp-opp-who { grid-area: who; }
.pvp-opp:not(.duel) > .pvp-team { grid-area: team; }
.pvp-opp:not(.duel) > .btn { grid-area: act; align-self: center; }
.pvp-opp-who { display: grid; gap: 4px; min-width: 0; justify-items: start; }
.pvp-opp-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.pvp-opp-who b, .pvp-opp-who .pvp-name { font-family: var(--pixel); font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pvp-opp-sub { font-size: 0.75rem; color: var(--muted); }
/* the live-duel card: who on top, the two challenge buttons as a full row */
.pvp-opp.duel { grid-template-columns: minmax(0, 1fr); }
.pvp-duel-bts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pvp-duel-bts .btn { width: 100%; }
.pvp-team { display: flex; gap: 2px; }
.pvp-mon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 50% 65%, #24477e, #0f1d38 75%); }

/* ranking and history */
.pvp-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.pvp-table th, .pvp-table td { padding: 7px 12px; text-align: left; border-top: 1px solid #ffffff10; }
.pvp-table th { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.pvp-table tr.top b { color: var(--accent); }
.pvp-trophy { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: middle; }
.pvp-history { display: grid; gap: 6px; }
.pvp-hist { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto 52px auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); border-left-width: 4px; }
.pvp-hist.won { border-left-color: #4cc96a; }
.pvp-hist.lost { border-left-color: #e5484d; }
.pvp-hist.draw { border-left-color: #a8b3c7; }
.pvp-hist b { font-family: var(--pixel); }
.pvp-hist .up { color: #4cc96a; font-family: var(--pixel); }
.pvp-hist .down { color: #ff7a8a; font-family: var(--pixel); }
@media (max-width: 700px) { .pvp-hist { grid-template-columns: 1fr auto; } }

/* the result after a fight */
.pvp-result { display: grid; justify-items: center; gap: 8px; padding: 16px; border-radius: 12px; text-align: center; border: 1px solid var(--line); background: var(--card); }
.pvp-result h3 { font-family: var(--pixel); font-size: 1.8rem; }
.pvp-result.won { border-color: #4cc96a; background: linear-gradient(180deg, #163a2a, var(--card)); }
.pvp-result.won h3 { color: #6dff8b; }
.pvp-result.lost { border-color: #6b2b40; background: linear-gradient(180deg, #3a1c2a, var(--card)); }
.pvp-result.lost h3 { color: #ff8fa3; }

/* ---------------------------------------------------------------- the replay */
.rp { display: grid; gap: 10px; }
.rp-arena {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 12px;
  padding: 16px; border-radius: 14px; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 120%, #2f4d2a 0%, #1b2f1c 35%, #0e1626 75%);
}
.rp-vs { font-family: var(--pixel); font-size: 1.6rem; color: var(--muted); align-self: center; }
.rp-side { display: grid; justify-items: center; gap: 4px; text-align: center; }
.rp-trainer { font-family: var(--pixel); font-size: 0.85rem; color: var(--muted); }
.rp-dots { display: flex; gap: 4px; }
.rp-dot { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #0b1424; border: 1px solid var(--line); }
.rp-dot.cur { border-color: var(--accent); }
.rp-dot.out { filter: grayscale(1) brightness(0.5); }
.rp-stage { position: relative; display: grid; place-items: end center; width: 150px; height: 130px; }
.rp-stage::after { content: ''; position: absolute; bottom: 2px; width: 90px; height: 14px; border-radius: 50%; background: #0006; z-index: 0; }
.rp-sprite { position: relative; z-index: 1; transition: transform 0.15s, opacity 0.4s, filter 0.4s; }
.rp-side b { font-family: var(--pixel); font-size: 1.05rem; }
.rp-types { display: flex; gap: 4px; }
.rp-hp { width: min(220px, 100%); height: 10px; border-radius: 5px; background: #0b1424; border: 1px solid #ffffff22; overflow: hidden; }
.rp-hp i { display: block; height: 100%; transition: width 0.3s; }
.rp-hp i.hi { background: linear-gradient(90deg, #2f8f4a, #4cc96a); }
.rp-hp i.mid { background: linear-gradient(90deg, #b8901a, #ffd23f); }
.rp-hp i.lo { background: linear-gradient(90deg, #8f2f3a, #e5484d); }
.rp-hp-text { font-size: 0.75rem; color: var(--muted); font-family: var(--pixel); }
.rp-side.enter .rp-sprite { animation: rp-enter 0.35s ease-out; }
.rp-side.side-a.hit .rp-sprite { animation: rp-lunge-a 0.25s ease-out; }
.rp-side.side-b.hit .rp-sprite { animation: rp-lunge-b 0.25s ease-out; }
.rp-side.hurt .rp-sprite { animation: rp-hurt 0.3s; }
.rp-side.ko .rp-sprite { opacity: 0.25; filter: grayscale(1); transform: translateY(10px); }
@keyframes rp-enter { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rp-lunge-a { 50% { transform: translateX(18px); } }
@keyframes rp-lunge-b { 50% { transform: translateX(-18px); } }
@keyframes rp-hurt { 25%, 75% { filter: brightness(2.2); transform: translateX(-4px); } 50% { transform: translateX(4px); } }
.rp-pops { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.rp-pop { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-family: var(--pixel); font-size: 1.15rem; color: #ff8a3d; text-shadow: 0 2px 0 #000; animation: rp-pop 1.1s ease-out forwards; }
.rp-pop.super { color: #ffcc00; font-size: 1.4rem; }
.rp-pop.weak { color: #a8b3c7; }
@keyframes rp-pop { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -40px; } }
@media (prefers-reduced-motion: reduce) { .rp-sprite, .rp-pop { animation: none !important; } }
.rp-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rp-speed { display: flex; gap: 4px; }
.rp-speed-bt { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0b1424; color: var(--muted); font-family: var(--pixel); cursor: pointer; }
.rp-speed-bt.on { border-color: var(--accent); color: var(--accent); }
.rp-log { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); min-height: 150px; align-content: start; font-size: 0.85rem; }
.rp-line.a { color: #9fc2ff; }
.rp-line.b { color: #ffb3c0; }
.rp-line.ko { color: var(--accent); font-weight: 600; }
.rp-line.enter { color: var(--muted); }
@media (max-width: 600px) { .rp-stage { width: 110px; height: 100px; } .rp-vs { font-size: 1.1rem; } }

/* ---------------------------------------------------------------- live duels (pvp/duel.js) */
.pvp-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.duel-invite {
  position: fixed; z-index: 60; right: 20px; bottom: 20px; width: min(380px, calc(calc(100vw / var(--ui-zoom, 1)) - 32px));
  display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 14px;
  border-radius: 14px; border: 2px solid var(--accent); background: var(--bg-2);
  box-shadow: 0 12px 32px #000c; animation: duel-in 0.3s ease-out;
}
.duel-invite > img { width: 48px; height: 48px; image-rendering: pixelated; }
.duel-invite-text { display: grid; gap: 4px; }
.duel-invite-text b { font-family: var(--pixel); font-size: 1rem; color: var(--accent); }
.duel-invite-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.duel-team { display: flex; gap: 2px; }
.duel-toast {
  position: fixed; z-index: 61; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(calc(100vw / var(--ui-zoom, 1)) - 32px);
  padding: 10px 18px; border-radius: 10px; background: #2a3550; border: 1px solid var(--line); font-size: 0.9rem;
}
@keyframes duel-in { from { transform: translateY(20px); opacity: 0; } }

/* ---------------------------------------------------------------- elo badges (pvp/elo.js) */
.elo { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 2px; border-radius: 999px; background: #0b1424; border: 1px solid var(--elo, #59647a); font-family: var(--pixel); font-size: 0.75rem; color: var(--elo, #a8b3c7); white-space: nowrap; vertical-align: middle; }
.elo-gem {
  display: grid; place-items: center; width: 18px; height: 18px; clip-path: polygon(50% 0, 100% 35%, 82% 100%, 18% 100%, 0 35%);
  background: linear-gradient(160deg, var(--elo-hi, #ccc), var(--elo, #59647a) 70%);
}
.elo-gem b { font-size: 0.5rem; color: #10182b; line-height: 1; margin-top: 3px; }
.elo-gem-img { width: 20px; height: 20px; object-fit: contain; }
.elo.big { font-size: 1rem; padding: 2px 12px 2px 3px; }
.elo.big .elo-gem { width: 28px; height: 28px; }
.elo.big .elo-gem b { font-size: 0.65rem; }
.elo.big .elo-gem-img { width: 30px; height: 30px; }
.elo-ferro { --elo: #8a8f99; --elo-hi: #c9ccd2; }
.elo-bronze { --elo: #b0703a; --elo-hi: #f0b27a; }
.elo-prata { --elo: #9fb3c8; --elo-hi: #eef4fb; }
.elo-ouro { --elo: #d9a91a; --elo-hi: #ffe58a; }
.elo-platina { --elo: #2fb5a0; --elo-hi: #a6f5e6; }
.elo-diamante { --elo: #4a86ff; --elo-hi: #b9d3ff; }
.elo-mestre { --elo: #b26bff; --elo-hi: #e2c4ff; }
.elo-desafiante { --elo: #ffd23f; box-shadow: 0 0 8px #ffd23f66; }
.pvp-elo { min-width: 190px; gap: 4px; }
.elo-bar { height: 6px; border-radius: 3px; background: #0b1424; overflow: hidden; }
.elo-bar i { display: block; height: 100%; background: linear-gradient(90deg, #4a86ff, #b26bff); }
.pvp-tier-change { font-family: var(--pixel); font-size: 1.1rem; color: var(--accent); }
.pvp-table tr.me td { background: #1f3460; }
.duel-invite.ranked { border-color: #ffd23f; box-shadow: 0 0 0 3px #ffd23f33, 0 12px 32px #000c; }
.duel-invite-elo { display: flex; align-items: center; gap: 6px; }
.duel-ranked-note { color: #ffd23f; }
