[hidden] { display: none !important; }
@font-face { font-family: "Press Start 2P"; src: url("fonts/PressStart2P-Regular.ttf") format("truetype"); font-display: block; }
:root {
  --inset-top: var(--discord-safe-area-inset-top, 0px);
  --inset-right: var(--discord-safe-area-inset-right, 0px);
  --inset-bottom: var(--discord-safe-area-inset-bottom, 0px);
  --inset-left: var(--discord-safe-area-inset-left, 0px);
  --box-top: var(--inset-top);
  --box-right: var(--inset-right);
  --box-bottom: var(--inset-bottom);
  --box-left: var(--inset-left);
  --box-mid: calc(var(--box-left) + (100% - var(--box-left) - var(--box-right)) / 2);
  --text-lift: 44px;
  --cell: 62px;
  --key: 74px;
  --ink: #283038;
  --paper: #f8f8f0;
  --parchment: #f6caa0;
  --battle-text: 88px;
  --battle-reserve: 260px;
}
html, body { margin: 0; height: 100%; background: #101018; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body { font: 16px/1.4 system-ui, sans-serif; }
#game { position: absolute; inset: var(--box-top) var(--box-right) var(--box-bottom) var(--box-left); }
#game canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

/* The packs' bordered boxes (content/tilesets/ui), laid as 9-slice frames at twice their size; a plain line when they can't be had. */
.framed-menu, .framed-text { background: var(--parchment); color: var(--ink); box-sizing: border-box; box-shadow: 0 0 0 2px var(--ink); image-rendering: pixelated; }
.framed-menu { border: 16px solid #c88050; border-image: url("/assets/ui/frame-menu.png") 8 fill / 16px round; }
.framed-text { border: 10px solid #c88050; border-image: url("/assets/ui/frame-text.png") 5 fill / 10px round; }

#hud { position: absolute; top: calc(8px + var(--box-top)); left: calc(8px + var(--box-left)); right: calc(8px + var(--box-right)); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#place-name { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: 4px 10px; font-weight: 700; opacity: 0; transition: opacity .4s; }
#place-name.shown { opacity: 1; }

#pills { position: absolute; left: 50%; bottom: calc(10px + var(--inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px; z-index: 2; }
#pills button { pointer-events: auto; width: 40px; height: 22px; padding: 0; border-radius: 11px; border: 2px solid var(--ink); background: rgba(248, 248, 240, .85); color: var(--ink); font-size: 13px; line-height: 1; }
#pills button:active { background: #c8d0e0; }
#repel-chip { display: flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px 0 3px; border-radius: 11px; border: 2px solid var(--ink); background: rgba(248, 248, 240, .85); color: var(--ink); font-size: 11px; line-height: 1; }
#repel-chip[hidden] { display: none; }
#repel-chip img { width: 16px; height: 16px; image-rendering: pixelated; }
body.in-battle #open-menu { opacity: .4; }

#pad { position: absolute; inset: 0; pointer-events: none; }
#pad button { pointer-events: auto; border: 3px solid var(--ink); color: #f0f0f4; font-size: 22px; font-weight: 700; }
#pad button.held { filter: brightness(1.5); }
.dpad, .buttons { position: absolute; pointer-events: auto; padding: 10px; touch-action: none; user-select: none; -webkit-user-select: none; }
.dpad { left: calc(12px + var(--inset-left)); bottom: calc(44px + var(--inset-bottom)); display: grid; grid-template-columns: repeat(3, var(--cell)); grid-template-rows: repeat(3, var(--cell)); }
.dpad::before { content: ""; grid-column: 2; grid-row: 2; background: #34343c; }
.dpad [data-dir] { width: var(--cell); height: var(--cell); background: #34343c; }
.dpad [data-dir="north"] { grid-column: 2; grid-row: 1; border-radius: 10px 10px 0 0; }
.dpad [data-dir="west"] { grid-column: 1; grid-row: 2; border-radius: 10px 0 0 10px; }
.dpad [data-dir="east"] { grid-column: 3; grid-row: 2; border-radius: 0 10px 10px 0; }
.dpad [data-dir="south"] { grid-column: 2; grid-row: 3; border-radius: 0 0 10px 10px; }
.buttons { right: calc(12px + var(--inset-right)); bottom: calc(44px + var(--inset-bottom)); display: flex; gap: 16px; align-items: flex-end; }
.buttons button { width: var(--key); height: var(--key); border-radius: 50%; background: #a02c5c; }
.buttons [data-button="a"] { margin-bottom: calc(var(--key) / 2); }

/* The handheld: the game in a screen with the pad below it, or beside it lying down, in battles and menus too. */
body.pad-on {
  --edge: 16px;
  --console: calc(var(--cell) * 3 + 20px + 44px + 8px);
  --box-top: calc(var(--inset-top) + var(--edge));
  --box-right: calc(var(--inset-right) + var(--edge));
  --box-left: calc(var(--inset-left) + var(--edge));
  --box-bottom: calc(var(--inset-bottom) + var(--console) + var(--edge));
  --text-lift: 8px;
  background: #5c4f8f;
}
body.pad-on #game { border-radius: 6px; box-shadow: 0 0 0 10px #1e1e28; overflow: hidden; }
body.pad-on #pills button { border-color: #3c3c46; background: #9a9aa6; color: #22222c; }
body.mini { --box-top: 0px; --box-right: 0px; --box-bottom: 0px; --box-left: 0px; --text-lift: 4px; background: #101018; }
body.mini #pad, body.mini #pills, body.mini #hint, body.mini #hud { display: none !important; }
body.mini #textbox { font-size: 12px; padding: 4px 8px; min-height: 0; }
@media (max-width: 440px) { :root { --cell: 54px; --key: 62px; } }
@media (max-width: 380px) { :root { --cell: 50px; --key: 58px; } }

@media (orientation: landscape) {
  body.pad-on {
    --box-top: calc(var(--inset-top) + var(--edge));
    --box-bottom: calc(var(--inset-bottom) + var(--edge));
    --box-left: calc(var(--inset-left) + var(--cell) * 3 + 52px);
    --box-right: calc(var(--inset-right) + var(--key) * 2 + 76px);
  }
  .dpad { bottom: auto; top: calc(50% - 22px); transform: translateY(-50%); }
  .buttons { bottom: auto; top: 50%; transform: translateY(-50%); }
  body.pad-on #pills { left: calc(var(--inset-left) + 22px + var(--cell) * 1.5); bottom: calc(14px + var(--inset-bottom)); flex-direction: column; gap: 8px; }
}

#textbox { position: absolute; left: calc(8px + var(--box-left)); right: calc(8px + var(--box-right)); bottom: calc(var(--text-lift) + var(--box-bottom)); max-width: 640px; margin: 0 auto; padding: 8px 12px; min-height: 3.2em; font-size: 18px; }
#textbox p { margin: 0; white-space: pre-wrap; }
#textbox .more { position: absolute; right: 2px; bottom: 0; animation: bob 0.8s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#link-ask { position: absolute; left: calc(8px + var(--box-left)); right: calc(8px + var(--box-right)); bottom: calc(var(--text-lift) + var(--box-bottom) + 70px); max-width: 640px; margin: 0 auto; padding: 8px 12px; font-size: 18px; z-index: 3; }
#live-clock { position: absolute; top: calc(8px + var(--box-top)); right: calc(8px + var(--box-right)); padding: 4px 8px; font: 10px/1.2 "Press Start 2P", monospace; z-index: 3; pointer-events: none; border-width: 6px; }
#live-clock.urgent { color: #d83830; }
#link-ask p { margin: 0 0 8px; overflow-wrap: anywhere; }
#link-ask .answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#link-ask button { min-height: 48px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
#link-ask button:first-child { background: #58a8f8; color: #fff; }

#hint { position: absolute; top: calc(10px + var(--inset-top, 0px)); left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 24px); padding: 6px 12px; border-radius: 6px; color: #f8f8f8; background: rgba(16, 16, 24, 0.85); font: 12px/1.5 system-ui, sans-serif; text-align: center; pointer-events: none; }
#notice { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; color: #f8f8f8; font: 16px/1.5 system-ui, sans-serif; text-align: center; background: #101018; }

/* The battle menu: Fight, Bag, Run and Party as the lower screen had them, then the moves two by two. */
#battle-menu {
  position: absolute; left: calc(8px + var(--box-left)); right: calc(8px + var(--box-right)); bottom: calc(12px + var(--box-bottom));
  max-width: 640px; margin: 0 auto; padding: 2px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; overflow-y: auto;
}
#battle-menu button {
  min-width: 0; min-height: 56px; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper); color: var(--ink);
  font: clamp(9px, 2.8vw, 13px)/1.3 "Press Start 2P", monospace; text-align: left; padding: 8px 4px 8px 18px; position: relative; display: flex; flex-direction: column; justify-content: center; gap: 6px; overflow-wrap: anywhere;
}
#battle-menu button:disabled { opacity: .45; }
#battle-menu button .detail { font-size: 9px; opacity: .85; display: flex; justify-content: space-between; align-items: center; gap: 6px; white-space: nowrap; }
#battle-menu button.wide { grid-column: 1 / -1; }
#battle-menu button.back { background: #d8d8e0; min-height: 44px; }
#battle-menu .type { border-radius: 4px; padding: 2px 4px; color: #fff; text-transform: uppercase; text-shadow: 1px 1px 0 rgba(0, 0, 0, .35); }
#battle-menu.command { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(0, 1fr); grid-template-areas: "fight fight fight" "bag run party"; }
#battle-menu.command button { align-items: center; text-align: center; padding-right: 18px; color: #fff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); border-radius: 14px; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -4px 0 rgba(0, 0, 0, .18); }
#battle-menu.command .fight { grid-area: fight; min-height: 84px; font-size: 18px; background: linear-gradient(#f06a5a, #d0403a); }
#battle-menu.command .bag { grid-area: bag; background: linear-gradient(#f8c050, #e09428); }
#battle-menu.command .run { grid-area: run; background: linear-gradient(#6aa8f0, #3e78d0); }
#battle-menu.command .party { grid-area: party; background: linear-gradient(#78cc68, #449a44); }
#battle-menu button.tinted { background: linear-gradient(color-mix(in srgb, var(--tint) 30%, #fff), color-mix(in srgb, var(--tint) 55%, #fff)); border-left-width: 4px; border-left-color: var(--tint); }
body.in-battle:not(.pad-on) { background: repeating-linear-gradient(135deg, #2a3644 0 12px, #26313e 12px 24px); }
#battle-probe { position: absolute; visibility: hidden; pointer-events: none; height: var(--battle-reserve); }
body.in-battle #textbox { top: calc(var(--scene-bottom, 0px) + 8px + var(--box-top)); bottom: auto; height: var(--battle-text); overflow: hidden; }
body.in-battle #battle-menu { top: calc(var(--scene-bottom, 0px) + 16px + var(--battle-text) + var(--box-top)); bottom: auto; max-height: calc(100% - var(--scene-bottom, 0px) - 16px - var(--battle-text) - var(--text-lift) - var(--box-top) - var(--box-bottom)); }
body.in-battle #battle-menu.full { top: calc(var(--scene-bottom, 0px) + 8px + var(--box-top)); max-height: calc(100% - var(--scene-bottom, 0px) - 8px - var(--text-lift) - var(--box-top) - var(--box-bottom)); }

/* Compact, for the handheld and for short screens: the menu is a small box of plain lines, so the battle keeps the screen. */
body.compact { --battle-text: 72px; --battle-reserve: 246px; }
body.compact.in-battle #textbox { font-size: 15px; padding: 6px 10px; }
body.compact #battle-menu { padding: 4px; gap: 4px; }
body.compact #battle-menu button, body.compact #battle-menu.command button {
  min-height: 40px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); text-shadow: none; box-shadow: none;
  font-size: clamp(9px, 2.7vw, 11px); padding: 4px 4px 4px 14px; gap: 3px; align-items: flex-start; text-align: left;
}
body.compact #battle-menu.command { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "fight bag" "party run"; }
body.compact #battle-menu.command button { font-size: 12px; justify-content: center; padding-left: 16px; }
body.compact #battle-menu button.tinted { background: color-mix(in srgb, var(--tint) 22%, #fff); }
body.compact #battle-menu button.back { min-height: 28px; background: rgba(40, 48, 56, .1); font-size: 10px; }
body.compact #battle-menu button .detail { font-size: 8px; }
body.compact #battle-menu button .detail i { display: none; }
@media (orientation: landscape) {
  body.compact { --battle-row: 150px; --battle-reserve: calc(var(--battle-row) + var(--text-lift) + 10px); }
  body.compact.in-battle #textbox { top: auto; bottom: calc(var(--text-lift) + var(--box-bottom)); left: calc(8px + var(--box-left)); right: calc(100% - var(--box-mid) + 4px); height: var(--battle-row); max-width: none; margin: 0; }
  body.compact.in-battle #battle-menu { top: auto; bottom: calc(var(--text-lift) + var(--box-bottom)); left: calc(var(--box-mid) + 4px); right: calc(8px + var(--box-right)); max-height: var(--battle-row); max-width: none; margin: 0; }
  body.compact.in-battle #battle-menu.full { left: calc(8px + var(--box-left)); }
}

/* The cursor: the originals' dark triangle, in the room kept on each item's left, moved by the pad or the arrow keys. */
button.cursor { position: relative; }
button.cursor::before { content: ""; position: absolute; left: 5px; top: 50%; margin-top: -5px; border-left: 7px solid var(--ink); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
#battle-menu button.cursor { filter: brightness(1.06); }
body.compact #battle-menu button.cursor { background: rgba(255, 255, 255, .45); }
body.compact #battle-menu button.cursor::before { left: 3px; }
#sheet button.cursor { background: #fff4dc; }

#sheet {
  position: absolute; left: calc(8px + var(--box-left)); right: calc(8px + var(--box-right)); bottom: calc(var(--text-lift) + var(--box-bottom));
  max-width: 560px; max-height: calc(100% - 56px - var(--text-lift) - var(--box-top) - var(--box-bottom)); margin: 0 auto; overflow-y: auto;
  padding: 4px 6px; font: 15px/1.35 system-ui, sans-serif;
}
#sheet header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#sheet h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 13px/1.3 "Press Start 2P", monospace; }
#sheet .close { width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 50%; background: #d8d8e0; font-size: 16px; color: var(--ink); }
#sheet .note { margin: 8px 0; min-height: 1.2em; overflow-wrap: anywhere; }
#sheet .note:empty { display: none; }
#sheet .row.marked { background: #cfe4ff; }
#sheet .row.marked.cursor { background: #b8d6ff; }
#sheet .row.selectable .right { font-weight: 700; color: #1c4f9a; }
#sheet .row.danger { background: #fde4de; border-color: #a83838; color: #7a1c1c; }
#sheet .row.danger.cursor { background: #ffd0c4; }
#sheet .row.danger:disabled { background: #fff; border-color: var(--ink); color: var(--ink); }
#sheet .details { margin: 8px 0; padding: 8px 10px; border: 3px solid var(--ink); border-radius: 8px; background: #fffdf4; overflow-wrap: anywhere; font-size: 13px; }
#sheet .details h4 { margin: 0 0 4px; font: 10px/1.4 "Press Start 2P", monospace; }
#sheet .details p { margin: 4px 0; }
#sheet .details .stats, #sheet .details .moves { display: grid; margin: 6px 0 0; padding: 0; list-style: none; gap: 2px 10px; }
#sheet .details .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#sheet .details li { display: flex; justify-content: space-between; gap: 6px; min-width: 0; }
#sheet .details .moves li { flex-wrap: wrap; }
#sheet .details .moves small { opacity: .75; }
#sheet .details:not(.inline) { display: none; }
@media (min-width: 760px) {
  #sheet.wide { max-width: 900px; }
  #sheet.wide .body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; column-gap: 14px; align-items: start; }
  #sheet.wide .body > * { grid-column: 1; }
  #sheet.wide .body > .details { display: block; grid-column: 2; grid-row: 1 / span 30; position: sticky; top: 0; margin-top: 12px; }
}
#sheet h3 { margin: 12px 0 6px; font: 11px/1.3 "Press Start 2P", monospace; overflow-wrap: anywhere; }
:is(#sheet, #battle-menu) .row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 52px; margin: 6px 0; padding: 8px 12px 8px 20px; flex-direction: row; overflow-wrap: normal;
  border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); text-align: left; font: inherit;
}
:is(#sheet, #battle-menu) .row:disabled { opacity: .45; }
#sheet .para { margin: 8px 0; line-height: 1.35; overflow-wrap: anywhere; }
#sheet .row.faced { justify-content: flex-start; gap: 10px; }
#sheet .row.faced > span:first-of-type { flex: 1; min-width: 0; }
#sheet .row.faced > img { flex: none; width: 44px; height: 44px; margin: -6px 0; image-rendering: pixelated; object-fit: contain; }
#sheet .row.faced.picked { background: #cfe4ff; }
#sheet .row.faced:disabled.picked, #sheet .row.faced:disabled { opacity: 1; }
:is(#sheet, #battle-menu) .row.back:not(.cursor) { background: #d8d8e0; }
:is(#sheet, #battle-menu) .row.entry { justify-content: flex-start; gap: 12px; min-height: 44px; margin: 5px 0; padding: 6px 12px 6px 22px; font-weight: 700; letter-spacing: .02em; }
:is(#sheet, #battle-menu) .row.entry svg { flex: none; }
#sheet .row .name .held { display: inline-block; margin-left: 6px; vertical-align: -2px; }
#sheet .row .name .held svg { display: block; }
:is(#sheet, #battle-menu) .row.item { justify-content: flex-start; gap: 10px; min-height: 44px; margin: 5px 0; padding: 6px 12px 6px 22px; }
:is(#sheet, #battle-menu) .row.item .icon { flex: none; width: 30px; height: 30px; margin: -3px 0; image-rendering: pixelated; object-fit: contain; }
:is(#sheet, #battle-menu) .row.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#sheet, #battle-menu) .row.item .right { flex: none; font: 11px "Press Start 2P", monospace; }
#sheet .item-head { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
#sheet .item-head img { width: 30px; height: 30px; image-rendering: pixelated; object-fit: contain; }
#sheet .item-head b { font-size: 17px; }
#sheet .item-head span { margin-left: auto; font-size: 13px; text-align: right; }
:is(#sheet, #battle-menu) .row.mon { display: grid; grid-template-columns: 60px minmax(0, 1fr) 30px; grid-template-rows: auto auto; column-gap: 10px; row-gap: 3px; align-items: center; min-height: 0; margin: 5px 0; padding: 5px 10px 6px 20px; }
:is(#sheet, #battle-menu) .row.mon.lead { background: linear-gradient(#e8f4ff, #d4e8fc); }
:is(#sheet, #battle-menu) .row.mon.lead.cursor { background: linear-gradient(#fff4dc, #ffe8c0); }
:is(#sheet, #battle-menu) .row.mon.fainted { background: #f4d4cc; }
:is(#sheet, #battle-menu) .row.mon .face { grid-row: 1 / 3; grid-column: 1; width: 60px; height: 45px; margin: -4px 0; image-rendering: pixelated; object-fit: contain; }
:is(#sheet, #battle-menu) .row.mon .face.scaled { width: 45px; height: 45px; margin: -4px 7px; }
:is(#sheet, #battle-menu) .row.mon.fainted .face { filter: grayscale(1) opacity(.6); }
:is(#sheet, #battle-menu) .row.mon .top, :is(#sheet, #battle-menu) .row.mon .hp { grid-column: 2; }
:is(#sheet, #battle-menu) .row.mon .top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
:is(#sheet, #battle-menu) .row.mon .top .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#sheet, #battle-menu) .row.mon .lv { font: 9px "Press Start 2P", monospace; flex: none; }
:is(#sheet, #battle-menu) .row.mon .status { flex: none; font: 8px/1 "Press Start 2P", monospace; color: #fff; padding: 3px 4px 2px; border-radius: 3px; text-shadow: 1px 1px 0 rgba(0, 0, 0, .3); }
:is(#sheet, #battle-menu) .row.mon .PSN { background: #a040a0; }
:is(#sheet, #battle-menu) .row.mon .TOX { background: #7c2a8c; }
:is(#sheet, #battle-menu) .row.mon .BRN { background: #d85828; }
:is(#sheet, #battle-menu) .row.mon .PAR { background: #c8a018; }
:is(#sheet, #battle-menu) .row.mon .SLP { background: #8890a0; }
:is(#sheet, #battle-menu) .row.mon .FRZ { background: #48a0c8; }
:is(#sheet, #battle-menu) .row.mon .FNT { background: #a83838; }
:is(#sheet, #battle-menu) .row.mon .hp { display: flex; align-items: center; gap: 6px; }
:is(#sheet, #battle-menu) .row.mon .bar { display: flex; align-items: center; flex: 1; min-width: 0; padding: 2px 2px 2px; gap: 3px; background: #303840; border-radius: 3px; }
:is(#sheet, #battle-menu) .row.mon .bar b { font: 6px/1 "Press Start 2P", monospace; color: #f8c838; }
:is(#sheet, #battle-menu) .row.mon .tracks { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
:is(#sheet, #battle-menu) .row.mon .fill { position: relative; height: 5px; background: #505860; }
:is(#sheet, #battle-menu) .xp { position: relative; display: block; height: 2px; background: #303840; }
:is(#sheet, #battle-menu) .xp i { position: absolute; left: 0; top: 0; bottom: 0; background: #40a8f8; }
#sheet .row.exp .xp { height: 5px; margin-top: 4px; border: 1px solid #303840; background: #303840; box-sizing: content-box; }
:is(#sheet, #battle-menu) .row.mon .fill i { position: absolute; left: 0; top: 0; bottom: 0; }
:is(#sheet, #battle-menu) .row.mon .nums { width: 54px; font: 9px "Press Start 2P", monospace; text-align: right; white-space: nowrap; }
:is(#sheet, #battle-menu) .row.mon .held { grid-row: 1 / 3; grid-column: 3; width: 30px; height: 30px; image-rendering: pixelated; object-fit: contain; }
#sheet .row.info { background: transparent; border-style: dashed; border-width: 2px; box-sizing: border-box; }
:is(#sheet, #battle-menu) .row .name { display: block; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#sheet, #battle-menu) .row > span:first-child { flex: 1; min-width: 0; }
:is(#sheet, #battle-menu) .row.info .name { white-space: normal; overflow-wrap: anywhere; }
#sheet .row .small { font-size: 13px; opacity: .75; display: block; overflow-wrap: anywhere; }
:is(#sheet, #battle-menu) .row .right { max-width: 50%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sheet .picker { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0; }
#sheet .picker button { width: 52px; height: 52px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; font-size: 22px; color: var(--ink); }
#sheet .picker output { min-width: 48px; text-align: center; font: 16px "Press Start 2P", monospace; }
#sheet .go { width: 100%; min-height: 52px; padding: 0 16px; border: 3px solid var(--ink); border-radius: 8px; background: #58a8f8; color: #fff; font-weight: 700; font-size: 16px; }
#sheet img.picture.draft { max-height: 38vh; object-fit: contain; }
#sheet img.picture { display: block; width: 100%; max-width: 480px; margin: 8px auto; image-rendering: pixelated; border-radius: 6px; }

/* The map with a pin at each place, a point the pad steps between and a tap finds; the cursor rings it, and the bubble names it. */
#sheet .chart { position: relative; max-width: 480px; margin: 8px auto; overflow: hidden; overflow: clip; border-radius: 6px; touch-action: pan-y; }
#sheet .chart .layer { position: relative; transform-origin: 0 0; will-change: transform; }
#sheet .chart img { display: block; width: 100%; image-rendering: pixelated; user-select: none; -webkit-user-drag: none; }
#sheet .chart .zoom { position: absolute; z-index: 2; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 6px; }
#sheet .chart .zoom button { width: 40px; height: 40px; padding: 0; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 18px "Press Start 2P", monospace; }
#sheet .chart .zoom button:disabled { opacity: 0.4; }
#sheet .chart .zoom button.cursor { background: #ffe9a8; }
#sheet .chart .pin { position: absolute; width: 2px; height: 2px; margin: -1px 0 0 -1px; padding: 0; border: 0; border-radius: 50%; background: transparent; pointer-events: none; transform: scale(var(--inverse, 1)); }
#sheet .chart .pin.cursor { background: transparent; }
#sheet .chart .pin.cursor::after { content: ""; position: absolute; inset: -11px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ink); }
#sheet .chart .pin.cursor::before { content: none; }
#sheet .chart .pin.lit::before { content: ""; position: absolute; inset: -9px; border: 2px solid #ffd23f; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); animation: lit-pulse 1.2s ease-in-out infinite; }
@keyframes lit-pulse { 0%, 100% { transform: scale(0.8); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.6; } }
#sheet .chart .bubble {
  position: absolute; z-index: 1; max-width: calc(100% - 4px); padding: 2px 4px; transform: translate(-50%, calc(-100% - 14px));
  display: flex; flex-direction: column; gap: 3px; pointer-events: none; text-align: center; white-space: nowrap;
}
#sheet .chart .bubble.below { transform: translate(-50%, 14px); }
#sheet .chart .bubble > * { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#sheet .chart .bubble b { font: 10px/1.4 "Press Start 2P", monospace; }
#sheet .chart .bubble span { font-size: 12px; line-height: 1.2; }
#sheet .chart .bubble .here { color: #c82828; font-weight: 700; }
#sheet .chart .bubble .grounded { color: #6a6a60; }
#sheet .chart .bubble .ask { white-space: normal; overflow: visible; }
#sheet .chart .bubble .answers { display: flex; gap: 6px; justify-content: center; }
#sheet .chart .bubble button { pointer-events: auto; min-height: 28px; padding: 2px 10px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; color: var(--ink); font: 10px "Press Start 2P", monospace; }
#sheet .chart .bubble button.cursor { background: #ffe9a8; }
#sheet .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; margin: 8px 0; }
#sheet .grid button { position: relative; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; background: #fff; padding: 0; overflow: hidden; }
#sheet .grid button:disabled { background: #e8e8e0; opacity: 1; }
#sheet .grid .number { position: absolute; top: 2px; left: 4px; font: 9px "Press Start 2P", monospace; color: var(--ink); }
#sheet .grid img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
#sheet .grid img.dim { filter: brightness(0); opacity: .6; }
#sheet .grid .unknown { font: 16px "Press Start 2P", monospace; color: #a0a0a8; }
#sheet .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
#sheet .choices button { min-height: 48px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; padding: 0 16px; }
#sheet .choices button.on { background: #58a8f8; color: #fff; }
#sheet .pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
#sheet .pager span { flex: 1; min-width: 0; text-align: center; font: 11px "Press Start 2P", monospace; }
#sheet .pager button { flex: none; width: 56px; min-height: 48px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; padding: 0; }
#sheet .pager button:disabled { opacity: .45; }
#sheet .pager button.cursor { outline: 3px solid #58a8f8; outline-offset: 2px; }
#sheet .pager button.cursor::before { display: none; }
#sheet .swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0 10px; }
#sheet .swatches.ten { grid-template-columns: repeat(10, 1fr); }
@media (max-width: 520px) { #sheet .swatches.ten { grid-template-columns: repeat(5, 1fr); } }
#sheet .swatches button { min-height: 40px; border: 3px solid var(--ink); border-radius: 8px; padding: 0; }
#sheet .swatches button.on { box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px var(--ink); }
#sheet .swatches button.cursor { outline: 3px solid #58a8f8; outline-offset: 2px; }
#sheet .swatches button.cursor::before { display: none; }
#sheet .slider { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
#sheet .slider button { flex: none; width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font-size: 16px; padding: 0; }
#sheet .slider button.cursor::before { display: none; }
#sheet .slider button.cursor { outline: 3px solid #58a8f8; outline-offset: 2px; }
#sheet .slider input { flex: 1; min-width: 0; height: 28px; margin: 0; border: 3px solid var(--ink); border-radius: 14px; appearance: none; -webkit-appearance: none; touch-action: pan-y; }
#sheet .slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 34px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; }
#sheet .slider input::-moz-range-thumb { width: 20px; height: 28px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; }
#sheet .mirror-stage { position: sticky; top: -4px; z-index: 1; background: var(--parchment); padding: 2px 0 4px; }
#sheet .mirror-stage img.picture { width: 256px; max-width: 100%; margin: 0 auto; }
@media (max-width: 520px), (max-height: 560px) { #sheet .mirror-stage img.picture { width: 192px; } }
#sheet .body:has(.mirror-stage) button { scroll-margin-top: 210px; }

#sheet .trade-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 0 8px; }
#sheet .trade-card { min-width: 0; padding: 6px 8px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; font-size: 13px; }
#sheet .trade-card.ready { background: #e4f6dc; }
#sheet .trade-card h4 { display: flex; justify-content: space-between; gap: 4px; margin: 0 0 4px; font: 9px/1.4 "Press Start 2P", monospace; }
#sheet .trade-card h4 > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet .trade-card .tag { color: #2a8a2a; flex: none; }
#sheet .trade-card .who { display: flex; align-items: center; gap: 6px; }
#sheet .trade-card .who > span { min-width: 0; }
#sheet .trade-card .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet .trade-card .who img { width: 44px; height: 44px; flex: none; object-fit: contain; image-rendering: pixelated; }
#sheet .trade-card p { margin: 3px 0 0; line-height: 1.25; }
#sheet .trade-card .moves { font-size: 12px; }
#sheet .trade-card .holds { font-size: 12px; opacity: .75; }
#sheet .trade-card .empty { opacity: .7; min-height: 4.5em; }
#sheet .trade-actions { display: grid; grid-template-columns: 3fr 2fr; gap: 6px; margin: 0 0 8px; }
#sheet .trade-actions button { min-height: 48px; padding: 4px 8px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-weight: 700; }
#sheet .trade-actions .go { background: #58a8f8; color: #fff; }
#sheet .trade-actions button:disabled { opacity: .5; }
#sheet .trade-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#sheet .trade-lists > div { min-width: 0; }
#sheet .trade-lists h3 { margin: 2px 0 4px; }
#sheet .trade-lists h5 { margin: 6px 0 2px; font: 8px/1.3 "Press Start 2P", monospace; opacity: .7; }
#sheet .trade-list { max-height: 230px; overflow-y: auto; }
#sheet .trade-list .creature { box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 4px; min-height: 40px; margin: 0 0 3px; padding: 2px 4px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; color: var(--ink); text-align: left; font: inherit; font-size: 13px; }
#sheet .trade-list .creature img { width: 30px; height: 30px; flex: none; object-fit: contain; image-rendering: pixelated; }
#sheet .trade-list .creature > span { min-width: 0; }
#sheet .trade-list .creature .name { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet .trade-list .creature .small { display: block; font-size: 11px; opacity: .75; }
#sheet .trade-list .creature.on { background: #58a8f8; color: #fff; }
#sheet .trade-list .creature:disabled { opacity: .5; }
#sheet .trade-list .creature.fainted img { filter: grayscale(1); }
#sheet .trade-list div.creature { border-style: dashed; background: transparent; }
#sheet .trade-list div.creature.on { background: #58a8f8; color: #fff; border-style: solid; }
#sheet .trade-stage { position: relative; height: 170px; margin: 6px 0; overflow: hidden; border: 3px solid var(--ink); border-radius: 8px; background: #181830; color: #fff; text-align: center; }
#sheet .trade-stage figure { position: absolute; top: 18px; margin: 0; width: 38%; }
#sheet .trade-stage figure img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; }
#sheet .trade-stage figcaption { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet .trade-stage .out { left: 4%; }
#sheet .trade-stage .in { right: 4%; }
#sheet .trade-stage .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#sheet .trade-stage.crossing .out { animation: trade-out 1.4s ease-in-out forwards; }
#sheet .trade-stage.crossing .in { animation: trade-in 1.4s ease-in-out forwards; }
#sheet .trade-stage.crossing .flash { animation: trade-flash 1.4s ease-in-out; }
#sheet .trade-stage.evolved .flash { animation: trade-flash 0.8s ease-in-out; }
#sheet .trade-stage.settled .out, #sheet .trade-stage.crossing .out { left: 58%; }
#sheet .trade-stage.settled .in, #sheet .trade-stage.crossing .in { right: 58%; }
@keyframes trade-out { from { left: 4%; } to { left: 58%; } }
@keyframes trade-in { from { right: 4%; } to { right: 58%; } }
@keyframes trade-flash { 0%, 40% { opacity: 0; } 55% { opacity: .85; } 100% { opacity: 0; } }
#evolution { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; background: rgba(8, 8, 24, .9); }
#evolution img { width: min(60vw, 40vh, 288px); height: min(60vw, 40vh, 288px); object-fit: contain; image-rendering: pixelated; }
#evolution img.lit { filter: brightness(0) invert(1); }
#evolution .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
#evolution.burst .flash { opacity: 1; transition: none; }
#evolution .stop { position: absolute; left: 50%; bottom: calc(24px + var(--inset-bottom, 0px)); transform: translateX(-50%); padding: 10px 28px; border: 3px solid var(--ink); border-radius: 8px; background: var(--parchment); color: var(--ink); font: 12px "Press Start 2P", monospace; }
body.evolving #textbox { z-index: 4; }
body.evolving #pad { z-index: 5; }
body.evolving .dpad, body.evolving [data-button="a"], body.evolving:not(.can-stop) [data-button="b"] { opacity: .4; }

#battle-menu.rows { display: block; font: 15px/1.35 system-ui, sans-serif; padding: 4px 6px; }
#battle-menu.rows .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; margin: 2px 0 6px; }
#battle-menu.rows .choices button { min-height: 38px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; padding: 0 8px; text-align: center; display: block; }
#battle-menu.rows .choices button.on { background: #58a8f8; color: #fff; }
#battle-menu.rows button.back { display: block; width: 100%; margin: 5px 0 0; text-align: center; font: 11px "Press Start 2P", monospace; }

#sheet input.text { box-sizing: border-box; width: 100%; min-height: 52px; margin: 6px 0; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 14px "Press Start 2P", monospace; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
#sheet input.text:focus { outline: 3px solid #58a8f8; outline-offset: 1px; }

body.halloween { --ink: #2a1838; --paper: #fff0dc; --parchment: #f2c08c; }
body.halloween #place-name { background: #2a1838; color: #ffa030; border-color: #ff7a18; }
body.halloween #place-name::before { content: "\1F383 "; }
body.halloween #pills button { border-color: #ff7a18; color: #ffa030; background: #2a1838; }
body.halloween .framed-menu, body.halloween .framed-text { box-shadow: 0 0 0 2px #7a3ab0; }

body.christmas { --ink: #1c3a2a; --paper: #fff4ee; --parchment: #f6d8c0; }
body.christmas #place-name { background: #1f5a34; color: #fff; border-color: #c42a2a; }
body.christmas #place-name::before { content: "\1F384 "; }
body.christmas #pills button { border-color: #c42a2a; color: #fff; background: #1f5a34; }
body.christmas .framed-menu, body.christmas .framed-text { box-shadow: 0 0 0 2px #b02828; }

#maker-map { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: #181820; padding: var(--inset-top) var(--inset-right) var(--inset-bottom) var(--inset-left); font: 14px/1.3 system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; }
body.making-map #pad, body.making-map #pills, body.making-map #hint { display: none; }
#maker-map header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--parchment); border-bottom: 3px solid var(--ink); }
#maker-map header h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px/1.3 "Press Start 2P", monospace; }
#maker-map header button { min-width: 48px; height: 48px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 700 15px system-ui, sans-serif; }
#maker-map header .close { width: 48px; border-radius: 50%; background: #d8d8e0; font-size: 18px; }
#maker-map header .save { padding: 0 16px; }
#maker-map header .save.due { background: #58a8f8; color: #fff; }
#maker-map header .save:disabled { opacity: .55; }
#maker-map .stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#maker-map canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#maker-map .toast { position: absolute; top: 8px; left: 8px; right: 8px; max-width: 520px; margin: 0 auto; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper); text-align: center; pointer-events: none; }
#maker-map .ask { position: absolute; left: 8px; right: 8px; bottom: 8px; max-width: 520px; margin: 0 auto; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 8px; background: var(--parchment); }
#maker-map .ask span { display: block; margin-bottom: 8px; font-weight: 700; }
#maker-map .ask .answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#maker-map .ask button { min-height: 52px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 700 15px system-ui, sans-serif; }
#maker-map .ask .yes { background: #48b048; color: #fff; }
#maker-map .ask .yes.danger { background: #c84040; }
#maker-map .ask .yes:disabled { background: #b8b8b0; color: #fff; }
#maker-map .dock { background: var(--parchment); border-top: 3px solid var(--ink); padding: 6px 6px 4px; }
#maker-map .tools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
#maker-map .tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
#maker-map .tool, #maker-map .tab { min-height: 48px; padding: 0; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 700 12px system-ui, sans-serif; letter-spacing: -.2px; overflow: hidden; text-overflow: clip; }
#maker-map .tab { min-height: 40px; border-radius: 8px 8px 0 0; background: #e8d8c0; }
#maker-map .tool.on { background: #58a8f8; color: #fff; }
#maker-map .tab.on { background: #fffdf4; }
#maker-map .tool:disabled { opacity: .45; }
#maker-map .palette { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 4px; background: #fffdf4; border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 8px 8px; scrollbar-width: thin; }
#maker-map .swatch { flex: 0 0 auto; width: 78px; height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 2px; padding: 4px 2px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 600 12px system-ui, sans-serif; }
#maker-map .swatch img { width: 60px; height: 60px; object-fit: contain; image-rendering: pixelated; }
#maker-map .swatch.flat img { width: 48px; height: 48px; margin: 6px 0; border: 1px solid rgba(0, 0, 0, .25); }
#maker-map .swatch span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#maker-map .swatch.on { background: #cfe4ff; box-shadow: inset 0 0 0 2px #58a8f8; }
#maker-map .dock > * { max-width: 760px; margin-left: auto; margin-right: auto; }
