@font-face { font-family:"BrawldexUI"; src:url("assets/fonts/power clear bold.ttf"); }
/* the website's calling-card font — same files, same name, so cards match exactly */
@font-face { font-family:"PKMN"; src:url("assets/fonts/power clear.ttf"); }
@font-face { font-family:"PKMN"; src:url("assets/fonts/power clear bold.ttf"); font-weight:700; }
@font-face { font-family:"BrawldexBody"; src:url("assets/fonts/power clear.ttf"); }
@font-face { font-family:"BrawldexNarrow"; src:url("assets/fonts/power green narrow.ttf"); }

:root{
  --bg:#000000; --panel:#0a0a0a; --panel2:#111111; --ink:#eef1ff;
  --muted:#9aa3c8; --gold:#ffd34d; --accent:#ff5a7e; --win:#5fc96a; --lose:#ff5a7e;
}
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{
  margin:0; height:100%; background:var(--bg); color:var(--ink);
  font-family:BrawldexBody,system-ui,sans-serif; overscroll-behavior:none; user-select:none;
}
#loading{
  position:fixed; inset:0; display:flex; align-items:center; justify-content:center;
  font-family:BrawldexUI; color:var(--gold); font-size:20px; letter-spacing:1px;
}
#app{ height:100dvh; display:flex; flex-direction:column; }

