/* Waymark II: a 16-bit field journal. Pixel font + system serif; no third parties. */
@font-face {
  font-family: "Waymark Field";
  src: url("waymark-field.woff2") format("woff2");
  font-display: block;
}

:root {
  --k: #2b2118; --s: #8a6a46; --p: #f4e7c8; --P: #dcc79a; --d: #b89a68;
  --a: #e8973a; --A: #b5652a; --t: #3f9e8f; --T: #2a6a63; --r: #c9604f; --v: #7b6bc8; --m: #7f9d4a;
  --w: #fffbe8; --c: #3df6ff; --g: #ff3df0; --n: #10151a; --N: #1b242b; --f: #3a4248; --y: #f2d25a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --px: "Waymark Field", ui-monospace, Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabs-h: 64px;
  color-scheme: dark;
}
:root.hc { --p: #ffffff; --P: #f0f0f0; --k: #000000; --a: #ffb000; --s: #333333; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--n); color: var(--p); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; overscroll-behavior: none; font-family: var(--serif); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px dashed var(--a); outline-offset: 2px; }

.px { font-family: var(--px); font-size: 20px; line-height: 24px; letter-spacing: 0; -webkit-font-smoothing: none; font-smooth: never; text-rendering: optimizeSpeed; }
.px-s { font-size: 10px; line-height: 12px; }
.px-l { font-size: 40px; line-height: 44px; }
.serif { font-family: var(--serif); }
.pixelated { image-rendering: pixelated; image-rendering: crisp-edges; }

.frame-parchment { border: 8px solid transparent; border-image: var(--frame-parchment) 4 fill / 8px / 0 stretch; image-rendering: pixelated; color: var(--k); }
.frame-ink { border: 8px solid transparent; border-image: var(--frame-ink) 4 fill / 8px / 0 stretch; image-rendering: pixelated; color: var(--p); }
.frame-static { border: 8px solid transparent; border-image: var(--frame-static) 4 fill / 8px / 0 stretch; image-rendering: pixelated; color: var(--w); }
.frame-teal { border: 8px solid transparent; border-image: var(--frame-teal) 4 fill / 8px / 0 stretch; image-rendering: pixelated; color: var(--w); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 4px 14px; border: 8px solid transparent; border-image: var(--frame-buttonGhost) 4 fill / 8px / 0 stretch; background: none; color: var(--k); image-rendering: pixelated; text-transform: uppercase; }
.btn-primary { border-image-source: var(--frame-button); color: var(--k); }
.btn-danger { color: var(--r); }
.btn-small { min-height: 40px; padding: 0 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn:active:not([disabled]) { transform: translateY(2px); }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; overflow-y: auto; background: var(--n) repeating-linear-gradient(0deg, transparent 0 15px, rgba(61, 246, 255, .04) 15px 16px), repeating-linear-gradient(90deg, transparent 0 15px, rgba(255, 61, 240, .035) 15px 16px); padding: calc(var(--safe-t) + 16px) 12px calc(var(--safe-b) + 24px); }
.boot-page { max-width: 560px; margin: 0 auto; padding: 14px 16px 18px; }
.boot-back { color: var(--s); font-size: .9rem; text-decoration: none; }
.boot-kicker { margin: 18px 0 0; color: var(--A); text-transform: uppercase; font-size: 10px; line-height: 12px; }
.boot-title { margin: 6px 0 0; font-size: 60px; line-height: 64px; color: var(--k); text-shadow: 3px 3px 0 var(--a); }
.boot-sub { margin: 6px 0 14px; color: var(--T); }
.boot-lede { font-size: 1.12rem; line-height: 1.5; margin: 0 0 14px; }
.boot-welcome { margin: 0 0 12px; padding: 8px 10px; background: rgba(63, 158, 143, .15); border-left: 4px solid var(--t); font-size: .95rem; }
.perm-list { list-style: none; margin: 0 0 10px; padding: 0; border-top: 2px dashed var(--d); }
.perm { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 2px dashed var(--d); }
.perm-name { grid-column: 1; }
.perm-why { grid-column: 1; font-size: .88rem; line-height: 1.35; color: var(--s); }
.perm { position: relative; }
.perm-state { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 64px; min-height: 36px; font-size: 10px; line-height: 12px; padding: 4px 8px; border: 0; background: var(--a); color: var(--k); text-transform: uppercase; box-shadow: inset -3px -3px 0 var(--A), 0 3px 0 var(--k); }
.perm-state:active:not([aria-disabled="true"]) { transform: translateY(2px); box-shadow: inset -3px -3px 0 var(--A), 0 1px 0 var(--k); }
.perm-state[data-value="asking"] { background: var(--P); animation: perm-blink .5s steps(2) infinite; }
.perm-state[data-value="granted"] { background: var(--t); color: var(--w); box-shadow: inset -3px -3px 0 var(--T); cursor: default; }
.perm-state[data-value="denied"] { background: var(--r); color: var(--w); box-shadow: inset -3px -3px 0 #8f3f33; }
.perm-state[data-value="unsupported"] { background: var(--P); color: var(--s); box-shadow: none; cursor: default; }
.perm-hint { grid-column: 1 / -1; margin: 4px 0 0; font-size: .85rem; line-height: 1.35; color: var(--r); }
.perm-state[data-value="unsupported"] ~ .perm-hint { color: var(--s); }
.perm-burst { position: absolute; z-index: 3; pointer-events: none; image-rendering: pixelated; }
.perm-stamp { position: absolute; z-index: 4; right: 74px; top: 50%; padding: 2px 6px; border: 3px solid var(--t); color: var(--t); background: rgba(244, 231, 200, .85); pointer-events: none; transform: translateY(-50%) rotate(-8deg); animation: perm-stamp 1.5s steps(12) forwards; }
.perm-won { animation: perm-flash .9s steps(6); }
.perm-won .perm-state { animation: perm-pop .45s steps(5); }
.perm-nope .perm-state { animation: perm-shake .36s steps(4); }
@keyframes perm-blink { 50% { opacity: .35; } }
@keyframes perm-stamp {
  0% { opacity: 0; transform: translateY(-50%) rotate(-8deg) scale(2.6); }
  15% { opacity: 1; transform: translateY(-50%) rotate(-8deg) scale(.92); }
  22%, 75% { opacity: 1; transform: translateY(-50%) rotate(-8deg) scale(1); }
  100% { opacity: 0; transform: translateY(-50%) rotate(-8deg) scale(1); }
}
@keyframes perm-flash { 0% { background: rgba(63, 158, 143, .55); } 100% { background: transparent; } }
@keyframes perm-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-4deg); } 100% { transform: scale(1); } }
@keyframes perm-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .perm-won, .perm-won .perm-state, .perm-nope .perm-state, .perm-state[data-value="asking"] { animation: none; } .perm-stamp { animation-timing-function: step-end; } }
.boot-warn { padding: 8px 10px; background: rgba(201, 96, 79, .15); border-left: 4px solid var(--r); font-size: .92rem; }
.boot-actions { display: grid; gap: 10px; margin: 16px 0; }
.boot-privacy { font-size: .85rem; line-height: 1.45; color: var(--s); margin: 0; }

