@font-face { font-family: Pixelify; src: url(fonts/pixelify-400.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: Pixelify; src: url(fonts/pixelify-700.woff2) format("woff2"); font-weight: 700; font-display: block; }
:root {
  --bg: #14162a; --ink: #f4f4f4; --dim: #a6adc4; --win: #1e2140; --win2: #262a50; --edge: #e8e4ff; --edge2: #5b6190; --gold: #f6d04d; --red: #ff6a6a; --green: #6ee36e;
  --paper: #f6f1e2; --paper-ink: #1d1f2b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Pixelify, ui-monospace, monospace; overscroll-behavior: none; }
body { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
#app { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage { position: relative; width: min(100vw, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9; font-size: clamp(11px, 1.7vw, 18px); overflow: hidden; background: #000; }
#game { width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
h2 { margin: 0 0 .3em; font-size: 1.35em; }
p { margin: 0; }
.small, .tag { color: var(--dim); font-size: .85em; }
.err { color: var(--red); }
.row { display: flex; gap: .45em; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: .5em; }
.center-row { justify-content: center; }
.col { display: flex; flex-direction: column; gap: .45em; }
.narrow { width: min(18em, 80%); }
input { font: inherit; color: var(--ink); background: #0f1020; border: 2px solid var(--edge2); padding: .3em .5em; border-radius: 0; -webkit-user-select: text; user-select: text; }
.field { display: flex; gap: .45em; align-items: center; color: var(--dim); }

/* pixel windows: a light frame around a dark panel */
.win { background: var(--win); border: 3px solid var(--edge); box-shadow: 0 0 0 3px #0b0c18, inset 0 0 0 2px var(--edge2), 0 8px 0 3px rgba(0, 0, 0, .35); padding: .9em 1.1em; }
.btn { font: inherit; color: var(--ink); background: var(--win2); border: 2px solid var(--edge2); padding: .32em .9em; cursor: pointer; box-shadow: 0 3px 0 #0b0c18; }
.btn:hover:not(:disabled) { background: #31366a; border-color: #8a90c8; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #0b0c18; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { background: #2f6e45; border-color: #6fd08a; }
.btn.big:hover:not(:disabled) { background: #3a8455; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn:focus-visible, .act:focus-visible, .mv:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* full-screen layers */
.screen { position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .7em; padding: 1em; text-align: center; overflow: auto; }
.screen.dim { background: rgba(10, 11, 24, .72); }
#title { background: linear-gradient(rgba(20, 22, 42, .2), rgba(20, 22, 42, .75)); }
.logo { font-size: 3.4em; font-weight: 700; color: var(--gold); letter-spacing: .03em; text-shadow: 0 4px 0 #8a5a1c, 0 8px 0 rgba(0, 0, 0, .35); }
.card-form { text-align: left; width: min(30em, 92%); }
.ng { display: flex; gap: 1em; align-items: center; }
#ngPreview { width: 6em; height: 9em; image-rendering: pixelated; background: #2b2f55; border: 2px solid var(--edge2); }
.swatches { display: flex; align-items: center; gap: .3em; flex-wrap: wrap; }
.swatches span { width: 3.4em; color: var(--dim); font-size: .85em; }
.swatches button { width: 1.5em; height: 1.5em; border: 2px solid #0b0c18; cursor: pointer; padding: 0; }
.swatches button.on { outline: 2px solid var(--gold); outline-offset: 1px; }

/* HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-start; padding: .5em .6em; pointer-events: none; }
#hud > * { pointer-events: auto; }
.where { background: rgba(14, 15, 32, .82); border: 2px solid var(--edge2); padding: .15em .6em; font-size: .9em; }
.hud-right { display: flex; gap: .35em; align-items: center; }
.hbtn { font: inherit; font-size: .9em; color: var(--ink); background: rgba(14, 15, 32, .85); border: 2px solid var(--edge2); padding: .15em .6em; cursor: pointer; }
.hbtn:hover { border-color: var(--gold); }
.online { display: flex; align-items: center; gap: .3em; font-size: .85em; background: rgba(14, 15, 32, .82); border: 2px solid var(--edge2); padding: .15em .5em; }
.online i { width: .6em; height: .6em; background: #6d7480; display: inline-block; }
.online.on i { background: var(--green); }
.banner { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); z-index: 7; background: var(--paper); color: var(--paper-ink); border: 3px solid var(--paper-ink); padding: .25em 1.2em; font-size: 1.15em; font-weight: 700; box-shadow: 0 0 0 3px var(--paper); animation: drop .3s ease-out; }
@keyframes drop { from { transform: translate(-50%, -150%); } }

/* dialogue */
.dialog { position: absolute; z-index: 15; left: 3%; right: 3%; bottom: 3%; padding: .8em 1em; background: var(--paper); color: var(--paper-ink); border: 3px solid var(--paper-ink); box-shadow: 0 0 0 3px var(--paper), 0 6px 0 3px rgba(0, 0, 0, .35); min-height: 25%; }
.dialog .who { position: absolute; top: -1.35em; left: .8em; background: var(--paper-ink); color: var(--gold); padding: .1em .6em; font-size: .9em; }
.dialog p { font-size: 1.05em; line-height: 1.35; min-height: 2.6em; }
.choices { display: flex; gap: .5em; justify-content: flex-end; margin-top: .5em; flex-wrap: wrap; }
.choices .btn { background: var(--paper-ink); }

/* menu drawer */
.drawer { position: absolute; z-index: 14; right: 0; top: 0; bottom: 0; width: min(62%, 34em); display: flex; flex-direction: column; background: var(--win); border-left: 3px solid var(--edge); box-shadow: -6px 0 0 rgba(0, 0, 0, .35); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30%); opacity: 0; } }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 2px solid var(--edge2); }
.tabs button { font: inherit; font-size: .85em; flex: 1; color: var(--dim); background: transparent; border: 0; border-right: 1px solid #2b2f55; padding: .5em .3em; cursor: pointer; }
.tabs button.on { color: var(--ink); background: var(--win2); box-shadow: inset 0 -3px 0 var(--gold); }
.tabs .close { flex: 0 0 2.4em; font-size: 1.1em; color: var(--ink); }
.menu-body { flex: 1; overflow: auto; padding: .7em; display: flex; flex-direction: column; gap: .5em; }

/* critter rows (party, box, bench) */
.mon { display: grid; grid-template-columns: 3em 1fr auto; gap: .2em .6em; align-items: center; background: var(--win2); border: 2px solid var(--edge2); padding: .35em .5em; }
.mon.lead { border-color: var(--gold); }
.mon.down { opacity: .6; }
.mon canvas { width: 3em; height: 3em; image-rendering: pixelated; }
.mon .info { display: flex; flex-direction: column; gap: .15em; min-width: 0; }
.mon b { font-weight: 700; }
.bar { height: .5em; background: #3a1d2a; border: 1px solid #0b0c18; }
.bar i { display: block; height: 100%; background: var(--green); }
.bar.xp { height: .3em; background: #20233f; } .bar.xp i { background: #7fd0ff; }
.mon .btns { display: flex; flex-direction: column; gap: .2em; }
.mon .btns .btn { font-size: .78em; padding: .15em .5em; }
.chip { display: inline-block; font-size: .72em; padding: 0 .4em; color: #11121f; font-weight: 700; vertical-align: middle; }
.lv { color: var(--dim); font-size: .85em; margin-left: .3em; }
.items { display: flex; flex-direction: column; gap: .35em; }
.item { display: flex; justify-content: space-between; align-items: center; gap: .6em; background: var(--win2); border: 2px solid var(--edge2); padding: .35em .6em; }
.item small { color: var(--dim); display: block; }
.dexgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5em, 1fr)); gap: .4em; }
.dexcell { background: var(--win2); border: 2px solid var(--edge2); padding: .3em; text-align: center; font-size: .78em; }
.dexcell canvas { width: 3em; height: 3em; image-rendering: pixelated; display: block; margin: 0 auto; }
.dexcell.unseen canvas { filter: brightness(0); opacity: .5; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5em; }
.badgecell { background: var(--win2); border: 2px solid var(--edge2); padding: .4em; text-align: center; font-size: .8em; }
.badgecell canvas { width: 2.4em; height: 2.4em; image-rendering: pixelated; display: block; margin: 0 auto .2em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2em 1em; }
.kv span:nth-child(odd) { color: var(--dim); }

/* Critter Center */
.center-win { width: min(34em, 94%); text-align: left; max-height: 92%; display: flex; flex-direction: column; }
.center-tabs { display: flex; gap: .3em; margin-bottom: .5em; }
.center-tabs button { font: inherit; color: var(--dim); background: transparent; border: 2px solid var(--edge2); padding: .2em .7em; cursor: pointer; }
.center-tabs button.on { color: var(--ink); background: var(--win2); border-color: var(--gold); }
.center-body { overflow: auto; display: flex; flex-direction: column; gap: .4em; min-height: 8em; }
.coins { margin-right: auto; color: var(--gold); }
.box-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; }

/* team picking (Cup rules) */
.team-win { width: min(56em, 96%); max-height: 94%; display: flex; flex-direction: column; text-align: left; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4em, 1fr)); gap: .4em; overflow: auto; }
.card { font: inherit; color: var(--ink); background: var(--win2); border: 2px solid var(--edge2); padding: .3em; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .15em; position: relative; }
.card.on { border-color: var(--gold); background: #33376a; }
.card .num { position: absolute; top: .15em; left: .35em; color: var(--gold); font-weight: 700; }
.card canvas { width: 3em; height: 3em; image-rendering: pixelated; }
.team-foot { display: flex; align-items: center; gap: .5em; flex-wrap: wrap; margin-top: .6em; }
.picked { display: flex; gap: .35em; margin-right: auto; }
.picked .slot { width: 2.8em; height: 2.8em; border: 2px dashed var(--edge2); display: grid; place-items: center; }
.picked .slot canvas { width: 2.4em; height: 2.4em; image-rendering: pixelated; }
.narrow-win { width: min(24em, 90%); text-align: center; }

/* battle */
#battleUI { position: absolute; left: 0; right: 0; bottom: 0; height: 28%; z-index: 8; }
.textbox { position: absolute; inset: 0; margin: 0 1.4% 1.4%; padding: .55em .9em; background: var(--paper); color: var(--paper-ink); border: 3px solid var(--paper-ink); box-shadow: 0 0 0 3px var(--paper); font-size: 1.15em; line-height: 1.35; cursor: pointer; }
.more { position: absolute; right: .6em; bottom: .3em; animation: blink 1s steps(2) infinite; visibility: hidden; }
.more.on { visibility: visible; }
@keyframes blink { 50% { opacity: 0; } }
.acts { position: absolute; inset: 0; margin: 0 1.4% 1.4%; display: grid; grid-template-columns: 1.1fr 1fr; gap: .5em; }
.prompt { background: var(--paper); color: var(--paper-ink); border: 3px solid var(--paper-ink); padding: .55em .9em; font-size: 1.1em; }
.acts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35em; }
.act { font: inherit; font-size: 1.1em; font-weight: 700; color: #fff; border: 3px solid #0b0c18; cursor: pointer; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25), 0 3px 0 #0b0c18; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.act:active:not(:disabled) { transform: translateY(2px); }
.act:disabled { filter: grayscale(.9) brightness(.6); cursor: default; }
.act.fight { background: #d8463f; } .act.bag { background: #d4a52a; } .act.mons { background: #3f9a52; } .act.run { background: #3f6fb0; }
.actions { position: absolute; inset: 0; margin: 0 1.4% 1.4%; display: grid; grid-template-columns: 1fr auto; gap: .5em; padding: .45em; background: var(--win); border: 3px solid var(--edge); }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: .35em; }
.mv { font: inherit; text-align: left; color: #11121f; border: 2px solid #11121f; padding: .15em .5em; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .4em; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 0 #11121f; }
.mv b { font-weight: 700; }
.mv small { font-size: .72em; opacity: .85; white-space: nowrap; }
.mv:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
.mv .eff { font-size: .7em; padding: 0 .3em; background: rgba(255, 255, 255, .6); }
.side-acts { display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; gap: .3em; }
.timer { text-align: center; color: var(--dim); font-size: .8em; }
.bench { position: absolute; left: 1.4%; right: 1.4%; bottom: 1.4%; z-index: 9; background: var(--win); border: 3px solid var(--edge); padding: .45em .6em; display: flex; flex-direction: column; gap: .35em; max-height: 98%; overflow: auto; }
.bench-list { display: flex; gap: .4em; flex-wrap: wrap; }
.benchmon { font: inherit; color: var(--ink); background: var(--win2); border: 2px solid var(--edge2); padding: .25em .5em; cursor: pointer; display: flex; gap: .4em; align-items: center; text-align: left; }
.benchmon:disabled { opacity: .45; cursor: default; }
.benchmon canvas { width: 2.4em; height: 2.4em; image-rendering: pixelated; }
.benchmon .bar { width: 5em; margin-top: .2em; }

/* chat and player popup */
.chat { position: absolute; z-index: 9; left: .6em; bottom: .6em; width: min(22em, 60%); display: flex; flex-direction: column; gap: .3em; }
.chat .log { display: flex; flex-direction: column; gap: .15em; font-size: .85em; max-height: 8em; overflow: hidden; }
.chat .log div { background: rgba(14, 15, 32, .78); padding: .1em .45em; }
.chat .log b { color: var(--gold); }
.chat form { display: flex; gap: .3em; }
.chat input { flex: 1; }
.pop { position: absolute; z-index: 13; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--win); border: 3px solid var(--edge); padding: .7em 1em; display: flex; flex-direction: column; gap: .4em; min-width: 12em; text-align: center; }
.toast { position: absolute; left: 50%; top: 26%; transform: translateX(-50%); background: var(--paper); color: var(--paper-ink); border: 3px solid var(--paper-ink); padding: .3em .9em; z-index: 30; max-width: 80%; text-align: center; }

/* phone controls */
#pad { width: min(100vw, 900px); display: flex; justify-content: space-between; align-items: center; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); touch-action: none; }
.dpad { display: grid; grid-template-columns: 52px 52px 52px; grid-template-rows: 52px 52px 52px; }
.dpad button, .ab button { font: inherit; color: var(--ink); background: rgba(38, 42, 80, .85); border: 2px solid var(--edge2); touch-action: none; font-size: 18px; }
.dpad [data-d="up"] { grid-column: 2; grid-row: 1; } .dpad [data-d="left"] { grid-column: 1; grid-row: 2; } .dpad [data-d="right"] { grid-column: 3; grid-row: 2; } .dpad [data-d="down"] { grid-column: 2; grid-row: 3; }
.dpad button.on, .ab button.on { background: #4a5090; }
.ab { display: flex; gap: 14px; align-items: flex-end; }
.ab button { width: 64px; height: 64px; border-radius: 50%; font-size: 22px; font-weight: 700; }
#aBtn { background: rgba(216, 70, 63, .85); margin-bottom: 26px; }
@media (orientation: landscape) and (pointer: coarse) {
  #pad { position: fixed; inset: auto 0 0 0; width: 100vw; pointer-events: none; padding: 0 calc(16px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  #pad > * { pointer-events: auto; opacity: .8; }
}
