/* ============================================================
   NEYOMON — "Midnight Pokédex" design system
   ============================================================ */
:root {
  --void: #0B0E17;
  --panel: #131829;
  --panel-2: #171E33;
  --edge: #232B45;
  --text: #EDF0F8;
  --muted: #8B93B0;
  --red: #FF3D2E;
  --red-dim: #c42a1e;
  --spark: #FFCB05;
  --good: #3ddc84;
  --warn: #ffb347;
  --hp-green: #4caf50;
  --hp-yellow: #ffc107;
  --hp-red: #f44336;
  --font-d: 'Chakra Petch', 'Segoe UI', sans-serif;
  --font-b: 'Inter', system-ui, sans-serif;
  --r: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--void);
  color: var(--text);
  font-family: var(--font-b);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 18px; }
h1, h2, h3, h4, button { font-family: var(--font-d); letter-spacing: 0.02em; }
img { user-select: none; -webkit-user-drag: none; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--edge); background: var(--panel-2); color: var(--text);
  padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--red); transform: translateY(-1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--red), var(--red-dim)); border-color: transparent; box-shadow: 0 4px 18px rgba(255, 61, 46, 0.3); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(255, 61, 46, 0.45); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.big { padding: 13px 20px; font-size: 16px; }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), input[type="number"] {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--edge); background: var(--void); color: var(--text);
  font-family: var(--font-b); font-size: 14px; outline: none; transition: border 0.15s;
}
input:focus { border-color: var(--red); }

/* ---------- boot loader ---------- */
#boot-loader {
  position: fixed; inset: 0; z-index: 200; background: var(--void);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.boot-ball {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(180deg, var(--red) 46%, #0d0d14 46%, #0d0d14 54%, #EDF0F8 54%);
  position: relative; animation: bounce 1s ease-in-out infinite;
  box-shadow: 0 8px 30px rgba(255, 61, 46, 0.4);
}
.boot-ball::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%; background: #EDF0F8; border: 4px solid #0d0d14;
}
.boot-ball.small { width: 40px; height: 40px; animation: spin 3s linear infinite; }
.boot-ball.tiny { width: 24px; height: 24px; animation: none; }
.boot-ball.tiny::after { width: 6px; height: 6px; border-width: 2px; }
@keyframes bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-14px) rotate(15deg) } }
@keyframes spin { to { transform: rotate(360deg) } }
.boot-text { font-family: var(--font-d); font-weight: 700; font-size: 22px; letter-spacing: 0.4em; color: var(--muted); }

