:root {
  --ink: #f6f1e3; --muted: #a9a7b8; --bg: #0f1018; --panel: #181a26; --panel-2: #20233a; --line: #2c3050; --line-2: #3a3f66;
  --xp: #ffd84a; --hp: #5fd068; --bad: #ff5a5a; --sky: #7cc4ff;
  --pix: 'Pixelify Sans', ui-monospace, monospace; --body: 'Space Grotesk', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 4px;
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); background-size: 6px 6px; }
main, .bar, .foot { position: relative; z-index: 1; }
a { color: inherit; }
.wrap { width: min(1180px, 100% - 32px); margin: 0 auto; }
h1, h2, h3 { font-family: var(--pix); font-weight: 700; line-height: 1.05; margin: 0; letter-spacing: .01em; }
h1 { font-size: clamp(2.4rem, 1.2rem + 4.6vw, 4.6rem); }
h2 { font-size: clamp(1.8rem, 1.2rem + 2.2vw, 2.8rem); }
h3 { font-size: 1.25rem; }
.eyebrow { font: 700 .74rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--xp); margin: 0 0 .9rem; }
.muted { color: var(--muted); }
.xp-text { color: var(--xp); }

/* pixel buttons: hard edges, a 3D step, a press */
.btn { display: inline-flex; align-items: center; gap: .5rem; font: 700 1rem/1 var(--pix); letter-spacing: .02em; color: #1a1406; background: var(--xp); border: 0; border-radius: var(--r); padding: .85rem 1.25rem; text-decoration: none; cursor: pointer; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 0 0 3px #1a1406; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); } .btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), 0 0 0 3px #1a1406; }
.btn.ghost { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.3), 0 0 0 3px var(--line-2); }
.btn.sm { font-size: .82rem; padding: .55rem .8rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .9rem; flex-wrap: wrap; align-items: center; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 50; background: rgba(15,16,24,.86); backdrop-filter: blur(10px); border-bottom: 2px solid var(--line); }
.bar-in { display: flex; align-items: center; gap: 1rem; height: 64px; }
.logo { display: flex; align-items: center; gap: .55rem; text-decoration: none; font: 700 1.25rem/1 var(--pix); }
.logo canvas { width: 30px; height: 30px; image-rendering: pixelated; }
.nav { display: flex; gap: 1.2rem; } .nav a { text-decoration: none; color: var(--muted); font: 600 .9rem/1 var(--body); } .nav a:hover { color: var(--ink); }
.sp { flex: 1; }
.ca-pill { font: 700 .7rem/1 var(--mono); color: var(--muted); background: var(--panel); padding: .5rem .7rem; border: 2px solid var(--line-2); border-radius: var(--r); cursor: pointer; white-space: nowrap; }
.ca-pill b { color: var(--ink); margin-left: .25rem; } .ca-pill:disabled { cursor: default; }
@media (max-width: 860px) { .nav { display: none; } }
@media (max-width: 520px) { .bar-in { gap: .5rem; } .ca-pill { display: none; } }

/* hero */
.hero { padding: 48px 0 30px; }
.hero-in { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 40px; align-items: end; margin-bottom: 30px; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 52ch; margin: 0 0 1.4rem; } .lede b { color: var(--ink); }
@media (max-width: 960px) { .hero-in { grid-template-columns: 1fr; } }