/* ---------- app shell ---------- */
.app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.view-field { background: var(--n); }
.cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reticle { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; pointer-events: none; background:
  linear-gradient(var(--a), var(--a)) center / 2px 6px no-repeat, linear-gradient(var(--a), var(--a)) center / 6px 2px no-repeat; outline: 2px solid rgba(16, 21, 26, .5); outline-offset: -8px; }
.ar-status { position: absolute; left: 50%; top: calc(var(--safe-t) + 60px); transform: translateX(-50%); width: max-content; max-width: min(92vw, 440px); margin: 0; padding: 4px 8px; background: rgba(16, 21, 26, .85); color: var(--p); font-size: 10px; line-height: 12px; text-align: center; pointer-events: none; }
.ar-status:empty { display: none; }

.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 8px) 8px 8px; background: linear-gradient(rgba(16, 21, 26, .9), rgba(16, 21, 26, 0)); z-index: 6; pointer-events: none; }
.hud-brand { color: var(--a); font-size: 10px; line-height: 12px; letter-spacing: 2px; }
.hud-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; pointer-events: auto; }
.chip { font-size: 10px; line-height: 12px; padding: 4px 6px; background: var(--N); color: var(--p); border: 2px solid var(--k); box-shadow: inset 0 0 0 1px #3a2e22; white-space: nowrap; }
.chip-btn { cursor: pointer; }
.chip-sim { color: var(--g); }
.chip-ink { padding-left: 20px; background: var(--N) var(--spr-ink) 2px center / 16px 16px no-repeat; image-rendering: pixelated; }
.chip[data-q="good"] { color: var(--t); }
.chip[data-q="fair"] { color: var(--a); }
.chip[data-q="poor"] { color: var(--r); }

.tabs { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: var(--safe-b); background: var(--k); border-top: 4px solid var(--A); z-index: 7; }
.tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; height: var(--tabs-h); padding: 6px 0; border: 0; background: none; color: var(--d); font-size: 10px; line-height: 12px; text-transform: uppercase; }
.tab.is-on { color: var(--y); background: #3a2e22; }
.tab-ico { width: 32px; height: 32px; background: center / 32px 32px no-repeat; image-rendering: pixelated; }
.ico-alert { background-image: var(--spr-compass); } .ico-flag { background-image: var(--spr-flag); } .ico-note { background-image: var(--spr-note); } .ico-ink { background-image: var(--spr-ink); }
.tab-dot { position: absolute; top: 6px; right: calc(50% - 22px); width: 8px; height: 8px; background: var(--r); box-shadow: 0 0 0 2px var(--k); }

.drop { position: absolute; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); transform: translateX(-50%); z-index: 6; min-width: 132px; }
.drop:active { transform: translate(-50%, 2px); }