/* ---------- auth ---------- */
#auth-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(255, 61, 46, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 85% 85%, rgba(255, 203, 5, 0.07), transparent),
    var(--void);
}
.auth-bg::after {
  content: ''; position: absolute; inset: 0; opacity: 0.35;
  background-image: radial-gradient(rgba(237, 240, 248, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}
.auth-card {
  position: relative; width: min(400px, 92vw); background: rgba(19, 24, 41, 0.9);
  border: 1px solid var(--edge); border-radius: 20px; padding: 34px 30px;
  backdrop-filter: blur(14px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.auth-logo { display: flex; align-items: center; gap: 12px; justify-content: center; }
.auth-logo h1 { font-size: 28px; letter-spacing: 0.25em; background: linear-gradient(90deg, var(--text), var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-tag { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 22px; }
.auth-tabs { display: flex; background: var(--void); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 8px; background: none; border: none; color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.auth-tab.active { background: var(--panel-2); color: var(--text); }
#login-form, #register-form { display: flex; flex-direction: column; gap: 12px; }
.auth-note { font-size: 11px; color: var(--muted); text-align: center; }
#auth-error { color: var(--red); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }
.auth-sprites { position: absolute; bottom: 4vh; left: 50%; transform: translateX(-50%); display: flex; gap: 4vw; opacity: 0.5; }
.auth-sprites img { width: 92px; height: 92px; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45)); animation: float 4s ease-in-out infinite; }
.auth-sprites img:nth-child(2n) { animation-delay: -2s; }
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-12px) } }

/* ---------- app shell ---------- */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 215px; min-width: 215px; background: var(--panel); border-right: 1px solid var(--edge);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 18px;
}
.sb-logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-d); font-weight: 700; letter-spacing: 0.2em; padding: 0 8px; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#nav button {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: none;
  border: 1px solid transparent; border-radius: 10px; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; transition: all 0.15s;
}
#nav button i { font-style: normal; font-size: 16px; }
#nav button:hover { color: var(--text); background: var(--panel-2); }
#nav button.active { color: var(--text); background: var(--panel-2); border-color: var(--edge); box-shadow: inset 3px 0 0 var(--red); }
.sb-foot { border-top: 1px solid var(--edge); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.sb-online { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; padding: 0 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.sb-user { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-weight: 600; font-size: 14px; }

#main { flex: 1; overflow-y: auto; position: relative; }
.screen { display: none; min-height: 100%; padding: 24px; animation: fadeSlide 0.25s ease; }
.screen.active { display: block; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ---------- panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--r);
  padding: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.panel h3 { margin-bottom: 14px; }

/* ---------- home ---------- */
.home-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; max-width: 1100px; margin: 0 auto; }
.trainer-card { grid-column: 1 / -1; }
.tc-top { display: flex; align-items: center; gap: 16px; }
.tc-avatar {
  width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--red), var(--red-dim)); font-family: var(--font-d);
  font-size: 26px; font-weight: 700; box-shadow: 0 6px 20px rgba(255, 61, 46, 0.35);
}
.tc-top h2 { font-size: 22px; }
.tc-money { margin-left: auto; font-family: var(--font-d); font-size: 22px; color: var(--spark); font-weight: 700; }
.tc-stats { display: flex; gap: 26px; margin: 18px 0; }
.tc-stats div { display: flex; flex-direction: column; }
.tc-stats b { font-family: var(--font-d); font-size: 20px; }
.tc-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.badge-wall { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--edge); color: var(--muted); font-size: 15px; background: var(--void);
}
.badge.earned { color: var(--bc); border-color: var(--bc); box-shadow: 0 0 12px color-mix(in srgb, var(--bc) 40%, transparent); background: color-mix(in srgb, var(--bc) 12%, var(--void)); }
.dex-ring-card { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ring {
  width: 130px; height: 130px; border-radius: 50%;
  background: conic-gradient(var(--red) calc(var(--pct) * 1%), var(--edge) 0);
  display: grid; place-items: center;
}
.ring-inner { width: 100px; height: 100px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; text-align: center; }
.ring-inner b { font-family: var(--font-d); font-size: 24px; display: block; }
.ring-inner span { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.party-strip-card { grid-column: 1 / -1; }
.party-strip { display: flex; gap: 12px; flex-wrap: wrap; }
.party-mini { position: relative; width: 76px; text-align: center; cursor: pointer; }
.party-mini img { width: 68px; height: 68px; image-rendering: pixelated; background: var(--void); border: 1px solid var(--edge); border-radius: 12px; transition: transform 0.15s; }
.party-mini:hover img { transform: translateY(-4px); border-color: var(--red); }
.party-mini span { font-size: 10px; color: var(--muted); }
.pm-hp { height: 4px; background: var(--edge); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.pm-hp div { height: 100%; background: var(--hp-green); border-radius: 2px; }

/* ---------- pokédex ---------- */
.dex-head { position: sticky; top: 0; z-index: 5; background: var(--void); padding-bottom: 12px; }
.gen-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.gen-tab { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--edge); background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.gen-tab.active { background: var(--red); border-color: var(--red); color: white; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.dex-card {
  position: relative; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 10px 6px; text-align: center; cursor: pointer; color: var(--text); transition: all 0.15s;
}
.dex-card:hover { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.dex-card img { width: 64px; height: 64px; image-rendering: pixelated; }
.dex-card img.silhouette { filter: brightness(0) opacity(0.35); }
.dex-card.unknown { cursor: default; opacity: 0.6; }
.dex-card.caught { border-color: rgba(255, 203, 5, 0.4); }
.dex-id { font-size: 10px; color: var(--muted); font-family: var(--font-d); }
.dex-name { font-size: 13px; font-weight: 600; margin: 2px 0 4px; }
.dex-types { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.dex-caught-dot { position: absolute; top: 6px; right: 8px; color: var(--spark); font-size: 10px; }
.type-chip {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 8px; color: #0d0d14; background: var(--tc);
}

/* ---------- holo card (signature) ---------- */
.holo-card {
  position: relative; overflow: hidden; border-radius: 18px; padding: 24px; text-align: center;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, color-mix(in srgb, var(--aura) 18%, transparent), transparent),
    linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid color-mix(in srgb, var(--aura) 45%, var(--edge));
  box-shadow: 0 0 40px color-mix(in srgb, var(--aura) 18%, transparent), 0 30px 60px rgba(0, 0, 0, 0.5);
}
.holo-scan {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.09) 45%, rgba(255, 255, 255, 0.16) 50%, rgba(255, 255, 255, 0.09) 55%, transparent 70%);
  background-size: 250% 100%; animation: scan 3.2s ease-in-out infinite;
}
@keyframes scan { 0% { background-position: 120% 0 } 60%, 100% { background-position: -120% 0 } }
.hc-head { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.gen-badge { font-size: 11px; color: var(--muted); border: 1px solid var(--edge); padding: 2px 10px; border-radius: 12px; }
.rarity { font-size: 10px; font-weight: 700; padding: 2px 10px; border-radius: 12px; letter-spacing: 0.1em; }
.rarity.legendary { background: rgba(255, 203, 5, 0.15); color: var(--spark); border: 1px solid var(--spark); }
.rarity.mythical { background: rgba(239, 112, 239, 0.12); color: #EF70EF; border: 1px solid #EF70EF; }
.hc-sprite { width: 170px; height: 170px; object-fit: contain; image-rendering: auto; margin: 8px 0; filter: drop-shadow(0 12px 28px color-mix(in srgb, var(--aura) 38%, transparent)); animation: float 3.5s ease-in-out infinite; }
.hc-inst { font-family: var(--font-d); color: var(--spark); font-size: 13px; margin: 6px 0; }
.hc-stats { max-width: 340px; margin: 14px auto 0; display: flex; flex-direction: column; gap: 5px; }
.stat-row { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 8px; font-size: 11px; }
.stat-label { color: var(--muted); font-weight: 700; }
.stat-bar { height: 7px; background: var(--void); border-radius: 4px; overflow: hidden; }
.stat-bar div { height: 100%; border-radius: 4px; }
.hc-foot { font-size: 12px; margin-top: 14px; }
.mini-sprite { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; image-rendering: auto; }
.hc-moves { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.move-chip { font-size: 11px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--tc); color: var(--text); background: color-mix(in srgb, var(--tc) 14%, var(--void)); }
.move-chip small { color: var(--muted); }

/* ---------- team ---------- */
.team-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; max-width: 1200px; margin: 0 auto; }
.mon-list { display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow-y: auto; }
.mon-list.box { display: grid; grid-template-columns: 1fr 1fr; }
.mon-card {
  display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--void);
  border: 1px solid var(--edge); border-radius: 12px; cursor: pointer; color: var(--text); text-align: left; transition: border 0.15s;
}
.mon-card:hover { border-color: var(--red); }
.mon-card.fainted { opacity: 0.45; }
.mon-card img { width: 46px; height: 46px; image-rendering: pixelated; }
.mon-card .pm-hp { flex: 1; margin: 0; }
.mon-card small { color: var(--muted); font-size: 10px; }
.mon-info { display: flex; flex-direction: column; min-width: 90px; }
.mon-info span { font-size: 11px; color: var(--muted); }
.mon-card.pick { cursor: pointer; }
.bag-list { display: flex; flex-direction: column; gap: 8px; }
.bag-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--void); border: 1px solid var(--edge); border-radius: 10px; font-size: 14px; }
.bag-row input { width: 80px; padding: 5px 8px; }

/* ---------- shop ---------- */
.shop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; max-width: 1000px; }
.shop-card { background: var(--void); border: 1px solid var(--edge); border-radius: 14px; padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.shop-icon { font-size: 34px; }
.shop-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.price { font-family: var(--font-d); color: var(--spark); font-weight: 700; }

/* ---------- world map screen ---------- */
.region-head { margin: 18px 0 8px; color: var(--spark); letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; }
.town-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.town-card { background: var(--void); border: 1px solid var(--edge); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.town-card.locked { opacity: 0.45; }
.town-card.here { border-color: var(--spark); }
.gym-tag { font-size: 11px; color: var(--bc); }

/* ---------- world / canvas ---------- */
#screen-world { padding: 0; display: none; }
#screen-world.active { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #101527, var(--void)); }
#world-wrap { position: relative; }
#world-canvas { border-radius: 18px; border: 1px solid var(--edge); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); max-width: 96vw; max-height: 82vh; image-rendering: auto; }
#map-header {
  position: absolute; top: 12px; left: 14px; z-index: 3; display: flex; align-items: baseline; gap: 10px;
  background: rgba(11, 14, 23, 0.8); border: 1px solid var(--edge); padding: 7px 14px; border-radius: 12px; backdrop-filter: blur(8px);
}
#map-name { font-family: var(--font-d); font-size: 16px; }
#map-region { font-size: 10px; color: var(--spark); letter-spacing: 0.2em; }
#interact-prompt {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%) translateY(6px); z-index: 3;
  background: rgba(11, 14, 23, 0.9); border: 1px solid var(--spark); color: var(--spark);
  padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: all 0.2s; pointer-events: none;
}
#interact-prompt.visible { opacity: 1; transform: translateX(-50%); }
#world-hint { position: absolute; bottom: 10px; width: 100%; text-align: center; font-size: 11px; color: var(--muted); opacity: 0.7; }
#dpad { position: absolute; right: 16px; bottom: 34px; display: none; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 4px; z-index: 3; }
.dp { background: rgba(19, 24, 41, 0.85); border: 1px solid var(--edge); border-radius: 12px; color: var(--text); font-size: 15px; touch-action: none; }
.dp:active { background: var(--red); }
.dp.up { grid-area: 1 / 2; } .dp.left { grid-area: 2 / 1; } .dp.center { grid-area: 2 / 2; color: var(--spark); font-weight: 700; } .dp.right { grid-area: 2 / 3; } .dp.down { grid-area: 3 / 2; }