/* the console bezel around the live world */
.bezel { background: #262a44; border-radius: 14px; padding: 14px 14px 12px; box-shadow: 0 0 0 3px #11131f, 0 24px 60px rgba(0,0,0,.55), inset 0 2px 0 rgba(255,255,255,.08); }
.bezel-top { display: flex; align-items: center; gap: .6rem; font: 700 .7rem/1 var(--mono); letter-spacing: .12em; color: var(--muted); margin: 0 4px 10px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); animation: blink 1.4s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.screen { position: relative; border-radius: 6px; overflow: hidden; background: #0c0d14; aspect-ratio: 640 / 384; box-shadow: inset 0 0 0 3px #0a0b11; }
.screen canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.tag { position: absolute; transform: translate(-50%, -100%); font: 700 clamp(9px, .9vw, 12px)/1 var(--mono); color: #fff; background: rgba(12,13,20,.82); padding: 3px 5px; border-radius: 3px; white-space: nowrap; pointer-events: auto; text-decoration: none; }
.tag.wild { color: #d9dae6; background: rgba(12,13,20,.45); font-weight: 500; font-size: clamp(8px, .75vw, 10px); }
.tag .lv { color: var(--xp); margin-left: 4px; }
.bubble { position: absolute; transform: translate(-50%, -100%); max-width: 170px; font: 600 10.5px/1.25 var(--body); color: #1a1406; background: #fffdf4; border: 2px solid #1a1406; border-radius: 6px; padding: 4px 6px; white-space: normal; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 6px; height: 6px; background: #fffdf4; border-right: 2px solid #1a1406; border-bottom: 2px solid #1a1406; transform: translateX(-50%) rotate(45deg); }
.zzz { position: absolute; transform: translate(-50%, -100%); font: 700 11px/1 var(--pix); color: var(--sky); animation: float 2s ease-in-out infinite; }
@keyframes float { 50% { transform: translate(-50%, -130%); } }
@media (prefers-reduced-motion: reduce) { .led, .zzz { animation: none; } }
.empty-note { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); font: 600 .78rem/1.3 var(--body); background: rgba(12,13,20,.82); padding: .45rem .7rem; border-radius: 4px; color: var(--ink); text-align: center; width: max-content; max-width: 92%; }

/* the old-game dialog box */
.dialog { margin-top: 12px; background: #fffdf4; color: #1a1406; border-radius: 8px; padding: 12px 16px; min-height: 64px; font: 600 1rem/1.4 var(--pix); box-shadow: inset 0 0 0 3px #1a1406, inset 0 0 0 6px #fffdf4, inset 0 0 0 8px #c9c1a4; position: relative; }
.dialog .arrow { position: absolute; right: 14px; bottom: 10px; animation: blink 1s steps(2) infinite; }
.stats-strip { display: flex; gap: 1rem; flex-wrap: wrap; font: 600 .7rem/1 var(--mono); color: var(--muted); letter-spacing: .04em; }
@media (max-width: 640px) { .bezel-top .stats-strip { display: none; } } .stats-strip b { color: var(--ink); }

/* sections */
.band { padding: 72px 0; border-top: 2px solid var(--line); }
.band.alt { background: var(--panel); }
.head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.sub { color: var(--muted); max-width: 62ch; margin: .8rem 0 0; }

/* how it works: five steps with a tiny sprite each */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.steps li { background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 18px; }
.band.alt .steps li { background: var(--bg); }
.steps .n { font: 700 .72rem/1 var(--mono); color: var(--xp); } .steps h3 { margin: .7rem 0 .5rem; } .steps p { margin: 0; color: var(--muted); font-size: .93rem; }
@media (max-width: 960px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr; } }

/* ranking */
.rank { width: 100%; border-collapse: collapse; font-size: .95rem; }
.rank th { text-align: left; font: 700 .7rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 10px 10px; }
.rank td { padding: 10px; border-top: 2px solid var(--line); vertical-align: middle; }
.rank tr:hover td { background: rgba(255,255,255,.02); }
.rank .who { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.rank canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.rank .nm { font: 700 1.05rem/1.1 var(--pix); } .rank .tk { font: 600 .78rem/1 var(--mono); color: var(--muted); }
.lvl { font: 700 1rem/1 var(--pix); color: var(--xp); }
.xpbar { height: 8px; background: #0b0c12; border-radius: 2px; box-shadow: inset 0 0 0 2px #2c3050; overflow: hidden; min-width: 80px; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb84a, var(--xp)); }
.type { display: inline-block; font: 700 .66rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: .3rem .45rem; border-radius: 3px; color: #12141c; }
.t-ember { background: #ff7a3d; } .t-tide { background: #3db8ff; } .t-leaf { background: #5fd068; } .t-spark { background: #ffe14d; } .t-stone { background: #b8a58a; } .t-shade { background: #9b7bff; }
.mood { font: 600 .8rem/1 var(--mono); } .mood.on { color: var(--hp); } .mood.off { color: var(--sky); }
.table-scroll { overflow-x: auto; }
.empty { border: 2px dashed var(--line-2); border-radius: 8px; padding: 26px; text-align: center; color: var(--muted); } .empty b { display: block; color: var(--ink); font: 700 1.2rem/1.2 var(--pix); margin-bottom: .4rem; }

/* battles */
.fights { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.fight { background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 14px; text-decoration: none; display: block; }
.band.alt .fight { background: var(--bg); }
.fight .vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.fight canvas { width: 56px; height: 56px; image-rendering: pixelated; }
.fight .nm { font: 700 .95rem/1.1 var(--pix); } .fight .win { color: var(--xp); } .fight .x { font: 700 1rem/1 var(--pix); color: var(--muted); }
.fight .meta { display: flex; justify-content: space-between; margin-top: 10px; font: 500 .74rem/1.3 var(--mono); color: var(--muted); }
.fight .line { margin-top: 8px; font-size: .86rem; color: var(--muted); font-style: italic; }

/* real / never */
.truth { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.truth li { display: flex; gap: 12px; align-items: baseline; color: var(--muted); }
.chip { flex: none; font: 700 .66rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: .32rem .5rem; border-radius: 3px; }
.chip.ok { background: rgba(95,208,104,.16); color: var(--hp); } .chip.never { background: rgba(255,90,90,.14); color: var(--bad); } .chip.hand { background: rgba(255,216,74,.14); color: var(--xp); }

.foot { border-top: 2px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .84rem; } .foot p { margin: 0; max-width: 90ch; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); background: #fffdf4; color: #1a1406; font: 700 .9rem/1.2 var(--pix); padding: .7rem 1rem; border-radius: 6px; box-shadow: 0 0 0 3px #1a1406; transition: transform .25s; z-index: 80; }
.toast.on { transform: translate(-50%, 0); }
:focus-visible { outline: 3px solid var(--xp); outline-offset: 2px; }
.toast:not(.on) { visibility: hidden; }

/* the battle arena (arena.js) */
.arena-modal { position: fixed; inset: 0; z-index: 90; background: rgba(6,7,12,.78); backdrop-filter: blur(4px); display: none; place-items: center; padding: 16px; }
.arena-modal.on { display: grid; }
.arena-win { width: min(820px, 100%); background: #262a44; border-radius: 14px; padding: 12px; box-shadow: 0 0 0 3px #11131f, 0 30px 80px rgba(0,0,0,.6); }
.arena-top, .arena-foot { display: flex; align-items: center; gap: .6rem; font: 700 .78rem/1 var(--mono); color: var(--muted); padding: 2px 4px 10px; }
.arena-foot { padding: 10px 4px 2px; }
.arena-title { color: var(--ink); font: 700 1rem/1.2 var(--pix); }
.arena-live { color: var(--bad); animation: blink 1.2s steps(2) infinite; }
.arena-btn { font: 700 .72rem/1 var(--mono); color: var(--ink); background: var(--panel); border: 2px solid var(--line-2); border-radius: 4px; padding: .45rem .65rem; cursor: pointer; }
.arena-btn:hover { border-color: var(--ink); }
.arena-link { color: var(--xp); text-decoration: none; font: 700 .8rem/1 var(--mono); }
.arena-stage { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 320 / 180; box-shadow: inset 0 0 0 3px #0a0b11; }
.arena-stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hpbox { position: absolute; width: 38%; background: #fffdf4; color: #1a1406; border-radius: 6px; padding: 6px 9px 7px; box-shadow: inset 0 0 0 3px #1a1406; transition: transform .35s cubic-bezier(.2,.9,.3,1.2); }
.hpbox.foe { left: 4%; top: 7%; transform: translateX(-130%); } .hpbox.me { right: 4%; bottom: 8%; transform: translateX(130%); }
.hpbox.in { transform: none; }
.hp-name { display: flex; justify-content: space-between; font: 700 clamp(.7rem, 1.6vw, 1rem)/1.1 var(--pix); } .hp-name span { color: #8a6a10; }
.hp-bar { height: 8px; margin-top: 5px; background: #3a3a3a; border-radius: 4px; overflow: hidden; box-shadow: inset 0 0 0 2px #1a1406; } .hp-bar i { display: block; height: 100%; width: 100%; background: #5fd068; }
.hp-num { text-align: right; font: 700 clamp(.65rem, 1.4vw, .85rem)/1 var(--pix); margin-top: 4px; }
.arena-say { min-height: 4.2em; margin-top: 10px; }
@media (max-width: 520px) { .hpbox { width: 46%; padding: 4px 6px 5px; } }

/* Coinmon of the Hour */
.champ { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; margin: 0 0 18px; padding: 14px 18px; border-radius: 10px; background: linear-gradient(100deg, #3a2f10, #1d1b2c 60%); box-shadow: inset 0 0 0 2px #6b5520; }
.champ canvas { width: 76px; height: 76px; image-rendering: pixelated; }
.champ .crown { font: 700 .72rem/1 var(--mono); letter-spacing: .14em; color: var(--xp); }
.champ .nm { font: 700 1.5rem/1.1 var(--pix); margin: .3rem 0; } .champ .meta { color: var(--muted); font-size: .9rem; }
.champ .side { text-align: right; font: 600 .8rem/1.5 var(--mono); color: var(--muted); } .champ .side b { color: var(--ink); font-size: 1.05rem; }
@media (max-width: 640px) { .champ { grid-template-columns: auto 1fr; } .champ .side { grid-column: 1 / -1; text-align: left; } }
.live-strip { display: flex; align-items: center; gap: .7rem; margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: rgba(255,90,90,.12); box-shadow: inset 0 0 0 2px rgba(255,90,90,.35); font: 600 .9rem/1.3 var(--body); }
.live-strip .dot { color: var(--bad); animation: blink 1.2s steps(2) infinite; font: 700 .72rem/1 var(--mono); }
.spec { font: 700 .74rem/1 var(--mono); color: #1a1406; background: var(--xp); border: 0; border-radius: 4px; padding: .5rem .7rem; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); white-space: nowrap; }
.spec.ghost { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line-2); }
.fight .acts { display: flex; gap: .5rem; margin-top: 10px; } .fight .live { color: var(--bad); font: 700 .7rem/1 var(--mono); }
.species { font: 500 .78rem/1 var(--mono); color: var(--muted); }

/* readability: the pixel font is for big titles only; small headings and every number use clear fonts */
h3 { font-family: var(--body); font-weight: 700; letter-spacing: 0; }
.lvl, .card-head .lv, .hp-name span, .hp-num, .tag .lv, .stats-strip b, .rank td, .evo .at, .fight .meta { font-family: var(--mono); font-weight: 700; }
.lvl { font-size: .95rem; }
.fight .nm, .rank .nm, .champ .nm, .arena-title { letter-spacing: .01em; }
.tag.fight { background: #ff5a5a; color: #fff; font: 700 clamp(9px, .9vw, 12px)/1 var(--mono); padding: 5px 7px; border-radius: 4px; border: 2px solid #1a1406; cursor: pointer; animation: pulse 1.1s ease-in-out infinite; }
.tag.fight:hover { background: #ff7a7a; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255,90,90,.35); } }
@media (prefers-reduced-motion: reduce) { .tag.fight { animation: none; } }
[hidden] { display: none !important; }
