/* MANDA Build Guide: a handheld-game look. Original art only (no one else's characters). A dark console, a red trainer
   card, cream dialog boxes with notched pixel corners, chunky buttons, a pixel font for the headings.
   Phone first. No inline styles anywhere: the page's security rule forbids them.
   Pixel corners are made with box-shadow (four straight edges and no corner pixel), never with border-radius. */
@font-face { font-family: "PS2P"; src: url("fonts/press-start-2p.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
:root {
  --bg: #101b33; --bg2: #16254a; --panel: #fffaf0; --ink: #1b2a49; --soft: #5b6b8c; --line: #1b2a49; --edge: #0a1124;
  --red: #ef4444; --red-d: #b91c1c; --yellow: #ffd23f; --yellow-d: #d9a800; --blue: #3b82f6; --green: #5fd068; --white: #ffffff;
  --px: "PS2P", ui-monospace, "SF Mono", Menlo, monospace;
  --tab-h: 68px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--white); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .55;
  background-image: linear-gradient(rgba(255,255,255,.04) 2px, transparent 2px), linear-gradient(90deg, rgba(255,255,255,.04) 2px, transparent 2px);
  background-size: 16px 16px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
svg { display: block; }

#app { position: relative; max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* ── the trainer card (top bar) ── */
.top { position: sticky; top: 0; z-index: 20; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(var(--red) 0 74%, var(--red-d) 74%); box-shadow: 0 4px 0 0 var(--edge), 0 8px 0 0 rgba(0,0,0,.35); }
.top .head { display: flex; align-items: center; gap: 12px; }
.top .logo { width: 60px; height: 60px; flex: none; background: var(--panel); display: grid; place-items: center; margin: 4px;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 rgba(27,42,73,.14); }
.top .names { flex: 1; min-width: 0; }
.top h1 { margin: 0; font: 400 12px/1.5 var(--px); color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top p { margin: 3px 0 0; font-size: 12.5px; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; margin: 4px; background: var(--yellow); color: var(--ink); display: grid; place-items: center;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 var(--yellow-d), inset 0 4px 0 0 rgba(255,255,255,.5); }
.icon-btn { font: 900 30px/1 system-ui, sans-serif; }
.icon-btn:active { transform: translateY(3px); }
.trainer { display: flex; align-items: center; gap: 10px; margin: 10px 4px 0; }
.lv { flex: none; font: 400 10px/1 var(--px); background: var(--edge); color: var(--yellow); padding: 6px 7px 5px; }
.lv.up { animation: pop .6s steps(4, end) 2; }
.xp { flex: 1; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; background: var(--edge); padding: 3px; }
.xp i { height: 10px; background: #2a3a66; display: block; }
.xp i.on { background: var(--yellow); box-shadow: inset 0 -3px 0 0 var(--yellow-d); }
@keyframes pop { 50% { transform: translateY(-4px) scale(1.15); } }

.offline { display: flex; align-items: center; gap: 10px; margin: 12px 4px 4px; padding: 6px 10px; background: #fff3c4; color: var(--ink); font-weight: 800; font-size: 13px; line-height: 1.3;
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge); }
.offline svg { flex: none; }

/* ── page ── */
main { flex: 1; padding: 16px 14px calc(var(--tab-h) + 104px + env(safe-area-inset-bottom)); }
.view-title { margin: 4px 2px 12px; font: 400 11px/1.5 var(--px); color: var(--yellow); }
.card { position: relative; background: var(--panel); color: var(--ink); padding: 14px; margin: 4px 4px 22px;
  box-shadow: 0 -4px 0 0 var(--line), 0 4px 0 0 var(--line), -4px 0 0 0 var(--line), 4px 0 0 0 var(--line),
    inset 0 4px 0 0 rgba(255,255,255,.85), inset 0 -4px 0 0 rgba(27,42,73,.1), 0 8px 0 0 rgba(0,0,0,.35); }
.card h2 { margin: 0 0 8px; font: 400 13px/1.6 var(--px); color: var(--ink); }
.card p { margin: 0 0 8px; }
.card p:last-child { margin-bottom: 0; }
.muted { color: var(--soft); }
.center { text-align: center; }

/* ── the creatures ── */
.mascot-row { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 0 0 6px; }
.mascot-row svg, .bob { animation: bob 1.2s steps(2, end) infinite; }
.mascot-row svg:nth-child(2) { animation-delay: .3s; }
.mascot-row svg:nth-child(3) { animation-delay: .6s; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.grass { height: 16px; margin: 0 -14px 14px; background: linear-gradient(#5fd068 0 4px, #3fae52 4px 8px, #2f8a42 8px 100%); }
.card h2.title-screen { margin: 0 0 8px; font: 400 20px/1.3 var(--px); color: var(--red-d); text-shadow: 3px 3px 0 #ffd23f; letter-spacing: 1px; }
@media (prefers-reduced-motion: reduce) { .mascot-row svg, .bob, .lv.up { animation: none; } }

/* a creature talking: its picture and a dialog box */
.say { display: flex; align-items: flex-start; gap: 12px; }
.say > svg { flex: none; margin-top: 6px; }
.say-box { flex: 1; min-width: 0; }

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 18px; margin: 4px; border: 0;
  background: var(--yellow); color: var(--ink); font: 400 11px/1.4 var(--px); text-decoration: none; text-align: center;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 var(--yellow-d), inset 0 4px 0 0 rgba(255,255,255,.55), 0 8px 0 0 rgba(0,0,0,.35); }
.btn:active { transform: translateY(4px); box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 var(--yellow-d); }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 var(--red-d), inset 0 4px 0 0 rgba(255,255,255,.3), 0 8px 0 0 rgba(0,0,0,.35); }
.btn.plain { background: #fff; box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -4px 0 0 #cfd8ee, 0 8px 0 0 rgba(0,0,0,.35); }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 10px; }
.btn.block { display: flex; width: calc(100% - 8px); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { flex: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* ── chips (the parts of the game) ── */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 12px; margin: 0 -14px; padding-left: 18px; padding-right: 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border: 0; background: #22345f; color: #fff; font: 400 10px/1.3 var(--px);
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 -3px 0 0 rgba(0,0,0,.25); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--yellow); color: var(--ink); box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 -3px 0 0 var(--yellow-d); }

/* ── idea cards ── */
.idea { display: flex; gap: 12px; width: 100%; text-align: left; align-items: flex-start; }
.badge { flex: none; width: 54px; height: 54px; background: var(--ink); display: grid; place-items: center; margin: 3px;
  box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 3px 0 0 rgba(255,255,255,.12); }
.idea .body { flex: 1; min-width: 0; }
.btn-reset { border: 0; background: none; padding: 0; margin: 0; color: inherit; text-align: left; width: 100%; box-shadow: none; }
.idea .no { display: block; font: 400 9px/1.4 var(--px); color: var(--soft); margin: 0 0 4px; }
.idea .t { display: block; font-size: 17px; line-height: 1.25; font-weight: 900; overflow-wrap: anywhere; }
.idea .snip { margin: 4px 0 8px; font-size: 14.5px; color: var(--soft); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--soft); }
.pill { display: inline-block; padding: 4px 7px 3px; margin: 2px; font: 400 9px/1.3 var(--px); background: #e8eefc; color: var(--ink);
  box-shadow: 0 -2px 0 0 var(--line), 0 2px 0 0 var(--line), -2px 0 0 0 var(--line), 2px 0 0 0 var(--line); }
.pill.new { background: #cfe2ff; } .pill.queued { background: #fde68a; } .pill.built { background: #a7f3b0; } .pill.parked { background: #e5e7eb; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 10px; height: 10px; background: #fff; display: block; box-shadow: 0 0 0 2px var(--line); margin: 2px; }
.pips i.on { background: var(--red); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 4px 20px; }
.stat { background: #22345f; padding: 10px 6px 8px; text-align: center; box-shadow: 0 -3px 0 0 var(--edge), 0 3px 0 0 var(--edge), -3px 0 0 0 var(--edge), 3px 0 0 0 var(--edge), inset 0 3px 0 0 rgba(255,255,255,.1); }
.stat b { display: block; font: 400 20px/1.3 var(--px); color: var(--yellow); }
.stat span { font-size: 12px; color: #cdd7f0; }
.card .stat { background: #e8eefc; box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.card .stat span { color: var(--soft); }
.card .stat b { color: var(--red-d); }

/* ── reports ── */
.rep h2 { font-size: 12px; }
.rep .when { font: 400 9px/1.5 var(--px); color: var(--soft); margin-bottom: 6px; }
.rep details { margin-top: 8px; }
.rep summary { cursor: pointer; font-weight: 900; min-height: 40px; display: flex; align-items: center; }
.sec { margin: 14px 0 0; }
.sec h4 { margin: 0 0 6px; font: 400 9px/1.6 var(--px); color: var(--red-d); }
.sec ul { margin: 0; padding-left: 20px; }
.sec li { margin: 6px 0; overflow-wrap: anywhere; }
.sec .why { display: block; color: var(--soft); font-size: 14.5px; }
.q { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 8px 0; }
.q span { flex: 1; overflow-wrap: anywhere; }

/* ── play ── */
.play-card { text-align: center; }
.play-card .btn { margin-top: 12px; min-height: 60px; font-size: 14px; }
.check { list-style: none; margin: 12px 0 0; padding: 0; text-align: left; }
.check li { display: flex; gap: 12px; align-items: center; margin: 10px 0; font-weight: 800; }
.check .tick { flex: none; width: 26px; height: 26px; margin: 3px; background: #fff; display: grid; place-items: center; font-size: 15px; line-height: 1;
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.check .tick.on { background: var(--green); }

/* ── tabs + add button ── */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--edge); border-top: 4px solid var(--edge); padding-bottom: env(safe-area-inset-bottom); }
.tab { position: relative; height: var(--tab-h); border: 0; background: var(--bg2); color: #cdd7f0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font: 400 9px/1 var(--px); box-shadow: inset 0 4px 0 0 rgba(255,255,255,.08); }
.tab + .tab { border-left: 4px solid var(--edge); }
.tab[aria-selected="true"] { background: var(--yellow); color: var(--ink); box-shadow: inset 0 -4px 0 0 var(--yellow-d), inset 0 4px 0 0 rgba(255,255,255,.5); }
.dot { position: absolute; top: 6px; right: calc(50% - 38px); min-width: 20px; height: 20px; padding: 3px 4px 0; background: var(--red); color: #fff; font: 400 9px/17px var(--px); text-align: center;
  box-shadow: 0 -2px 0 0 var(--edge), 0 2px 0 0 var(--edge), -2px 0 0 0 var(--edge), 2px 0 0 0 var(--edge); }
.fab { position: fixed; z-index: 21; right: max(22px, calc(50% - 280px + 22px)); bottom: calc(var(--tab-h) + 26px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border: 0; background: var(--red); color: #fff; display: grid; place-items: center; padding: 0;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 -5px 0 0 var(--red-d), inset 0 4px 0 0 rgba(255,255,255,.3), 0 9px 0 0 rgba(0,0,0,.4); }
.fab:active { transform: translateY(4px); }

/* ── sheets ── */
.veil { position: fixed; inset: 0; z-index: 40; background: rgba(6,10,22,.74); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: calc(100% - 8px); max-width: 552px; max-height: 92vh; overflow-y: auto; background: var(--panel); color: var(--ink); padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), inset 0 4px 0 0 rgba(255,255,255,.85); }
.sheet h2 { margin: 0 0 12px; font: 400 13px/1.6 var(--px); }
.sheet .x { float: right; margin: -2px -2px 0 8px; }
.sheet h2.sub { margin-top: 18px; }
.field { margin: 0 0 16px; }
.field label, .field .lab { display: block; margin: 0 0 8px; font: 400 9px/1.6 var(--px); color: var(--red-d); }
.field input, .field textarea { width: calc(100% - 8px); margin: 4px; font: inherit; color: var(--ink); background: #fff; border: 0; padding: 12px;
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 3px 0 0 rgba(27,42,73,.08); }
.field textarea { min-height: 130px; resize: vertical; }
.field .count { text-align: right; font-size: 12px; color: var(--soft); margin-top: 2px; }
.opts { display: flex; flex-wrap: wrap; gap: 10px; }
.opt { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; margin: 3px; border: 0; background: #fff; color: var(--ink); font: 400 10px/1.3 var(--px);
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -3px 0 0 #dbe3f5; }
.opt[aria-checked="true"] { background: var(--yellow); box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -3px 0 0 var(--yellow-d); }
.err { margin: 4px 4px 14px; padding: 10px 12px; background: #fee2e2; color: #7f1d1d; font-weight: 700; box-shadow: 0 -3px 0 0 var(--red-d), 0 3px 0 0 var(--red-d), -3px 0 0 0 var(--red-d), 3px 0 0 0 var(--red-d); }
.note { margin: 14px 4px; padding: 10px 12px; background: #fff3c4; box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.note b { display: block; margin: 0 0 4px; font: 400 9px/1.6 var(--px); color: var(--red-d); }
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 14px; }
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; margin: 12px 0; }
.steps li::before { content: counter(step); flex: none; width: 28px; height: 28px; margin: 3px; background: var(--yellow); color: var(--ink); font: 400 11px/28px var(--px); text-align: center;
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line); }
.steps li > span { flex: 1; min-width: 0; }
.steps .ico { display: inline-block; vertical-align: -6px; margin: 0 2px; }

/* ── states ── */
.full { min-height: 100vh; display: grid; place-items: center; padding: calc(20px + env(safe-area-inset-top)) 20px 20px; }
.full .card { width: 100%; max-width: 440px; }
.full input { width: calc(100% - 8px); margin: 10px 4px; font: inherit; border: 0; padding: 12px; color: var(--ink); background: #fff;
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 3px 0 0 rgba(27,42,73,.08); }
.spinner { display: inline-block; width: 24px; height: 24px; background: conic-gradient(var(--yellow) 0 25%, transparent 0); animation: spin .8s steps(4, end) infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; top: calc(136px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 60; max-width: 88%; background: var(--yellow); color: var(--ink); padding: 10px 14px; font: 400 10px/1.5 var(--px); text-align: center;
  box-shadow: 0 -4px 0 0 var(--edge), 0 4px 0 0 var(--edge), -4px 0 0 0 var(--edge), 4px 0 0 0 var(--edge), 0 8px 0 0 rgba(0,0,0,.35); }
