@font-face { font-family: "Pixelify"; src: local("Pixelify Sans"); font-display: swap; }

:root {
  --bg: #12152a;
  --bg2: #1b1f3a;
  --panel: #f4efd8;
  --ink: #1b1f2e;
  --red: #e5484d;
  --red-d: #a92a30;
  --gold: #ffcf40;
  --muted: #8b90b8;
  --text: #eef0ff;
  --ok: #4fd16a;
  --mid: #f2c53a;
  --low: #e5484d;
  --pix: "Silkscreen", "Pixelify Sans", ui-monospace, "Courier New", monospace;
  --body: "Pixelify Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--body); }
a { color: var(--gold); }
img.pix { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--muted); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Site chrome ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1280px; margin: 0 auto; padding: 10px 20px; }
.brand { font: 700 18px var(--pix); letter-spacing: .06em; color: var(--text); text-decoration: none; }
.brand b { color: var(--red); }
.top nav { display: flex; gap: 16px; font-size: 14px; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; padding: 6px 0; }
.top nav a:hover, .top nav a[aria-current] { color: var(--text); }

.hero { max-width: 1280px; margin: 0 auto; padding: 0 20px 28px; }
.hero-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 4px 0 12px; }
.hero-bar h1 { font: 700 22px/1.25 var(--pix); margin: 0; letter-spacing: .02em; }
.hero-bar h1 span { color: var(--red); }
.hero-bar p { margin: 0; color: var(--muted); font-size: 14px; }
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.feature-list li { background: var(--bg2); border: 2px solid #2c3160; padding: 10px 12px; }
@media (max-width: 820px) {
  .top nav { display: none; }
}

/* ---------- Game frame ---------- */
#game { background: linear-gradient(180deg, #1d2148 0%, #2b2354 45%, #3a2440 100%); border: 3px solid var(--ink); box-shadow: 0 0 0 3px #2c3160, 6px 6px 0 3px #0a0c1a; border-radius: 6px; min-height: 560px; position: relative; }
#game noscript p { padding: 24px; }
.screen { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-height: 560px; }
.center { text-align: center; }
.screen h2 { font: 700 20px var(--pix); margin: 0; letter-spacing: .04em; text-align: center; }
.head { text-align: center; }

.btn { min-height: 44px; border: 3px solid var(--ink); background: var(--panel); color: var(--ink); padding: 10px 14px; font: 700 14px var(--pix); letter-spacing: .05em; box-shadow: 3px 3px 0 var(--ink); border-radius: 2px; transition: transform .06s; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #f25a5f; }
.btn.big { padding: 14px; font-size: 16px; }
.btn.ghost { background: transparent; color: var(--text); border-color: #4a5090; box-shadow: none; font-size: 12px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 12px; padding: 4px; }

/* Intro */
.intro { justify-content: center; }
.intro-main, .intro-side { display: flex; flex-direction: column; gap: 14px; }
.intro-main { text-align: center; align-items: center; }
.logo { font: 700 clamp(40px, 6vw, 72px)/1 var(--pix); letter-spacing: .06em; color: var(--panel); text-shadow: 4px 4px 0 var(--ink); }
.logo b { color: var(--red); }
.sub { font: 12px var(--pix); color: var(--gold); letter-spacing: .12em; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 420px; }
.facts li { background: rgba(0,0,0,.25); border: 2px solid #3d4280; padding: 8px 4px; display: grid; }
.facts b { font: 700 24px var(--pix); color: var(--panel); }
.facts span { font-size: 11px; color: var(--muted); }
.actions { display: grid; gap: 8px; width: 100%; max-width: 420px; }
.champ { display: flex; gap: 14px; align-items: center; background: rgba(0,0,0,.25); padding: 14px; border: 2px solid #3d4280; }
.champ-name { font: 700 16px var(--pix); color: var(--red); }
.mod { font-size: 13px; color: var(--gold); margin-top: 4px; }
.champ-team { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.champ-team div { background: rgba(0,0,0,.25); border: 2px solid #3d4280; display: grid; justify-items: center; gap: 4px; padding: 6px 2px; }
.champ-team div.ace { border-color: var(--gold); }
.champ-team .type { margin: 0; }
.how { font-size: 13px; color: var(--muted); margin: 0; max-width: 420px; }
@media (min-width: 860px) {
  .intro { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; padding: 32px 40px; }
}

/* Monster cards */
.mon-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.action-bar { position: sticky; bottom: 0; padding: 10px 0 0; background: linear-gradient(transparent, #3a2440 30%); display: flex; justify-content: center; }
.action-bar .btn { width: 100%; max-width: 420px; }
.lead .btn.ghost { align-self: center; }
.mon-card { position: relative; display: flex; gap: 10px; align-items: center; text-align: left; background: var(--panel); color: var(--ink); border: 3px solid var(--ink); padding: 6px 8px; border-radius: 2px; box-shadow: 2px 2px 0 var(--ink); }
.mon-card:hover { background: #fff8e2; }
.mon-card.selected { background: #ffe1e1; border-color: var(--red-d); box-shadow: 2px 2px 0 var(--red-d); }
.mon-card img { flex: none; background: rgba(27,31,46,.06); }
.mon-info { min-width: 0; display: grid; gap: 2px; }
.mon-name { font: 700 14px var(--pix); }
.mon-stats { font-size: 11px; color: #555a74; }
.mon-moves { display: flex; flex-wrap: wrap; gap: 3px; }
.mon-moves span { font-size: 10px; padding: 0 4px; border-left: 4px solid var(--c); background: rgba(0,0,0,.05); }
.pick-badge { position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; background: var(--red); color: #fff; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--ink); }
.type { display: inline-block; font: 700 9px var(--pix); color: #fff; background: var(--c); padding: 1px 5px; margin-right: 3px; text-shadow: 1px 1px 0 rgba(0,0,0,.4); letter-spacing: .04em; border: 1px solid rgba(0,0,0,.35); }

/* Battle */
.battle { gap: 12px; }
.stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.controls { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ctl-label { font: 10px var(--pix); color: var(--muted); letter-spacing: .08em; }
@media (min-width: 860px) {
  .battle { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 20px; align-items: start; }
  .battle .arena { height: 400px; }
  .battle .foe-spr { width: 160px; height: 160px; }
  .battle .me-spr { width: 184px; height: 184px; }
  .battle .hud { width: 46%; }
  .battle .team { grid-template-columns: repeat(3, 1fr); }
  .battle .tm { grid-template-columns: auto 1fr; justify-items: start; align-items: center; gap: 6px; padding: 4px 6px 7px; font-size: 11px; }
}
.arena { position: relative; height: 270px; background:
    radial-gradient(ellipse 38% 9% at 72% 44%, #5a5f9c 0 98%, transparent 100%),
    radial-gradient(ellipse 42% 10% at 28% 88%, #6a6fb0 0 98%, transparent 100%),
    linear-gradient(180deg, #2a2f66 0%, #5b3a6e 55%, #d9dcf0 55.5%, #c3c7e6 100%);
  border: 3px solid var(--ink); }
.spr { position: absolute; transition: opacity .4s, transform .4s; }
.foe-spr { right: 14%; top: 18%; }
.me-spr { left: 10%; bottom: 6%; transform: scaleX(-1); }
.spr.fainted { opacity: 0; transform: translateY(20px); }
.me-spr.fainted { transform: scaleX(-1) translateY(20px); }
.spr.shake { animation: shake .35s; }
.foe-spr.lunge { animation: lungeL .3s; }
.me-spr.lunge { animation: lungeR .3s; }
@keyframes shake { 0%,100% { translate: 0 } 20% { translate: -6px 0; filter: brightness(3) } 40% { translate: 6px 0 } 60% { translate: -4px 0; filter: brightness(3) } 80% { translate: 4px 0 } }
@keyframes lungeL { 50% { translate: -18px 8px } }
@keyframes lungeR { 50% { translate: 18px -8px } }
.hud { position: absolute; background: var(--panel); color: var(--ink); border: 3px solid var(--ink); padding: 4px 8px; width: 52%; box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
.hud.foe { left: 8px; top: 8px; }
.hud.me { right: 8px; bottom: 8px; }
.hud-name { font: 700 12px var(--pix); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.hud-name small { font-weight: 400; }
.bar { height: 8px; background: #3b3f55; border: 2px solid var(--ink); margin: 3px 0 1px; }
.bar i { display: block; height: 100%; transition: width .45s ease-out; background: var(--ok); }
.bar i.mid { background: var(--mid); }
.bar i.low { background: var(--low); }
.hud-hp { font: 11px var(--pix); text-align: right; }
.balls { display: flex; gap: 3px; }
.balls span { width: 7px; height: 7px; border-radius: 50%; background: #9a9db3; border: 1px solid var(--ink); }
.balls span.on { background: var(--red); }
.st { font-size: 9px; color: #fff; padding: 0 3px; }
.st-burn { background: #e2602e; } .st-para { background: #c9a512; } .st-poison, .st-toxic { background: #8a3fb0; } .st-sleep { background: #6b6f88; }
.turn-no { position: absolute; right: 8px; top: 8px; font: 10px var(--pix); color: #c9cce6; }
.msg { min-height: 54px; background: var(--ink); color: #fff; border: 3px solid var(--panel); padding: 8px 10px; font-size: 15px; }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.move { min-height: 64px; text-align: left; background: var(--panel); color: var(--ink); border: 3px solid var(--ink); border-left: 8px solid var(--c); padding: 6px 8px; display: grid; gap: 1px; box-shadow: 2px 2px 0 var(--ink); }
.move:hover { background: #fff8e2; }
.move b { font: 700 12px var(--pix); }
.mv-meta { font-size: 10px; color: #555a74; }
.eff { font: 700 10px var(--pix); }
.eff-super { color: #c4162a; } .eff-weak { color: #6b6f88; } .eff-none { color: #6b6f88; text-decoration: line-through; } .eff-status { color: #4a5090; } .eff-normal { color: #33384f; }
.team { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.tm { position: relative; background: rgba(255,255,255,.08); border: 2px solid #4a5090; color: var(--text); padding: 2px 2px 6px; display: grid; justify-items: center; font-size: 9px; overflow: hidden; }
.tm span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--ok); }
.tm.current { border-color: var(--gold); }
.tm:disabled { opacity: .45; }
.tm.current:disabled { opacity: 1; }
.tm:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.battle-foot { text-align: right; }

/* Result */
.result { text-align: center; justify-content: center; }
.res-main, .res-side { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.res-side { width: 100%; }
.res-side .btn, .res-side .share-preview { width: 100%; max-width: 420px; }
@media (min-width: 860px) {
  .result { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; padding: 32px 40px; }
}
.result h2.win { color: var(--gold); font-size: 26px; }
.result h2.lose { color: var(--red); font-size: 26px; }
.big-turns { font: 700 56px var(--pix); line-height: 1; }
.big-turns small { font-size: 16px; }
.grid { display: flex; justify-content: center; gap: 6px; }
.grid div { background: var(--red); border: 2px solid var(--ink); padding: 2px; }
.grid div.down { background: #2a2d40; }
.grid div.down img { opacity: .35; filter: grayscale(1); }
.stats-row { display: flex; justify-content: center; gap: 18px; }
.stats-row div { display: grid; }
.stats-row b { font: 700 20px var(--pix); }
.stats-row span { font-size: 11px; color: var(--muted); }
.share-preview { text-align: left; background: rgba(0,0,0,.3); border: 2px dashed #4a5090; padding: 8px; font-size: 12px; white-space: pre-wrap; margin: 0; }
.countdown { font: 12px var(--pix); color: var(--gold); }

/* ---------- Content sections ---------- */
main.content { max-width: 1080px; margin: 0 auto; padding: 8px 16px 48px; }
.content section { margin: 0 0 36px; }
.content h2 { font: 700 22px/1.3 var(--pix); color: var(--panel); margin: 0 0 12px; }
.content h3 { font-size: 17px; margin: 18px 0 6px; color: var(--gold); }
.content p, .content li { color: #c9cce6; }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps li { background: var(--bg2); border: 2px solid #2c3160; padding: 12px 14px 12px 48px; position: relative; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; display: grid; place-items: center; background: var(--red); color: #fff; font: 700 14px var(--pix); border: 2px solid var(--ink); }
.steps b { color: var(--text); display: block; }
.table-wrap { overflow-x: auto; }
table.chart { border-collapse: collapse; font-size: 13px; min-width: 560px; }
table.chart th, table.chart td { border: 1px solid #2c3160; padding: 4px 6px; text-align: center; }
table.chart th { background: var(--bg2); font-weight: 600; }
table.chart td.x2 { background: #1f5c2f; color: #b9ffc8; font-weight: 700; }
table.chart td.x05 { background: #5c1f24; color: #ffc4c7; }
table.chart td.x0 { background: #000; color: #888; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.dex { background: var(--bg2); border: 2px solid #2c3160; padding: 10px; display: flex; gap: 10px; align-items: center; }
.dex h3 { margin: 0 0 2px; font-size: 15px; color: var(--text); }
.dex p { margin: 2px 0 0; font-size: 12px; }
details { background: var(--bg2); border: 2px solid #2c3160; padding: 10px 14px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 600; color: var(--text); }
details p { margin: 8px 0 0; }
footer { border-top: 2px solid #2c3160; padding: 20px 16px 32px; text-align: center; font-size: 13px; color: var(--muted); }
footer p { max-width: 760px; margin: 6px auto; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.cta { display: inline-block; text-decoration: none; margin-top: 8px; }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .top { padding: 8px 12px; }
  .hero { padding: 0 0 20px; }
  .hero-bar { padding: 0 12px; }
  .hero-bar h1 { font-size: 17px; }
  .hero-bar p { font-size: 12px; }
  #game { border-left: 0; border-right: 0; border-radius: 0; box-shadow: none; min-height: calc(100svh - 120px); }
  .screen { padding: 12px; min-height: calc(100svh - 120px); }
  .mon-list { grid-template-columns: 1fr; gap: 8px; }
  .arena { height: 236px; }
  .hud { width: 58%; padding: 3px 6px; }
  .team { grid-template-columns: repeat(3, 1fr); }
  .tm { font-size: 10px; min-height: 52px; }
  .move { min-height: 58px; padding: 5px 6px; }
  .move b { font-size: 11px; }
  .champ-team { gap: 4px; }
  .champ-team img { width: 40px; height: 40px; }
  .facts b { font-size: 20px; }
  main.content { padding: 8px 12px 40px; }
}
.link.speed { min-height: 36px; }
@media (max-width: 600px) and (max-height: 780px) {
  .arena { height: 200px; }
  .msg { min-height: 46px; font-size: 14px; }
}