/* ---------- battle ---------- */
#battle-overlay {
  position: fixed; inset: 0; z-index: 90; background: var(--void);
  display: none; flex-direction: column;
}
#battle-overlay.active { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0 } }
#battle-flash { position: absolute; inset: 0; background: white; opacity: 0; pointer-events: none; z-index: 5; }
#battle-flash.active { animation: vsflash 0.5s ease; }
@keyframes vsflash { 0%, 100% { opacity: 0 } 20%, 60% { opacity: 0.9 } 40% { opacity: 0.1 } }
#battle-scene { flex: 1; position: relative; overflow: hidden; min-height: 0; }
#battle-scene.shake { animation: bshake 0.3s ease; }
@keyframes bshake { 0%, 100% { transform: none } 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
/* biome backdrops */
.b-scene { position: absolute; inset: 0; }
.b-grass  { background: #69a854 url('/assets/battle-bg/grass.svg') center / cover no-repeat; }
.b-forest { background: #275f3d url('/assets/battle-bg/forest.svg') center / cover no-repeat; }
.b-sea    { background: #2e86c1 url('/assets/battle-bg/sea.svg') center / cover no-repeat; }
.b-cave   { background: #241d33 url('/assets/battle-bg/cave.svg') center / cover no-repeat; }
.b-town   { background: #a89f92 url('/assets/battle-bg/town.svg') center / cover no-repeat; }
.b-gym    { background: #2e2a4a url('/assets/battle-bg/gym.svg') center / cover no-repeat; }
.b-league { background: #1a1030 url('/assets/battle-bg/league.svg') center / cover no-repeat; }
.b-platform { position: absolute; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.22), rgba(0,0,0,0.3) 68%); }
.b-platform.enemy { right: 6%; top: 36%; width: min(240px, 32vw); height: min(72px, 15vw); }
.b-platform.player { left: 4%; bottom: 10%; width: min(320px, 44vw); height: min(92px, 18vw); }
.b-sprite { position: absolute; width: clamp(120px, 22vw, 190px); height: clamp(120px, 22vw, 190px); object-fit: contain; image-rendering: pixelated; transition: filter 0.2s, opacity 0.35s, transform 0.35s; z-index: 2; }
.b-sprite.enemy { right: 8%; top: 8%; filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.4)); animation: float 3s ease-in-out infinite; }
.b-sprite.player { left: 6%; bottom: 14%; width: clamp(160px, 32vw, 260px); height: clamp(160px, 32vw, 260px); transform: scaleX(-1); filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.5)); }
.b-sprite.fainted { opacity: 0; transform: translateY(40px); }
.b-sprite.player.fainted { transform: scaleX(-1) translateY(40px); }
.b-sprite.in-ball { transform: scale(0.05); opacity: 0.7; transition: transform 0.45s ease, opacity 0.45s; }
.b-sprite.lunge-up { animation: lungeUp 0.24s ease; }
.b-sprite.lunge-down { animation: lungeDown 0.24s ease; }
@keyframes lungeUp { 50% { transform: scaleX(-1) translate(-30px, -24px) } }
@keyframes lungeDown { 50% { transform: translate(-30px, 24px) } }
.b-sprite.hit-flash { filter: brightness(3) saturate(0.2); }
.b-plate {
  position: absolute; z-index: 3; width: min(250px, 46vw); background: rgba(14, 18, 30, 0.92); border: 1px solid var(--edge);
  border-radius: 12px; padding: 10px 14px; backdrop-filter: blur(6px);
}
.b-plate.enemy { top: 4%; left: 4%; }
.b-plate.player { bottom: 26%; right: 4%; }
.b-trainer { position: absolute; top: 4%; right: 4%; z-index: 3; display: flex; align-items: center; gap: 10px; background: rgba(14, 18, 30, 0.92); border: 1px solid var(--edge); padding: 8px 12px; border-radius: 12px; font-family: var(--font-d); font-size: 13px; }
.b-trainer-avatar { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--ac, #ffb347) 25%, var(--void)); border: 1px solid var(--ac, #ffb347); color: var(--ac, #ffb347); font-size: 20px; font-weight: 700; }
.item-icon { width: 24px; height: 24px; image-rendering: pixelated; vertical-align: middle; }
img.shop-icon { width: 46px; height: 46px; image-rendering: pixelated; margin: 0 auto; }
.b-balls { color: var(--red); letter-spacing: 2px; font-size: 10px; }
.b-name { font-family: var(--font-d); font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.b-lv { color: var(--spark); font-size: 12px; }
.b-hpbar { height: 8px; background: var(--void); border-radius: 5px; margin-top: 6px; overflow: hidden; border: 1px solid var(--edge); }
.b-hpfill { height: 100%; width: 100%; border-radius: 5px; }
.b-hpnum { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; font-family: var(--font-d); }
.b-xpbar { height: 4px; background: var(--void); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.b-xpfill { height: 100%; background: var(--spark); transition: width 0.6s ease; }
#battle-bottom { background: var(--panel); border-top: 1px solid var(--edge); padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); min-height: 152px; display: flex; flex-direction: column; gap: 10px; }
#battle-log { font-size: 15px; min-height: 26px; }
#battle-log b { color: var(--spark); }
#battle-log .xp { color: var(--spark); } #battle-log .money { color: var(--good); } #battle-log .badge { color: var(--spark); }
.b-log-anim { animation: logIn 0.25s ease; }
@keyframes logIn { from { opacity: 0; transform: translateY(5px) } }
.b-menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 700px; }
.b-moves, .b-bag, .b-switch { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 130px; overflow-y: auto; }
.b-btn {
  padding: 13px 16px; border-radius: 12px; border: 1px solid var(--edge); background: var(--panel-2);
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.12s; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
}
.b-btn:hover:not(:disabled) { border-color: var(--red); transform: translateY(-2px); }
.b-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.b-btn.fight { background: linear-gradient(135deg, var(--red), var(--red-dim)); border: none; justify-content: center; align-items: center; font-size: 16px; }
.b-btn.move { border-left: 4px solid var(--type); }
.b-btn.move small, .b-btn.poke small { color: var(--muted); font-size: 11px; }
.b-btn.back { justify-content: center; align-items: center; color: var(--muted); }
.b-btn.poke { flex-direction: row; align-items: center; gap: 10px; }
.b-mini { width: 34px; height: 34px; object-fit: contain; image-rendering: auto; }
.b-sprite, .hc-sprite.modern-art, .party-mini img, .mon-card img, .starter-card img { image-rendering: auto; object-fit: contain; }
.b-btn.item { flex-direction: row; justify-content: space-between; align-items: center; }
.b-empty { color: var(--muted); padding: 10px; }
body.in-battle #chat-dock, body.in-battle #online-toggle { display: none; }

/* ---------- modals ---------- */
#modal-root { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 7, 12, 0.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; opacity: 0; transition: opacity 0.2s; pointer-events: auto;
  overflow-y: auto; padding: 20px;
}
.modal-backdrop.active { opacity: 1; }
.modal {
  width: min(460px, 94vw); background: var(--panel); border: 1px solid var(--edge);
  border-radius: 18px; padding: 24px; animation: modalIn 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.92) translateY(14px) } }
.modal-title { font-size: 19px; margin-bottom: 12px; text-align: center; }
.modal-body { font-size: 14px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.modal .holo-card { padding: 20px; }
.modal-dialogue .modal { border-color: var(--spark); }
.dlg-name { display: inline-block; font-family: var(--font-d); font-weight: 700; color: var(--c); border: 1px solid var(--c); padding: 3px 12px; border-radius: 10px; margin-bottom: 12px; }
.dlg-text { font-size: 15px; line-height: 1.55; min-height: 48px; }

/* ---------- starter ---------- */
.modal-backdrop.static { background: rgba(5, 7, 12, 0.85); opacity: 1; z-index: 130; }
.starter-box { width: min(720px, 95vw); }
.starter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.starter-card {
  background: var(--void); border: 1px solid var(--edge); border-radius: 14px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; color: var(--text); transition: all 0.15s;
}
.starter-card:hover { border-color: var(--spark); transform: translateY(-4px); box-shadow: 0 10px 26px rgba(255, 203, 5, 0.15); }
.starter-card img { width: 88px; height: 88px; object-fit: contain; image-rendering: auto; }
.starter-card span { font-size: 13px; font-weight: 600; }

/* ---------- chat ---------- */
#chat-dock {
  position: fixed; left: 14px; bottom: 14px; z-index: 80; width: min(330px, 90vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; cursor: pointer; font-family: var(--font-d); font-size: 13px; background: var(--panel-2); }
.chat-head b { background: var(--red); border-radius: 8px; font-size: 10px; padding: 1px 6px; margin-left: 4px; }
.chat-presence { font-size: 11px; color: var(--good); }
.chat-body { display: none; }
#chat-dock.open .chat-body { display: block; }
.chat-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.chat-tab { flex: 1; background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px; border-radius: 8px; cursor: pointer; }
.chat-tab.active { background: var(--void); color: var(--text); }
.chat-messages { height: 190px; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.chat-msg { line-height: 1.35; word-break: break-word; }
.chat-msg .chat-meta { color: var(--muted); font-size: 11px; margin-right: 6px; }
.chat-msg .chat-meta b { color: #7ec8ff; }
.chat-msg.system { text-align: center; }
.chat-sys { font-size: 11px; color: var(--muted); font-style: italic; }
.chat-input-row { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--edge); }
.chat-input-row input { padding: 8px 12px; font-size: 13px; }

/* ---------- online panel ---------- */
#online-toggle {
  position: fixed; right: 14px; bottom: 14px; z-index: 80; width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); font-size: 19px; cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4); transition: transform 0.15s;
}
#online-toggle:hover { transform: scale(1.08); }
#online-panel {
  position: fixed; right: 14px; bottom: 72px; z-index: 80; width: min(310px, 90vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 14px;
  transform: translateY(12px); opacity: 0; pointer-events: none; transition: all 0.2s;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
#online-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.op-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.op-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.op-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--void); border: 1px solid var(--edge); border-radius: 10px; }
.op-user { display: flex; flex-direction: column; }
.op-user small { font-size: 11px; }
.op-me { font-size: 11px; color: var(--muted); }
.op-actions { display: flex; gap: 6px; }

/* ---------- trade ---------- */
.modal-trade-wrap .modal { width: min(560px, 95vw); }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.trade-col { background: var(--void); border: 1px solid var(--edge); border-radius: 12px; padding: 14px; min-height: 170px; }
.trade-col.confirmed { border-color: var(--good); box-shadow: 0 0 14px rgba(61, 220, 132, 0.15); }
.trade-col h4 { margin-bottom: 10px; font-size: 14px; }
.trade-offer-view { font-size: 13px; line-height: 1.7; min-height: 60px; margin-bottom: 10px; }
.trade-col .btn { margin: 2px 4px 2px 0; }
.tr-money-row { display: flex; gap: 6px; margin-top: 6px; }
.tr-money-row input { padding: 6px 10px; font-size: 13px; }
.trade-invite { flex-direction: column; }
.ti-actions { display: flex; gap: 8px; margin-top: 8px; }
.tiny-note { font-size: 11px; text-align: center; margin-top: 10px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 150; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--edge); border-left: 4px solid var(--muted);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; max-width: 320px;
  transform: translateX(120%); transition: transform 0.25s cubic-bezier(0.2, 1, 0.4, 1);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); display: flex; flex-direction: column;
}
.toast.show { transform: none; }
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }

/* ---------- transition fade ---------- */
#transition-fade { position: fixed; inset: 0; background: var(--void); opacity: 0; pointer-events: none; transition: opacity 0.22s ease; z-index: 140; }
#transition-fade.active { opacity: 1; pointer-events: auto; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; }
  .sb-logo span { display: none; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav button { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
  .sb-foot { border: none; padding: 0; flex-direction: row; align-items: center; }
  .sb-user span { display: none; }
  #dpad { display: grid; }
  .home-grid, .team-grid { grid-template-columns: 1fr; }
  .b-menu { grid-template-columns: 1fr 1fr; }
  .b-sprite { width: 130px; height: 130px; }
  .b-plate { width: 180px; padding: 8px 10px; }
  #world-hint { display: none; }
  .screen { padding: 14px; }
}