/* MARGINALIA — paper menus that match the site's sketchbook. */

:root {
  --font-brush: 'Caveat Brush', 'Segoe Print', 'Comic Sans MS', cursive;
  --font-hand: 'Patrick Hand', 'Segoe Print', 'Comic Sans MS', cursive;
  --wob-a: 255px 14px 225px 14px / 14px 225px 14px 255px;
  --wob-b: 14px 225px 14px 255px / 255px 14px 225px 14px;
  --wob-c: 16px 7px 18px 7px / 7px 16px 7px 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
:root, [data-theme="dark"] {
  --paper: #1a1f2e;
  --paper-2: #252c41;
  --paper-3: #2e3650;
  --ink: #f1ecdf;
  --ink-soft: #cfcabd;
  --ink-dim: #9a9588;
  --shadow: rgb(0 0 0 / 0.5);
  --tape: rgb(255 214 120 / 0.32);
  --grid: rgb(150 180 255 / 0.075);
  --scrim: rgb(10 12 20 / 0.62);
  --c-yel: #ffd54a;
  --on-yel: #241e18;
  --c-play: #7ba3ff;
  --c-red: #ff7a6b;
  --c-green: #6edba8;
  --c-pink: #ff7fa6;
  --chip: #fbf6e9;
}
[data-theme="light"] {
  --paper: #f1e8d2;
  --paper-2: #fbf6e9;
  --paper-3: #f4ecd9;
  --ink: #2a2420;
  --ink-soft: #55493f;
  --ink-dim: #7d7266;
  --shadow: rgb(42 36 32 / 0.24);
  --tape: rgb(232 186 80 / 0.6);
  --grid: rgb(70 110 170 / 0.16);
  --scrim: rgb(60 45 30 / 0.45);
  --c-yel: #ffd54a;
  --on-yel: #241e18;
  --c-play: #3a68d8;
  --c-red: #d8332b;
  --c-green: #2c8f63;
  --c-pink: #d6457a;
  --chip: #fffdf6;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: clamp(16px, min(1.25vw, 2.1vh), 21px); }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-hand); font-size: 1rem; line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ── Building blocks ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  font-family: var(--font-brush); font-size: 1.35rem; letter-spacing: 0.02em;
  padding: 0.45em 1.1em; min-height: 48px;
  background: var(--paper-2); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: var(--wob-a);
  box-shadow: 3px 4px 0 var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:hover, .btn:focus-visible { transform: translate(-1px, -2px) rotate(-0.6deg); box-shadow: 4px 6px 0 var(--shadow); outline: none; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.primary { background: var(--c-yel); color: var(--on-yel); border-color: var(--on-yel); }
[data-theme="dark"] .btn.primary { border-color: var(--ink); }
.btn.small { font-size: 1.05rem; min-height: 40px; padding: 0.3em 0.8em; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn .sub { font-family: var(--font-hand); font-size: 0.8em; opacity: 0.8; }

.sheet {
  background: var(--paper-2); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: var(--wob-c);
  box-shadow: 5px 7px 0 var(--shadow);
  padding: 1.1rem 1.2rem;
  position: relative;
}
.tape::before {
  content: ''; position: absolute; top: -12px; left: 50%; width: 96px; height: 24px; transform: translateX(-50%) rotate(-3deg);
  background: var(--tape); border-radius: 2px;
}
h1, h2, h3 { font-family: var(--font-brush); font-weight: normal; margin: 0; letter-spacing: 0.02em; }
h2 { font-size: 2rem; }
h3 { font-size: 1.35rem; }
.dim { color: var(--ink-dim); }
.soft { color: var(--ink-soft); }
.star-ic { color: #e8b020; }

.chip-icon {
  width: 44px; height: 44px; flex: none;
  background: var(--chip); border: 2px solid var(--ink); border-radius: var(--wob-c);
  display: grid; place-items: center; overflow: hidden;
}
.chip-icon img { width: 100%; height: 100%; image-rendering: auto; }
.chip-icon.lg { width: 58px; height: 58px; }
.chip-icon.evo { background: #fff3c4; box-shadow: 0 0 0 3px #f6c33a; }

/* ── Screens ─────────────────────────────────────────────────────────── */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen {
  position: absolute; inset: 0; pointer-events: auto; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: calc(1rem + var(--sat)) calc(1rem + var(--sar)) calc(1.5rem + var(--sab)) calc(1rem + var(--sal));
  background: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  animation: fade-in 0.22s ease-out;
}
.screen.clear { background: transparent; }
.screen.modal { background: var(--scrim); display: flex; align-items: center; justify-content: center; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(0.97) rotate(-1deg); } to { opacity: 1; transform: none; } }
.wrap { max-width: 980px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.topbar h2 { flex: 1; }
.purse {
  font-family: var(--font-brush); font-size: 1.4rem; padding: 0.15em 0.7em;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: var(--wob-b);
}

/* title */
.title-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; text-align: center; }
.logo { font-family: var(--font-brush); font-size: clamp(3rem, 13vw, 6.5rem); line-height: 0.9; margin: 0; color: var(--ink); text-shadow: 3px 4px 0 var(--shadow); transform: rotate(-2deg); }
.logo .m { color: #e0533d; }
.tag { font-size: 1.25rem; color: var(--ink-soft); margin-top: -0.4rem; max-width: 30rem; text-shadow: 0 0 6px var(--paper), 0 0 3px var(--paper), 0 0 2px var(--paper); }
.title-menu { display: flex; flex-direction: column; gap: 0.7rem; width: min(22rem, 100%); }
.title-menu .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.title-menu .btn { width: 100%; }
.title-panel { padding: 1.4rem 1.2rem 1.2rem; width: min(26rem, 100%); display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.backlink { position: absolute; top: calc(0.8rem + var(--sat)); left: calc(1rem + var(--sal)); font-family: var(--font-brush); font-size: 1.15rem; text-decoration: none; color: var(--ink-soft); }
.backlink:hover { color: var(--ink); }
.title-purse { position: absolute; top: calc(0.7rem + var(--sat)); right: calc(1rem + var(--sar)); }
.pip { display: inline-block; min-width: 1.3em; padding: 0 0.35em; border-radius: 1em; background: #e0533d; color: #fff; font-size: 0.75em; line-height: 1.3; margin-left: 0.3em; }

/* grids of cards */
.grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
.card {
  text-align: left; background: var(--paper-2); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: var(--wob-c);
  box-shadow: 3px 4px 0 var(--shadow); padding: 0.75rem 0.85rem;
  display: flex; gap: 0.8rem; align-items: flex-start; position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
}
button.card:hover, button.card:focus-visible { transform: translate(-1px, -2px) rotate(-0.4deg); box-shadow: 4px 6px 0 var(--shadow); outline: none; }
.card.sel { box-shadow: 0 0 0 4px var(--c-yel), 4px 6px 0 var(--shadow); }
.card.locked { opacity: 0.8; }
.card.locked .portrait, .card.locked .chip-icon img { filter: grayscale(1) brightness(0.8); }
.card .body { flex: 1; min-width: 0; }
.card .name { font-family: var(--font-brush); font-size: 1.4rem; line-height: 1; }
.card .what { color: var(--ink-dim); font-size: 0.95rem; }
.card .line { font-size: 0.98rem; margin-top: 0.25rem; display: flex; gap: 0.35rem; align-items: center; }
.card .ultline { font-size: 0.98rem; margin-top: 0.25rem; color: var(--ink-soft); }
.card .line img { width: 22px; height: 22px; background: var(--chip); border-radius: 5px; border: 1.5px solid var(--ink); }
.portrait { width: 76px; height: 76px; flex: none; background: var(--chip); border: 2px solid var(--ink); border-radius: var(--wob-b); }
.lock-tag { font-size: 0.95rem; color: var(--c-red); margin-top: 0.3rem; }
.price { font-family: var(--font-brush); font-size: 1.15rem; }
.badge { position: absolute; top: -10px; right: 10px; background: var(--c-yel); color: var(--on-yel); font-family: var(--font-brush); font-size: 1rem; padding: 0 0.5em; border: 2px solid var(--on-yel); border-radius: var(--wob-a); transform: rotate(4deg); }
.footer-bar { position: sticky; bottom: calc(-1.5rem - var(--sab)); margin: 1.2rem -1rem calc(-1.5rem - var(--sab)); padding: 0.8rem 1rem calc(0.9rem + var(--sab)); background: linear-gradient(transparent, var(--paper) 30%); display: flex; gap: 0.7rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* map cards */
.mapcard { flex-direction: column; padding: 0; overflow: hidden; }
.mapcard .swatch { height: 92px; width: 100%; border-bottom: 2.5px solid var(--ink); position: relative; display: flex; align-items: center; justify-content: center; gap: 0.3rem; }
.mapcard .swatch img { width: 52px; height: 52px; }
.mapcard .body { padding: 0.6rem 0.85rem 0.8rem; }
.sw-lined { background: #f7f2e3 repeating-linear-gradient(transparent 0 16px, #a7bfdf 16px 17px); }
.sw-lined::before { content: ''; position: absolute; left: 22px; top: 0; bottom: 0; width: 3px; border-left: 1.5px solid #e58a84; border-right: 1.5px solid #e58a84; }
.sw-graph { background-color: #f2f5ee; background-image: linear-gradient(#b5d1c0 1px, transparent 1px), linear-gradient(90deg, #b5d1c0 1px, transparent 1px); background-size: 12px 12px; }
.sw-napkin { background-color: #fbfaf6; background-image: repeating-linear-gradient(45deg, #e6e0d3 0 1.5px, transparent 1.5px 20px), repeating-linear-gradient(-45deg, #e6e0d3 0 1.5px, transparent 1.5px 20px); }
.sw-blueprint { background-color: #1d4b86; background-image: linear-gradient(#3c6cab 1px, transparent 1px), linear-gradient(90deg, #3c6cab 1px, transparent 1px); background-size: 14px 14px; }
.sw-chalk { background: radial-gradient(ellipse at 30% 40%, #3a4b40, transparent 60%), #2b3a31; }
.stats-row { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.95rem; color: var(--ink-soft); margin-top: 0.3rem; }
.check { color: var(--c-green); font-family: var(--font-brush); }

/* red ink chips */
.redink { margin-top: 1.2rem; }
.redink h3 { color: var(--c-red); }
.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.6rem; }
.chip {
  border: 2px solid var(--ink); background: var(--paper-2); border-radius: var(--wob-b);
  padding: 0.35rem 0.7rem; font-size: 1rem; text-align: left; line-height: 1.15; max-width: 16rem;
}
.chip b { font-family: var(--font-brush); font-weight: normal; font-size: 1.12rem; }
.chip small { display: block; color: var(--ink-dim); font-size: 0.88rem; }
.chip.on { background: #ffdcd6; color: #2a2420; border-color: #d8332b; box-shadow: 2px 3px 0 #d8332b55; }
.chip.on small { color: #6a4a40; }
.bonus { font-family: var(--font-brush); color: var(--c-red); font-size: 1.3rem; }

/* list rows (shop, report card) */
.list { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.rowcard { display: flex; gap: 0.7rem; align-items: center; padding: 0.6rem 0.7rem; }
.rowcard .body { flex: 1; min-width: 0; }
.rowcard .name { font-size: 1.25rem; }
.pips { display: flex; gap: 3px; margin-top: 0.25rem; }
.pips i { width: 14px; height: 9px; border: 1.5px solid var(--ink); border-radius: 3px; display: block; }
.pips i.on { background: var(--c-yel); }
.done { background: color-mix(in srgb, var(--c-green) 18%, var(--paper-2)); }
.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs .btn { font-size: 1.1rem; min-height: 40px; padding: 0.2em 0.9em; }
.tabs .btn.on { background: var(--c-yel); color: var(--on-yel); }
.recipe { font-size: 0.92rem; color: var(--ink-soft); margin-top: 0.2rem; }
.unknown .name { color: var(--ink-dim); }

/* settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.55rem 0; border-bottom: 1.5px dashed color-mix(in srgb, var(--ink) 30%, transparent); font-size: 1.15rem; }
.setting input[type=range] { width: min(12rem, 45vw); accent-color: #e0533d; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--wob-c); overflow: hidden; }
.seg button { background: var(--paper-2); border: none; padding: 0.3rem 0.7rem; font-size: 1rem; }
.seg button.on { background: var(--c-yel); color: var(--on-yel); }
.seg button + button { border-left: 2px solid var(--ink); }

/* ── Modals in a run ─────────────────────────────────────────────────── */
.modal .sheet { width: min(34rem, 100%); max-height: 100%; overflow-y: auto; animation: pop-in 0.22s ease-out; }
.modal .sheet h2 { text-align: center; }
.choices { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.9rem 0 0.4rem; }
.choice { width: 100%; animation: pop-in 0.25s ease-out backwards; }
.choice:nth-child(2) { animation-delay: 0.05s; } .choice:nth-child(3) { animation-delay: 0.1s; } .choice:nth-child(4) { animation-delay: 0.15s; }
.choice .name { font-size: 1.3rem; }
.choice .tagline { font-size: 0.85rem; font-family: var(--font-hand); color: var(--ink-dim); margin-left: 0.4rem; }
.choice .new { color: #e0533d; font-family: var(--font-brush); font-size: 1rem; margin-left: 0.3rem; }
.choice .desc { font-size: 1rem; color: var(--ink-soft); }
.choice .evohint { font-size: 0.88rem; color: #c48a12; margin-top: 0.15rem; }
.choice .key { position: absolute; right: 10px; bottom: 6px; font-size: 0.8rem; color: var(--ink-dim); }
.banish-mode .choice { box-shadow: 0 0 0 3px #d8332b; }
.lv-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-top: 0.6rem; }
.lv-actions .btn { font-size: 1.05rem; min-height: 40px; padding: 0.2em 0.9em; }
.chest-items { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.9rem 0; }
.chest-item { display: flex; gap: 0.7rem; align-items: center; animation: pop-in 0.3s ease-out backwards; }
.chest-item .name { font-family: var(--font-brush); font-size: 1.3rem; }
.chest-item.evo .name { color: #c48a12; }
.build { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.4rem 0 0.8rem; }
.build .chip-icon { position: relative; }
.build .lv { position: absolute; bottom: -1px; right: 1px; font-family: var(--font-brush); font-size: 0.85rem; color: #2a2420; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.15rem 1rem; font-size: 1rem; }
.statgrid div { display: flex; justify-content: space-between; border-bottom: 1px dashed color-mix(in srgb, var(--ink) 25%, transparent); }
.btnrow { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.results .big { font-family: var(--font-brush); font-size: clamp(2.4rem, 9vw, 3.4rem); text-align: center; line-height: 1; }
.results .sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; text-align: center; margin: 0.8rem 0; }
.results .sum b { display: block; font-family: var(--font-brush); font-size: 1.6rem; font-weight: normal; }
.dmgrow { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; font-size: 0.98rem; }
.dmgrow .chip-icon { width: 32px; height: 32px; }
.dmgrow .bar { flex: 1; height: 10px; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden; }
.dmgrow .bar i { display: block; height: 100%; background: #e0533d; }
.dmgrow .num { min-width: 4.5rem; text-align: right; font-family: var(--font-brush); }
.unlock-note { margin-top: 0.6rem; padding: 0.5rem 0.7rem; border: 2px dashed #c48a12; border-radius: var(--wob-c); color: var(--ink); background: color-mix(in srgb, var(--c-yel) 16%, transparent); }

/* ── HUD ─────────────────────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--font-brush); color: #2a2420; }
#hud.dark-map { color: #f1ecdf; }
.xp { position: absolute; top: var(--sat); left: 0; right: 0; height: 14px; background: rgb(0 0 0 / 0.25); border-bottom: 2px solid #2a2420; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4c7fd9, #7ba3ff); transition: width 0.15s; }
.xp-lv { position: absolute; right: calc(8px + var(--sar)); top: -1px; font-size: 0.95rem; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.hud-row { position: absolute; top: calc(18px + var(--sat)); left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.hud-left { display: flex; flex-direction: column; gap: 2px; width: calc(50% - 50px); }
.slots { display: flex; gap: 2px; flex-wrap: wrap; }
.slot { --s: clamp(21px, 2.3vw, 34px); width: var(--s); height: var(--s); background: #fbf6e9; border: 1.5px solid #2a2420; border-radius: 6px; position: relative; overflow: hidden; }
.slot img { width: 100%; height: 100%; }
.slot.evo { background: #fff3c4; border-color: #c48a12; }
.slot b { position: absolute; right: 1px; bottom: -3px; font-weight: normal; font-size: 0.72rem; color: #2a2420; text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 2px #fff; }
.hud-mid { position: absolute; left: 50%; top: 0; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.timer { font-size: 1.9rem; line-height: 1; text-shadow: 0 0 4px var(--hud-glow, #fff8), 2px 2px 0 var(--hud-glow, #fff8); }
.kills { font-family: var(--font-hand); font-size: 0.95rem; opacity: 0.9; }
.hud-right { display: flex; align-items: center; gap: 6px; }
.stars { font-family: var(--font-brush); font-size: 1.05rem; background: #fbf6e9; color: #2a2420; border: 1.5px solid #2a2420; border-radius: 9px; padding: 0 0.4em; line-height: 1.3; }
.icon-btn { pointer-events: auto; width: 44px; height: 44px; border-radius: var(--wob-c); border: 2px solid #2a2420; background: #fbf6e9; color: #2a2420; font-size: 1rem; box-shadow: 2px 3px 0 rgb(0 0 0 / 0.25); }
.boss { position: absolute; top: calc(86px + var(--sat)); left: 50%; transform: translateX(-50%); width: min(26rem, 82vw); text-align: center; }
.boss-name { font-size: 1.3rem; color: #d8332b; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.boss-bar { height: 14px; border: 2px solid #2a2420; background: rgb(0 0 0 / 0.3); border-radius: 5px; overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #d8332b, #ff7a6b); transition: width 0.2s; }
.ult {
  pointer-events: auto; position: absolute; right: calc(16px + var(--sar)); bottom: calc(20px + var(--sab)); width: 84px; height: 84px; border-radius: 50%;
  border: 2.5px solid #2a2420; background: #fbf6e9; color: #2a2420; padding: 0; display: grid; place-items: center;
  box-shadow: 3px 4px 0 rgb(0 0 0 / 0.25); opacity: 0.75; transition: transform 0.15s, opacity 0.2s;
}
.ult svg { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); transform: rotate(-90deg); }
.ult-track { fill: none; stroke: rgb(0 0 0 / 0.1); stroke-width: 6; }
.ult-ring { fill: none; stroke: #e0533d; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 176; stroke-dashoffset: 176; transition: stroke-dashoffset 0.2s; }
.ult-label { position: relative; font-size: 0.95rem; line-height: 1; text-align: center; padding: 0 6px; }
.ult-key { position: absolute; bottom: 10px; font-family: var(--font-hand); font-size: 0.7rem; opacity: 0.7; }
.ult.ready { opacity: 1; background: var(--c-yel); animation: ult-wobble 1s ease-in-out infinite; }
.ult.ready .ult-ring { stroke: #2a2420; }
@keyframes ult-wobble { 0%, 100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.06); } }
.banner {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) rotate(-3deg);
  font-size: clamp(2rem, 8vw, 3.6rem); color: #d8332b; white-space: nowrap; text-align: center;
  text-shadow: 3px 3px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
  animation: banner 2.4s ease-out forwards;
}
.banner small { display: block; font-size: 0.45em; color: #2a2420; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6) rotate(-6deg); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); } 80% { opacity: 1; } 100% { opacity: 0; } }
.toast {
  position: absolute; left: 50%; top: calc(140px + var(--sat)); transform: translateX(-50%);
  font-family: var(--font-hand); font-size: 1.1rem; background: #fbf6e9; color: #2a2420; border: 2px solid #2a2420; border-radius: var(--wob-c);
  padding: 0.25rem 0.8rem; opacity: 0; transition: opacity 0.3s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.on { opacity: 1; }
.hint {
  position: absolute; left: 50%; bottom: calc(26% + var(--sab)); transform: translateX(-50%); text-align: center;
  font-family: var(--font-hand); font-size: 1.2rem; background: #fbf6e9; color: #2a2420; border: 2px solid #2a2420; border-radius: var(--wob-a);
  padding: 0.5rem 1rem; width: max-content; max-width: 88vw; box-shadow: 3px 4px 0 rgb(0 0 0 / 0.2);
  animation: fade-in 0.4s;
}
.hint b { font-family: var(--font-brush); font-weight: normal; font-size: 1.3rem; }

@media (max-width: 520px) {
  html, body { font-size: 16px; }
  .timer { font-size: 1.6rem; }
  .ult { width: 74px; height: 74px; }
  .ult-key { display: none; }
  .results .sum { grid-template-columns: repeat(2, 1fr); }
  .modal { align-items: flex-end !important; }
  .modal .sheet { border-radius: 16px 16px 6px 6px; }
  .portrait { width: 64px; height: 64px; }
}
@media (hover: none) { .ult-key { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ── Jev at the controls ─────────────────────────────────────────────── */
:root { --jev-w: 340px; --jev-h: 40vh; --jev: #7b5cff; --jev-d: #5a3fd6; }
.jev-btn { border-color: var(--jev); }
.jev-btn .sub { color: var(--jev); }
[data-theme="dark"] .jev-btn .sub { color: #b5a3ff; }
.jev-input { font: inherit; font-size: 1rem; padding: 0.3rem 0.5rem; width: min(15rem, 52vw); background: var(--chip); color: #2a2420; border: 2px solid var(--ink); border-radius: var(--wob-c); }

/* the game shares the window with the panel */
body.jev-side #game { width: calc(100% - var(--jev-w)); }
body.jev-side #hud, body.jev-side #ui { right: var(--jev-w); }
body.jev-bottom #game { height: calc(100% - var(--jev-h)); }
body.jev-bottom #hud, body.jev-bottom #ui { bottom: var(--jev-h); }
body.jev-bottom .ult { bottom: 12px; }

#jev-panel {
  position: fixed; z-index: 25; overflow-y: auto; overscroll-behavior: contain;
  background: #fbf6e9; color: #2a2420; font-family: var(--font-hand); font-size: 0.9rem; line-height: 1.2;
  padding: 0.6rem 0.75rem 0.8rem; pointer-events: auto; user-select: none;
  background-image: linear-gradient(rgb(123 92 255 / 0.07) 1px, transparent 1px); background-size: 100% 22px;
}
body.jev-side #jev-panel { top: 0; right: 0; bottom: 0; width: var(--jev-w); border-left: 3px solid var(--jev); padding-top: calc(0.6rem + var(--sat)); }
body.jev-bottom #jev-panel { left: 0; right: 0; bottom: 0; height: var(--jev-h); border-top: 3px solid var(--jev); padding-bottom: calc(0.6rem + var(--sab)); }
.jp-head { display: flex; align-items: center; gap: 0.45rem; }
.jp-head b { font-family: var(--font-brush); font-weight: normal; font-size: 1.5rem; color: var(--jev-d); }
.jp-status { flex: 1; color: #6b6158; }
.jp-cost { font-family: var(--font-brush); font-size: 1.6rem; color: #2a2420; }
.jp-dot { width: 10px; height: 10px; border-radius: 50%; background: #aaa; }
#jev-panel.on .jp-dot { background: #4fb35f; }
#jev-panel.on.thinking .jp-dot { background: var(--jev); animation: jev-pulse 0.5s ease-in-out infinite; }
#jev-panel.err .jp-dot { background: #e0533d; }
@keyframes jev-pulse { 50% { opacity: 0.3; transform: scale(0.7); } }
.jp-stats { color: #6b6158; font-size: 0.78rem; margin: 0.05rem 0 0.4rem; }
.jp-title { font-family: var(--font-brush); color: var(--jev-d); font-size: 0.95rem; margin-top: 0.35rem; }
.jp-move { display: flex; gap: 0.5rem; align-items: flex-start; }
.jp-rose { width: 190px; height: 190px; flex: none; overflow: visible; }
.jp-ring { fill: none; stroke: rgb(123 92 255 / 0.18); stroke-dasharray: 2 4; }
.jp-petal { fill: rgb(123 92 255 / 0.35); stroke: rgb(90 63 214 / 0.5); stroke-width: 1; }
.jp-petal.chosen { fill: var(--jev); stroke: #2a2420; stroke-width: 2; }
.jp-stay { fill: rgb(123 92 255 / 0.3); stroke: rgb(90 63 214 / 0.6); }
.jp-stay.chosen { fill: var(--jev); stroke: #2a2420; stroke-width: 2; }
.jp-staylab { font-size: 9px; text-anchor: middle; fill: #2a2420; }
.jp-lab text { text-anchor: middle; fill: #6b6158; }
.jp-dir { font-size: 10px; font-weight: bold; }
.jp-pct { font-size: 11px; font-family: var(--font-brush); }
.jp-lab.chosen text { fill: var(--jev-d); }
.jp-lab.chosen .jp-pct { font-size: 13px; }
.jp-side { flex: 1; min-width: 0; font-size: 0.82rem; }
.jp-now b { color: var(--jev-d); font-weight: normal; font-family: var(--font-brush); font-size: 1.05rem; }
.jp-special { margin-top: 0.3rem; }
.jp-sp-name { font-size: 0.8rem; }
.jp-bar { height: 9px; border: 1.5px solid #2a2420; border-radius: 4px; overflow: hidden; background: #fff; }
.jp-bar i { display: block; height: 100%; background: #e0533d; transition: width 0.1s; }
.jp-bar.yes i { background: var(--jev); }
.jp-sp-txt { color: #6b6158; font-size: 0.75rem; }
.jp-trail { font-size: 1rem; line-height: 1; letter-spacing: -1px; color: var(--jev-d); word-break: break-all; min-height: 1.1em; }
.jp-lat { width: 100%; height: 28px; display: block; }
.jp-lat polyline { fill: none; stroke: var(--jev); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.jp-latxt { color: #6b6158; font-size: 0.72rem; }
.jp-decision { margin-top: 0.5rem; padding: 0.45rem 0.55rem; background: #fff; border: 2px solid var(--jev); border-radius: var(--wob-c); }
.jp-dtitle { font-family: var(--font-brush); font-size: 1.1rem; }
.jp-ask { color: var(--jev); font-family: var(--font-hand); font-size: 0.85rem; animation: jev-pulse 0.8s ease-in-out infinite; }
.jp-opts { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.jp-opts li { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 2.6rem; gap: 0.35rem; align-items: center; font-size: 0.82rem; padding: 1px 0; }
.jp-ol { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jp-ob { height: 8px; background: rgb(123 92 255 / 0.12); border-radius: 4px; overflow: hidden; }
.jp-ob i { display: block; height: 100%; background: rgb(123 92 255 / 0.55); transition: width 0.35s ease-out; }
.jp-op { text-align: right; font-family: var(--font-brush); }
.jp-opts li.chosen .jp-ol { color: var(--jev-d); font-weight: bold; }
.jp-opts li.chosen .jp-ob i { background: var(--jev); }
.jp-feed { margin: 0.15rem 0 0; padding: 0 0 0 1.1rem; font-size: 0.8rem; }
.jp-feed li { padding: 1px 0; }
.jp-feed li + li { opacity: 0.72; }
.jp-when { color: #6b6158; font-size: 0.72rem; }
.jp-conf { color: var(--jev-d); font-family: var(--font-brush); }
.jp-stop { margin-top: 0.5rem; font-family: var(--font-brush); font-size: 1rem; padding: 0.15rem 0.8rem; min-height: 34px; background: #fff; color: #2a2420; border: 2px solid #2a2420; border-radius: var(--wob-a); }

/* side panel: a big rose on top, the details in two columns under it */
body.jev-side .jp-move { flex-direction: column; align-items: stretch; }
body.jev-side .jp-rose { width: 100%; height: auto; max-height: 300px; }
body.jev-side .jp-side { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 0.8rem; font-size: 0.85rem; }
body.jev-side .jp-side > .jp-title:first-child, body.jev-side .jp-now { grid-column: 1 / -1; }
body.jev-side .jp-special { grid-column: 1 / -1; }
body.jev-side .jp-now b { font-size: 1.3rem; }

/* bottom strip on phones: rose and decision side by side, short feed */
body.jev-bottom #jev-panel { font-size: 0.8rem; padding: 0.4rem 0.6rem; }
body.jev-bottom .jp-head b { font-size: 1.2rem; }
body.jev-bottom .jp-cost { font-size: 1.3rem; }
body.jev-bottom .jp-rose { width: 172px; height: 172px; margin: -6px -4px 0 -8px; }
body.jev-bottom .jp-feed li:nth-child(n+4) { display: none; }
body.jev-bottom .jp-latbox { display: none; }
body.jev-bottom .jp-dir { font-size: 13px; }
body.jev-bottom .jp-pct { font-size: 14px; }

/* what Jev is about to press, and its odds on level-up cards */
.jev-target { outline: 3px solid var(--jev) !important; outline-offset: 3px; box-shadow: 0 0 0 7px rgb(123 92 255 / 0.25) !important; animation: jev-aim 0.5s ease-in-out infinite alternate; }
@keyframes jev-aim { to { outline-offset: 6px; } }
.jev-badge { position: absolute; left: 10px; right: 10px; bottom: -11px; height: 18px; background: #fff; border: 1.5px solid var(--jev); border-radius: 9px; overflow: hidden; display: block; }
.jev-badge i { position: absolute; inset: 0 auto 0 0; background: rgb(123 92 255 / 0.3); }
.jev-badge em { position: relative; font-style: normal; font-family: var(--font-brush); font-size: 0.85rem; color: var(--jev-d); padding-left: 0.4rem; line-height: 16px; }
.choice.jev-pick { box-shadow: 0 0 0 4px var(--jev), 4px 6px 0 var(--shadow); }
.choice.jev-pick .jev-badge i { background: rgb(123 92 255 / 0.6); }
.choices:has(.jev-badge) { gap: 1.1rem; }