.stir { position: absolute; left: 50%; top: calc(var(--safe-t) + 54px); transform: translateX(-50%); z-index: 8; min-height: 48px; padding: 2px 10px 2px 44px; background: var(--spr-alert) 6px center / 32px 32px no-repeat; text-align: left; animation: stir 0.9s steps(2) infinite; max-width: 94vw; }
.stir small { display: block; font-size: 10px; line-height: 12px; color: var(--c); }
@keyframes stir { 50% { filter: hue-rotate(60deg) brightness(1.2); } }

.near-tray { position: absolute; left: 8px; right: 8px; bottom: calc(var(--tabs-h) + var(--safe-b) + 76px); display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; z-index: 4; }
.near-tray::-webkit-scrollbar { display: none; }
.near-card { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; max-width: 70vw; padding: 2px 6px; text-align: left; background: none; }
.near-card img { width: 32px; height: 32px; image-rendering: pixelated; }
.near-card b { display: block; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
.near-card small { font-size: 10px; line-height: 12px; color: var(--s); }
.near-label { flex: 0 0 auto; align-self: center; color: var(--y); font-size: 10px; line-height: 12px; text-transform: uppercase; text-shadow: 1px 1px 0 var(--k); }

.guide { position: absolute; left: 50%; top: calc(var(--safe-t) + 54px); transform: translateX(-50%); z-index: 5; display: flex; gap: 8px; align-items: center; font-size: 10px; line-height: 12px; padding: 2px 4px 2px 8px; max-width: 94vw; }
.guide button { border: 0; background: none; color: var(--a); font: inherit; font-size: 20px; padding: 0 4px; }

.sim-pad { position: absolute; right: 8px; bottom: calc(var(--tabs-h) + var(--safe-b) + 76px); display: grid; grid-template-columns: repeat(3, 48px); gap: 4px; z-index: 5; }
.sim-pad button { height: 48px; padding: 0; background: none; color: var(--g); touch-action: none; user-select: none; -webkit-user-select: none; }

/* ---------- chart ---------- */
.view-chart { background: var(--n); }
.map-stats { position: absolute; left: 8px; top: calc(var(--safe-t) + 44px); font-size: 10px; line-height: 12px; padding: 2px 6px; pointer-events: none; max-width: 62vw; }
.map-stats b { color: var(--y); font-weight: normal; }
.map-tools { position: absolute; right: 8px; top: calc(var(--safe-t) + 44px); display: grid; gap: 4px; }
.icon-btn { width: 48px; height: 48px; padding: 0; background: none; color: var(--a); }
.icon-btn.is-on { color: var(--y); border-image-source: var(--frame-teal); }
.map-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b) + 70px); margin: 0; text-align: center; color: var(--d); font-size: 10px; line-height: 12px; pointer-events: none; text-shadow: 1px 1px 0 var(--k); }