/* ---------- top bar ---------- */
#topbar{
  display:flex; flex-direction:column; gap:3px; padding:4px 6px;
  background:#000; border-bottom:0; flex:0 0 auto;
}
#roster{
  display:flex; flex-wrap:nowrap; gap:3px; width:100%;
  overflow:hidden; justify-content:center; align-items:stretch;
}
.chip{
  display:flex; flex-direction:column; align-items:center; gap:0; background:rgba(12,16,40,.72);
  border:1px solid #2a345c; border-radius:6px; padding:1px; flex:1 1 0; min-width:0; max-width:64px; position:relative;
}
.chip-top{ position:relative; width:100%; display:flex; align-items:center; justify-content:center; }
.chip-img{ width:100%; height:auto; aspect-ratio:1/1; image-rendering:pixelated; }
.chip-ball{ position:absolute; right:0; bottom:0; width:12px; height:12px; image-rendering:pixelated; }
.chip-name{ display:none; }            /* hide name to keep squares tiny */
.chip-types{ display:none; }
.chip-hp{ width:90%; height:3px; background:#3a1d22; border-radius:2px; overflow:hidden; margin:1px auto 0; }
.chip-hp > i{ display:block; height:100%; background:linear-gradient(90deg,#3ddc6e,#7be87b); }
.chip.dead{ opacity:0.32; filter:grayscale(0.8); }
.chip.mine{ border-color:#ffd24a; box-shadow:0 0 6px rgba(255,210,74,0.5); }

/* item pickup feed — floats over the arena, doesn't resize the field */
#itemFeed{
  position:absolute; left:6px; bottom:6px; z-index:5;
  display:flex; flex-direction:column-reverse; gap:2px; max-height:40%; width:auto; max-width:70%;
  overflow:hidden; pointer-events:none;
}
.feed-row{ display:flex; align-items:center; gap:6px; font-size:11px; color:#cdd7f5;
  background:rgba(20,26,52,0.6); border-radius:5px; padding:1px 6px; animation:feedIn .25s ease; }
.feed-row img{ width:16px; height:16px; image-rendering:pixelated; }
.feed-row b{ color:#ffd24a; font-weight:600; }
.feed-row .fd-desc{ color:#9fb0d6; }
@keyframes feedIn{ from{ opacity:0; transform:translateY(-4px); } to{ opacity:1; transform:none; } }

/* mini controls floated on the arena */
#miniCtrls{ position:absolute; right:6px; top:6px; display:flex; gap:4px; z-index:5; }
#miniCtrls .ghost{ padding:4px 8px; font-size:12px; }
.brand{ font-family:BrawldexUI; font-size:22px; letter-spacing:1px; color:var(--gold); text-shadow:0 2px 0 #7a5a00; }
.brand span{ color:var(--accent); }
.stats{ margin-left:auto; display:flex; align-items:center; gap:10px; }
.stat{ display:flex; flex-direction:column; align-items:center; line-height:1; }
.stat label{ font-size:9px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); }
.stat b{ font-family:BrawldexUI; font-size:16px; color:var(--ink); }
.stat:nth-child(3) b{ color:var(--gold); }
.ghost{
  background:#0c1330; border:2px solid #2a345c; color:var(--ink);
  border-radius:10px; padding:8px 12px; font-size:13px; cursor:pointer; font-family:BrawldexBody;
}
.ghost:active{ transform:translateY(1px); }

/* ---------- stage ---------- */
#stage{ position:relative; flex:1 1 auto; min-height:0; background:#000; }
#arena{ width:100%; height:100%; display:block; image-rendering:pixelated; }
#roster{
  display:flex; flex-wrap:nowrap; gap:4px; padding:2px 0 0; width:100%;
  overflow-x:auto; overflow-y:hidden; justify-content:flex-start;
}
#roster::-webkit-scrollbar{ height:4px; }
#roster::-webkit-scrollbar-thumb{ background:#2a345c; border-radius:3px; }
.chip{
  display:flex; flex-direction:column; align-items:center; gap:1px; background:rgba(12,16,40,.72);
  border:1px solid #2a345c; border-radius:7px; padding:2px 3px 3px; width:62px; flex:0 0 auto; position:relative;
}
.chip.mine{ border-color:var(--gold); box-shadow:0 0 8px rgba(255,211,77,.5); }
.chip.dead{ opacity:.32; filter:grayscale(1); }
.chip-top{ position:relative; width:26px; height:26px; }
.chip-img{ width:26px; height:26px; image-rendering:pixelated; }
.chip-ball{ position:absolute; right:-5px; bottom:-3px; width:14px; height:14px; image-rendering:pixelated; }
.chip-name{ font-family:BrawldexNarrow; font-size:8px; line-height:1; white-space:nowrap; max-width:50px; overflow:hidden; text-overflow:ellipsis; }
.chip-types{ display:flex; flex-direction:row; gap:1px; justify-content:center; }
.ctype{ width:24px; height:auto; image-rendering:pixelated; }
.chip-hp{ width:100%; height:4px; background:#0a0d1c; border-radius:2px; overflow:hidden; margin-top:1px; }
.chip-hp>i{ display:block; height:100%; width:100%; background:var(--win); transition:width .12s; }
.chip-status{ position:absolute; top:1px; left:1px; display:flex; gap:1px; }
.chip-status img{ width:11px; height:11px; image-rendering:pixelated; }
.chip-ability{ display:flex; flex-direction:column; align-items:center; margin-top:2px; width:100%; }
.chip-ability .ab-name{ font-family:BrawldexUI, monospace; font-weight:700; font-size:8px; line-height:1.05;
  color:#c9a8ff; text-align:center; white-space:normal; }
.chip-ability .ab-desc{ font-family:BrawldexNarrow, monospace; font-size:7px; line-height:1.05;
  color:#9fb0d6; text-align:center; white-space:normal; margin-top:1px; }
.chip-item{ position:absolute; bottom:14px; left:1px; width:14px; height:14px; image-rendering:pixelated;
  filter:drop-shadow(0 1px 1px rgba(0,0,0,0.8)); z-index:3; }
.chip-shiny{ position:absolute; top:0px; right:2px; color:#ff3b3b; font-size:11px; line-height:1;
  text-shadow:0 0 2px rgba(255,0,0,0.6), 0 1px 1px rgba(0,0,0,0.7); z-index:3; pointer-events:none; }
.ball-tag{ font-family:BrawldexNarrow; font-size:11px; padding:1px 6px; border-radius:6px; color:#111; }
.ball-tag.poke{ background:#ee3b3b; color:#fff; } .ball-tag.great{ background:#2f7bd6; color:#fff; }
.ball-tag.ultra{ background:#e6b422; } .ball-tag.master{ background:#7b3ff2; color:#fff; }

/* ---------- bottom panel: floating overlay so the canvas fills the whole screen ---------- */
#panel{
  position:absolute; left:10px; right:10px; bottom:calc(10px + env(safe-area-inset-bottom));
  z-index:9; background:rgba(14,18,40,0.86); border:1px solid rgba(255,255,255,0.1);
  border-radius:16px; padding:10px 12px; backdrop-filter:none;
}
#panel.hidden{ display:none; }
#status{ margin:0 0 10px; font-size:14px; color:var(--muted); text-align:center; min-height:18px; }
#status .ok{ color:var(--win); } #status .no{ color:var(--accent); }

#picks{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:12px; }
#picks.hidden{ display:none; }
@media (max-width:430px){ #picks{ grid-template-columns:repeat(2,1fr); } }

.pick-card{
  display:flex; flex-direction:column; align-items:center; gap:5px;
  background:var(--panel); border:3px solid var(--type,#2a345c); border-radius:13px;
  padding:9px 6px; cursor:pointer; color:var(--ink); transition:transform .08s,box-shadow .12s;
}
.pick-card:active{ transform:scale(.96); }
.pick-card.sel{ box-shadow:0 0 0 3px var(--gold),0 0 18px var(--type); background:var(--panel2); }
.pick-sprite{ width:46px; height:46px; image-rendering:pixelated; }
.pick-name{ font-family:BrawldexUI; font-size:12px; text-align:center; line-height:1.1; }
.pick-types{ display:flex; gap:3px; flex-wrap:wrap; justify-content:center; }
.type{
  font-family:BrawldexNarrow; font-size:9px; padding:1px 5px; border-radius:5px;
  color:#0b0f22; font-weight:bold; text-transform:uppercase;
}

.actions{ display:flex; align-items:center; gap:10px; justify-content:center; flex-wrap:wrap; }
.primary{
  font-family:BrawldexUI; font-size:16px; letter-spacing:.5px; color:#0b0f22; background:var(--gold);
  border:none; border-radius:12px; padding:13px 30px; cursor:pointer; box-shadow:0 4px 0 #a9831f;
}
.primary:active{ transform:translateY(3px); box-shadow:0 1px 0 #a9831f; }
.primary:disabled{ filter:grayscale(.6) brightness(.7); box-shadow:none; cursor:default; }
.seed{ font-family:BrawldexNarrow; font-size:11px; color:var(--muted); }

/* ---------- economy: overlays ---------- */
.overlay{
  position:absolute; inset:0; z-index:5; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:12px; padding:20px; text-align:center;
  background:radial-gradient(120% 90% at 50% 0%, rgba(26,32,64,.94), rgba(8,10,22,.97));
  backdrop-filter:blur(3px);
}
.overlay.hidden{ display:none; }
.overlay h3{ font-family:BrawldexUI; font-size:22px; margin:0; color:var(--gold); letter-spacing:1px; }
.overlay-sub{ color:var(--muted); font-size:13px; margin:0; max-width:34ch; }
.ghost-btn{ background:#2a345c; color:var(--ink); box-shadow:0 4px 0 #161d39; }
.coins-stat b{ color:var(--gold); }

/* steal wheel */
.wheel-wrap{ position:relative; width:300px; height:300px; }
#wheel{ width:300px; height:300px; }
.wheel-ptr{
  position:absolute; top:-4px; left:50%; transform:translateX(-50%); z-index:2;
  width:0; height:0; border-left:14px solid transparent; border-right:14px solid transparent;
  border-top:24px solid var(--gold); filter:drop-shadow(0 2px 2px rgba(0,0,0,.5));
}
.wheel-result{ font-family:BrawldexUI; font-size:15px; color:var(--ink); min-height:20px; margin:0; }
.wheel-result b{ color:var(--gold); }

/* PC grid */
.pc-grid{
  display:grid; grid-template-columns:repeat(4,1fr); gap:8px;
  width:100%; max-width:440px; max-height:52vh; overflow-y:auto; padding:4px;
}
@media (max-width:430px){ .pc-grid{ grid-template-columns:repeat(3,1fr); } }
.pc-cell{
  display:flex; flex-direction:column; align-items:center; gap:3px; cursor:pointer;
  background:var(--panel); border:2px solid var(--type,#2a345c); border-radius:11px; padding:7px 4px;
  color:var(--ink);
}
.pc-cell canvas{ width:40px; height:40px; image-rendering:pixelated; }
.pc-cell span{ font-family:BrawldexNarrow; font-size:9px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.pc-cell.on{ box-shadow:0 0 0 3px var(--gold), 0 0 14px var(--type); background:var(--panel2); }

/* lootbox */
#ballStage{
  width:120px; height:120px; display:flex; align-items:center; justify-content:center;
  background:#0c1330; border:3px solid #2a345c; border-radius:18px;
}
#ballSprite{ width:96px; height:96px; image-rendering:pixelated; }

/* ---- mode picker ---- */
#modeModal, #pickModal, #mapModal, #musicModal{ position:fixed; inset:0; background:rgba(8,10,22,0.82); z-index:50;
  align-items:center; justify-content:center; padding:18px; }
.mode-card{ background:#161a2e; border:1px solid #2b3253; border-radius:16px; padding:20px 18px;
  width:100%; max-width:380px; box-shadow:0 18px 50px rgba(0,0,0,0.5); }
.mode-card h2{ margin:0 0 14px; font-size:18px; color:#eef; text-align:center; }
.mode-group{ margin-bottom:16px; }
.mode-group > label{ display:block; font-size:12px; text-transform:uppercase; letter-spacing:0.08em;
  color:#8ea0c8; margin-bottom:7px; }
.mode-row{ display:flex; flex-wrap:wrap; gap:7px; }
.mode-row .seg{ flex:1 1 auto; min-width:62px; padding:9px 8px; border-radius:10px;
  border:1px solid #2f3760; background:#1d2440; color:#cdd7f5; font-size:13px; font-weight:600;
  cursor:pointer; transition:all .12s; }
.mode-row .seg.on{ background:linear-gradient(180deg,#5468ff,#3f4fd6); border-color:#6b7cff;
  color:#fff; box-shadow:0 2px 10px rgba(84,104,255,0.4); }
#modeApply{ width:100%; margin-top:4px; }
#ballGroup.disabled{ opacity:0.4; pointer-events:none; }

/* boss roster chip */
.chip.boss{ border-color:#ff5470; box-shadow:0 0 10px rgba(255,84,112,0.6); }
.chip.boss .chip-name::before{ content:"☠ "; color:#ff5470; }
#roster{ flex-wrap:nowrap; align-items:flex-start; justify-content:center; overflow-x:auto; }

/* ---- developer move previewer ---- */
#devModal{ position:fixed; inset:0; background:rgba(6,8,18,0.88); z-index:60;
  display:flex; align-items:center; justify-content:center; padding:16px; }
.dev-card{ background:#13172a; border:1px solid #2b3253; border-radius:14px; padding:14px;
  width:100%; max-width:420px; max-height:86vh; display:flex; flex-direction:column; gap:10px; }
.dev-head{ display:flex; align-items:center; justify-content:space-between; }
.dev-head h2{ margin:0; font-size:17px; color:#eef; }
#devSearch{ width:100%; padding:9px 11px; border-radius:9px; border:1px solid #2f3760;
  background:#0d1124; color:#dce3ff; font-size:14px; }
#devList{ flex:1 1 auto; overflow-y:auto; display:flex; flex-direction:column; gap:2px; min-height:120px; }
.dev-move{ display:flex; align-items:center; gap:8px; padding:7px 9px; border-radius:8px;
  background:#1a2038; border:1px solid transparent; cursor:pointer; font-size:13px; color:#cdd7f5; }
.dev-move:hover{ background:#232b4d; }
.dev-move.on{ border-color:#6b7cff; background:#2a3360; }
.dev-move .dm-type{ font-size:10px; padding:1px 6px; border-radius:6px; color:#fff; opacity:0.9; }
.dev-move .dm-name{ flex:1 1 auto; }
.dev-move .dm-kind{ font-size:10px; color:#8ea0c8; }
.dev-foot{ display:flex; align-items:center; gap:8px; }
#devCurrent{ flex:1 1 auto; font-size:12px; color:#8ea0c8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ---- gym run ---- */
#gymModal{ position:fixed; inset:0; background:rgba(6,8,18,0.9); z-index:60;
  display:flex; align-items:center; justify-content:center; padding:16px; }
.gym-card{ background:#13172a; border:1px solid #2b3253; border-radius:14px; padding:18px 16px;
  width:100%; max-width:440px; max-height:88vh; overflow-y:auto; display:flex; flex-direction:column; gap:10px; }
.gym-card h2{ margin:0; font-size:19px; color:#ffd24a; text-align:center; }
.gym-sub{ margin:0; text-align:center; font-size:13px; color:#9fb0d6; }
.gym-team{ display:flex; flex-wrap:wrap; gap:6px; justify-content:center; }
.gym-mon{ width:62px; display:flex; flex-direction:column; align-items:center; gap:1px;
  background:#1a2038; border:2px solid #2a345c; border-radius:9px; padding:3px; cursor:pointer; position:relative; }
.gym-mon.sel{ border-color:#6b7cff; box-shadow:0 0 8px rgba(107,124,255,0.5); }
.gym-mon.can-evo::after{ content:"▲"; position:absolute; top:1px; right:3px; color:#5fe07b; font-size:9px; }
.gym-mon canvas{ width:46px; height:46px; image-rendering:pixelated; }
.gym-mon .gm-name{ font-size:9px; color:#cdd7f5; text-align:center; line-height:1.1; max-width:60px; overflow:hidden; }
.gym-choice{ display:flex; flex-direction:column; gap:7px; }
.gym-hint{ margin:0; text-align:center; font-size:12px; color:#8ea0c8; min-height:16px; }
.gym-progress{ display:flex; flex-wrap:wrap; gap:4px; justify-content:center; margin-bottom:4px; }
.gym-badge{ font-size:10px; padding:2px 7px; border-radius:10px; background:#222a4a; color:#8ea0c8; }
.gym-badge.won{ background:#2f6b3a; color:#cfeecf; }
.gym-badge.now{ background:#5468ff; color:#fff; }

/* team tints on roster squares (6v6 / gym) */
.chip.team0{ border-color:#4a90ff; }
.chip.team1{ border-color:#ff5470; }

/* recording indicator */
/* Record indicator disabled — the user screen-records on their phone, so this must
   never appear on screen. Hidden here so no code path can show it. */
#recDot{ display:none !important; }
@keyframes recPulse{ 0%,100%{ opacity:1 } 50%{ opacity:0.5 } }

/* ability feed rows (like item rows but violet-accented) */
.feed-row.ability{ background:rgba(40,26,60,0.6); }
.feed-row .fd-ico{ color:#c9a8ff; font-size:14px; width:16px; text-align:center; }
.feed-row.ability b{ color:#c9a8ff; }

/* ---------- full-screen overhaul: canvas fills everything; HUD is drawn ON canvas ---------- */
#topbar{ display:none !important; }        /* roster now drawn on-canvas (shows in recordings) */
#itemFeed{ display:none !important; }      /* feed now drawn on-canvas */
#app{ position:fixed; inset:0; height:100dvh; }
#stage{ position:absolute; inset:0; }
#miniCtrls{ z-index:9; }
#recDot{ z-index:9; }