/* ---------- journal / dispatch pages ---------- */
.page-view { overflow-y: auto; background: var(--n); padding: calc(var(--safe-t) + 44px) 8px calc(var(--tabs-h) + var(--safe-b) + 24px); -webkit-overflow-scrolling: touch; }
.page { max-width: 640px; margin: 0 auto; padding: 10px 12px 16px; min-height: 60vh; }
.page-title { margin: 0 0 8px; color: var(--k); text-shadow: 2px 2px 0 var(--P); }
.page h3 { font-family: var(--px); font-size: 10px; line-height: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--A); margin: 18px 0 6px; font-weight: normal; }
.page p, .page li { font-size: .98rem; line-height: 1.5; }
.page .quiet { color: var(--s); font-size: .9rem; }
.subtabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 0 0 10px; border-bottom: 2px solid var(--k); }
.subtab { border: 0; background: var(--P); color: var(--s); padding: 4px 8px; font-size: 10px; line-height: 12px; text-transform: uppercase; }
.subtab.is-on { background: var(--k); color: var(--y); }
.entry { padding: 10px 0; border-bottom: 2px dashed var(--d); }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.entry-head .px { font-size: 20px; }
.entry-stats { font-family: var(--px); font-size: 10px; line-height: 12px; color: var(--s); }
.entry-text { margin: 6px 0 0; font-style: italic; }
.entry-note { margin: 6px 0 0; padding-left: 8px; border-left: 3px solid var(--a); white-space: pre-wrap; }
.entry-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.wx { font-family: var(--px); font-size: 10px; line-height: 12px; padding: 2px 5px; border: 2px solid var(--k); background: var(--p); color: var(--k); }
.wx.is-on { background: var(--k); color: var(--y); }
.route-mini { display: block; width: 100%; height: 72px; margin-top: 6px; background: var(--n); image-rendering: pixelated; }
.rank { display: flex; align-items: center; gap: 10px; padding: 8px; background: rgba(184, 154, 104, .25); margin-bottom: 8px; }
.rank b { font-family: var(--px); font-weight: normal; font-size: 20px; }
.bar { height: 8px; background: var(--P); border: 2px solid var(--k); }
.bar i { display: block; height: 100%; background: var(--t); }
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.plate-cell { position: relative; aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 2px solid var(--k); background: var(--P); }
.plate-cell canvas { width: 80%; height: 80%; image-rendering: pixelated; }
.plate-cell span { position: absolute; left: 2px; top: 1px; font-family: var(--px); font-size: 10px; line-height: 12px; color: var(--s); }
.plate-cell.is-empty { background: repeating-linear-gradient(45deg, var(--P) 0 4px, var(--d) 4px 6px); opacity: .55; }
.fam-row { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; font-family: var(--px); font-size: 10px; line-height: 12px; text-transform: uppercase; color: var(--A); }
.party-list { list-style: none; padding: 0; margin: 0; }
.party-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--d); }
.party-item canvas { width: 56px; height: 56px; background: var(--n); image-rendering: pixelated; }
.party-item .px { font-size: 20px; }
.party-meta { font-family: var(--px); font-size: 10px; line-height: 12px; color: var(--s); }
.hpbar { height: 6px; margin-top: 3px; background: var(--k); }
.hpbar i { display: block; height: 100%; background: var(--m); }
.hpbar i.low { background: var(--r); }
.el { display: inline-block; padding: 0 4px; color: var(--w); font-family: var(--px); font-size: 10px; line-height: 12px; }
.inv { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.inv span { display: inline-flex; align-items: center; gap: 4px; font-family: var(--px); font-size: 10px; }
.inv img { width: 32px; height: 32px; image-rendering: pixelated; }
.list { list-style: none; padding: 0; margin: 0; }
.list-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; width: 100%; padding: 8px 0; border: 0; border-bottom: 2px dashed var(--d); background: none; text-align: left; color: var(--k); }
.list-item img { width: 32px; height: 32px; image-rendering: pixelated; }
.list-item b { display: block; font-weight: 600; }
.list-item small { display: block; color: var(--s); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 58vw; }
.list-dist { font-family: var(--px); font-size: 10px; line-height: 12px; color: var(--s); text-align: right; white-space: pre; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ach div { display: flex; gap: 6px; align-items: center; padding: 4px; border: 2px solid var(--k); background: var(--p); font-size: .82rem; line-height: 1.25; }
.ach div.locked { opacity: .4; filter: grayscale(1); }
.ach img { width: 32px; height: 32px; image-rendering: pixelated; flex: 0 0 auto; }

input[type="search"], input[type="text"], input[type="date"], select, textarea { width: 100%; min-height: 44px; padding: 8px; border: 2px solid var(--k); border-radius: 0; background: var(--w); color: var(--k); font-family: var(--serif); font-size: 16px; }
textarea { min-height: 100px; resize: vertical; line-height: 1.45; }
select { width: auto; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.chipf { font-family: var(--px); font-size: 10px; line-height: 12px; padding: 4px 6px; border: 2px solid var(--k); background: var(--p); color: var(--k); text-transform: uppercase; }
.chipf.is-on { background: var(--k); color: var(--y); }

.meter { height: 12px; border: 2px solid var(--k); background: var(--P); display: flex; }
.meter i { display: block; height: 100%; }
.meter-legend { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 6px 0 0; padding: 0; list-style: none; font-family: var(--px); font-size: 10px; line-height: 12px; color: var(--s); }
.meter-legend li::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 4px; background: var(--c); border: 1px solid var(--k); }
.export-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--d); }
.export-opt b { font-weight: 600; }
.export-opt small { grid-column: 1; color: var(--s); font-size: .85rem; line-height: 1.35; }
.export-opt .btn { grid-row: 1 / span 2; grid-column: 2; }
.status { padding: 6px 8px; border-left: 4px solid var(--t); background: rgba(63, 158, 143, .14); font-size: .92rem; }
.status.is-stale { border-left-color: var(--r); background: rgba(201, 96, 79, .14); }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--d); }
.setting small { grid-column: 1 / -1; color: var(--s); font-size: .82rem; }
.setting input[type="range"] { width: 140px; accent-color: var(--A); }
.setting output { font-family: var(--px); font-size: 10px; color: var(--A); }
.toggle { appearance: none; -webkit-appearance: none; width: 44px; height: 24px; border: 2px solid var(--k); background: var(--P); position: relative; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--s); }
.toggle:checked { background: var(--t); }
.toggle:checked::after { left: 22px; background: var(--w); }

/* ---------- battle ---------- */
.battle { position: fixed; inset: 0; z-index: 20; background: rgba(16, 21, 26, .25); }
.battle.no-cam { background: #0d1217 var(--scene, none) center / cover no-repeat; image-rendering: pixelated; }
.battle.no-cam::before { content: ""; position: absolute; inset: 0; background: rgba(13, 18, 23, .55); }
.battle > * { z-index: 1; }
.battle.glitching { animation: glitch .12s steps(2) 6; }
@keyframes glitch { 0% { filter: hue-rotate(0) saturate(2); transform: translateX(3px); } 50% { filter: hue-rotate(140deg) contrast(1.6); transform: translateX(-3px); } 100% { filter: none; transform: none; } }
.plate { position: absolute; padding: 2px 8px 4px; min-width: 190px; max-width: 70vw; font-size: 20px; }
.plate small { font-size: 10px; line-height: 12px; color: var(--s); }
.plate:empty { display: none; }
.battle.hurt .plate-me { animation: glitch .12s steps(2) 3; }
.plate-foe { left: 8px; top: calc(var(--safe-t) + 12px); }
.plate-me { right: 8px; bottom: calc(var(--safe-b) + 244px); }
.plate .hpbar { height: 8px; border: 2px solid var(--k); background: var(--P); }
.plate .hpnum { display: block; text-align: right; font-size: 10px; line-height: 12px; }
.battle-box { position: absolute; left: 6px; right: 6px; bottom: calc(var(--safe-b) + 6px); min-height: 164px; padding: 6px 8px; display: grid; grid-template-columns: 1fr; gap: 6px; }
.battle-text { margin: 0; min-height: 48px; white-space: pre-wrap; }
.battle-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.battle-menu button { min-height: 44px; border: 0; background: none; color: var(--k); text-align: left; padding: 0 0 0 20px; position: relative; text-transform: uppercase; }
.battle-menu button::before { content: ""; position: absolute; left: 4px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left-color: transparent; }
.battle-menu button:hover::before, .battle-menu button:focus-visible::before, .battle-menu button.is-sel::before { border-left-color: var(--k); animation: blink .6s steps(2) infinite; }
.battle-menu button[disabled] { color: var(--d); }
.battle-menu .wide { grid-column: 1 / -1; }
.battle-menu small { font-size: 10px; line-height: 12px; color: var(--s); display: block; }
@keyframes blink { 50% { opacity: 0; } }
.more { position: absolute; right: 12px; bottom: 6px; animation: blink .6s steps(2) infinite; }

/* ---------- dialog ---------- */
.dialog { position: fixed; inset: 0; z-index: 25; background: rgba(16, 21, 26, .55); display: flex; align-items: flex-end; }
.dialog-box { width: 100%; max-width: 640px; margin: 0 auto calc(var(--safe-b) + 8px); display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 6px 8px 8px; }
.dialog-portrait { width: 64px; height: 64px; background: var(--P); border: 2px solid var(--k); }
.dialog-name { margin: 0; color: var(--A); font-size: 10px; line-height: 12px; text-transform: uppercase; }
.dialog-text { margin: 4px 0 6px; min-height: 72px; white-space: pre-wrap; }
.dialog-opts { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(16, 21, 26, .6); }
.sheet-card { position: absolute; left: 4px; right: 4px; bottom: 4px; max-height: 88vh; overflow-y: auto; padding: 8px 12px calc(var(--safe-b) + 12px); animation: rise .15s steps(3); }
@media (min-width: 700px) { .sheet-card { left: 50%; right: auto; width: 620px; transform: translateX(-50%); } }
@keyframes rise { from { translate: 0 24px; } }
.sheet-card h2 { margin: 2px 0 4px; font-family: var(--px); font-weight: normal; font-size: 20px; line-height: 24px; color: var(--k); word-break: break-word; }
.sheet-meta { margin: 0 0 10px; font-family: var(--px); font-size: 10px; line-height: 14px; color: var(--s); }
.sheet-text { white-space: pre-wrap; line-height: 1.5; word-break: break-word; }
.sheet-text a { color: var(--A); }
.sheet-media img { display: block; width: 100%; margin: 6px 0 10px; border: 2px solid var(--k); }
.sheet-media audio { width: 100%; margin: 6px 0 10px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field > span { font-family: var(--px); font-size: 10px; line-height: 12px; text-transform: uppercase; color: var(--A); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.seg.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg button { min-height: 40px; border: 2px solid var(--k); background: var(--p); color: var(--k); font-family: var(--px); font-size: 10px; line-height: 12px; text-transform: uppercase; }
.seg button.is-on { background: var(--k); color: var(--y); }
.swatches { display: flex; gap: 6px; }
.swatch { width: 32px; height: 32px; border: 2px solid var(--k); background: var(--c); }
.swatch.is-on { box-shadow: 0 0 0 3px var(--p), 0 0 0 5px var(--k); }
.media-box { display: grid; gap: 6px; padding: 8px; border: 2px dashed var(--d); }
.media-box img { width: 100%; border: 2px solid var(--k); }
.rec { display: flex; align-items: center; gap: 8px; }
.rec-dot { width: 12px; height: 12px; background: var(--s); }
.rec.is-live .rec-dot { background: var(--r); animation: blink .8s steps(2) infinite; }
.aim-readout { font-family: var(--px); font-size: 10px; line-height: 14px; color: var(--s); }
.form-error { color: var(--r); font-size: .9rem; }
.shop { display: grid; gap: 6px; }
.shop-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; }
.shop-row img { width: 32px; height: 32px; image-rendering: pixelated; }
.specimen-card { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: start; }
.specimen-card canvas { width: 112px; height: 112px; background: var(--n); border: 2px solid var(--k); image-rendering: pixelated; }
.stat-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-family: var(--px); font-size: 10px; line-height: 14px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 50px); z-index: 40; transform: translate(-50%, -8px); width: max-content; max-width: min(94vw, 480px); padding: 4px 10px; font-size: 10px; line-height: 14px; opacity: 0; pointer-events: none; transition: opacity .15s steps(3); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-warn { border-image-source: var(--frame-static); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:root.rm * { animation: none !important; transition: none !important; }
